os2snap.cmd 14 KB

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