os2snap.cmd 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. @echo off
  2. rem *** $Id$
  3. rem *** Batch file for creating of FPC snapshot for OS/2.
  4. rem *** FPCDIR variable must be set to your base FPC directory and
  5. rem *** must _not_ contain forward slashes (only backslashes allowed).
  6. rem *** Your compiler (PPOS2.EXE per default) and AS.EXE must be somewhere
  7. rem *** on PATH (unless you set path to them explicitly using FPCTOOLS
  8. rem *** variable, which must end with \ if present).
  9. rem *** One of the following parameters may be specified: rtl, compiler,
  10. rem *** both, cycle and snapshot - "snapshot" being the default, optionally
  11. rem *** followed by second parameter "debug" causing debugging symbols
  12. rem *** not to be stripped from the created compiler (parameter _must_ be
  13. rem *** in lowercase to be recognized correctly, unless running under 4os2).
  14. rem *** Meaning of parameters:
  15. rem *** rtl .......... RTL only, no snapshot created
  16. rem *** compiler ..... compiler only, no snapshot created
  17. rem *** both ......... both RTL and compiler, no snapshot created
  18. rem *** snapshot ..... both RTL and compiler, snapshot _is_ created
  19. rem *** cycle ........ RTL and compiler compiled, the resulting compiler
  20. rem *** is then copied to /BIN/OS2 (backing up previous
  21. rem *** version to ppos2.old) and used to compile both RTL and
  22. rem *** compiler again, and then finally snapshot is created
  23. rem *** PPOS2.EXE is used for the compilation, unless a different compiler name
  24. rem *** is specified in COMPILER variable.
  25. rem *** Environment variable OTHEROPTS may be used to specify additional
  26. rem *** switches (e.g. setting level of verbosity, etc.).
  27. echo *"Makefile" for OS/2:
  28. echo *Setting up environment ...
  29. rem Check whether FPCDIR exists
  30. if %FPCDIR%. == . goto ErrorDir
  31. if exist %FPCDIR% goto DirOK
  32. if exist %FPCDIR%\. goto DirOK
  33. if exist %FPCDIR%\makefile goto DirOK
  34. if exist %FPCDIR%\SOURCE\makefile goto DirOK
  35. if exist %FPCDIR%\SOURCE\COMPILER\pp.pas goto DirOK
  36. goto ErrorDir
  37. :DirOK
  38. rem Set path to source files
  39. if exist %FPCDIR%\SOURCE goto SrcExists
  40. if exist %FPCDIR%\SOURCE\. goto SrcExists
  41. if exist %FPCDIR%\SOURCE\makefile goto SrcExists
  42. set FPCSRC=%FPCDIR%
  43. goto SetOpts
  44. :SrcExists
  45. set FPCSRC=%FPCDIR%\SOURCE
  46. :SetOpts
  47. rem Common options for OS/2 target
  48. set OS2OPT=-TOS2 %OTHEROPTS%
  49. rem Stack size for the compiler
  50. set STACKOPT=-Cs64500
  51. rem Options for OS/2 compiler
  52. set OS2COPT=%OS2OPT% %STACKOPT%
  53. rem Stripping sybols
  54. set STRIPDEBUG=-Xs
  55. rem Options and paths for the OS/2 RTL
  56. set OS2RTL=-FU%FPCSRC%/RTL/OS2 %OS2OPT% %FPCSRC%/RTL/OS2/
  57. rem Options and paths for the OS/2 RTL parts compiled from common sources
  58. set OS2RTLC=-FU%FPCSRC%/RTL/OS2 %OS2OPT% %FPCSRC%/RTL/INC/
  59. rem Options and paths for the OS/2 RTL parts compiled from processor dependent sources
  60. set OS2RTLP=-FU%FPCSRC%/RTL/OS2 %OS2OPT% %FPCSRC%/RTL/I386/
  61. rem Options and paths for the OS/2 RTL parts for Object Pascal extensions
  62. set OS2RTLO=-FU%FPCSRC%/RTL/OS2 %OS2OPT% %FPCSRC%/RTL/OBJPAS/
  63. rem Default compiler for the first compilation
  64. set CYCLE=0
  65. if .%COMPILER% == . goto SetCompiler
  66. goto PrgFound
  67. :SetCompiler
  68. set COMPILER=PPOS2.EXE
  69. :PrgFound
  70. echo *Searching for tools ...
  71. if %FPCTOOLS%. == . goto SetupTools
  72. goto ToolsOK
  73. :SetupTools
  74. if exist %FPCDIR%\BIN\%COMPILER% goto Tools1
  75. if exist %FPCDIR%\BIN\%COMPILER%.EXE goto Tools1
  76. goto NoTools1
  77. :Tools1
  78. if exist %FPCDIR%\BIN\AS.EXE goto Tools1OK
  79. echo *Warning: %COMPILER% found, but AS.EXE isn't in the same directory!
  80. goto NoTools1
  81. :Tools1OK
  82. set FPCTOOLS=%FPCDIR%\BIN\
  83. goto ToolsOK
  84. :NoTools1
  85. if exist %FPCDIR%\BIN\GO32V2\%COMPILER% goto Tools2
  86. if exist %FPCDIR%\BIN\GO32V2\%COMPILER%.EXE goto Tools2
  87. goto NoTools2
  88. :Tools2
  89. if exist %FPCDIR%\BIN\GO32V2\AS.EXE goto Tools2OK
  90. echo *Warning: %COMPILER% found, but AS.EXE isn't in the same directory!
  91. goto NoTools2
  92. :Tools2OK
  93. set FPCTOOLS=%FPCDIR%\BIN\GO32V2\
  94. goto ToolsOK
  95. :NoTools2
  96. if exist %FPCDIR%\BIN\GO32V1\%COMPILER% goto Tools3
  97. if exist %FPCDIR%\BIN\GO32V1\%COMPILER%.EXE goto Tools3
  98. goto NoTools3
  99. :Tools3
  100. if exist %FPCDIR%\BIN\GO32V1\AS.EXE goto Tools3OK
  101. echo *Warning: %COMPILER% found, but AS.EXE isn't in the same directory!
  102. goto NoTools3
  103. :Tools3OK
  104. set FPCTOOLS=%FPCDIR%\BIN\GO32V1\
  105. goto ToolsOK
  106. :NoTools3
  107. if exist %FPCDIR%\BIN\OS2\%COMPILER% goto Tools4
  108. if exist %FPCDIR%\BIN\OS2\%COMPILER%.EXE goto Tools4
  109. goto NoTools4
  110. :Tools4
  111. if exist %FPCDIR%\BIN\OS2\AS.EXE goto Tools4OK
  112. echo *Warning: %COMPILER% found, but AS.EXE isn't in the same directory!
  113. goto NoTools4
  114. :Tools4OK
  115. set FPCTOOLS=%FPCDIR%\BIN\OS2\
  116. goto ToolsOK
  117. :NoTools4
  118. echo *Warning: Cannot locate your %COMPILER% and AS.EXE, make sure they're on PATH!
  119. :ToolsOK
  120. echo *Checking parameters
  121. set PARAMS=%1
  122. if .%PARAMS% == . set PARAMS=snapshot
  123. if %2. == debug set STRIPDEBUG=
  124. if %@EVAL[0] == 0 goto Shl1
  125. goto Cmd1
  126. :Shl1
  127. set PARAMS=%@LOWER[%PARAMS%]
  128. if .%@LOWER[%2] == .debug set STRIPDEBUG=
  129. :Cmd1
  130. if %PARAMS% == clean goto CleanRTL
  131. if %PARAMS% == both goto CleanRTL
  132. if %PARAMS% == snapshot goto CleanRTL
  133. if %PARAMS% == rtl goto CleanRTL
  134. if %PARAMS% == cycle goto CleanRTL
  135. if %PARAMS% == compiler goto CleanCompiler
  136. echo *Error: Unknown parameter - %PARAMS%
  137. goto End
  138. :CleanRTL
  139. if %@eval[0] == 0 goto JPCleanRTL
  140. echo *Cleaning up the RTL (error messages are OK here) ...
  141. del %FPCSRC%\RTL\OS2\*.ppo
  142. del %FPCSRC%\RTL\OS2\*.oo2
  143. del %FPCSRC%\RTL\OS2\ppas.bat
  144. del %FPCSRC%\RTL\OS2\ppas.cmd
  145. del %FPCSRC%\RTL\OS2\link.res
  146. goto ContCleanRTL
  147. :JPCleanRTL
  148. echo *Cleaning up the RTL ...
  149. del %FPCSRC%\RTL\OS2\*.ppo >& nul
  150. del %FPCSRC%\RTL\OS2\*.oo2 >& nul
  151. del %FPCSRC%\RTL\OS2\ppas.bat >& nul
  152. del %FPCSRC%\RTL\OS2\ppas.cmd >& nul
  153. del %FPCSRC%\RTL\OS2\link.res >& nul
  154. :ContCleanRTL
  155. if %PARAMS% == rtl goto Branches
  156. :CleanCompiler
  157. if %@eval[0] == 0 goto JPCleanComp
  158. echo *Cleaning up the compiler (error messages are OK here) ...
  159. del %FPCSRC%\COMPILER\*.ppo
  160. del %FPCSRC%\COMPILER\*.oo2
  161. del %FPCSRC%\COMPILER\pp
  162. del %FPCSRC%\COMPILER\pp.exe
  163. del %FPCSRC%\COMPILER\ppos2.exe
  164. del %FPCSRC%\COMPILER\ppas.bat
  165. del %FPCSRC%\COMPILER\ppas.cmd
  166. del %FPCSRC%\COMPILER\link.res
  167. goto ContCleanComp
  168. :JPCleanComp
  169. echo *Cleaning up the compiler ...
  170. del %FPCSRC%\COMPILER\*.ppo >& nul
  171. del %FPCSRC%\COMPILER\*.oo2 >& nul
  172. del %FPCSRC%\COMPILER\pp >& nul
  173. del %FPCSRC%\COMPILER\pp.exe >& nul
  174. del %FPCSRC%\COMPILER\ppos2.exe >& nul
  175. del %FPCSRC%\COMPILER\ppas.bat >& nul
  176. del %FPCSRC%\COMPILER\ppas.cmd >& nul
  177. del %FPCSRC%\COMPILER\link.res >& nul
  178. :ContCleanComp
  179. if %PARAMS% == compiler goto Branches
  180. if %PARAMS% == both goto Branches
  181. :CleanSnapshot
  182. if %@eval[0] == 0 goto JPCleanSnap
  183. echo *Deleting the old snapshot (error messages are OK here) ...
  184. del %FPCSRC%\snap-os2.zip
  185. goto ContCleanSnap
  186. :JPCleanSnap
  187. echo *Deleting the old snapshot ...
  188. del %FPCSRC%\snap-os2.zip >& nul
  189. :ContCleanSnap
  190. if %PARAMS% == clean goto End
  191. :Branches
  192. if %PARAMS% == both goto RTL1
  193. if %PARAMS% == snapshot goto RTL1
  194. if %PARAMS% == compiler goto Compiler
  195. if %PARAMS% == rtl goto RTL1
  196. if %PARAMS% == cycle goto RTL1
  197. echo *Error: Unknown parameter - %PARAMS%
  198. goto End
  199. :RTL1
  200. echo *Assembling the helpers ...
  201. %FPCDIR%\BIN\OS2\as -o %FPCSRC%/RTL/OS2/prt0.oo2 %FPCSRC%/RTL/OS2/prt0.as
  202. %FPCDIR%\BIN\OS2\as -o %FPCSRC%/RTL/OS2/prt1.oo2 %FPCSRC%/RTL/OS2/prt1.as
  203. %FPCDIR%\BIN\OS2\as -o %FPCSRC%/RTL/OS2/code2.oo2 %FPCSRC%/RTL/OS2/code2.as
  204. %FPCDIR%\BIN\OS2\as -o %FPCSRC%/RTL/OS2/code3.oo2 %FPCSRC%/RTL/OS2/code3.as
  205. echo *Compiling the system unit ...
  206. %FPCTOOLS%%COMPILER% -Sg -Us %OS2RTL%SYSOS2.PAS
  207. echo *Compiling unit Objects ...
  208. %FPCTOOLS%%COMPILER% %OS2RTLC%OBJECTS.PP
  209. echo *Compiling unit Strings ...
  210. %FPCTOOLS%%COMPILER% %OS2RTLC%STRINGS.PP
  211. echo *Compiling unit HeapTrace ...
  212. %FPCTOOLS%%COMPILER% %OS2RTLC%HEAPTRC.PP
  213. echo *Compiling unit CPU ...
  214. %FPCTOOLS%%COMPILER% %OS2RTLP%CPU.PP
  215. echo *Compiling unit MMX ...
  216. %FPCTOOLS%%COMPILER% %OS2RTLP%MMX.PP
  217. echo *Compiling unit TypInfo ...
  218. %FPCTOOLS%%COMPILER% %OS2RTLO%TYPINFO.PP
  219. echo *Compiling unit DosCalls ...
  220. %FPCTOOLS%%COMPILER% %OS2RTL%DOSCALLS.PAS
  221. echo *Compiling unit DOS ...
  222. %FPCTOOLS%%COMPILER% %OS2RTL%DOS.PAS
  223. echo *Compiling unit CRT ...
  224. %FPCTOOLS%%COMPILER% %OS2RTL%CRT.PAS
  225. echo *Compiling unit Printer ...
  226. %FPCTOOLS%%COMPILER% %OS2RTL%PRINTER.PAS
  227. echo *Compiling unit SysUtils ...
  228. %FPCTOOLS%%COMPILER% %OS2RTLO%SYSUTILS.PP
  229. echo *Compiling unit Math ...
  230. %FPCTOOLS%%COMPILER% %OS2RTLO%MATH.PP
  231. echo *Compiling unit UComplex ...
  232. %FPCTOOLS%%COMPILER% %OS2RTLC%UCOMPLEX.PP
  233. echo *Compiling unit GetOpts ...
  234. %FPCTOOLS%%COMPILER% %OS2RTLC%GETOPTS.PP
  235. echo *Compiling unit KbdCalls ...
  236. %FPCTOOLS%%COMPILER% %OS2RTL%KBDCALLS.PAS
  237. echo *Compiling unit MouCalls ...
  238. %FPCTOOLS%%COMPILER% %OS2RTL%MOUCALLS.PAS
  239. echo *Compiling unit VioCalls ...
  240. %FPCTOOLS%%COMPILER% %OS2RTL%VIOCALLS.PAS
  241. echo *Compiling unit Ports ...
  242. %FPCTOOLS%%COMPILER% %OS2RTL%PORTS.PAS
  243. echo *Compiling PM units ...
  244. %FPCTOOLS%%COMPILER% %OS2RTL%PMWIN.PAS
  245. %FPCTOOLS%%COMPILER% %OS2RTL%PMBITMAP.PAS
  246. %FPCTOOLS%%COMPILER% %OS2RTL%PMGPI.PAS
  247. echo *Compiling MMOS2 units ...
  248. %FPCTOOLS%%COMPILER% %OS2RTL%DIVE.PAS
  249. if %PARAMS% == rtl goto End
  250. :Compiler
  251. echo *Compiling the compiler itself ...
  252. %FPCTOOLS%%COMPILER% %OS2COPT% %STRIPDEBUG% -FE%FPCSRC%/COMPILER -Fu%FPCSRC%/COMPILER -dGDB -dI386 %FPCSRC%/COMPILER/PP.PAS
  253. :Comp2
  254. ren %FPCSRC%\COMPILER\pp.exe ppos2.exe
  255. if exist %FPCSRC%\COMPILER\ppos2.exe goto OKCompiler
  256. if exist %FPCSRC%\COMPILER\ppas.bat goto PPasBat
  257. if exist %FPCSRC%\COMPILER\ppas.bat goto PPasCmd
  258. echo *Error: Compiler wasn't compiled!!
  259. goto End
  260. :PPasBat
  261. echo *Automatic binding failed, trying again ...
  262. call %FPCSRC%\COMPILER\ppas.bat
  263. del %FPCSRC%\COMPILER\ppas.bat
  264. goto Comp2
  265. goto PPas
  266. :PPasCmd
  267. echo *Automatic binding failed, trying again ...
  268. call %FPCSRC%\COMPILER\ppas.cmd
  269. del %FPCSRC%\COMPILER\ppas.cmd
  270. goto Comp2
  271. :OKCompiler
  272. if %PARAMS% == compiler goto End
  273. if %PARAMS% == both goto End
  274. if %PARAMS% == cycle goto Cycle
  275. goto CheckEnv
  276. :Cycle
  277. rem Another loop?
  278. if %CYCLE% == 2 goto CheckEnv
  279. echo *Backing up previous compiler version ...
  280. copy %FPCDIR%\BIN\OS2\ppos2.exe %FPCDIR%\BIN\OS2\ppos2.old
  281. echo *Copying the newly created compiler to %FPCDIR%\BIN\OS2 ...
  282. copy %FPCSRC%\COMPILER\ppos2.exe %FPCDIR%\BIN\OS2
  283. if %CYCLE% == 1 goto Cycle2
  284. set COMPILER=PPOS2.EXE
  285. set CYCLE=1
  286. goto SetupTools
  287. :Cycle2
  288. set CYCLE=2
  289. goto SetupTools
  290. :CheckEnv
  291. if %@EVAL[0] == 0 goto Pack
  292. echo *Warning: Packing in this environment might fail.
  293. echo *You should press Ctrl-Break now if the current drive is different from that
  294. echo *of %FPCDIR%; otherwise press any key to continue.
  295. pause>nul
  296. cd %FPCSRC%
  297. :Pack
  298. echo *Packing the snapshot ...
  299. if %@EVAL[0] == 0 goto SHL2
  300. goto Cmd2
  301. :Shl2
  302. pushd
  303. cdd %FPCSRC%
  304. :Cmd2
  305. rem ZIP.EXE must be on the PATH
  306. zip -9 -r snap-os2.zip compiler\ppos2.exe rtl\os2\*.ppo rtl\os2\*.oo2
  307. if exist snap-os2.zip goto ZipOK
  308. echo *Error: The ZIP file hasn't been created!!
  309. :ZipOK
  310. if %@EVAL[0] == 0 popd
  311. echo *Done.
  312. goto End
  313. :ErrorDir
  314. echo *Error: Environment variable FPCDIR must point to your base FPC directory!!!
  315. goto End
  316. $Log$
  317. Revision 1.5 2000-01-02 16:38:51 hajny
  318. + unit Ports added
  319. Revision 1.3 1999/10/01 09:00:21 hajny
  320. + PMGPI and DIVE added
  321. Revision 1.2 1999/09/15 07:31:49 hajny
  322. + some units added, OTHEROPTS variable support
  323. :End