pp.pas 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. 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. M68K generate a compiler for the M68000
  25. SPARC generate a compiler for SPARC
  26. POWERPC generate a compiler for the PowerPC
  27. USEOVERLAY compiles a TP version which uses overlays
  28. DEBUG version with debug code is generated
  29. EXTDEBUG some extra debug code is executed
  30. SUPPORT_MMX only i386: releases the compiler switch
  31. MMX which allows the compiler to generate
  32. MMX instructions
  33. EXTERN_MSG Don't compile the msgfiles in the compiler, always
  34. use external messagefiles, default for TP
  35. NOAG386INT no Intel Assembler output
  36. NOAG386NSM no NASM output
  37. NOAG386BIN leaves out the binary writer, default for TP
  38. NORA386DIR No direct i386 assembler reader
  39. -----------------------------------------------------------------
  40. Required switches for a i386 compiler be compiled by Free Pascal Compiler:
  41. GDB;I386
  42. }
  43. {$i defines.inc}
  44. {$ifdef FPC}
  45. {$ifndef GDB}
  46. { people can try to compile without GDB }
  47. { $error The compiler switch GDB must be defined}
  48. {$endif GDB}
  49. { exactly one target CPU must be defined }
  50. {$ifdef I386}
  51. {$ifdef CPUDEFINED}
  52. {$fatal ONLY one of the switches for the CPU type must be defined}
  53. {$endif CPUDEFINED}
  54. {$define CPUDEFINED}
  55. {$endif I386}
  56. {$ifdef M68K}
  57. {$ifdef CPUDEFINED}
  58. {$fatal ONLY one of the switches for the CPU type must be defined}
  59. {$endif CPUDEFINED}
  60. {$define CPUDEFINED}
  61. {$endif M68K}
  62. {$ifdef iA64}
  63. {$ifdef CPUDEFINED}
  64. {$fatal ONLY one of the switches for the CPU type must be defined}
  65. {$endif CPUDEFINED}
  66. {$define CPUDEFINED}
  67. {$endif iA64}
  68. {$ifdef POWERPC}
  69. {$ifdef CPUDEFINED}
  70. {$fatal ONLY one of the switches for the CPU type must be defined}
  71. {$endif CPUDEFINED}
  72. {$define CPUDEFINED}
  73. {$endif POWERPC}
  74. {$ifdef ALPHA}
  75. {$ifdef CPUDEFINED}
  76. {$fatal ONLY one of the switches for the CPU type must be defined}
  77. {$endif CPUDEFINED}
  78. {$define CPUDEFINED}
  79. {$endif ALPHA}
  80. {$ifndef CPUDEFINED}
  81. {$fatal A CPU type switch must be defined}
  82. {$endif CPUDEFINED}
  83. {$ifdef support_mmx}
  84. {$ifndef i386}
  85. {$fatal I386 switch must be on for MMX support}
  86. {$endif i386}
  87. {$endif support_mmx}
  88. {$endif}
  89. uses
  90. {$ifdef FPC}
  91. {$ifdef profile}
  92. profile,
  93. {$endif profile}
  94. {$ifdef heaptrc}
  95. ppheap,
  96. {$endif heaptrc}
  97. {$ifdef Unix}
  98. catch,
  99. {$endif}
  100. {$ifdef go32v2}
  101. {$ifdef DEBUG}
  102. {$define NOCATCH}
  103. {$endif DEBUG}
  104. catch,
  105. {$endif}
  106. {$endif FPC}
  107. globals,compiler;
  108. var
  109. oldexit : pointer;
  110. procedure myexit;
  111. begin
  112. exitproc:=oldexit;
  113. { Show Runtime error if there was an error }
  114. if (erroraddr<>nil) then
  115. begin
  116. case exitcode of
  117. 100:
  118. begin
  119. erroraddr:=nil;
  120. writeln('Error while reading file');
  121. end;
  122. 101:
  123. begin
  124. erroraddr:=nil;
  125. writeln('Error while writing file');
  126. end;
  127. 202:
  128. begin
  129. erroraddr:=nil;
  130. writeln('Error: Stack Overflow');
  131. end;
  132. 203:
  133. begin
  134. erroraddr:=nil;
  135. writeln('Error: Out of memory');
  136. end;
  137. end;
  138. { we cannot use aktfilepos.file because all memory might have been
  139. freed already !
  140. But we can use global parser_current_file var }
  141. Writeln('Compilation aborted ',parser_current_file,':',aktfilepos.line);
  142. end;
  143. end;
  144. begin
  145. oldexit:=exitproc;
  146. exitproc:=@myexit;
  147. { Call the compiler with empty command, so it will take the parameters }
  148. Halt(compiler.Compile(''));
  149. end.
  150. {
  151. $Log$
  152. Revision 1.9 2001-11-14 01:12:45 florian
  153. * variant paramter passing and functions results fixed
  154. Revision 1.8 2001/08/26 13:36:46 florian
  155. * some cg reorganisation
  156. * some PPC updates
  157. Revision 1.7 2001/02/26 19:44:53 peter
  158. * merged generic m68k updates from fixes branch
  159. Revision 1.6 2000/11/29 00:30:37 florian
  160. * unused units removed from uses clause
  161. * some changes for widestrings
  162. Revision 1.5 2000/11/13 15:26:12 marco
  163. * Renamefest
  164. Revision 1.4 2000/10/01 21:15:55 pierre
  165. * lineinfo explicit load not needed anymore
  166. Revision 1.3 2000/09/24 15:06:23 peter
  167. * use defines.inc
  168. Revision 1.2 2000/07/13 11:32:45 michael
  169. + removed logs
  170. }