pp.pas 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 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. {$UNDEFINE 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. {$ifndef CPUOK}
  68. {$fatal One of the switches I386,Alpha or M68K must be defined}
  69. {$endif}
  70. {$ifdef support_mmx}
  71. {$ifndef i386}
  72. {$fatal I386 switch must be on for MMX support}
  73. {$endif i386}
  74. {$endif support_mmx}
  75. {$endif}
  76. {$ifdef TP}
  77. {$IFNDEF DPMI}
  78. {$M 24000,0,655360}
  79. {$ELSE}
  80. {$M 65000}
  81. {$ENDIF DPMI}
  82. {$E+,N+,F+,S-,R-}
  83. {$endif TP}
  84. program pp;
  85. {$IFDEF TP}
  86. {$UNDEF PROFILE}
  87. {$IFDEF DPMI}
  88. {$UNDEF USEOVERLAY}
  89. {$ENDIF}
  90. {$ENDIF}
  91. {$ifdef FPC}
  92. {$UNDEF USEOVERLAY}
  93. {$ENDIF}
  94. uses
  95. {$ifdef useoverlay}
  96. {$ifopt o+}
  97. Overlay,ppovin,
  98. {$else}
  99. {$error You must compile with the $O+ switch}
  100. {$endif}
  101. {$endif useoverlay}
  102. {$ifdef profile}
  103. profile,
  104. {$endif profile}
  105. {$ifdef FPC}
  106. {$ifdef heaptrc}
  107. ppheap,
  108. {$endif heaptrc}
  109. {$ifdef linux}
  110. catch,
  111. {$endif}
  112. {$endif FPC}
  113. globals,compiler
  114. ;
  115. {$ifdef useoverlay}
  116. {$O files}
  117. {$O globals}
  118. {$O hcodegen}
  119. {$O pass_1}
  120. {$O pass_2}
  121. {$O tree}
  122. {$O types}
  123. {$O objects}
  124. {$O options}
  125. {$O cobjects}
  126. {$O globals}
  127. {$O systems}
  128. {$O parser}
  129. {$O pbase}
  130. {$O pdecl}
  131. {$O pexports}
  132. {$O pexpr}
  133. {$O pmodules}
  134. {$O pstatmnt}
  135. {$O psub}
  136. {$O psystem}
  137. {$O ptconst}
  138. {$O script}
  139. {$O switches}
  140. {$O comphook}
  141. {$O dos}
  142. {$O scanner}
  143. {$O symtable}
  144. {$O objects}
  145. {$O aasm}
  146. {$O link}
  147. {$O assemble}
  148. {$O messages}
  149. {$O gendef}
  150. {$O import}
  151. {$ifdef i386}
  152. {$O os2_targ}
  153. {$O win_targ}
  154. {$endif i386}
  155. {$ifdef gdb}
  156. {$O gdb}
  157. {$endif gdb}
  158. {$ifdef i386}
  159. {$O opts386}
  160. {$O i386base}
  161. {$O i386asm}
  162. {$O tgeni386}
  163. {$ifndef NOOPT}
  164. {$O aopt386}
  165. {$endif}
  166. {$IfNDef Nora386dir}
  167. {$O ra386dir}
  168. {$endif}
  169. {$IfNDef Nora386int}
  170. {$O ra386int}
  171. {$endif}
  172. {$IfNDef Nora386att}
  173. {$O ra386att}
  174. {$endif}
  175. {$ifndef NoAg386Int}
  176. {$O ag386int}
  177. {$endif}
  178. {$ifndef NoAg386Att}
  179. {$O ag386att}
  180. {$endif}
  181. {$ifndef NoAg386Nsm}
  182. {$O ag386nsm}
  183. {$endif}
  184. {$endif}
  185. {$ifdef m68k}
  186. {$O opts68k}
  187. {$O m68k}
  188. {$O cga68k}
  189. {$O tgen68k}
  190. {$O cg68kadd}
  191. {$O cg68kcal}
  192. {$O cg68kcnv}
  193. {$O cg68kcon}
  194. {$O cg68kflw}
  195. {$O cg68kld}
  196. {$O cg68kinl}
  197. {$O cg68kmat}
  198. {$O cg68kset}
  199. {$IfNDef Nora68kMot}
  200. {$O ra68kmot}
  201. {$endif}
  202. {$IfNDef Noag68kGas}
  203. {$O ag68kgas}
  204. {$endif}
  205. {$IfNDef Noag68kMot}
  206. {$O ag68kmot}
  207. {$endif}
  208. {$IfNDef Noag68kMit}
  209. {$O ag68kmit}
  210. {$endif}
  211. {$endif}
  212. {$endif useoverlay}
  213. var
  214. oldexit : pointer;
  215. procedure myexit;{$ifndef FPC}far;{$endif}
  216. begin
  217. exitproc:=oldexit;
  218. { Show Runtime error if there was an error }
  219. if (erroraddr<>nil) then
  220. begin
  221. case exitcode of
  222. 202 : begin
  223. erroraddr:=nil;
  224. Writeln('Error: Stack Overflow');
  225. end;
  226. 203 : begin
  227. erroraddr:=nil;
  228. Writeln('Error: Out of memory');
  229. end;
  230. end;
  231. Writeln('Compilation aborted at line ',aktfilepos.line);
  232. end;
  233. end;
  234. begin
  235. oldexit:=exitproc;
  236. exitproc:=@myexit;
  237. {$ifdef fpc}
  238. heapblocks:=true;
  239. {$endif}
  240. {$ifdef UseOverlay}
  241. InitOverlay;
  242. {$endif}
  243. { Call the compiler with empty command, so it will take the parameters }
  244. Halt(Compile(''));
  245. end.
  246. {
  247. $Log$
  248. Revision 1.4 1999-08-02 17:15:03 michael
  249. + CPU check better
  250. Revision 1.3 1999/08/02 17:14:10 florian
  251. + changed the temp. generator to an object
  252. Revision 1.2 1999/08/01 18:22:37 florian
  253. * made it again compilable
  254. Revision 1.1 1998/12/26 15:20:31 florian
  255. + more changes for the new version
  256. }