os2snap.cmd 9.0 KB

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