pp.pas 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. {$ifndef CPUDEFINED}
  75. {$fatal A CPU type switch must be defined}
  76. {$endif CPUDEFINED}
  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. uses
  84. {$ifdef FPC}
  85. {$ifdef profile}
  86. profile,
  87. {$endif profile}
  88. {$ifdef heaptrc}
  89. ppheap,
  90. {$endif heaptrc}
  91. {$ifdef Unix}
  92. catch,
  93. {$endif}
  94. {$ifdef go32v2}
  95. {$ifdef DEBUG}
  96. {$define NOCATCH}
  97. {$endif DEBUG}
  98. catch,
  99. {$endif}
  100. {$endif FPC}
  101. globals,compiler;
  102. var
  103. oldexit : pointer;
  104. procedure myexit;
  105. begin
  106. exitproc:=oldexit;
  107. { Show Runtime error if there was an error }
  108. if (erroraddr<>nil) then
  109. begin
  110. case exitcode of
  111. 100:
  112. begin
  113. erroraddr:=nil;
  114. writeln('Error while reading file');
  115. end;
  116. 101:
  117. begin
  118. erroraddr:=nil;
  119. writeln('Error while writing file');
  120. end;
  121. 202:
  122. begin
  123. erroraddr:=nil;
  124. writeln('Error: Stack Overflow');
  125. end;
  126. 203:
  127. begin
  128. erroraddr:=nil;
  129. writeln('Error: Out of memory');
  130. end;
  131. end;
  132. { we cannot use aktfilepos.file because all memory might have been
  133. freed already !
  134. But we can use global parser_current_file var }
  135. Writeln('Compilation aborted ',parser_current_file,':',aktfilepos.line);
  136. end;
  137. end;
  138. begin
  139. oldexit:=exitproc;
  140. exitproc:=@myexit;
  141. { Call the compiler with empty command, so it will take the parameters }
  142. Halt(compiler.Compile(''));
  143. end.
  144. {
  145. $Log$
  146. Revision 1.8 2001-08-26 13:36:46 florian
  147. * some cg reorganisation
  148. * some PPC updates
  149. Revision 1.7 2001/02/26 19:44:53 peter
  150. * merged generic m68k updates from fixes branch
  151. Revision 1.6 2000/11/29 00:30:37 florian
  152. * unused units removed from uses clause
  153. * some changes for widestrings
  154. Revision 1.5 2000/11/13 15:26:12 marco
  155. * Renamefest
  156. Revision 1.4 2000/10/01 21:15:55 pierre
  157. * lineinfo explicit load not needed anymore
  158. Revision 1.3 2000/09/24 15:06:23 peter
  159. * use defines.inc
  160. Revision 1.2 2000/07/13 11:32:45 michael
  161. + removed logs
  162. }