os2snap.cmd 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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. goto ErrorDir
  36. :DirOK
  37. rem Set path to source files
  38. if exist %FPCDIR%\SOURCE goto SrcExists
  39. if exist %FPCDIR%\SOURCE\. goto SrcExists
  40. if exist %FPCDIR%\SOURCE\makefile goto SrcExists
  41. set FPCSRC=%FPCDIR%
  42. goto SetOpts
  43. :SrcExists
  44. set FPCSRC=%FPCDIR%\SOURCE
  45. :SetOpts
  46. rem Common options for OS/2 target
  47. set OS2OPT=-TOS2 %OTHEROPTS%
  48. rem Stack size for the compiler
  49. set STACKOPT=-Cs64500
  50. rem Options for OS/2 compiler
  51. set OS2COPT=%OS2OPT% %STACKOPT%
  52. rem Stripping sybols
  53. set STRIPDEBUG=-Xs
  54. rem Options and paths for the OS/2 RTL
  55. set OS2RTL=-FU%FPCSRC%/RTL/OS2 %OS2OPT% %FPCSRC%/RTL/OS2/
  56. rem Options and paths for the OS/2 RTL parts compiled from common sources
  57. set OS2RTLC=-FU%FPCSRC%/RTL/OS2 %OS2OPT% %FPCSRC%/RTL/INC/
  58. rem Options and paths for the OS/2 RTL parts compiled from processor dependent sources
  59. set OS2RTLP=-FU%FPCSRC%/RTL/OS2 %OS2OPT% %FPCSRC%/RTL/I386/
  60. rem Options and paths for the OS/2 RTL parts for Object Pascal extensions
  61. set OS2RTLO=-FU%FPCSRC%/RTL/OS2 %OS2OPT% %FPCSRC%/RTL/OBJPAS/
  62. rem Default compiler for the first compilation
  63. set CYCLE=0
  64. if .%COMPILER% == . goto SetCompiler
  65. goto PrgFound
  66. :SetCompiler
  67. set COMPILER=PPOS2.EXE
  68. :PrgFound
  69. echo *Searching for tools ...
  70. if %FPCTOOLS%. == . goto SetupTools
  71. goto ToolsOK
  72. :SetupTools
  73. if exist %FPCDIR%\BIN\%COMPILER% goto Tools1
  74. if exist %FPCDIR%\BIN\%COMPILER%.EXE goto Tools1
  75. goto NoTools1
  76. :Tools1
  77. if exist %FPCDIR%\BIN\AS.EXE goto Tools1OK
  78. echo *Warning: %COMPILER% found, but AS.EXE isn't in the same directory!
  79. goto NoTools1
  80. :Tools1OK
  81. set FPCTOOLS=%FPCDIR%\BIN\
  82. goto ToolsOK
  83. :NoTools1
  84. if exist %FPCDIR%\BIN\GO32V2\%COMPILER% goto Tools2
  85. if exist %FPCDIR%\BIN\GO32V2\%COMPILER%.EXE goto Tools2
  86. goto NoTools2
  87. :Tools2
  88. if exist %FPCDIR%\BIN\GO32V2\AS.EXE goto Tools2OK
  89. echo *Warning: %COMPILER% found, but AS.EXE isn't in the same directory!
  90. goto NoTools2
  91. :Tools2OK
  92. set FPCTOOLS=%FPCDIR%\BIN\GO32V2\
  93. goto ToolsOK
  94. :NoTools2
  95. if exist %FPCDIR%\BIN\GO32V1\%COMPILER% goto Tools3
  96. if exist %FPCDIR%\BIN\GO32V1\%COMPILER%.EXE goto Tools3
  97. goto NoTools3
  98. :Tools3
  99. if exist %FPCDIR%\BIN\GO32V1\AS.EXE goto Tools3OK
  100. echo *Warning: %COMPILER% found, but AS.EXE isn't in the same directory!
  101. goto NoTools3
  102. :Tools3OK
  103. set FPCTOOLS=%FPCDIR%\BIN\GO32V1\
  104. goto ToolsOK
  105. :NoTools3
  106. if exist %FPCDIR%\BIN\OS2\%COMPILER% goto Tools4
  107. if exist %FPCDIR%\BIN\OS2\%COMPILER%.EXE goto Tools4
  108. goto NoTools4
  109. :Tools4
  110. if exist %FPCDIR%\BIN\OS2\AS.EXE goto Tools4OK
  111. echo *Warning: %COMPILER% found, but AS.EXE isn't in the same directory!
  112. goto NoTools4
  113. :Tools4OK
  114. set FPCTOOLS=%FPCDIR%\BIN\OS2\
  115. goto ToolsOK
  116. :NoTools4
  117. echo *Warning: Cannot locate your %COMPILER% and AS.EXE, make sure they're on PATH!
  118. :ToolsOK
  119. echo *Checking parameters
  120. set PARAMS=%1
  121. if .%PARAMS% == . set PARAMS=snapshot
  122. if %2. == debug set STRIPDEBUG=
  123. if %@EVAL[0] == 0 goto Shl1
  124. goto Cmd1
  125. :Shl1
  126. set PARAMS=%@LOWER[%PARAMS%]
  127. if .%@LOWER[%2] == .debug set STRIPDEBUG=
  128. :Cmd1
  129. if %PARAMS% == both goto CleanRTL
  130. if %PARAMS% == snapshot goto CleanRTL
  131. if %PARAMS% == rtl goto CleanRTL
  132. if %PARAMS% == cycle goto CleanRTL
  133. if %PARAMS% == compiler goto CleanCompiler
  134. echo *Error: Unknown parameter - %PARAMS%
  135. goto End
  136. :CleanRTL
  137. echo *Cleaning up the RTL (error messages are OK here) ...
  138. del %FPCSRC%\RTL\OS2\*.ppo
  139. del %FPCSRC%\RTL\OS2\*.oo2
  140. del %FPCSRC%\RTL\OS2\ppas.bat
  141. del %FPCSRC%\RTL\OS2\ppas.cmd
  142. del %FPCSRC%\RTL\OS2\link.res
  143. if %PARAMS% == rtl goto Branches
  144. :CleanCompiler
  145. echo *Cleaning up the compiler (error messages are OK here) ...
  146. del %FPCSRC%\COMPILER\*.ppo
  147. del %FPCSRC%\COMPILER\*.oo2
  148. del %FPCSRC%\COMPILER\pp.
  149. del %FPCSRC%\COMPILER\pp.exe
  150. del %FPCSRC%\COMPILER\ppos2.exe
  151. del %FPCSRC%\COMPILER\ppas.bat
  152. del %FPCSRC%\COMPILER\ppas.cmd
  153. del %FPCSRC%\COMPILER\link.res
  154. if %PARAMS% == compiler goto Branches
  155. if %PARAMS% == both goto Branches
  156. :CleanSnapshot
  157. echo *Deleting the old snapshot (error messages are OK here) ...
  158. del %FPCSRC%\snap-os2.zip
  159. :Branches
  160. if %PARAMS% == both goto RTL1
  161. if %PARAMS% == snapshot goto RTL1
  162. if %PARAMS% == compiler goto Compiler
  163. if %PARAMS% == rtl goto RTL1
  164. if %PARAMS% == cycle goto RTL1
  165. echo *Error: Unknown parameter - %PARAMS%
  166. goto End
  167. :RTL1
  168. echo *Assembling the helpers ...
  169. %FPCDIR%\BIN\OS2\as -o %FPCSRC%/RTL/OS2/prt0.oo2 %FPCSRC%/RTL/OS2/prt0.as
  170. %FPCDIR%\BIN\OS2\as -o %FPCSRC%/RTL/OS2/prt1.oo2 %FPCSRC%/RTL/OS2/prt1.as
  171. %FPCDIR%\BIN\OS2\as -o %FPCSRC%/RTL/OS2/code2.oo2 %FPCSRC%/RTL/OS2/code2.as
  172. %FPCDIR%\BIN\OS2\as -o %FPCSRC%/RTL/OS2/code3.oo2 %FPCSRC%/RTL/OS2/code3.as
  173. echo *Compiling the system unit ...
  174. %FPCTOOLS%%COMPILER% -Sg -Us %OS2RTL%SYSOS2.PAS
  175. echo *Compiling unit Objects ...
  176. %FPCTOOLS%%COMPILER% %OS2RTLC%OBJECTS.PP
  177. echo *Compiling unit Strings ...
  178. %FPCTOOLS%%COMPILER% %OS2RTLC%STRINGS.PP
  179. echo *Compiling unit HeapTrace ...
  180. %FPCTOOLS%%COMPILER% %OS2RTLC%HEAPTRC.PP
  181. echo *Compiling unit CPU ...
  182. %FPCTOOLS%%COMPILER% %OS2RTLP%CPU.PP
  183. echo *Compiling unit MMX ...
  184. %FPCTOOLS%%COMPILER% %OS2RTLP%MMX.PP
  185. echo *Compiling unit TypInfo ...
  186. %FPCTOOLS%%COMPILER% %OS2RTLO%TYPINFO.PP
  187. echo *Compiling unit DosCalls ...
  188. %FPCTOOLS%%COMPILER% %OS2RTL%DOSCALLS.PAS
  189. echo *Compiling unit DOS ...
  190. %FPCTOOLS%%COMPILER% %OS2RTL%DOS.PAS
  191. echo *Compiling unit CRT ...
  192. %FPCTOOLS%%COMPILER% %OS2RTL%CRT.PAS
  193. echo *Compiling unit Printer ...
  194. %FPCTOOLS%%COMPILER% %OS2RTL%PRINTER.PAS
  195. echo *Compiling unit SysUtils ...
  196. %FPCTOOLS%%COMPILER% %OS2RTLO%SYSUTILS.PP
  197. echo *Compiling unit Math ...
  198. %FPCTOOLS%%COMPILER% %OS2RTLO%MATH.PP
  199. echo *Compiling unit UComplex ...
  200. %FPCTOOLS%%COMPILER% %OS2RTLC%UCOMPLEX.PP
  201. echo *Compiling unit GetOpts ...
  202. %FPCTOOLS%%COMPILER% %OS2RTLC%GETOPTS.PP
  203. echo *Compiling unit KbdCalls ...
  204. %FPCTOOLS%%COMPILER% %OS2RTL%KBDCALLS.PAS
  205. echo *Compiling unit MouCalls ...
  206. %FPCTOOLS%%COMPILER% %OS2RTL%MOUCALLS.PAS
  207. echo *Compiling unit VioCalls ...
  208. %FPCTOOLS%%COMPILER% %OS2RTL%VIOCALLS.PAS
  209. echo *Compiling PM units ...
  210. %FPCTOOLS%%COMPILER% %OS2RTL%PMWIN.PAS
  211. %FPCTOOLS%%COMPILER% %OS2RTL%PMBITMAP.PAS
  212. %FPCTOOLS%%COMPILER% %OS2RTL%PMGPI.PAS
  213. echo *Compiling MMOS2 units ...
  214. %FPCTOOLS%%COMPILER% %OS2RTL%DIVE.PAS
  215. if %PARAMS% == rtl goto End
  216. :Compiler
  217. echo *Compiling the compiler itself ...
  218. %FPCTOOLS%%COMPILER% %OS2COPT% %STRIPDEBUG% -FE%FPCSRC%/COMPILER -Fu%FPCSRC%/COMPILER -dGDB -dI386 %FPCSRC%/COMPILER/PP.PAS
  219. :Comp2
  220. ren %FPCSRC%\COMPILER\pp.exe ppos2.exe
  221. if exist %FPCSRC%\COMPILER\ppos2.exe goto OKCompiler
  222. if exist %FPCSRC%\COMPILER\ppas.bat goto PPasBat
  223. if exist %FPCSRC%\COMPILER\ppas.bat goto PPasCmd
  224. echo *Error: Compiler wasn't compiled!!
  225. goto End
  226. :PPasBat
  227. echo *Automatic binding failed, trying again ...
  228. call %FPCSRC%\COMPILER\ppas.bat
  229. del %FPCSRC%\COMPILER\ppas.bat
  230. goto Comp2
  231. goto PPas
  232. :PPasCmd
  233. echo *Automatic binding failed, trying again ...
  234. call %FPCSRC%\COMPILER\ppas.cmd
  235. del %FPCSRC%\COMPILER\ppas.cmd
  236. goto Comp2
  237. :OKCompiler
  238. if %PARAMS% == compiler goto End
  239. if %PARAMS% == both goto End
  240. if %PARAMS% == cycle goto Cycle
  241. goto CheckEnv
  242. :Cycle
  243. rem Another loop?
  244. if %CYCLE% == 2 goto CheckEnv
  245. echo *Backing up previous compiler version ...
  246. copy %FPCDIR%\BIN\OS2\ppos2.exe %FPCDIR%\BIN\OS2\ppos2.old
  247. echo *Copying the newly created compiler to %FPCDIR%\BIN\OS2 ...
  248. copy %FPCSRC%\COMPILER\ppos2.exe %FPCDIR%\BIN\OS2
  249. if %CYCLE% == 1 goto Cycle2
  250. set COMPILER=PPOS2.EXE
  251. set CYCLE=1
  252. goto SetupTools
  253. :Cycle2
  254. set CYCLE=2
  255. goto SetupTools
  256. :CheckEnv
  257. if %@EVAL[0] == 0 goto Pack
  258. echo *Warning: Packing in this environment might fail.
  259. echo *You should press Ctrl-Break now if the current drive is different from that
  260. echo *of %FPCDIR%; otherwise press any key to continue.
  261. pause>nul
  262. cd %FPCSRC%
  263. :Pack
  264. echo *Packing the snapshot ...
  265. if %@EVAL[0] == 0 goto SHL2
  266. goto Cmd2
  267. :Shl2
  268. pushd
  269. cdd %FPCSRC%
  270. :Cmd2
  271. rem ZIP.EXE must be on the PATH
  272. zip -9 -r snap-os2.zip compiler\ppos2.exe rtl\os2\*.ppo rtl\os2\*.oo2
  273. if exist snap-os2.zip goto ZipOK
  274. echo *Error: The ZIP file hasn't been created!!
  275. :ZipOK
  276. if %@EVAL[0] == 0 popd
  277. echo *Done.
  278. goto End
  279. :ErrorDir
  280. echo *Error: Environment variable FPCDIR must point to your base FPC directory!!!
  281. goto End
  282. $Log$
  283. Revision 1.3 1999-10-01 09:00:21 hajny
  284. + PMGPI and DIVE added
  285. Revision 1.2 1999/09/15 07:31:49 hajny
  286. + some units added, OTHEROPTS variable support
  287. :End