pp.pas 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. 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. 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. -----------------------------------------------------------------
  41. Required switches for a i386 compiler be compiled by Free Pascal Compiler:
  42. GDB;I386
  43. Required switches for a i386 compiler be compiled by Turbo Pascal:
  44. GDB;I386;TP
  45. Required switches for a 68000 compiler be compiled by Turbo Pascal:
  46. GDB;M68k;TP
  47. }
  48. {$i defines.inc}
  49. {$ifdef FPC}
  50. {$ifndef GDB}
  51. { people can try to compile without GDB }
  52. { $error The compiler switch GDB must be defined}
  53. {$endif GDB}
  54. { but I386 or M68K must be defined }
  55. { and only one of the two }
  56. {$ifdef I386}
  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 I386}
  62. {$ifdef M68K}
  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 M68K}
  68. {$ifdef iA64}
  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 iA64}
  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.7 2001-02-26 19:44:53 peter
  147. * merged generic m68k updates from fixes branch
  148. Revision 1.6 2000/11/29 00:30:37 florian
  149. * unused units removed from uses clause
  150. * some changes for widestrings
  151. Revision 1.5 2000/11/13 15:26:12 marco
  152. * Renamefest
  153. Revision 1.4 2000/10/01 21:15:55 pierre
  154. * lineinfo explicit load not needed anymore
  155. Revision 1.3 2000/09/24 15:06:23 peter
  156. * use defines.inc
  157. Revision 1.2 2000/07/13 11:32:45 michael
  158. + removed logs
  159. }