os2snap.bat 9.3 KB

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