Initial revision
[AROS-Contrib.git] / development / compilers / freepascal / compiler / pp.pas
blob728171dfd5a487d7e075a582bf626b73d161cc1f
2 $Id$
3 Copyright (c) 1998-2000 by Florian Klaempfl
5 Commandline compiler for Free Pascal
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 ****************************************************************************}
24 possible compiler switches (* marks a currently required switch):
25 -----------------------------------------------------------------
26 USE_RHIDE generates errors and warning in an format recognized
27 by rhide
28 TP to compile the compiler with Turbo or Borland Pascal
29 GDB* support of the GNU Debugger
30 I386 generate a compiler for the Intel i386+
31 M68K generate a compiler for the M68000
32 USEOVERLAY compiles a TP version which uses overlays
33 DEBUG version with debug code is generated
34 EXTDEBUG some extra debug code is executed
35 SUPPORT_MMX only i386: releases the compiler switch
36 MMX which allows the compiler to generate
37 MMX instructions
38 EXTERN_MSG Don't compile the msgfiles in the compiler, always
39 use external messagefiles, default for TP
40 NOAG386INT no Intel Assembler output
41 NOAG386NSM no NASM output
42 NOAG386BIN leaves out the binary writer, default for TP
43 LOGMEMBLOCKS adds memory manager which logs the size of
44 each allocated memory block, the information
45 is written to memuse.log after compiling
46 -----------------------------------------------------------------
48 Required switches for a i386 compiler be compiled by Free Pascal Compiler:
49 GDB;I386
51 Required switches for a i386 compiler be compiled by Turbo Pascal:
52 GDB;I386;TP
54 Required switches for a 68000 compiler be compiled by Turbo Pascal:
55 GDB;M68k;TP
58 {$ifdef FPC}
59 {$ifndef GDB}
60 { people can try to compile without GDB }
61 { $error The compiler switch GDB must be defined}
62 {$endif GDB}
63 { but I386 or M68K must be defined }
64 { and only one of the two }
65 {$ifndef I386}
66 {$ifndef M68K}
67 {$fatal One of the switches I386 or M68K must be defined}
68 {$endif M68K}
69 {$endif I386}
70 {$ifdef I386}
71 {$ifdef M68K}
72 {$fatal ONLY one of the switches I386 or M68K must be defined}
73 {$endif M68K}
74 {$endif I386}
75 {$ifdef support_mmx}
76 {$ifndef i386}
77 {$fatal I386 switch must be on for MMX support}
78 {$endif i386}
79 {$endif support_mmx}
80 {$endif}
82 {$ifdef TP}
83 {$IFNDEF DPMI}
84 {$M 24000,0,655360}
85 {$ELSE}
86 {$M 65000}
87 {$ENDIF DPMI}
88 {$E+,N+,F+,S-,R-}
89 {$endif TP}
92 program pp;
94 {$IFDEF TP}
95 {$UNDEF PROFILE}
96 {$IFDEF DPMI}
97 {$UNDEF USEOVERLAY}
98 {$ENDIF}
99 {$DEFINE NOAG386BIN}
100 {$ENDIF}
101 {$ifdef FPC}
102 {$UNDEF USEOVERLAY}
103 {$ENDIF}
105 uses
106 {$ifdef useoverlay}
107 {$ifopt o+}
108 Overlay,ppovin,
109 {$else}
110 {$error You must compile with the $O+ switch}
111 {$endif}
112 {$endif useoverlay}
113 {$ifdef profile}
114 profile,
115 {$endif profile}
116 {$ifdef FPC}
117 {$ifdef heaptrc}
118 ppheap,
119 {$endif heaptrc}
120 {$ifdef linux}
121 catch,
122 {$endif}
123 {$ifdef go32v2}
124 {$ifdef DEBUG}
125 {$define NOCATCH}
126 {$endif DEBUG}
127 catch,
128 {$endif}
129 {$endif FPC}
130 globals,compiler
131 {$ifdef logmemblocks}
132 {$ifdef fpc}
133 ,memlog
134 {$endif fpc}
135 {$endif logmemblocks}
138 {$ifdef useoverlay}
139 {$O files}
140 {$O globals}
141 {$O hcodegen}
142 {$O pass_1}
143 {$O pass_2}
144 {$O tree}
145 {$O types}
146 {$O objects}
147 {$O options}
148 {$O cobjects}
149 {$O globals}
150 {$O systems}
151 {$O parser}
152 {$O pbase}
153 {$O pdecl}
154 {$O pexports}
155 {$O pexpr}
156 {$O pmodules}
157 {$O pstatmnt}
158 {$O psub}
159 {$O psystem}
160 {$O ptconst}
161 {$O script}
162 {$O switches}
163 {$O temp_gen}
164 {$O comphook}
165 {$O dos}
166 {$O scanner}
167 {$O symtable}
168 {$O objects}
169 {$O aasm}
170 {$O link}
171 {$O assemble}
172 {$O messages}
173 {$O gendef}
174 {$O import}
175 {$ifdef gdb}
176 {$O gdb}
177 {$endif gdb}
178 {$ifdef i386}
179 {$O cpubase}
180 {$O cgai386}
181 {$O tgeni386}
182 {$O cg386add}
183 {$O cg386cal}
184 {$O cg386cnv}
185 {$O cg386con}
186 {$O cg386flw}
187 {$O cg386ld}
188 {$O cg386inl}
189 {$O cg386mat}
190 {$O cg386set}
191 {$ifndef NOOPT}
192 {$O aopt386}
193 {$O opts386}
194 {$endif}
195 {$IfNDef Nora386dir}
196 {$O ra386dir}
197 {$endif}
198 {$IfNDef Nora386int}
199 {$O ra386int}
200 {$endif}
201 {$IfNDef Nora386att}
202 {$O ra386att}
203 {$endif}
204 {$ifndef NoAg386Int}
205 {$O ag386int}
206 {$endif}
207 {$ifndef NoAg386Att}
208 {$O ag386att}
209 {$endif}
210 {$ifndef NoAg386Nsm}
211 {$O ag386nsm}
212 {$endif}
213 {$endif}
214 {$ifdef m68k}
215 {$O opts68k}
216 {$O cpubase}
217 {$O cga68k}
218 {$O tgen68k}
219 {$O cg68kadd}
220 {$O cg68kcal}
221 {$O cg68kcnv}
222 {$O cg68kcon}
223 {$O cg68kflw}
224 {$O cg68kld}
225 {$O cg68kinl}
226 {$O cg68kmat}
227 {$O cg68kset}
228 {$IfNDef Nora68kMot}
229 {$O ra68kmot}
230 {$endif}
231 {$IfNDef Noag68kGas}
232 {$O ag68kgas}
233 {$endif}
234 {$IfNDef Noag68kMot}
235 {$O ag68kmot}
236 {$endif}
237 {$IfNDef Noag68kMit}
238 {$O ag68kmit}
239 {$endif}
240 {$endif}
241 {$endif useoverlay}
244 oldexit : pointer;
245 procedure myexit;{$ifndef FPC}far;{$endif}
246 begin
247 exitproc:=oldexit;
248 { Show Runtime error if there was an error }
249 if (erroraddr<>nil) then
250 begin
252 case exitcode of
253 100:
254 begin
255 erroraddr:=nil;
256 writeln('Error while reading file');
257 end;
258 101:
259 begin
260 erroraddr:=nil;
261 writeln('Error while writing file');
262 end;
263 202:
264 begin
265 erroraddr:=nil;
266 writeln('Error: Stack Overflow');
267 end;
268 203:
269 begin
270 erroraddr:=nil;
271 writeln('Error: Out of memory');
272 end;
273 end;
274 { we cannot use aktfilepos.file because all memory might have been
275 freed already !
276 But we can use global parser_current_file var }
277 Writeln('Compilation aborted ',parser_current_file,':',aktfilepos.line);
278 end;
279 end;
281 begin
282 oldexit:=exitproc;
283 exitproc:=@myexit;
284 {$ifdef UseOverlay}
285 InitOverlay;
286 {$endif}
288 { Call the compiler with empty command, so it will take the parameters }
289 Halt(compiler.Compile(''));
290 end.
292 $Log$
293 Revision 1.1 2002/02/19 08:23:10 sasu
294 Initial revision
296 Revision 1.1.2.1 2000/09/27 22:35:02 pierre
297 * suppress lineinfo explicit in _uses
299 Revision 1.1 2000/07/13 06:29:54 michael
300 + Initial import
302 Revision 1.60 2000/04/02 15:22:19 florian
303 * fixed bug 903: the compiler gives now a nice message if it can't create
304 the .o file, (same for future .ar)
306 Revision 1.59 2000/03/20 09:36:23 florian
307 * using the directive DEBUG when compiling the compiler will include now
308 the lineinfo unit on all targets
310 Revision 1.58 2000/03/16 10:29:06 florian
311 * disk full runerror writes now a nice message
313 Revision 1.57 2000/03/14 16:30:14 pierre
314 + lineinfo for win32 with debug
316 Revision 1.56 2000/02/18 12:34:43 pierre
317 DEBUG implies NOCATCH for go32v2
319 Revision 1.55 2000/02/10 23:44:43 florian
320 * big update for exception handling code generation: possible mem holes
321 fixed, break/continue/exit should work always now as expected
323 Revision 1.54 2000/02/09 13:22:59 peter
324 * log truncated
326 Revision 1.53 2000/01/07 01:14:30 peter
327 * updated copyright to 2000
329 Revision 1.52 1999/11/06 14:34:23 peter
330 * truncated log to 20 revs
332 Revision 1.51 1999/11/05 13:15:00 florian
333 * some fixes to get the new cg compiling again
335 Revision 1.50 1999/09/17 17:14:10 peter
336 * @procvar fixes for tp mode
337 * @<id>:= gives now an error
339 Revision 1.49 1999/09/16 23:05:54 florian
340 * m68k compiler is again compilable (only gas writer, no assembler reader)
342 Revision 1.48 1999/09/10 18:48:08 florian
343 * some bug fixes (e.g. must_be_valid and procinfo.funcret_is_valid)
344 * most things for stored properties fixed
346 Revision 1.47 1999/09/02 18:47:45 daniel
347 * Could not compile with TP, some arrays moved to heap
348 * NOAG386BIN default for TP
349 * AG386* files were not compatible with TP, fixed.
351 Revision 1.46 1999/08/28 15:34:20 florian
352 * bug 519 fixed
354 Revision 1.45 1999/08/04 00:23:18 florian
355 * renamed i386asm and i386base to cpuasm and cpubase