This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

GNAT: automatically build source generation tools


In order to generate everything in the build directory, I had to
change the command line for the 4 tools (which previously had
hardcoded file names). I've lost a bit of functionality in xnmake from
the command line (generate two files at once), but it was not used by
the Makefile. Also I added BUILD_GNATMAKE since I use the build
gnatmake to build the tools, and copied $(build_exeext) from the top
level Makefile, since I assume this is what needs to be used there.

I'm no Makefile expert and new to GCC patches, so comments are highly
welcomed :).

With the patch plus removing -Wno-long-long, the build goes to stage3
on i686-pc-linux-gnu without having the tools installed. I tried
editing a few things and dependancies behaved right too.

(Legalese is ok for FSF.)

-- 
Laurent Guerby <guerby@acm.org>

2001-10-03  Laurent Guerby <guerby@acm.org>

	* xnmake.adb: Change command line arguments.
	* xtreeprs.adb: Likewise.
	* xeinfo.adb: Likewise.
	* xsinfo.adb: Likewise.
	* Make-lang.in, Makefile.in: Add machinery for building the above tools.

*** Make-lang.in.orig	Thu Oct  4 00:15:24 2001
--- Make-lang.in	Wed Oct  3 23:10:13 2001
*************** ada.uninstall:
*** 555,560 ****
--- 555,561 ----
  ada.mostlyclean:
  	-$(RM) ada/*$(objext) ada/*.ali ada/b_*.c
  	-$(RM) ada/sdefault.adb ada/stamp-sdefault
+ 	-$(RMDIR) ada/tmp-dir
  	-$(RMDIR) ada/tools
  ada.clean:
  ada.distclean:
*** Makefile.in.orig	Wed Oct  3 21:29:49 2001
--- Makefile.in	Wed Oct  3 23:23:22 2001
*************** exeext =
*** 119,124 ****
--- 119,127 ----
  arext  = .a
  soext  = .so
  shext  =
+ build_exeext = @build_exeext@
+ 
+ BUILD_GNATMAKE=gnatmake
  
  HOST_CC=$(CC)
  HOST_CFLAGS=$(ALL_CFLAGS)
*************** b_gnatdll.c : $(GNATDLL_OBJS)
*** 2409,2428 ****
  	$(GNATBIND) $(ADA_INCLUDES) -o b_gnatdll.c gnatdll.ali
  b_gnatdll.o : b_gnatdll.c
  
! $(srcdir)/treeprs.ads : treeprs.adt sinfo.ads xtreeprs.spt
! 	(cd $(srcdir); xtreeprs)
! 
! $(srcdir)/einfo.h : einfo.ads einfo.adb xeinfo.spt
! 	(cd $(srcdir); xeinfo einfo.h)
  
! $(srcdir)/sinfo.h : sinfo.ads xsinfo.spt
! 	(cd $(srcdir); xsinfo sinfo.h)
  
! $(srcdir)/nmake.adb : nmake.adt sinfo.ads xnmake.spt
! 	(cd $(srcdir); xnmake)
  
! $(srcdir)/nmake.ads :  nmake.adt sinfo.ads xnmake.spt
! 	(cd $(srcdir); xnmake)
  
  ADA_INCLUDE_DIR = $(libsubdir)/adainclude
  ADA_RTL_OBJ_DIR = $(libsubdir)/adalib
--- 2412,2460 ----
  	$(GNATBIND) $(ADA_INCLUDES) -o b_gnatdll.c gnatdll.ali
  b_gnatdll.o : b_gnatdll.c
  
! # xtreeprs, xeinfo, xsinfo and xnmake are four tools that need to be
! # built on the build machine in order to generate various host and
! # target independant source files. They are built with the gnatmake
! # provided by the build compiler, and in a separate directory to avoid
! # any interference with the new sources and objects.
! 
! xtreeprs$(build_ext) : xtreeprs.adb
! 	-if [ -d tmp-dir ] ; then true ; else mkdir tmp-dir ; fi
! 	cp $(srcdir)/xtreeprs.adb tmp-dir
! 	(cd tmp-dir && $(BUILD_GNATMAKE) -g -o ../$@ xtreeprs.adb)
! 
! xeinfo$(build_ext) : xeinfo.adb
! 	-if [ -d tmp-dir ] ; then true ; else mkdir tmp-dir ; fi
! 	cp $(srcdir)/xeinfo.adb tmp-dir
! 	(cd tmp-dir && $(BUILD_GNATMAKE) -g -o ../$@ xeinfo.adb)
! 
! xsinfo$(build_ext) : xsinfo.adb
! 	-if [ -d tmp-dir ] ; then true ; else mkdir tmp-dir ; fi
! 	cp $(srcdir)/xsinfo.adb tmp-dir
! 	(cd tmp-dir && $(BUILD_GNATMAKE) -g -o ../$@ xsinfo.adb)
! 
! xnmake$(build_ext) : xnmake.adb
! 	-if [ -d tmp-dir ] ; then true ; else mkdir tmp-dir ; fi
! 	cp $(srcdir)/xnmake.adb tmp-dir
! 	(cd tmp-dir && $(BUILD_GNATMAKE) -g -o ../$@ xnmake.adb)
! 
! # treeprs.ads, einfo.h, sinfo.h, nmake.ads and nmake.adb are generated
! # in the build directory using the previously build tools.
! 
! treeprs.ads : xtreeprs$(build_ext) treeprs.adt sinfo.ads
! 	./xtreeprs$(build_ext) $(srcdir)/sinfo.ads $(srcdir)/treeprs.adt $@
! 
! einfo.h : xeinfo$(build_ext) einfo.ads einfo.adb
! 	./xeinfo$(build_ext) $(srcdir)/einfo.ads $(srcdir)/einfo.adb $@
  
! sinfo.h : xsinfo$(build_ext) sinfo.ads
! 	./xsinfo$(build_ext) $(srcdir)/sinfo.ads $@
  
! nmake.adb : xnmake$(build_ext) nmake.adt sinfo.ads
! 	./xnmake$(build_ext) -b $(srcdir)/sinfo.ads $(srcdir)/nmake.adt nmake.adb
  
! nmake.ads : xnmake$(build_ext) nmake.adt sinfo.ads
! 	./xnmake$(build_ext) -s $(srcdir)/sinfo.ads $(srcdir)/nmake.adt nmake.ads
  
  ADA_INCLUDE_DIR = $(libsubdir)/adainclude
  ADA_RTL_OBJ_DIR = $(libsubdir)/adalib
*** xeinfo.adb.orig	Wed Oct  3 22:24:57 2001
--- xeinfo.adb	Wed Oct  3 22:32:52 2001
***************
*** 26,50 ****
  --                                                                          --
  ------------------------------------------------------------------------------
  
! --  Program to construct C header file a-einfo.h (C version of einfo.ads spec)
! --  for use by Gigi. This header file contaInF all definitions and access
  --  functions, but does not contain set procedures, since Gigi is not allowed
  --  to modify the GNAT tree)
  
! --    Input files:
  
  --       einfo.ads     spec of Einfo package
  --       einfo.adb     body of Einfo package
  
! --    Output files:
  
! --       a-einfo.h     Corresponding c header file
  
  --  Note: It is assumed that the input files have been compiled without errors
  
- --  An optional argument allows the specification of an output file name to
- --  override the default a-einfo.h file name for the generated output file.
- 
  --  Most, but not all of the functions in Einfo can be inlined in the C header.
  --  They are the functions identified by pragma Inline in the spec. Functions
  --  that cannot be inlined are simply defined in the header.
--- 26,47 ----
  --                                                                          --
  ------------------------------------------------------------------------------
  
! --  Program to construct C header file einfo.h (C version of einfo.ads spec)
! --  for use by Gigi. This header file contains all definitions and access
  --  functions, but does not contain set procedures, since Gigi is not allowed
  --  to modify the GNAT tree)
  
! --    Input files (first and second command line arguments):
  
  --       einfo.ads     spec of Einfo package
  --       einfo.adb     body of Einfo package
  
! --    Output files (third command line argument):
  
! --       einfo.h     Corresponding c header file
  
  --  Note: It is assumed that the input files have been compiled without errors
  
  --  Most, but not all of the functions in Einfo can be inlined in the C header.
  --  They are the functions identified by pragma Inline in the spec. Functions
  --  that cannot be inlined are simply defined in the header.
*************** begin
*** 251,264 ****
  
     Match ("$Revision: 1.1 $", "$Rev" & "ision: " & Break (' ') * XEinforev);
  
!    if Argument_Count > 0 then
!       Create (Ofile, Out_File, Argument (1));
!    else
!       Create (Ofile, Out_File, "a-einfo.h");
     end if;
  
!    Open (InB, In_File, "einfo.adb");
!    Open (InF, In_File, "einfo.ads");
  
     Lineno := 0;
  
--- 248,260 ----
  
     Match ("$Revision: 1.1 $", "$Rev" & "ision: " & Break (' ') * XEinforev);
  
!    if Argument_Count /= 3 then
!       raise Err;
     end if;
  
!    Open (InF, In_File, Argument (1)); -- einfo.ads
!    Open (InB, In_File, Argument (2)); -- einfo.adb
!    Create (Ofile, Out_File, Argument (3)); -- einfo.h
  
     Lineno := 0;
  
*************** begin
*** 448,454 ****
  
     Close (InB);
     Close (InF);
!    Open (InF, In_File, "einfo.adb");
     Lineno := 0;
  
     --  Loop through input lines to find bodies of inlined functions
--- 444,450 ----
  
     Close (InB);
     Close (InF);
!    Open (InF, In_File, Argument (2)); -- einfo.adb
     Lineno := 0;
  
     --  Loop through input lines to find bodies of inlined functions
*** xnmake.adb.orig	Wed Oct  3 21:29:23 2001
--- xnmake.adb	Wed Oct  3 23:28:49 2001
***************
*** 28,55 ****
  
  --  Program to construct the spec and body of the Nmake package
  
! --    Input files:
  
  --       sinfo.ads     Spec of Sinfo package
  --       nmake.adt     Template for Nmake package
  
! --    Output files:
  
  --       nmake.ads     Spec of Nmake package
! --       nmake.adb     Body of Nmake package
  
  --  Note: this program assumes that sinfo.ads has passed the error checks that
  --  are carried out by the csinfo utility, so it does not duplicate these
  --  checks and assumes that sinfo.ads has the correct form.
  
- --   In the absence of any switches, both the ads and adb files are output.
- --   The switch -s or /s indicates that only the ads file is to be output.
- --   The switch -b or /b indicates that only the adb file is to be output.
- 
- --   If a file name argument is given, then the output is written to this file
- --   rather than to nmake.ads or nmake.adb. A file name can only be given if
- --   exactly one of the -s or -b options is present.
- 
  with Ada.Command_Line;              use Ada.Command_Line;
  with Ada.Strings.Unbounded;         use Ada.Strings.Unbounded;
  with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
--- 28,50 ----
  
  --  Program to construct the spec and body of the Nmake package
  
! --    Option (first command line argument)
! --       -s or -b     generate spec or body
! 
! --    Input files (second and third command line arguments):
  
  --       sinfo.ads     Spec of Sinfo package
  --       nmake.adt     Template for Nmake package
  
! --    Output files (fourth command line argument):
  
  --       nmake.ads     Spec of Nmake package
! --       or nmake.adb  Body of Nmake package
  
  --  Note: this program assumes that sinfo.ads has passed the error checks that
  --  are carried out by the csinfo utility, so it does not duplicate these
  --  checks and assumes that sinfo.ads has the correct form.
  
  with Ada.Command_Line;              use Ada.Command_Line;
  with Ada.Strings.Unbounded;         use Ada.Strings.Unbounded;
  with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
*************** procedure XNmake is
*** 84,91 ****
     Lineno : Natural;
     NWidth : Natural;
  
!    FileS : VString := V ("nmake.ads");
!    FileB : VString := V ("nmake.adb");
     --  Set to null if corresponding file not to be generated
  
     Given_File : VString := Nul;
--- 79,86 ----
     Lineno : Natural;
     NWidth : Natural;
  
!    FileS : VString;
!    FileB : VString;
     --  Set to null if corresponding file not to be generated
  
     Given_File : VString := Nul;
*************** begin
*** 214,273 ****
     NWidth := 28;
     Anchored_Mode := True;
  
!    for ArgN in 1 .. Argument_Count loop
!       declare
!          Arg : constant String := Argument (ArgN);
! 
!       begin
!          if Arg (1) = '/' or else Arg (1) = '-' then
!             if Arg'Length = 2
!               and then (Arg (2) = 'b' or else Arg (2) = 'B')
!             then
!                FileS := Nul;
! 
!             elsif Arg'Length = 2
!               and then (Arg (2) = 's' or else Arg (2) = 'S')
!             then
!                FileB := Nul;
! 
!             else
!                raise Err;
!             end if;
! 
!          else
!             if Given_File /= Nul then
!                raise Err;
!             else
!                Given_File := V (Arg);
!             end if;
!          end if;
!       end;
!    end loop;
! 
!    if FileS = Nul and then FileB = Nul then
        raise Err;
  
!    elsif Given_File /= Nul then
!       if FileS = Nul then
!          FileS := Given_File;
  
!       elsif FileB = Nul then
!          FileB := Given_File;
  
        else
           raise Err;
        end if;
!    end if;
  
!    Open (InS, In_File, "sinfo.ads");
!    Open (InT, In_File, "nmake.adt");
  
     if FileS /= Nul then
!       Create (OutS, Out_File, S (FileS));
!    end if;
! 
!    if FileB /= Nul then
!       Create (OutB, Out_File, S (FileB));
     end if;
  
     Anchored_Mode := True;
--- 209,255 ----
     NWidth := 28;
     Anchored_Mode := True;
  
!    if Argument_Count /= 4 then
        raise Err;
+    end if;
  
!    declare
!       Arg : constant String := Argument (1);
  
!    begin
!       if Arg (1) = '/' or else Arg (1) = '-' then
!          if Arg'Length = 2
!            and then (Arg (2) = 'b' or else Arg (2) = 'B')
!          then
!             FileS := Nul;
!             FileB := V (Argument (4)); -- nmake.adb
! 
!          elsif Arg'Length = 2
!            and then (Arg (2) = 's' or else Arg (2) = 'S')
!          then
!             FileS := V (Argument (4)); -- nmake.ads
!             FileB := Nul;
! 
!          else
!             raise Err;
!          end if;
  
        else
           raise Err;
        end if;
!    end;
  
!    Open (InS, In_File, Argument (2)); -- sinfo.ads
!    Open (InT, In_File, Argument (3)); -- nmake.adt
  
     if FileS /= Nul then
!       Create (OutS, Out_File, Argument (4)); -- nmake.ads
!    elsif FileB /= Nul then
!       Create (OutB, Out_File, Argument (4)); -- nmake.adb
!    else
!       -- Even if the code supports it, the command line scheme does
!       -- not support generation of both sources
!       raise Err;
     end if;
  
     Anchored_Mode := True;
*** xsinfo.adb.orig	Wed Oct  3 22:48:13 2001
--- xsinfo.adb	Wed Oct  3 22:34:15 2001
***************
*** 26,50 ****
  --                                                                          --
  ------------------------------------------------------------------------------
  
! --  Program to construct C header file a-sinfo.h (C version of sinfo.ads spec,
  --  for use by Gigi, contains all definitions and access functions, but does
  --  not contain set procedures, since Gigi never modifies the GNAT tree)
  
! --    Input files:
  
  --       sinfo.ads     Spec of Sinfo package
  
! --    Output files:
  
! --       a-sinfo.h     Corresponding c header file
  
  --  Note: this program assumes that sinfo.ads has passed the error checks
  --  which are carried out by the CSinfo utility, so it does not duplicate
  --  these checks and assumes the soruce is correct.
  
- --  An optional argument allows the specification of an output file name to
- --  override the default a-sinfo.h file name for the generated output file.
- 
  with Ada.Command_Line;              use Ada.Command_Line;
  with Ada.Strings.Unbounded;         use Ada.Strings.Unbounded;
  with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
--- 26,47 ----
  --                                                                          --
  ------------------------------------------------------------------------------
  
! --  Program to construct C header file sinfo.h (C version of sinfo.ads spec,
  --  for use by Gigi, contains all definitions and access functions, but does
  --  not contain set procedures, since Gigi never modifies the GNAT tree)
  
! --    Input file (first command line argument):
  
  --       sinfo.ads     Spec of Sinfo package
  
! --    Output files (second command line argument):
  
! --       sinfo.h     Corresponding C header file
  
  --  Note: this program assumes that sinfo.ads has passed the error checks
  --  which are carried out by the CSinfo utility, so it does not duplicate
  --  these checks and assumes the soruce is correct.
  
  with Ada.Command_Line;              use Ada.Command_Line;
  with Ada.Strings.Unbounded;         use Ada.Strings.Unbounded;
  with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
*************** begin
*** 122,134 ****
     Anchored_Mode := True;
     Match ("$Revision: 1.1 $", "$Rev" & "ision: "  & Break (' ') * XSinforev);
  
!    if Argument_Count > 0 then
!       Create (Ofile, Out_File, Argument (1));
!    else
!       Create (Ofile, Out_File, "a-sinfo.h");
     end if;
  
!    Open (InS, In_File, "sinfo.ads");
  
     --  Get Sinfo rev and write header to output file
  
--- 119,130 ----
     Anchored_Mode := True;
     Match ("$Revision: 1.1 $", "$Rev" & "ision: "  & Break (' ') * XSinforev);
  
!    if Argument_Count /= 2 then
!       raise Err;
     end if;
  
!    Open (InS, In_File, Argument (1)); -- sinfo.ads
!    Create (Ofile, Out_File, Argument (2)); -- sinfo.h
  
     --  Get Sinfo rev and write header to output file
  
*** xtreeprs.adb.orig	Thu Oct  4 00:13:20 2001
--- xtreeprs.adb	Wed Oct  3 22:05:47 2001
***************
*** 28,48 ****
  
  --  Program to construct the spec of the Treeprs package
  
! --    Input files:
  
  --       sinfo.ads     Spec of Sinfo package
  --       treeprs.adt   Template for Treeprs package
  
! --    Output files:
  
  --       treeprs.ads   Spec of Treeprs package
  
  --  Note: this program assumes that sinfo.ads has passed the error checks which
  --  are carried out by the CSinfo utility so it does not duplicate these checks
  
- --  An optional argument allows the specification of an output file name to
- --  override the default treeprs.ads file name for the generated output file.
- 
  with Ada.Command_Line;              use Ada.Command_Line;
  with Ada.Strings.Unbounded;         use Ada.Strings.Unbounded;
  with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
--- 28,45 ----
  
  --  Program to construct the spec of the Treeprs package
  
! --    Input files: (first and second command line arguments)
  
  --       sinfo.ads     Spec of Sinfo package
  --       treeprs.adt   Template for Treeprs package
  
! --    Output files: (third command line argument)
  
  --       treeprs.ads   Spec of Treeprs package
  
  --  Note: this program assumes that sinfo.ads has passed the error checks which
  --  are carried out by the CSinfo utility so it does not duplicate these checks
  
  with Ada.Command_Line;              use Ada.Command_Line;
  with Ada.Strings.Unbounded;         use Ada.Strings.Unbounded;
  with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
*************** begin
*** 151,164 ****
  
     Match ("$Revision: 1.1 $", "$Rev" & "ision: " & Break (' ') * Treeprsrev);
  
!    if Argument_Count > 0 then
!       Create (OutS, Out_File, Argument (1));
!    else
!       Create (OutS, Out_File, "treeprs.ads");
     end if;
  
!    Open (InS, In_File, "sinfo.ads");
!    Open (InT, In_File, "treeprs.adt");
  
     --  Initialize special fields table
  
--- 148,160 ----
  
     Match ("$Revision: 1.1 $", "$Rev" & "ision: " & Break (' ') * Treeprsrev);
  
!    if Argument_Count /= 3 then
!       raise Err;
     end if;
  
!    Open (InS, In_File, Argument (1)); -- sinfo.ads
!    Open (InT, In_File, Argument (2)); -- treeprs.adt
!    Create (OutS, Out_File, Argument (3)); -- treeprs.ads
  
     --  Initialize special fields table
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]