pp.pas 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. {$ifndef I386}
  59. {$ifndef M68K}
  60. {$fatal One of the switches I386 or M68K must be defined}
  61. {$endif M68K}
  62. {$endif I386}
  63. {$ifdef I386}
  64. {$ifdef M68K}
  65. {$fatal ONLY one of the switches I386 or M68K must be defined}
  66. {$endif M68K}
  67. {$endif I386}
  68. {$ifdef support_mmx}
  69. {$ifndef i386}
  70. {$fatal I386 switch must be on for MMX support}
  71. {$endif i386}
  72. {$endif support_mmx}
  73. {$endif}
  74. uses
  75. {$ifdef FPC}
  76. {$ifdef profile}
  77. profile,
  78. {$endif profile}
  79. {$ifdef heaptrc}
  80. ppheap,
  81. {$endif heaptrc}
  82. {$ifdef linux}
  83. catch,
  84. {$endif}
  85. {$ifdef go32v2}
  86. {$ifdef DEBUG}
  87. {$define NOCATCH}
  88. {$endif DEBUG}
  89. catch,
  90. {$endif}
  91. {$endif FPC}
  92. globals,compiler;
  93. var
  94. oldexit : pointer;
  95. procedure myexit;
  96. begin
  97. exitproc:=oldexit;
  98. { Show Runtime error if there was an error }
  99. if (erroraddr<>nil) then
  100. begin
  101. case exitcode of
  102. 100:
  103. begin
  104. erroraddr:=nil;
  105. writeln('Error while reading file');
  106. end;
  107. 101:
  108. begin
  109. erroraddr:=nil;
  110. writeln('Error while writing file');
  111. end;
  112. 202:
  113. begin
  114. erroraddr:=nil;
  115. writeln('Error: Stack Overflow');
  116. end;
  117. 203:
  118. begin
  119. erroraddr:=nil;
  120. writeln('Error: Out of memory');
  121. end;
  122. end;
  123. { we cannot use aktfilepos.file because all memory might have been
  124. freed already !
  125. But we can use global parser_current_file var }
  126. Writeln('Compilation aborted ',parser_current_file,':',aktfilepos.line);
  127. end;
  128. end;
  129. begin
  130. oldexit:=exitproc;
  131. exitproc:=@myexit;
  132. { Call the compiler with empty command, so it will take the parameters }
  133. Halt(compiler.Compile(''));
  134. end.
  135. {
  136. $Log$
  137. Revision 1.4 2000-10-01 21:15:55 pierre
  138. * lineinfo explicit load not needed anymore
  139. Revision 1.3 2000/09/24 15:06:23 peter
  140. * use defines.inc
  141. Revision 1.2 2000/07/13 11:32:45 michael
  142. + removed logs
  143. }