pp.pas 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. Commandline compiler for Free Pascal
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************}
  17. {
  18. possible compiler switches (* marks a currently required switch):
  19. -----------------------------------------------------------------
  20. USE_RHIDE generates errors and warning in an format recognized
  21. by rhide
  22. TP to compile the compiler with Turbo or Borland Pascal
  23. GDB* support of the GNU Debugger
  24. I386 generate a compiler for the Intel i386+
  25. M68K generate a compiler for the M68000
  26. USEOVERLAY compiles a TP version which uses overlays
  27. EXTDEBUG some extra debug code is executed
  28. SUPPORT_MMX only i386: releases the compiler switch
  29. MMX which allows the compiler to generate
  30. MMX instructions
  31. EXTERN_MSG Don't compile the msgfiles in the compiler, always
  32. use external messagefiles, default for TP
  33. NOAG386INT no Intel Assembler output
  34. NOAG386NSM no NASM output
  35. -----------------------------------------------------------------
  36. Required switches for a i386 compiler be compiled by Free Pascal Compiler:
  37. GDB;I386
  38. Required switches for a i386 compiler be compiled by Turbo Pascal:
  39. GDB;I386;TP
  40. Required switches for a 68000 compiler be compiled by Turbo Pascal:
  41. GDB;M68k;TP
  42. }
  43. {$ifdef FPC}
  44. {$ifndef GDB}
  45. { people can try to compile without GDB }
  46. { $error The compiler switch GDB must be defined}
  47. {$endif GDB}
  48. { One of Alpha, I386 or M68K must be defined }
  49. {$UNDEF CPUOK}
  50. {$ifdef I386}
  51. {$define CPUOK}
  52. {$endif}
  53. {$ifdef M68K}
  54. {$ifndef CPUOK}
  55. {$DEFINE CPUOK}
  56. {$else}
  57. {$fatal cannot define two CPU switches}
  58. {$endif}
  59. {$endif}
  60. {$ifdef alpha}
  61. {$ifndef CPUOK}
  62. {$DEFINE CPUOK}
  63. {$else}
  64. {$fatal cannot define two CPU switches}
  65. {$endif}
  66. {$endif}
  67. {$ifdef powerpc}
  68. {$ifndef CPUOK}
  69. {$DEFINE CPUOK}
  70. {$else}
  71. {$fatal cannot define two CPU switches}
  72. {$endif}
  73. {$endif}
  74. {$ifndef CPUOK}
  75. {$fatal One of the switches I386,Alpha, PowerPC or M68K must be defined}
  76. {$endif}
  77. {$ifdef support_mmx}
  78. {$ifndef i386}
  79. {$fatal I386 switch must be on for MMX support}
  80. {$endif i386}
  81. {$endif support_mmx}
  82. {$endif}
  83. {$ifdef TP}
  84. {$IFNDEF DPMI}
  85. {$M 24000,0,655360}
  86. {$ELSE}
  87. {$M 65000}
  88. {$ENDIF DPMI}
  89. {$E+,N+,F+,S-,R-}
  90. {$endif TP}
  91. program pp;
  92. {$IFDEF TP}
  93. {$UNDEF PROFILE}
  94. {$IFDEF DPMI}
  95. {$UNDEF USEOVERLAY}
  96. {$ENDIF}
  97. {$ENDIF}
  98. {$ifdef FPC}
  99. {$UNDEF USEOVERLAY}
  100. {$ENDIF}
  101. uses
  102. {$ifdef useoverlay}
  103. {$ifopt o+}
  104. Overlay,ppovin,
  105. {$else}
  106. {$error You must compile with the $O+ switch}
  107. {$endif}
  108. {$endif useoverlay}
  109. {$ifdef profile}
  110. profile,
  111. {$endif profile}
  112. {$ifdef FPC}
  113. {$ifdef heaptrc}
  114. ppheap,
  115. {$endif heaptrc}
  116. {$ifdef linux}
  117. catch,
  118. {$endif}
  119. {$endif FPC}
  120. globals,compiler
  121. ;
  122. {$ifdef useoverlay}
  123. {$O files}
  124. {$O globals}
  125. {$O hcodegen}
  126. {$O pass_1}
  127. {$O pass_2}
  128. {$O tree}
  129. {$O types}
  130. {$O objects}
  131. {$O options}
  132. {$O cobjects}
  133. {$O globals}
  134. {$O systems}
  135. {$O parser}
  136. {$O pbase}
  137. {$O pdecl}
  138. {$O pexports}
  139. {$O pexpr}
  140. {$O pmodules}
  141. {$O pstatmnt}
  142. {$O psub}
  143. {$O psystem}
  144. {$O ptconst}
  145. {$O script}
  146. {$O switches}
  147. {$O comphook}
  148. {$O dos}
  149. {$O scanner}
  150. {$O symtable}
  151. {$O objects}
  152. {$O aasm}
  153. {$O link}
  154. {$O assemble}
  155. {$O messages}
  156. {$O gendef}
  157. {$O import}
  158. {$ifdef i386}
  159. {$O os2_targ}
  160. {$O win_targ}
  161. {$endif i386}
  162. {$ifdef gdb}
  163. {$O gdb}
  164. {$endif gdb}
  165. {$ifdef i386}
  166. {$O opts386}
  167. {$O i386base}
  168. {$O i386asm}
  169. {$O tgeni386}
  170. {$ifndef NOOPT}
  171. {$O aopt386}
  172. {$endif}
  173. {$IfNDef Nora386dir}
  174. {$O ra386dir}
  175. {$endif}
  176. {$IfNDef Nora386int}
  177. {$O ra386int}
  178. {$endif}
  179. {$IfNDef Nora386att}
  180. {$O ra386att}
  181. {$endif}
  182. {$ifndef NoAg386Int}
  183. {$O ag386int}
  184. {$endif}
  185. {$ifndef NoAg386Att}
  186. {$O ag386att}
  187. {$endif}
  188. {$ifndef NoAg386Nsm}
  189. {$O ag386nsm}
  190. {$endif}
  191. {$endif}
  192. {$ifdef m68k}
  193. {$O opts68k}
  194. {$O m68k}
  195. {$O cga68k}
  196. {$O tgen68k}
  197. {$O cg68kadd}
  198. {$O cg68kcal}
  199. {$O cg68kcnv}
  200. {$O cg68kcon}
  201. {$O cg68kflw}
  202. {$O cg68kld}
  203. {$O cg68kinl}
  204. {$O cg68kmat}
  205. {$O cg68kset}
  206. {$IfNDef Nora68kMot}
  207. {$O ra68kmot}
  208. {$endif}
  209. {$IfNDef Noag68kGas}
  210. {$O ag68kgas}
  211. {$endif}
  212. {$IfNDef Noag68kMot}
  213. {$O ag68kmot}
  214. {$endif}
  215. {$IfNDef Noag68kMit}
  216. {$O ag68kmit}
  217. {$endif}
  218. {$endif}
  219. {$endif useoverlay}
  220. var
  221. oldexit : pointer;
  222. procedure myexit;{$ifndef FPC}far;{$endif}
  223. begin
  224. exitproc:=oldexit;
  225. { Show Runtime error if there was an error }
  226. if (erroraddr<>nil) then
  227. begin
  228. case exitcode of
  229. 202 : begin
  230. erroraddr:=nil;
  231. Writeln('Error: Stack Overflow');
  232. end;
  233. 203 : begin
  234. erroraddr:=nil;
  235. Writeln('Error: Out of memory');
  236. end;
  237. end;
  238. Writeln('Compilation aborted at line ',aktfilepos.line);
  239. end;
  240. end;
  241. begin
  242. oldexit:=exitproc;
  243. exitproc:=@myexit;
  244. {$ifdef UseOverlay}
  245. InitOverlay;
  246. {$endif}
  247. { Call the compiler with empty command, so it will take the parameters }
  248. Halt(Compile(''));
  249. end.
  250. {
  251. $Log$
  252. Revision 1.8 2000-01-07 01:14:54 peter
  253. * updated copyright to 2000
  254. Revision 1.7 1999/10/12 21:20:47 florian
  255. * new codegenerator compiles again
  256. Revision 1.6 1999/08/04 12:59:22 jonas
  257. * all tokes now start with an underscore
  258. * PowerPC compiles!!
  259. Revision 1.5 1999/08/02 21:29:06 florian
  260. * the main branch psub.pas is now used for
  261. newcg compiler
  262. Revision 1.4 1999/08/02 17:15:03 michael
  263. + CPU check better
  264. Revision 1.3 1999/08/02 17:14:10 florian
  265. + changed the temp. generator to an object
  266. Revision 1.2 1999/08/01 18:22:37 florian
  267. * made it again compilable
  268. Revision 1.1 1998/12/26 15:20:31 florian
  269. + more changes for the new version
  270. }