mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 14:39:36 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			181 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			ObjectPascal
		
	
	
	
	
	
			
		
		
	
	
			181 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			ObjectPascal
		
	
	
	
	
	
{
 | 
						|
    $Id$
 | 
						|
    Copyright (c) 1998-2000 by Florian Klaempfl
 | 
						|
 | 
						|
    Commandline compiler for Free Pascal
 | 
						|
 | 
						|
    This program is free software; you can redistribute it and/or modify
 | 
						|
    it under the terms of the GNU General Public License as published by
 | 
						|
    the Free Software Foundation; either version 2 of the License, or
 | 
						|
    (at your option) any later version.
 | 
						|
 | 
						|
    This program is distributed in the hope that it will be useful,
 | 
						|
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
						|
    GNU General Public License for more details.
 | 
						|
 | 
						|
    You should have received a copy of the GNU General Public License
 | 
						|
    along with this program; if not, write to the Free Software
 | 
						|
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
						|
 | 
						|
 ****************************************************************************
 | 
						|
}
 | 
						|
program pp;
 | 
						|
 | 
						|
{
 | 
						|
  possible compiler switches (* marks a currently required switch):
 | 
						|
  -----------------------------------------------------------------
 | 
						|
  TP                  to compile the compiler with Turbo or Borland Pascal
 | 
						|
  GDB*                support of the GNU Debugger
 | 
						|
  I386                generate a compiler for the Intel i386+
 | 
						|
  M68K                generate a compiler for the M68000
 | 
						|
  SPARC               generate a compiler for SPARC
 | 
						|
  POWERPC             generate a compiler for the PowerPC
 | 
						|
  USEOVERLAY          compiles a TP version which uses overlays
 | 
						|
  DEBUG               version with debug code is generated
 | 
						|
  EXTDEBUG            some extra debug code is executed
 | 
						|
  SUPPORT_MMX         only i386: releases the compiler switch
 | 
						|
                      MMX which allows the compiler to generate
 | 
						|
                      MMX instructions
 | 
						|
  EXTERN_MSG          Don't compile the msgfiles in the compiler, always
 | 
						|
                      use external messagefiles, default for TP
 | 
						|
  NOAG386INT          no Intel Assembler output
 | 
						|
  NOAG386NSM          no NASM output
 | 
						|
  NOAG386BIN          leaves out the binary writer, default for TP
 | 
						|
  NORA386DIR          No direct i386 assembler reader
 | 
						|
  -----------------------------------------------------------------
 | 
						|
 | 
						|
  Required switches for a i386 compiler be compiled by Free Pascal Compiler:
 | 
						|
  GDB;I386
 | 
						|
 | 
						|
  Required switches for a i386 compiler be compiled by Turbo Pascal:
 | 
						|
  GDB;I386;TP
 | 
						|
 | 
						|
  Required switches for a 68000 compiler be compiled by Turbo Pascal:
 | 
						|
  GDB;M68k;TP
 | 
						|
}
 | 
						|
 | 
						|
{$i defines.inc}
 | 
						|
 | 
						|
{$ifdef FPC}
 | 
						|
   {$ifndef GDB}
 | 
						|
      { people can try to compile without GDB }
 | 
						|
      { $error The compiler switch GDB must be defined}
 | 
						|
   {$endif GDB}
 | 
						|
   { but I386 or M68K must be defined }
 | 
						|
   { and only one of the two }
 | 
						|
   {$ifdef I386}
 | 
						|
     {$ifdef CPUDEFINED}
 | 
						|
        {$fatal ONLY one of the switches for the CPU type must be defined}
 | 
						|
     {$endif CPUDEFINED}
 | 
						|
     {$define CPUDEFINED}
 | 
						|
   {$endif I386}
 | 
						|
   {$ifdef M68K}
 | 
						|
     {$ifdef CPUDEFINED}
 | 
						|
        {$fatal ONLY one of the switches for the CPU type must be defined}
 | 
						|
     {$endif CPUDEFINED}
 | 
						|
     {$define CPUDEFINED}
 | 
						|
   {$endif M68K}
 | 
						|
   {$ifdef iA64}
 | 
						|
     {$ifdef CPUDEFINED}
 | 
						|
        {$fatal ONLY one of the switches for the CPU type must be defined}
 | 
						|
     {$endif CPUDEFINED}
 | 
						|
     {$define CPUDEFINED}
 | 
						|
   {$endif iA64}
 | 
						|
   {$ifndef CPUDEFINED}
 | 
						|
     {$fatal A CPU type switch must be defined}
 | 
						|
   {$endif CPUDEFINED}
 | 
						|
   {$ifdef support_mmx}
 | 
						|
     {$ifndef i386}
 | 
						|
       {$fatal I386 switch must be on for MMX support}
 | 
						|
     {$endif i386}
 | 
						|
   {$endif support_mmx}
 | 
						|
{$endif}
 | 
						|
 | 
						|
uses
 | 
						|
{$ifdef FPC}
 | 
						|
  {$ifdef profile}
 | 
						|
    profile,
 | 
						|
  {$endif profile}
 | 
						|
  {$ifdef heaptrc}
 | 
						|
    ppheap,
 | 
						|
  {$endif heaptrc}
 | 
						|
  {$ifdef Unix}
 | 
						|
    catch,
 | 
						|
  {$endif}
 | 
						|
  {$ifdef go32v2}
 | 
						|
    {$ifdef DEBUG}
 | 
						|
      {$define NOCATCH}
 | 
						|
    {$endif DEBUG}
 | 
						|
    catch,
 | 
						|
  {$endif}
 | 
						|
{$endif FPC}
 | 
						|
  globals,compiler;
 | 
						|
 | 
						|
var
 | 
						|
  oldexit : pointer;
 | 
						|
procedure myexit;
 | 
						|
begin
 | 
						|
  exitproc:=oldexit;
 | 
						|
{ Show Runtime error if there was an error }
 | 
						|
  if (erroraddr<>nil) then
 | 
						|
   begin
 | 
						|
     case exitcode of
 | 
						|
      100:
 | 
						|
        begin
 | 
						|
           erroraddr:=nil;
 | 
						|
           writeln('Error while reading file');
 | 
						|
        end;
 | 
						|
      101:
 | 
						|
        begin
 | 
						|
           erroraddr:=nil;
 | 
						|
           writeln('Error while writing file');
 | 
						|
        end;
 | 
						|
      202:
 | 
						|
        begin
 | 
						|
           erroraddr:=nil;
 | 
						|
           writeln('Error: Stack Overflow');
 | 
						|
        end;
 | 
						|
      203:
 | 
						|
        begin
 | 
						|
           erroraddr:=nil;
 | 
						|
           writeln('Error: Out of memory');
 | 
						|
        end;
 | 
						|
     end;
 | 
						|
     { we cannot use aktfilepos.file because all memory might have been
 | 
						|
       freed already !
 | 
						|
       But we can use global parser_current_file var }
 | 
						|
     Writeln('Compilation aborted ',parser_current_file,':',aktfilepos.line);
 | 
						|
   end;
 | 
						|
end;
 | 
						|
 | 
						|
begin
 | 
						|
  oldexit:=exitproc;
 | 
						|
  exitproc:=@myexit;
 | 
						|
 | 
						|
{ Call the compiler with empty command, so it will take the parameters }
 | 
						|
  Halt(compiler.Compile(''));
 | 
						|
end.
 | 
						|
{
 | 
						|
  $Log$
 | 
						|
  Revision 1.7  2001-02-26 19:44:53  peter
 | 
						|
    * merged generic m68k updates from fixes branch
 | 
						|
 | 
						|
  Revision 1.6  2000/11/29 00:30:37  florian
 | 
						|
    * unused units removed from uses clause
 | 
						|
    * some changes for widestrings
 | 
						|
 | 
						|
  Revision 1.5  2000/11/13 15:26:12  marco
 | 
						|
   * Renamefest
 | 
						|
 | 
						|
  Revision 1.4  2000/10/01 21:15:55  pierre
 | 
						|
   * lineinfo explicit load not needed anymore
 | 
						|
 | 
						|
  Revision 1.3  2000/09/24 15:06:23  peter
 | 
						|
    * use defines.inc
 | 
						|
 | 
						|
  Revision 1.2  2000/07/13 11:32:45  michael
 | 
						|
  + removed logs
 | 
						|
 | 
						|
}
 |