os2snap.bat 10 KB

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