os2snap.cmd 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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). However, be sure which
  9. rem *** version of AS.EXE, etc. gets called if several such files exist.
  10. rem *** One of the following parameters may be specified: rtl, compiler,
  11. rem *** both, cycle and snapshot ("snapshot" being the default), optionally
  12. rem *** followed by a second parameter "debug" (causing debugging symbols
  13. rem *** not to be stripped from the created compiler), or "release" (code
  14. rem *** optimization, debug info stripped out). Parameters _must_ be in
  15. rem *** lowercase to be recognized correctly, unless running under 4os2).
  16. rem *** Meaning of parameters:
  17. rem *** rtl .......... RTL only, _no_ snapshot created
  18. rem *** compiler ..... compiler only, _no_ snapshot created
  19. rem *** both ......... both RTL and compiler, _no_ snapshot created
  20. rem *** snapshot ..... both RTL and compiler, snapshot _is_ created
  21. rem *** cycle ........ RTL and compiler compiled, the resulting compiler
  22. rem *** is then copied to %FPCTOOLS% (BIN\OS2 by default)
  23. rem *** backing up possible previous version to ppos2.x),
  24. rem *** the whole procedure is started again (RTL is compiled
  25. rem *** with the new compiler version this time) and after
  26. rem *** another cycle (to make sure the new compiler works
  27. rem *** correctly) the snapshot is finally created
  28. rem *** PPOS2.EXE is used for the compilation, unless a different compiler name
  29. rem *** is specified in FPCCOMPILER variable. In any case, the compiler should
  30. rem *** reside in the same directory as the other required tools (AS.EXE,
  31. rem *** LD.EXE, etc.).
  32. rem *** Environment variable OTHEROPTS may be used to specify additional
  33. rem *** switches (e.g. setting level of verbosity, etc.).
  34. echo *"Makefile" for OS/2:
  35. echo *Setting up environment ...
  36. rem Check whether FPCDIR exists
  37. if %FPCDIR%. == . goto ErrorDir
  38. if exist %FPCDIR% goto DirOK
  39. if exist %FPCDIR%\. goto DirOK
  40. if exist %FPCDIR%\makefile goto DirOK
  41. if exist %FPCDIR%\SOURCE\makefile goto DirOK
  42. if exist %FPCDIR%\SOURCE\COMPILER\pp.pas goto DirOK
  43. goto ErrorDir
  44. :DirOK
  45. rem Set path to the source files
  46. if exist %FPCDIR%\SOURCE goto SrcExists
  47. if exist %FPCDIR%\SOURCE\. goto SrcExists
  48. if exist %FPCDIR%\SOURCE\makefile goto SrcExists
  49. if exist %FPCDIR%\SOURCE\COMPILER\pp.pas goto SrcExists
  50. set FPCSRC=%FPCDIR%
  51. goto SetOpts
  52. :SrcExists
  53. set FPCSRC=%FPCDIR%\SOURCE
  54. :SetOpts
  55. rem Path to file with options
  56. set OS2OPTF=%FPCSRC%\OS2SNAP.OPT
  57. rem Path for the OS/2 RTL
  58. set OS2RTL=%FPCSRC%\RTL\OS2
  59. rem Path for OS/2 RTL parts compiled from common sources
  60. set OS2RTLC=%FPCSRC%\RTL\INC
  61. rem Path for OS/2 RTL parts compiled from processor dependent sources
  62. set OS2RTLP=%FPCSRC%\RTL\I386
  63. rem Path for OS/2 RTL parts for Object Pascal extensions
  64. set OS2RTLO=%FPCSRC%\RTL\OBJPAS
  65. rem Path to the compiler source
  66. set COMPSPATH=%FPCSRC%\COMPILER
  67. rem Option to skip the default configuration file
  68. set SKIPCFG=-n
  69. rem Common options for OS/2 target
  70. set OS2OPT1=-TOS2
  71. set OS2OPT2=-dGDB
  72. set OS2OPT3=-dI386
  73. set OS2OPT4=-Sg
  74. rem "Release" options (optimizations, strip debug symbols)
  75. set RELEASEOPT1=-Og2p1
  76. set RELEASEOPT2=-Xs
  77. rem "Debug" options (add debug symbols, do all code generation checks)
  78. set DEBUGOPT1=-g
  79. set DEBUGOPT2=-Crtoi
  80. rem Place for debug or release options, empty by default
  81. set CURRENTOPT1=
  82. set CURRENTOPT2=
  83. rem Stack size for the compiler
  84. set STACKOPT=-Cs64500
  85. rem Path to object files
  86. set OS2OBJP=-Fo%OS2RTL%
  87. rem Path to units
  88. set OS2UNITP=-Fu%OS2RTL%
  89. rem Path to compiler units
  90. set COMPUNITP=-Fu%COMPSPATH%
  91. rem Path to compiler include files
  92. set COMPINCP=-Fi%COMPSPATH%
  93. rem Path to compiler object files
  94. set COMPOBJP=-Fo%COMPSPATH%
  95. rem Target path for units
  96. set OS2UNITT=-FU%OS2RTL%
  97. rem Target path for executables
  98. set OS2EXET=-FE%COMPSPATH%
  99. rem Path to include files
  100. set OS2INCP=-Fi%OS2RTL%;%OS2RTLC%;%OS2RTLO%;%OS2RTLP%
  101. rem Default compiler for the first compilation
  102. set CYCLE=0
  103. set COMPILER=%FPCCOMPILER%
  104. if .%FPCCOMPILER% == . goto SetCompiler
  105. goto PrgFound
  106. :SetCompiler
  107. set COMPILER=PPOS2.EXE
  108. :PrgFound
  109. echo *Searching for tools ...
  110. set REALTOOLS=%FPCTOOLS%
  111. if %FPCTOOLS%. == . goto SetupTools
  112. goto ToolsOK
  113. :SetupTools
  114. if exist %FPCDIR%\BIN\OS2\%COMPILER% goto Tools1
  115. if exist %FPCDIR%\BIN\OS2\%COMPILER%.EXE goto Tools1
  116. goto NoTools1
  117. :Tools1
  118. if exist %FPCDIR%\BIN\OS2\AS.EXE goto Tools1OK
  119. echo *Warning: %COMPILER% found, but AS.EXE isn't in the same directory!
  120. goto NoTools1
  121. :Tools1OK
  122. set REALTOOLS=%FPCDIR%\BIN\OS2\
  123. goto ToolsOK
  124. :NoTools1
  125. if exist %FPCDIR%\BIN\%COMPILER% goto Tools2
  126. if exist %FPCDIR%\BIN\%COMPILER%.EXE goto Tools2
  127. goto NoTools2
  128. :Tools2
  129. if exist %FPCDIR%\BIN\AS.EXE goto Tools2OK
  130. echo *Warning: %COMPILER% found, but AS.EXE isn't in the same directory!
  131. goto NoTools2
  132. :Tools2OK
  133. set REALTOOLS=%FPCDIR%\BIN\
  134. goto ToolsOK
  135. :NoTools2
  136. echo *Warning: Cannot locate your %COMPILER% and AS.EXE, make sure they're on PATH!
  137. :ToolsOK
  138. echo *Checking parameters
  139. set PARAMS=%1
  140. if .%PARAMS% == . set PARAMS=snapshot
  141. if %2. == debug set CURRENTOPT1=%DEBUGOPT1%
  142. if %2. == debug set CURRENTOPT2=%DEBUGOPT2%
  143. if %2. == release set CURRENTOPT1=%RELEASEOPT1%
  144. if %2. == release set CURRENTOPT2=%RELEASEOPT2%
  145. if %@EVAL[0] == 0 goto Shl1
  146. goto Cmd1
  147. :Shl1
  148. set PARAMS=%@LOWER[%PARAMS%]
  149. if .%@LOWER[%2] == .debug set CURRENTOPT1=%DEBUGOPT1%
  150. if .%@LOWER[%2] == .debug set CURRENTOPT2=%DEBUGOPT2%
  151. if .%@LOWER[%2] == .release set CURRENTOPT1=%RELEASEOPT1%
  152. if .%@LOWER[%2] == .release set CURRENTOPT2=%RELEASEOPT2%
  153. :Cmd1
  154. if %PARAMS% == clean goto CleanRTL
  155. if %PARAMS% == both goto CleanRTL
  156. if %PARAMS% == snapshot goto CleanRTL
  157. if %PARAMS% == rtl goto CleanRTL
  158. if %PARAMS% == cycle goto CleanRTL
  159. if %PARAMS% == compiler goto CleanCompiler
  160. echo *Error: Unknown parameter - %PARAMS%
  161. goto End
  162. :CleanRTL
  163. if %@eval[0] == 0 goto JPCleanRTL
  164. echo *Cleaning up the RTL (error messages are OK here) ...
  165. del %OS2OPTF%
  166. del %OS2RTL%\*.ppo
  167. del %OS2RTL%\*.oo2
  168. del %OS2RTL%\ppas.bat
  169. del %OS2RTL%\ppas.cmd
  170. del %OS2RTL%\link.res
  171. goto ContCleanRTL
  172. :JPCleanRTL
  173. echo *Cleaning up the RTL ...
  174. del %OS2OPTF% >& nul
  175. del %OS2RTL%\*.ppo >& nul
  176. del %OS2RTL%\*.oo2 >& nul
  177. del %OS2RTL%\ppas.bat >& nul
  178. del %OS2RTL%\ppas.cmd >& nul
  179. del %OS2RTL%\link.res >& nul
  180. :ContCleanRTL
  181. if %PARAMS% == rtl goto Branches
  182. :CleanCompiler
  183. if %@eval[0] == 0 goto JPCleanComp
  184. echo *Cleaning up the compiler (error messages are OK here) ...
  185. del %OS2OPTF%
  186. del %COMPSPATH%\*.ppo
  187. del %COMPSPATH%\*.oo2
  188. del %COMPSPATH%\pp
  189. del %COMPSPATH%\pp.exe
  190. del %COMPSPATH%\ppos2.exe
  191. del %COMPSPATH%\ppas.bat
  192. del %COMPSPATH%\ppas.cmd
  193. del %COMPSPATH%\link.res
  194. goto ContCleanComp
  195. :JPCleanComp
  196. echo *Cleaning up the compiler ...
  197. del %OS2OPTF% >& nul
  198. del %COMPSPATH%\*.ppo >& nul
  199. del %COMPSPATH%\*.oo2 >& nul
  200. del %COMPSPATH%\pp >& nul
  201. del %COMPSPATH%\pp.exe >& nul
  202. del %COMPSPATH%\ppos2.exe >& nul
  203. del %COMPSPATH%\ppas.bat >& nul
  204. del %COMPSPATH%\ppas.cmd >& nul
  205. del %COMPSPATH%\link.res >& nul
  206. :ContCleanComp
  207. if %PARAMS% == compiler goto Branches
  208. if %PARAMS% == both goto Branches
  209. :CleanSnapshot
  210. if %@eval[0] == 0 goto JPCleanSnap
  211. echo *Deleting the old snapshot (error messages are OK here) ...
  212. del %FPCSRC%\snap-os2.zip
  213. goto ContCleanSnap
  214. :JPCleanSnap
  215. echo *Deleting the old snapshot ...
  216. del %FPCSRC%\snap-os2.zip >& nul
  217. :ContCleanSnap
  218. if %PARAMS% == clean goto End
  219. :Branches
  220. if %PARAMS% == both goto RTL1
  221. if %PARAMS% == snapshot goto RTL1
  222. if %PARAMS% == compiler goto Compiler
  223. if %PARAMS% == rtl goto RTL1
  224. if %PARAMS% == cycle goto RTL1
  225. echo *Error: Unknown parameter - %PARAMS%
  226. goto End
  227. :RTL1
  228. echo *Creating file with all the needed options and paths for RTL ...
  229. echo %SKIPCFG% > %OS2OPTF%
  230. echo %OS2OPT1% >> %OS2OPTF%
  231. echo %OS2OPT2% >> %OS2OPTF%
  232. echo %OS2OPT3% >> %OS2OPTF%
  233. echo %OS2OPT4% >> %OS2OPTF%
  234. echo %OS2OBJP% >> %OS2OPTF%
  235. echo %OS2UNITP% >> %OS2OPTF%
  236. echo %OS2INCP% >> %OS2OPTF%
  237. echo %OS2UNITT% >> %OS2OPTF%
  238. echo -FD%REALTOOLS% >> %OS2OPTF%
  239. if not .%CURRENTOPT1% == . echo %CURRENTOPT1% >> %OS2OPTF%
  240. if not .%CURRENTOPT2% == . echo %CURRENTOPT2% >> %OS2OPTF%
  241. echo *Assembling the helpers ...
  242. %REALTOOLS%\as -o %OS2RTL%\prt0.oo2 %OS2RTL%\prt0.as
  243. %REALTOOLS%\as -o %OS2RTL%\prt1.oo2 %OS2RTL%\prt1.as
  244. %REALTOOLS%\as -o %OS2RTL%\code2.oo2 %OS2RTL%\code2.as
  245. %REALTOOLS%\as -o %OS2RTL%\code3.oo2 %OS2RTL%\code3.as
  246. echo *Compiling the system unit ...
  247. %REALTOOLS%%COMPILER% @%OS2OPTF% -Us %OTHEROPTS% %OS2RTL%\SYSOS2.PAS
  248. echo *Compiling unit Objects ...
  249. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTLC%\OBJECTS.PP
  250. echo *Compiling unit Strings ...
  251. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTLC%\STRINGS.PP
  252. echo *Compiling unit HeapTrace ...
  253. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTLC%\HEAPTRC.PP
  254. echo *Compiling unit CPU ...
  255. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTLP%\CPU.PP
  256. echo *Compiling unit MMX ...
  257. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTLP%\MMX.PP
  258. echo *Compiling unit TypInfo ...
  259. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTLO%\TYPINFO.PP
  260. echo *Compiling unit DosCalls ...
  261. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTL%\DOSCALLS.PAS
  262. echo *Compiling unit DOS ...
  263. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTL%\DOS.PAS
  264. echo *Compiling unit CRT ...
  265. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTL%\CRT.PAS
  266. echo *Compiling unit Printer ...
  267. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTL%\PRINTER.PAS
  268. echo *Compiling unit SysUtils ...
  269. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTLO%\SYSUTILS.PP
  270. echo *Compiling unit Math ...
  271. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTLO%\MATH.PP
  272. echo *Compiling unit UComplex ...
  273. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTLC%\UCOMPLEX.PP
  274. echo *Compiling unit GetOpts ...
  275. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTLC%\GETOPTS.PP
  276. echo *Compiling unit KbdCalls ...
  277. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTL%\KBDCALLS.PAS
  278. echo *Compiling unit MouCalls ...
  279. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTL%\MOUCALLS.PAS
  280. echo *Compiling unit VioCalls ...
  281. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTL%\VIOCALLS.PAS
  282. echo *Compiling unit MonCalls ...
  283. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTL%\MONCALLS.PAS
  284. echo *Compiling unit Ports ...
  285. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTL%\PORTS.PAS
  286. echo *Compiling PM units ...
  287. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTL%\PMWIN.PAS
  288. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTL%\PMBITMAP.PAS
  289. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTL%\PMGPI.PAS
  290. echo *Compiling MMOS2 units ...
  291. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %OS2RTL%\DIVE.PAS
  292. if %PARAMS% == rtl goto End
  293. :Compiler
  294. echo *Creating file with all the needed options and paths for the compiler ...
  295. echo %SKIPCFG% > %OS2OPTF%
  296. echo %OS2OPT1% >> %OS2OPTF%
  297. echo %OS2OPT2% >> %OS2OPTF%
  298. echo %OS2OPT3% >> %OS2OPTF%
  299. echo %OS2OPT4% >> %OS2OPTF%
  300. echo %OS2OBJP% >> %OS2OPTF%
  301. echo %OS2UNITP% >> %OS2OPTF%
  302. echo -FD%REALTOOLS% >> %OS2OPTF%
  303. echo %COMPUNITP% >> %OS2OPTF%
  304. echo %COMPINCP% >> %OS2OPTF%
  305. echo %COMPOBJP% >> %OS2OPTF%
  306. echo %STACKOPT% >> %OS2OPTF%
  307. echo %OS2EXET% >> %OS2OPTF%
  308. if not .%CURRENTOPT1% == . echo %CURRENTOPT1% >> %OS2OPTF%
  309. if not .%CURRENTOPT2% == . echo %CURRENTOPT2% >> %OS2OPTF%
  310. echo *Compiling the compiler ...
  311. %REALTOOLS%%COMPILER% @%OS2OPTF% %OTHEROPTS% %COMPSPATH%\PP.PAS
  312. :Comp2
  313. ren %COMPSPATH%\pp.exe ppos2.exe
  314. if exist %COMPSPATH%\ppos2.exe goto OKCompiler
  315. if exist %COMPSPATH%\ppas.bat goto PPasBat
  316. if exist %COMPSPATH%\ppas.cmd goto PPasCmd
  317. echo *Error: The compiler wasn't compiled!!
  318. goto End
  319. :PPasBat
  320. echo *Automatic binding failed, trying again ...
  321. call %COMPSPATH%\ppas.bat
  322. del %COMPSPATH%\ppas.bat
  323. goto Comp2
  324. goto PPas
  325. :PPasCmd
  326. echo *Automatic binding failed, trying again ...
  327. call %COMPSPATH%\ppas.cmd
  328. del %COMPSPATH%\ppas.cmd
  329. goto Comp2
  330. :OKCompiler
  331. if %PARAMS% == compiler goto End
  332. if %PARAMS% == both goto End
  333. if %PARAMS% == cycle goto Cycle
  334. goto CheckEnv
  335. :Cycle
  336. rem Another loop?
  337. if %CYCLE% == 2 goto CheckEnv
  338. echo *Backing up previous compiler version ...
  339. copy %REALTOOLS%ppos2.exe %REALTOOLS%ppos2.%CYCLE%
  340. echo *Copying the newly created compiler to %REALTOOLS% ...
  341. copy %COMPSPATH%\ppos2.exe %REALTOOLS%.
  342. if %CYCLE% == 1 goto Cycle2
  343. set COMPILER=PPOS2.EXE
  344. set CYCLE=1
  345. goto Cmd1
  346. :Cycle2
  347. set CYCLE=2
  348. goto Cmd1
  349. :CheckEnv
  350. if %@EVAL[0] == 0 goto Pack
  351. echo *Warning: Packing in this environment might fail.
  352. echo *You should press Ctrl-Break now if the current drive is different from that
  353. echo *of %FPCDIR%; otherwise press any key to continue.
  354. pause>nul
  355. cd %FPCSRC%
  356. :Pack
  357. echo *Packing the snapshot ...
  358. if %@EVAL[0] == 0 goto SHL2
  359. goto Cmd2
  360. :Shl2
  361. pushd
  362. cdd %FPCSRC%
  363. :Cmd2
  364. rem ZIP.EXE must be on the PATH
  365. zip -9 -r snap-os2.zip compiler\ppos2.exe rtl\os2\*.ppo rtl\os2\*.oo2 rtl\os2\*.ao2
  366. if exist snap-os2.zip goto ZipOK
  367. echo *Error: The ZIP file hasn't been created!!
  368. :ZipOK
  369. if %@EVAL[0] == 0 popd
  370. echo *Done.
  371. goto End
  372. :ErrorDir
  373. echo *Error: Environment variable FPCDIR must point to your base FPC directory!!!
  374. goto End
  375. $Log$
  376. Revision 1.6 2000-01-16 18:44:21 hajny
  377. * got rid of PPC386.CFG dependency
  378. Revision 1.3 1999/10/01 09:00:21 hajny
  379. + PMGPI and DIVE added
  380. Revision 1.2 1999/09/15 07:31:49 hajny
  381. + some units added, OTHEROPTS variable support
  382. :End