pp.pas 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 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. program pp;
  19. {
  20. possible compiler switches (* marks a currently required switch):
  21. -----------------------------------------------------------------
  22. GDB* support of the GNU Debugger
  23. I386 generate a compiler for the Intel i386+
  24. x86_64 generate a compiler for the AMD x86-64 architecture
  25. M68K generate a compiler for the M68000
  26. SPARC generate a compiler for SPARC
  27. POWERPC generate a compiler for the PowerPC
  28. USEOVERLAY compiles a TP version which uses overlays
  29. DEBUG version with debug code is generated
  30. EXTDEBUG some extra debug code is executed
  31. SUPPORT_MMX only i386: releases the compiler switch
  32. MMX which allows the compiler to generate
  33. MMX instructions
  34. EXTERN_MSG Don't compile the msgfiles in the compiler, always
  35. use external messagefiles, default for TP
  36. NOAG386INT no Intel Assembler output
  37. NOAG386NSM no NASM output
  38. NOAG386BIN leaves out the binary writer, default for TP
  39. NORA386DIR No direct i386 assembler reader
  40. TEST_GENERIC Test Generic version of code generator
  41. (uses generic RTL calls)
  42. -----------------------------------------------------------------
  43. Required switches for a i386 compiler be compiled by Free Pascal Compiler:
  44. GDB;I386
  45. }
  46. {$i fpcdefs.inc}
  47. {$ifdef FPC}
  48. {$ifndef GDB}
  49. { people can try to compile without GDB }
  50. { $error The compiler switch GDB must be defined}
  51. {$endif GDB}
  52. { exactly one target CPU must be defined }
  53. {$ifdef I386}
  54. {$ifdef CPUDEFINED}
  55. {$fatal ONLY one of the switches for the CPU type must be defined}
  56. {$endif CPUDEFINED}
  57. {$define CPUDEFINED}
  58. {$endif I386}
  59. {$ifdef x86_64}
  60. {$ifdef CPUDEFINED}
  61. {$fatal ONLY one of the switches for the CPU type must be defined}
  62. {$endif CPUDEFINED}
  63. {$define CPUDEFINED}
  64. {$endif x86_64}
  65. {$ifdef M68K}
  66. {$ifdef CPUDEFINED}
  67. {$fatal ONLY one of the switches for the CPU type must be defined}
  68. {$endif CPUDEFINED}
  69. {$define CPUDEFINED}
  70. {$endif M68K}
  71. {$ifdef iA64}
  72. {$ifdef CPUDEFINED}
  73. {$fatal ONLY one of the switches for the CPU type must be defined}
  74. {$endif CPUDEFINED}
  75. {$define CPUDEFINED}
  76. {$endif iA64}
  77. {$ifdef POWERPC}
  78. {$ifdef CPUDEFINED}
  79. {$fatal ONLY one of the switches for the CPU type must be defined}
  80. {$endif CPUDEFINED}
  81. {$define CPUDEFINED}
  82. {$endif POWERPC}
  83. {$ifdef ALPHA}
  84. {$ifdef CPUDEFINED}
  85. {$fatal ONLY one of the switches for the CPU type must be defined}
  86. {$endif CPUDEFINED}
  87. {$define CPUDEFINED}
  88. {$endif ALPHA}
  89. {$ifdef SPARC}
  90. {$ifdef CPUDEFINED}
  91. {$fatal ONLY one of the switches for the CPU type must be defined}
  92. {$endif CPUDEFINED}
  93. {$define CPUDEFINED}
  94. {$endif SPARC}
  95. {$ifndef CPUDEFINED}
  96. {$fatal A CPU type switch must be defined}
  97. {$endif CPUDEFINED}
  98. {$ifdef support_mmx}
  99. {$ifndef i386}
  100. {$fatal I386 switch must be on for MMX support}
  101. {$endif i386}
  102. {$endif support_mmx}
  103. {$endif}
  104. uses
  105. {$ifdef FPC}
  106. {$ifdef profile}
  107. profile,
  108. {$endif profile}
  109. {$ifdef heaptrc}
  110. ppheap,
  111. {$endif heaptrc}
  112. {$ifndef NOCATCH}
  113. {$ifdef Unix}
  114. catch,
  115. {$endif}
  116. {$ifdef go32v2}
  117. catch,
  118. {$endif}
  119. {$endif NOCATCH}
  120. {$endif FPC}
  121. globals,compiler;
  122. var
  123. oldexit : pointer;
  124. procedure myexit;
  125. begin
  126. exitproc:=oldexit;
  127. { Show Runtime error if there was an error }
  128. if (erroraddr<>nil) then
  129. begin
  130. case exitcode of
  131. 100:
  132. begin
  133. erroraddr:=nil;
  134. writeln('Error while reading file');
  135. end;
  136. 101:
  137. begin
  138. erroraddr:=nil;
  139. writeln('Error while writing file');
  140. end;
  141. 202:
  142. begin
  143. erroraddr:=nil;
  144. writeln('Error: Stack Overflow');
  145. end;
  146. 203:
  147. begin
  148. erroraddr:=nil;
  149. writeln('Error: Out of memory');
  150. end;
  151. end;
  152. { we cannot use aktfilepos.file because all memory might have been
  153. freed already !
  154. But we can use global parser_current_file var }
  155. Writeln('Compilation aborted ',parser_current_file,':',aktfilepos.line);
  156. end;
  157. end;
  158. begin
  159. oldexit:=exitproc;
  160. exitproc:=@myexit;
  161. { Call the compiler with empty command, so it will take the parameters }
  162. Halt(compiler.Compile(''));
  163. end.
  164. {
  165. $Log$
  166. Revision 1.18 2002-10-30 21:45:02 peter
  167. * do not include catch unit when compiling with NOCATCH
  168. Revision 1.17 2002/10/15 18:16:44 peter
  169. * GDB switch is not required
  170. Revision 1.16 2002/08/23 13:17:59 mazen
  171. *** empty log message ***
  172. Revision 1.15 2002/07/04 20:43:01 florian
  173. * first x86-64 patches
  174. Revision 1.14 2002/05/22 19:02:16 carl
  175. + generic FPC_HELP_FAIL
  176. + generic FPC_HELP_DESTRUCTOR instated (original from Pierre)
  177. + generic FPC_DISPOSE_CLASS
  178. + TEST_GENERIC define
  179. Revision 1.13 2002/05/18 13:34:13 peter
  180. * readded missing revisions
  181. Revision 1.12 2002/05/16 19:46:43 carl
  182. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  183. + try to fix temp allocation (still in ifdef)
  184. + generic constructor calls
  185. + start of tassembler / tmodulebase class cleanup
  186. Revision 1.10 2002/03/24 19:06:29 carl
  187. + patch for SPARC from Mazen NEIFER
  188. }