pp.pas 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. USE_RHIDE generates errors and warning in an format recognized
  23. by rhide
  24. TP to compile the compiler with Turbo or Borland Pascal
  25. GDB* support of the GNU Debugger
  26. I386 generate a compiler for the Intel i386+
  27. M68K generate a compiler for the M68000
  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. LOGMEMBLOCKS adds memory manager which logs the size of
  40. each allocated memory block, the information
  41. is written to memuse.log after compiling
  42. -----------------------------------------------------------------
  43. Required switches for a i386 compiler be compiled by Free Pascal Compiler:
  44. GDB;I386
  45. Required switches for a i386 compiler be compiled by Turbo Pascal:
  46. GDB;I386;TP
  47. Required switches for a 68000 compiler be compiled by Turbo Pascal:
  48. GDB;M68k;TP
  49. }
  50. {$i defines.inc}
  51. {$ifdef FPC}
  52. {$ifndef GDB}
  53. { people can try to compile without GDB }
  54. { $error The compiler switch GDB must be defined}
  55. {$endif GDB}
  56. { but I386 or M68K must be defined }
  57. { and only one of the two }
  58. {$ifdef I386}
  59. {$ifdef CPUDEFINED}
  60. {$fatal ONLY one of the switches for the CPU type must be defined}
  61. {$endif CPUDEFINED}
  62. {$define CPUDEFINED}
  63. {$endif I386}
  64. {$ifdef M68K}
  65. {$ifdef CPUDEFINED}
  66. {$fatal ONLY one of the switches for the CPU type must be defined}
  67. {$endif CPUDEFINED}
  68. {$define CPUDEFINED}
  69. {$endif M68K}
  70. {$ifdef iA64}
  71. {$ifdef CPUDEFINED}
  72. {$fatal ONLY one of the switches for the CPU type must be defined}
  73. {$endif CPUDEFINED}
  74. {$define CPUDEFINED}
  75. {$endif iA64}
  76. {$ifndef CPUDEFINED}
  77. {$fatal A CPU type switch must be defined}
  78. {$endif CPUDEFINED}
  79. {$ifdef support_mmx}
  80. {$ifndef i386}
  81. {$fatal I386 switch must be on for MMX support}
  82. {$endif i386}
  83. {$endif support_mmx}
  84. {$endif}
  85. uses
  86. {$ifdef FPC}
  87. {$ifdef profile}
  88. profile,
  89. {$endif profile}
  90. {$ifdef heaptrc}
  91. ppheap,
  92. {$endif heaptrc}
  93. {$ifdef Unix}
  94. catch,
  95. {$endif}
  96. {$ifdef go32v2}
  97. {$ifdef DEBUG}
  98. {$define NOCATCH}
  99. {$endif DEBUG}
  100. catch,
  101. {$endif}
  102. {$endif FPC}
  103. globals,compiler;
  104. var
  105. oldexit : pointer;
  106. procedure myexit;
  107. begin
  108. exitproc:=oldexit;
  109. { Show Runtime error if there was an error }
  110. if (erroraddr<>nil) then
  111. begin
  112. case exitcode of
  113. 100:
  114. begin
  115. erroraddr:=nil;
  116. writeln('Error while reading file');
  117. end;
  118. 101:
  119. begin
  120. erroraddr:=nil;
  121. writeln('Error while writing file');
  122. end;
  123. 202:
  124. begin
  125. erroraddr:=nil;
  126. writeln('Error: Stack Overflow');
  127. end;
  128. 203:
  129. begin
  130. erroraddr:=nil;
  131. writeln('Error: Out of memory');
  132. end;
  133. end;
  134. { we cannot use aktfilepos.file because all memory might have been
  135. freed already !
  136. But we can use global parser_current_file var }
  137. Writeln('Compilation aborted ',parser_current_file,':',aktfilepos.line);
  138. end;
  139. end;
  140. begin
  141. oldexit:=exitproc;
  142. exitproc:=@myexit;
  143. { Call the compiler with empty command, so it will take the parameters }
  144. Halt(compiler.Compile(''));
  145. end.
  146. {
  147. $Log$
  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. }