diff options
author | bosch <bosch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-03-08 20:11:04 +0000 |
---|---|---|
committer | bosch <bosch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-03-08 20:11:04 +0000 |
commit | f15731c43ae5e8cea424ea40f905c19afa1bd2e4 (patch) | |
tree | b584a79288c93215b05fb451943291ccd039388b /gcc/ada/make.adb | |
parent | 1d347c236ad815c77bd345611ed221b0bd6091de (diff) | |
download | gcc-f15731c43ae5e8cea424ea40f905c19afa1bd2e4.tar.gz |
* 41intnam.ads, 42intnam.ads, 4aintnam.ads, 4cintnam.ads,
4dintnam.ads, 4gintnam.ads, 4hintnam.ads, 4lintnam.ads,
4mintnam.ads, 4pintnam.ads, 4rintnam.ads, 4sintnam.ads,
4uintnam.ads, 4vcalend.adb, 4zintnam.ads, 52system.ads,
5amastop.adb, 5asystem.ads, 5ataprop.adb, 5atpopsp.adb,
5avxwork.ads, 5bosinte.adb, 5bsystem.ads, 5esystem.ads,
5fsystem.ads, 5ftaprop.adb, 5ginterr.adb, 5gmastop.adb,
5gsystem.ads, 5gtaprop.adb, 5gtasinf.adb, 5gtasinf.ads,
5hparame.ads, 5hsystem.ads, 5htaprop.adb, 5htraceb.adb,
5itaprop.adb, 5ksystem.ads, 5kvxwork.ads, 5lintman.adb,
5lsystem.ads, 5mvxwork.ads, 5ninmaop.adb, 5nosinte.ads,
5ntaprop.adb, 5ointerr.adb, 5omastop.adb, 5oosinte.adb,
5osystem.ads, 5otaprop.adb, 5otaspri.ads, 5pvxwork.ads,
5qtaprop.adb, 5sintman.adb, 5ssystem.ads, 5staprop.adb,
5stpopse.adb, 5svxwork.ads, 5tosinte.ads, 5uintman.adb,
5vasthan.adb, 5vinmaop.adb, 5vinterr.adb, 5vintman.adb,
5vmastop.adb, 5vparame.ads, 5vsystem.ads, 5vtaprop.adb,
5vtpopde.adb, 5wmemory.adb, 5wsystem.ads, 5wtaprop.adb,
5ysystem.ads, 5zinterr.adb, 5zintman.adb, 5zosinte.adb,
5zosinte.ads, 5zsystem.ads, 5ztaprop.adb, 6vcpp.adb, 6vcstrea.adb,
7sintman.adb, 7staprop.adb, 7stpopsp.adb, 9drpc.adb,
Make-lang.in, Makefile.in, a-caldel.adb, a-comlin.ads,
a-dynpri.adb, a-except.adb, a-except.ads, a-finali.adb,
a-ncelfu.ads, a-reatim.adb, a-retide.adb, a-stream.ads,
a-ststio.adb, a-ststio.ads, a-stwifi.adb, a-tags.adb, a-tasatt.adb,
a-textio.adb, a-tideau.adb, a-tiflau.adb, a-tigeau.adb,
a-tigeau.ads, a-tiinau.adb, a-timoau.adb, a-witeio.adb,
a-wtdeau.adb, a-wtenau.adb, a-wtflau.adb, a-wtgeau.adb,
a-wtgeau.ads, a-wtinau.adb, a-wtmoau.adb, ada-tree.def, ada-tree.h,
adaint.c, adaint.h, ali-util.adb, ali.adb, ali.ads, atree.adb,
atree.ads, atree.h, back_end.adb, bcheck.adb, bindgen.adb,
bindusg.adb, checks.adb, comperr.adb, config-lang.in, csets.adb,
csets.ads, cstand.adb, cstreams.c, debug.adb, debug.ads, decl.c,
einfo.adb, einfo.ads, einfo.h, elists.h, errout.adb, errout.ads,
eval_fat.adb, exp_aggr.adb, exp_attr.adb, exp_ch11.adb,
exp_ch12.adb, exp_ch13.adb, exp_ch2.adb, exp_ch3.adb, exp_ch3.ads,
exp_ch4.adb, exp_ch5.adb, exp_ch6.adb, exp_ch7.adb, exp_ch7.ads,
exp_ch9.adb, exp_ch9.ads, exp_dbug.adb, exp_dbug.ads, exp_disp.ads,
exp_dist.adb, exp_fixd.adb, exp_intr.adb, exp_pakd.adb,
exp_prag.adb, exp_strm.adb, exp_util.adb, exp_util.ads,
expander.adb, expect.c, fe.h, fmap.adb, fmap.ads, fname-uf.adb,
freeze.adb, frontend.adb, g-awk.adb, g-cgideb.adb, g-comlin.adb,
g-comlin.ads, g-debpoo.adb, g-dirope.adb, g-dirope.ads,
g-dyntab.adb, g-expect.adb, g-expect.ads, g-io.ads, g-io_aux.adb,
g-io_aux.ads, g-locfil.adb, g-locfil.ads, g-os_lib.adb,
g-os_lib.ads, g-regexp.adb, g-regpat.adb, g-socket.adb,
g-socket.ads, g-spipat.adb, g-table.adb, g-trasym.adb,
g-trasym.ads, gigi.h, gmem.c, gnat1drv.adb, gnatbind.adb, gnatbl.c,
gnatchop.adb, gnatcmd.adb, gnatdll.adb, gnatfind.adb, gnatlbr.adb,
gnatlink.adb, gnatls.adb, gnatmem.adb, gnatprep.adb, gnatvsn.ads,
gnatxref.adb, hlo.adb, hostparm.ads, i-cobol.adb, i-cpp.adb,
i-cstrea.ads, i-cstrin.adb, i-pacdec.adb, i-vxwork.ads,
impunit.adb, init.c, inline.adb, io-aux.c, layout.adb, lib-load.adb,
lib-util.adb, lib-writ.adb, lib-writ.ads, lib-xref.adb,
lib-xref.ads, lib.adb, lib.ads, make.adb, makeusg.adb, mdll.adb,
memroot.adb, misc.c, mlib-tgt.adb, mlib-utl.adb, mlib-utl.ads,
mlib.adb, namet.adb, namet.ads, namet.h, nlists.h, nmake.adb,
nmake.ads, nmake.adt, opt.adb, opt.ads, osint.adb, osint.ads,
output.adb, output.ads, par-ch2.adb, par-ch3.adb, par-ch5.adb,
par-prag.adb, par-tchk.adb, par-util.adb, par.adb, prj-attr.adb,
prj-dect.adb, prj-env.adb, prj-env.ads, prj-nmsc.adb, prj-part.adb,
prj-proc.adb, prj-strt.adb, prj-tree.adb, prj-tree.ads, prj.adb,
prj.ads, raise.c, raise.h, repinfo.adb, restrict.adb, restrict.ads,
rident.ads, rtsfind.adb, rtsfind.ads, s-arit64.adb, s-asthan.adb,
s-atacco.adb, s-atacco.ads, s-auxdec.adb, s-crc32.adb, s-crc32.ads,
s-direio.adb, s-fatgen.adb, s-fileio.adb, s-finimp.adb,
s-gloloc.adb, s-gloloc.ads, s-interr.adb, s-mastop.adb,
s-mastop.ads, s-memory.adb, s-parame.ads, s-parint.adb,
s-pooglo.adb, s-pooloc.adb, s-rpc.adb, s-secsta.adb, s-sequio.adb,
s-shasto.adb, s-soflin.adb, s-soflin.ads, s-stache.adb,
s-taasde.adb, s-taasde.ads, s-tadeca.adb, s-tadeca.ads,
s-tadert.adb, s-tadert.ads, s-taenca.adb, s-taenca.ads,
s-taprob.adb, s-taprop.ads, s-tarest.adb, s-tasdeb.adb,
s-tasini.adb, s-tasini.ads, s-taskin.adb, s-taskin.ads,
s-tasque.adb, s-tasque.ads, s-tasren.adb, s-tasren.ads,
s-tassta.adb, s-tasuti.adb, s-tasuti.ads, s-tataat.adb,
s-tataat.ads, s-tpoben.adb, s-tpoben.ads, s-tpobop.adb,
s-tposen.adb, s-tposen.ads, s-traceb.adb, s-traceb.ads,
s-unstyp.ads, s-widenu.adb, scn-nlit.adb, scn.adb, sem.adb,
sem_aggr.adb, sem_attr.adb, sem_attr.ads, sem_case.adb,
sem_ch10.adb, sem_ch11.adb, sem_ch11.ads, sem_ch12.adb,
sem_ch13.adb, sem_ch13.ads, sem_ch2.adb, sem_ch3.adb, sem_ch3.ads,
sem_ch4.adb, sem_ch5.adb, sem_ch6.adb, sem_ch6.ads, sem_ch7.adb,
sem_ch8.adb, sem_ch8.ads, sem_ch9.adb, sem_disp.adb, sem_dist.adb,
sem_elab.adb, sem_elim.adb, sem_elim.ads, sem_eval.adb,
sem_intr.adb, sem_mech.adb, sem_prag.adb, sem_res.adb,
sem_type.adb, sem_util.adb, sem_util.ads, sem_vfpt.adb,
sem_warn.adb, sinfo.adb, sinfo.ads, sinfo.h, sinput-l.adb,
sinput-l.ads, sinput.adb, sinput.ads, snames.adb, snames.ads,
snames.h, sprint.adb, sprint.ads, stringt.adb, stringt.ads,
stringt.h, style.adb, switch.adb, switch.ads, sysdep.c, system.ads,
table.adb, targparm.adb, targparm.ads, targtyps.c, tbuild.adb,
tbuild.ads, tracebak.c, trans.c, tree_gen.adb, tree_io.adb,
treepr.adb, treepr.ads, treeprs.ads, treeprs.adt, ttypes.ads,
types.adb, types.ads, types.h, uintp.ads, urealp.ads, usage.adb,
utils.c, utils2.c, validsw.adb, xnmake.adb, xr_tabls.adb,
xr_tabls.ads, xref_lib.adb, xref_lib.ads : Merge in ACT changes.
* 1ssecsta.adb, 1ssecsta.ads, a-chlat9.ads, a-cwila9.ads,
g-enblsp.adb, g-md5.adb, g-md5.ads, gnatname.adb, gnatname.ads,
mkdir.c, osint-b.adb, osint-b.ads, osint-c.adb, osint-c.ads,
osint-l.adb, osint-l.ads, osint-m.adb, osint-m.ads : New files
* 3lsoccon.ads, 5qparame.ads, 5qvxwork.ads, 5smastop.adb,
5zparame.ads, gnatmain.adb, gnatmain.ads, gnatpsys.adb : Removed
* mdllfile.adb, mdllfile.ads, mdlltool.adb, mdlltool.ads : Renamed
to mdll-fil.ad[bs] and mdll-util.ad[bs]
* mdll-fil.adb, mdll-fil.ads, mdll-utl.adb, mdll-utl.ads : Renamed
from mdllfile.ad[bs] and mdlltool.ad[bs]
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50451 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/make.adb')
-rw-r--r-- | gcc/ada/make.adb | 881 |
1 files changed, 560 insertions, 321 deletions
diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb index 500caf8a6e1..e46c54e836f 100644 --- a/gcc/ada/make.adb +++ b/gcc/ada/make.adb @@ -6,9 +6,9 @@ -- -- -- B o d y -- -- -- --- $Revision: 1.9 $ +-- $Revision$ -- -- --- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -30,27 +30,27 @@ with Ada.Exceptions; use Ada.Exceptions; with Ada.Command_Line; use Ada.Command_Line; with GNAT.Directory_Operations; use GNAT.Directory_Operations; -with GNAT.OS_Lib; use GNAT.OS_Lib; -with ALI; use ALI; -with ALI.Util; use ALI.Util; +with ALI; use ALI; +with ALI.Util; use ALI.Util; with Csets; with Debug; -with Fname; use Fname; -with Fname.SF; use Fname.SF; -with Fname.UF; use Fname.UF; -with Gnatvsn; use Gnatvsn; -with Hostparm; use Hostparm; +with Fname; use Fname; +with Fname.SF; use Fname.SF; +with Fname.UF; use Fname.UF; +with Gnatvsn; use Gnatvsn; +with Hostparm; use Hostparm; with Makeusg; with MLib.Prj; with MLib.Tgt; with MLib.Utl; -with Namet; use Namet; -with Opt; use Opt; -with Osint; use Osint; +with Namet; use Namet; +with Opt; use Opt; +with Osint.M; use Osint.M; +with Osint; use Osint; with Gnatvsn; -with Output; use Output; -with Prj; use Prj; +with Output; use Output; +with Prj; use Prj; with Prj.Com; with Prj.Env; with Prj.Ext; @@ -58,13 +58,13 @@ with Prj.Pars; with Prj.Util; with SFN_Scan; with Sinput.L; -with Snames; use Snames; -with Stringt; use Stringt; -with Table; -with Types; use Types; -with Switch; use Switch; +with Snames; use Snames; +with Stringt; use Stringt; +with Switch; use Switch; +with Switch.M; use Switch.M; +with Targparm; -with System.WCh_Con; use System.WCh_Con; +with System.WCh_Con; use System.WCh_Con; package body Make is @@ -193,6 +193,17 @@ package body Make is Table_Increment => 100, Table_Name => "Make.Saved_Make_Switches"); + package Switches_To_Check is new Table.Table ( + Table_Component_Type => String_Access, + Table_Index_Type => Integer, + Table_Low_Bound => 1, + Table_Initial => 20, + Table_Increment => 100, + Table_Name => "Make.Switches_To_Check"); + + Normalized_Switches : Argument_List_Access := new Argument_List (1 .. 10); + Last_Norm_Switch : Natural := 0; + Saved_Maximum_Processes : Natural := 0; Saved_WC_Encoding_Method : WC_Encoding_Method := WC_Encoding_Method'First; Saved_WC_Encoding_Method_Set : Boolean := False; @@ -238,23 +249,6 @@ package body Make is Table_Name => "Make.Bad_Compilation"); -- Full name of all the source files for which compilation fails. - type Special_Argument is record - File : String_Access; - Args : Argument_List_Access; - end record; - -- File is the name of the file for which a special set of compilation - -- arguments (Args) is required. - - package Special_Args is new Table.Table ( - Table_Component_Type => Special_Argument, - Table_Index_Type => Natural, - Table_Low_Bound => 1, - Table_Initial => 20, - Table_Increment => 100, - Table_Name => "Make.Special_Args"); - -- Compilation arguments of all the source files for which an entry has - -- been found in the project file. - Original_Ada_Include_Path : constant String_Access := Getenv ("ADA_INCLUDE_PATH"); Original_Ada_Objects_Path : constant String_Access := @@ -283,9 +277,6 @@ package body Make is function Is_Marked (Source_File : File_Name_Type) return Boolean; -- Returns True if Source_File was previously marked. - procedure Unmark (Source_File : File_Name_Type); - -- Unmarks Source_File. - ------------------- -- Misc Routines -- ------------------- @@ -315,14 +306,22 @@ package body Make is -- after S1. S2 is printed last. Both N1 and N2 are printed in quotation -- marks. + Usage_Needed : Boolean := True; + -- Flag used to make sure Makeusg is call at most once + + procedure Usage; + -- Call Makeusg, if Usage_Needed is True. + -- Set Usage_Needed to False. + ----------------------- -- Gnatmake Routines -- ----------------------- subtype Lib_Mark_Type is Byte; + -- ??? this needs a comment - Ada_Lib_Dir : constant Lib_Mark_Type := 1; - GNAT_Lib_Dir : constant Lib_Mark_Type := 2; + Ada_Lib_Dir : constant Lib_Mark_Type := 1; + -- ??? this needs a comment -- Note that the notion of GNAT lib dir is no longer used. The code -- related to it has not been removed to give an idea on how to use @@ -352,11 +351,6 @@ package body Make is -- Get directory prefix of this file and get lib mark stored in name -- table for this directory. Then check if an Ada lib mark has been set. - procedure Mark_Dir_Path - (Path : String_Access; - Mark : Lib_Mark_Type); - -- Invoke Mark_Directory on each directory of the path. - procedure Mark_Directory (Dir : String; Mark : Lib_Mark_Type); @@ -388,14 +382,16 @@ package body Make is -- Return the switches for the source file in the specified package -- of a project file. If the Source_File ends with a standard GNAT -- extension (".ads" or ".adb"), try first the full name, then the - -- name without the extension. If there is no switches for either - -- names, try the default switches for Ada. If all failed, return - -- No_Variable_Value. + -- name without the extension, then, if Allow_ALI is True, the name with + -- the extension ".ali". If there is no switches for either names, try the + -- default switches for Ada. If all failed, return No_Variable_Value. - procedure Test_If_Relative_Path (Switch : String_Access); + procedure Test_If_Relative_Path + (Switch : in out String_Access; + Parent : String_Access); -- Test if Switch is a relative search path switch. - -- Fail if it is. This subprogram is only called - -- when using project files. + -- If it is, fail if Parent is null, otherwise prepend the path with + -- Parent. This subprogram is only called when using project files. procedure Set_Library_For (Project : Project_Id; @@ -442,6 +438,9 @@ package body Make is Object_Suffix : constant String := Get_Object_Suffix.all; Executable_Suffix : constant String := Get_Executable_Suffix.all; + Syntax_Only : Boolean := False; + -- Set to True when compiling with -gnats + Display_Executed_Programs : Boolean := True; -- Set to True if name of commands should be output on stderr. @@ -510,6 +509,20 @@ package body Make is -- Displays Program followed by the arguments in Args if variable -- Display_Executed_Programs is set. The lower bound of Args must be 1. + type Temp_File_Names is array (Positive range <>) of Temp_File_Name; + + type Temp_Files_Ptr is access Temp_File_Names; + + The_Mapping_File_Names : Temp_Files_Ptr; + Last_Mapping_File_Name : Natural := 0; + + procedure Delete_Mapping_Files; + -- Delete all temporary mapping files + + procedure Init_Mapping_File (File_Name : in out Temp_File_Name); + -- Create a new temporary mapping file, and fill it with the project file + -- mappings, when using project file(s) + -------------------- -- Add_Object_Dir -- -------------------- @@ -554,60 +567,55 @@ package body Make is is generic with package T is new Table.Table (<>); - procedure Generic_Position (New_Position : out Integer); - -- Generic procedure that allocates a position for S in T at the - -- beginning or the end, depending on the boolean Append_Switch. + function Generic_Position return Integer; + -- Generic procedure that adds S at the end or beginning of T depending + -- of the value of the boolean Append_Switch. ---------------------- -- Generic_Position -- ---------------------- - procedure Generic_Position (New_Position : out Integer) is + function Generic_Position return Integer is begin T.Increment_Last; if Append_Switch then - New_Position := Integer (T.Last); + return Integer (T.Last); else for J in reverse T.Table_Index_Type'Succ (T.First) .. T.Last loop T.Table (J) := T.Table (T.Table_Index_Type'Pred (J)); end loop; - New_Position := Integer (T.First); + return Integer (T.First); end if; end Generic_Position; - procedure Gcc_Switches_Pos is new Generic_Position (Gcc_Switches); - procedure Binder_Switches_Pos is new Generic_Position (Binder_Switches); - procedure Linker_Switches_Pos is new Generic_Position (Linker_Switches); + function Gcc_Switches_Pos is new Generic_Position (Gcc_Switches); + function Binder_Switches_Pos is new Generic_Position (Binder_Switches); + function Linker_Switches_Pos is new Generic_Position (Linker_Switches); - procedure Saved_Gcc_Switches_Pos is new + function Saved_Gcc_Switches_Pos is new Generic_Position (Saved_Gcc_Switches); - procedure Saved_Binder_Switches_Pos is new + function Saved_Binder_Switches_Pos is new Generic_Position (Saved_Binder_Switches); - procedure Saved_Linker_Switches_Pos is new + function Saved_Linker_Switches_Pos is new Generic_Position (Saved_Linker_Switches); - New_Position : Integer; - -- Start of processing for Add_Switch begin if And_Save then case Program is when Compiler => - Saved_Gcc_Switches_Pos (New_Position); - Saved_Gcc_Switches.Table (New_Position) := S; + Saved_Gcc_Switches.Table (Saved_Gcc_Switches_Pos) := S; when Binder => - Saved_Binder_Switches_Pos (New_Position); - Saved_Binder_Switches.Table (New_Position) := S; + Saved_Binder_Switches.Table (Saved_Binder_Switches_Pos) := S; when Linker => - Saved_Linker_Switches_Pos (New_Position); - Saved_Linker_Switches.Table (New_Position) := S; + Saved_Linker_Switches.Table (Saved_Linker_Switches_Pos) := S; when None => raise Program_Error; @@ -616,16 +624,13 @@ package body Make is else case Program is when Compiler => - Gcc_Switches_Pos (New_Position); - Gcc_Switches.Table (New_Position) := S; + Gcc_Switches.Table (Gcc_Switches_Pos) := S; when Binder => - Binder_Switches_Pos (New_Position); - Binder_Switches.Table (New_Position) := S; + Binder_Switches.Table (Binder_Switches_Pos) := S; when Linker => - Linker_Switches_Pos (New_Position); - Linker_Switches.Table (New_Position) := S; + Linker_Switches.Table (Linker_Switches_Pos) := S; when None => raise Program_Error; @@ -754,6 +759,8 @@ package body Make is Bind_Last := Bind_Last + 1; Bind_Args (Bind_Last) := new String'(Name_Buffer (1 .. Name_Len)); + GNAT.OS_Lib.Normalize_Arguments (Bind_Args (Args'First .. Bind_Last)); + Display (Gnatbind.all, Bind_Args (Args'First .. Bind_Last)); if Gnatbind_Path = null then @@ -918,9 +925,6 @@ package body Make is Num_Args : Integer; -- Number of compiler arguments processed - Special_Arg : Argument_List_Access; - -- Special arguments if any of a given compilation file - -- Start of processing for Check begin @@ -990,114 +994,71 @@ package body Make is Get_Name_String (ALIs.Table (ALI).Sfile); - for J in 1 .. Special_Args.Last loop - if Special_Args.Table (J).File.all = - Name_Buffer (1 .. Name_Len) + Switches_To_Check.Set_Last (0); + + for J in Gcc_Switches.First .. Gcc_Switches.Last loop + + -- Skip non switches, -I and -o switches + + if Gcc_Switches.Table (J) (1) = '-' + and then Gcc_Switches.Table (J) (2) /= 'o' + and then Gcc_Switches.Table (J) (2) /= 'I' then - Special_Arg := Special_Args.Table (J).Args; - exit; + Normalize_Compiler_Switches + (Gcc_Switches.Table (J).all, + Normalized_Switches, + Last_Norm_Switch); + + for K in 1 .. Last_Norm_Switch loop + Switches_To_Check.Increment_Last; + Switches_To_Check.Table (Switches_To_Check.Last) := + Normalized_Switches (K); + end loop; end if; end loop; - if Main_Project /= No_Project then - null; - end if; - - if Special_Arg = null then - for J in Gcc_Switches.First .. Gcc_Switches.Last loop - - -- Skip non switches, -I and -o switches + for J in 1 .. Switches_To_Check.Last loop - if (Gcc_Switches.Table (J) (1) = '-' - or else - Gcc_Switches.Table (J) (1) = Switch_Character) - and then Gcc_Switches.Table (J) (2) /= 'o' - and then Gcc_Switches.Table (J) (2) /= 'I' - then - Num_Args := Num_Args + 1; - - -- Comparing switches is delicate because gcc reorders - -- a number of switches, according to lang-specs.h, but - -- gnatmake doesn't have the sufficient knowledge to - -- perform the same reordering. Instead, we ignore orders - -- between different "first letter" switches, but keep - -- orders between same switches, e.g -O -O2 is different - -- than -O2 -O, but -g -O is equivalent to -O -g. - - if Gcc_Switches.Table (J) (2) /= Prev_Switch then - Prev_Switch := Gcc_Switches.Table (J) (2); - Arg := - Units.Table (ALIs.Table (ALI).First_Unit).First_Arg; - end if; + -- Comparing switches is delicate because gcc reorders + -- a number of switches, according to lang-specs.h, but + -- gnatmake doesn't have the sufficient knowledge to + -- perform the same reordering. Instead, we ignore orders + -- between different "first letter" switches, but keep + -- orders between same switches, e.g -O -O2 is different + -- than -O2 -O, but -g -O is equivalent to -O -g. - Switch_Found := False; + if Switches_To_Check.Table (J) (2) /= Prev_Switch then + Prev_Switch := Switches_To_Check.Table (J) (2); + Arg := + Units.Table (ALIs.Table (ALI).First_Unit).First_Arg; + end if; - for K in Arg .. - Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg - loop - if Gcc_Switches.Table (J).all = Args.Table (K).all then - Arg := K + 1; - Switch_Found := True; - exit; - end if; - end loop; + Switch_Found := False; - if not Switch_Found then - if Opt.Verbose_Mode then - Verbose_Msg (ALIs.Table (ALI).Sfile, - "switch mismatch"); - end if; + for K in Arg .. + Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg + loop + Num_Args := Num_Args + 1; - ALI := No_ALI_Id; - return; - end if; + if + Switches_To_Check.Table (J).all = Args.Table (K).all + then + Arg := K + 1; + Switch_Found := True; + exit; end if; end loop; - -- Special_Arg is non-null - - else - for J in Special_Arg'Range loop - - -- Skip non switches, -I and -o switches - - if (Special_Arg (J) (1) = '-' - or else Special_Arg (J) (1) = Switch_Character) - and then Special_Arg (J) (2) /= 'o' - and then Special_Arg (J) (2) /= 'I' - then - Num_Args := Num_Args + 1; - - if Special_Arg (J) (2) /= Prev_Switch then - Prev_Switch := Special_Arg (J) (2); - Arg := - Units.Table (ALIs.Table (ALI).First_Unit).First_Arg; - end if; - - Switch_Found := False; - - for K in Arg .. - Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg - loop - if Special_Arg (J).all = Args.Table (K).all then - Arg := K + 1; - Switch_Found := True; - exit; - end if; - end loop; - - if not Switch_Found then - if Opt.Verbose_Mode then - Verbose_Msg (ALIs.Table (ALI).Sfile, - "switch mismatch"); - end if; - - ALI := No_ALI_Id; - return; - end if; + if not Switch_Found then + if Opt.Verbose_Mode then + Verbose_Msg (ALIs.Table (ALI).Sfile, + "switch mismatch"); end if; - end loop; - end if; + + ALI := No_ALI_Id; + return; + end if; + end loop; if Num_Args /= Integer (Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg - @@ -1199,9 +1160,8 @@ package body Make is if Name_Len <= 0 then return; - elsif Name_Buffer (1) = Get_Switch_Character - or else Name_Buffer (1) = '-' - then + elsif Name_Buffer (1) = '-' then + -- Do not check if File is a switch other than "-l" if Name_Buffer (2) /= 'l' then @@ -1350,11 +1310,16 @@ package body Make is -- expected library file name. Process_Id of the process spawned to -- execute the compile. + No_Mapping_File : constant Temp_File_Name := (others => ' '); + type Compilation_Data is record Pid : Process_Id; Full_Source_File : File_Name_Type; Lib_File : File_Name_Type; Source_Unit : Unit_Name_Type; + Mapping_File : Temp_File_Name := No_Mapping_File; + Use_Mapping_File : Boolean := False; + Syntax_Only : Boolean := False; end record; Running_Compile : array (1 .. Max_Process) of Compilation_Data; @@ -1396,6 +1361,8 @@ package body Make is Pid : Process_Id; Text : Text_Buffer_Ptr; + Mfile : Temp_File_Name := No_Mapping_File; + Data : Prj.Project_Data; Arg_Index : Natural; @@ -1403,11 +1370,17 @@ package body Make is Need_To_Check_Standard_Library : Boolean := Check_Readonly_Files; + Mapping_File_Arg : constant String_Access := new String' + (1 => '-', 2 => 'g', 3 => 'n', 4 => 'a', 5 => 't', 6 => 'e', 7 => 'm', + 8 .. 7 + Mfile'Length => ' '); + procedure Add_Process - (Pid : Process_Id; - Sfile : File_Name_Type; - Afile : File_Name_Type; - Uname : Unit_Name_Type); + (Pid : Process_Id; + Sfile : File_Name_Type; + Afile : File_Name_Type; + Uname : Unit_Name_Type; + Mfile : Temp_File_Name := No_Mapping_File; + UMfile : Boolean := False); -- Adds process Pid to the current list of outstanding compilation -- processes and record the full name of the source file Sfile that -- we are compiling, the name of its library file Afile and the @@ -1427,7 +1400,7 @@ package body Make is -- resp. No_File, No_File and No_Name if there were no compilations -- to wait for. - procedure Collect_Arguments_And_Compile; + procedure Collect_Arguments_And_Compile (Source_File : File_Name_Type); -- Collect arguments from project file (if any) and compile package Good_ALI is new Table.Table ( @@ -1469,15 +1442,21 @@ package body Make is -- pragmas file to be specified for For_Project, -- otherwise return an empty argument list. + procedure Get_Mapping_File; + -- Get a mapping file name. If there is one to be reused, reuse it. + -- Otherwise, create a new mapping file. + ----------------- -- Add_Process -- ----------------- procedure Add_Process - (Pid : Process_Id; - Sfile : File_Name_Type; - Afile : File_Name_Type; - Uname : Unit_Name_Type) + (Pid : Process_Id; + Sfile : File_Name_Type; + Afile : File_Name_Type; + Uname : Unit_Name_Type; + Mfile : Temp_File_Name := No_Mapping_File; + UMfile : Boolean := False) is OC1 : constant Positive := Outstanding_Compiles + 1; @@ -1489,6 +1468,9 @@ package body Make is Running_Compile (OC1).Full_Source_File := Sfile; Running_Compile (OC1).Lib_File := Afile; Running_Compile (OC1).Source_Unit := Uname; + Running_Compile (OC1).Mapping_File := Mfile; + Running_Compile (OC1).Use_Mapping_File := UMfile; + Running_Compile (OC1).Syntax_Only := Syntax_Only; Outstanding_Compiles := OC1; end Add_Process; @@ -1524,6 +1506,16 @@ package body Make is Sfile := Running_Compile (J).Full_Source_File; Afile := Running_Compile (J).Lib_File; Uname := Running_Compile (J).Source_Unit; + Syntax_Only := Running_Compile (J).Syntax_Only; + + -- If a mapping file was used by this compilation, + -- get its file name for reuse by a subsequent compilation + + if Running_Compile (J).Use_Mapping_File then + Last_Mapping_File_Name := Last_Mapping_File_Name + 1; + The_Mapping_File_Names (Last_Mapping_File_Name) := + Running_Compile (J).Mapping_File; + end if; -- To actually remove this Pid and related info from -- Running_Compile replace its entry with the last valid @@ -1558,8 +1550,15 @@ package body Make is -- Collect_Arguments_And_Compile -- ----------------------------------- - procedure Collect_Arguments_And_Compile is + procedure Collect_Arguments_And_Compile (Source_File : File_Name_Type) is begin + + -- If we use mapping file (-P or -C switches), then get one + + if Create_Mapping_File then + Get_Mapping_File; + end if; + -- If no project file is used, then just call Compile with -- the specified Args. @@ -1579,7 +1578,7 @@ package body Make is declare Source_File_Name : constant String := - Name_Buffer (1 .. Name_Len); + Get_Name_String (Source_File); Current_Project : Prj.Project_Id; Path_Name : File_Name_Type := Source_File; Compiler_Package : Prj.Package_Id; @@ -1741,7 +1740,8 @@ package body Make is String_To_Name_Buffer (Element.Value); New_Args (Index) := new String' (Name_Buffer (1 .. Name_Len)); - Test_If_Relative_Path (New_Args (Index)); + Test_If_Relative_Path + (New_Args (Index), Parent => null); Current := Element.Next; end loop; @@ -1759,15 +1759,16 @@ package body Make is -- this switch, plus the saved gcc switches. when Single => - String_To_Name_Buffer (Switches.Value); + declare - New_Args : constant Argument_List := + New_Args : Argument_List := (1 => new String' (Name_Buffer (1 .. Name_Len))); begin - Test_If_Relative_Path (New_Args (1)); + Test_If_Relative_Path + (New_Args (1), Parent => null); Pid := Compile (Path_Name, Lib_File, @@ -1792,8 +1793,8 @@ package body Make is (Path_Name, Lib_File, Args & Output_Flag & Object_File & - Configuration_Pragmas_Switch (Current_Project) & - The_Saved_Gcc_Switches.all); + Configuration_Pragmas_Switch (Current_Project) & + The_Saved_Gcc_Switches.all); end case; end if; end; @@ -1807,7 +1808,7 @@ package body Make is function Compile (S : Name_Id; L : Name_Id; Args : Argument_List) return Process_Id is - Comp_Args : Argument_List (Args'First .. Args'Last + 7); + Comp_Args : Argument_List (Args'First .. Args'Last + 8); Comp_Next : Integer := Args'First; Comp_Last : Integer; @@ -1833,6 +1834,34 @@ package body Make is -- Start of processing for Compile begin + -- By default, Syntax_Only is False + + Syntax_Only := False; + + for J in Args'Range loop + if Args (J).all = "-gnats" then + + -- If we compile with -gnats, the bind step and the link step + -- are inhibited. Also, we set Syntax_Only to True, so that + -- we don't fail when we don't find the ALI file, after + -- compilation. + + Do_Bind_Step := False; + Do_Link_Step := False; + Syntax_Only := True; + + elsif Args (J).all = "-gnatc" then + + -- If we compile with -gnatc, the bind step and the link step + -- are inhibited. We set Syntax_Only to True for the case when + -- -gnats was previously specified. + + Do_Bind_Step := False; + Do_Link_Step := False; + Syntax_Only := False; + end if; + end loop; + Comp_Args (Comp_Next) := Comp_Flag; Comp_Next := Comp_Next + 1; @@ -1906,11 +1935,18 @@ package body Make is Comp_Args (Comp_Last) := new String'(Name_Buffer (1 .. Name_Len)); end if; + if Create_Mapping_File then + Comp_Last := Comp_Last + 1; + Comp_Args (Comp_Last) := Mapping_File_Arg; + end if; + Get_Name_String (S); Comp_Last := Comp_Last + 1; Comp_Args (Comp_Last) := new String'(Name_Buffer (1 .. Name_Len)); + GNAT.OS_Lib.Normalize_Arguments (Comp_Args (Args'First .. Comp_Last)); + Display (Gcc.all, Comp_Args (Args'First .. Comp_Last)); if Gcc_Path = null then @@ -1959,6 +1995,31 @@ package body Make is end if; end Debug_Msg; + ---------------------- + -- Get_Mapping_File -- + ---------------------- + + procedure Get_Mapping_File is + begin + -- If there is a mapping file ready to be reused, reuse it + + if Last_Mapping_File_Name > 0 then + Mfile := The_Mapping_File_Names (Last_Mapping_File_Name); + Last_Mapping_File_Name := Last_Mapping_File_Name - 1; + + -- Otherwise, create and initialize a new one + + else + Init_Mapping_File (File_Name => Mfile); + end if; + + -- Put the name in the mapping file argument for the invocation + -- of the compiler. + + Mapping_File_Arg (8 .. Mapping_File_Arg'Last) := Mfile; + + end Get_Mapping_File; + ----------------------- -- Get_Next_Good_ALI -- ----------------------- @@ -2014,7 +2075,6 @@ package body Make is -- Package and Queue initializations. Good_ALI.Init; - Bad_Compilation.Init; Output.Set_Standard_Error; Init_Q; @@ -2188,12 +2248,11 @@ package body Make is -- Check for special compilation flags Arg_Index := 0; - Get_Name_String (Source_File); -- Start the compilation and record it. We can do this -- because there is at least one free process. - Collect_Arguments_And_Compile; + Collect_Arguments_And_Compile (Source_File); -- Make sure we could successfully start the compilation @@ -2201,7 +2260,12 @@ package body Make is Record_Failure (Full_Source_File, Source_Unit); else Add_Process - (Pid, Full_Source_File, Lib_File, Source_Unit); + (Pid, + Full_Source_File, + Lib_File, + Source_Unit, + Mfile, + Create_Mapping_File); end if; end if; end if; @@ -2222,11 +2286,28 @@ package body Make is if not Compilation_OK then Record_Failure (Full_Source_File, Source_Unit); + end if; + + if Compilation_OK or else Keep_Going then - else -- Re-read the updated library file - Text := Read_Library_Info (Lib_File); + declare + Saved_Object_Consistency : constant Boolean := + Opt.Check_Object_Consistency; + + begin + -- If compilation was not OK, don't check object + -- consistency. + + Opt.Check_Object_Consistency := + Opt.Check_Object_Consistency and Compilation_OK; + Text := Read_Library_Info (Lib_File); + + -- Restore Check_Object_Consistency to its initial value + + Opt.Check_Object_Consistency := Saved_Object_Consistency; + end; -- If no ALI file was generated by this compilation nothing -- more to do, otherwise scan the ali file and record it. @@ -2238,9 +2319,15 @@ package body Make is Scan_ALI (Lib_File, Text, Ignore_ED => False, Err => True); if ALI = No_ALI_Id then - Inform - (Lib_File, "incompatible ALI file, please recompile"); - Record_Failure (Full_Source_File, Source_Unit); + + -- Record a failure only if not already done + + if Compilation_OK then + Inform + (Lib_File, + "incompatible ALI file, please recompile"); + Record_Failure (Full_Source_File, Source_Unit); + end if; else Free (Text); Record_Good_ALI (ALI); @@ -2252,12 +2339,15 @@ package body Make is -- is set Read_Library_Info checks that the time stamp of the -- object file is more recent than that of the ALI). For an -- example of problems caught by this test see [6625-009]. + -- However, we record a failure only if not already done. else - Inform - (Lib_File, - "WARNING: ALI or object file not found after compile"); - Record_Failure (Full_Source_File, Source_Unit); + if Compilation_OK and not Syntax_Only then + Inform + (Lib_File, + "WARNING: ALI or object file not found after compile"); + Record_Failure (Full_Source_File, Source_Unit); + end if; end if; end if; end if; @@ -2296,7 +2386,8 @@ package body Make is if not ALIs.Table (ALI).No_Run_Time then declare - Sfile : Name_Id; + Sfile : Name_Id; + Add_It : Boolean := True; begin Name_Len := Standard_Library_Package_Body_Name'Length; @@ -2304,7 +2395,14 @@ package body Make is Standard_Library_Package_Body_Name; Sfile := Name_Enter; - if not Is_Marked (Sfile) then + -- If we have a special runtime, we add the standard + -- library only if we can find it. + + if Opt.RTS_Switch then + Add_It := Find_File (Sfile, Osint.Source) /= No_File; + end if; + + if Add_It and then not Is_Marked (Sfile) then Insert_Q (Sfile); Mark (Sfile); end if; @@ -2394,6 +2492,20 @@ package body Make is end if; end Compile_Sources; + -------------------------- + -- Delete_Mapping_Files -- + -------------------------- + + procedure Delete_Mapping_Files is + Success : Boolean; + + begin + for Index in 1 .. Last_Mapping_File_Name loop + Delete_File + (Name => The_Mapping_File_Names (Index), Success => Success); + end loop; + end Delete_Mapping_Files; + ------------- -- Display -- ------------- @@ -2406,8 +2518,18 @@ package body Make is Write_Str (Program); for J in Args'Range loop - Write_Str (" "); - Write_Str (Args (J).all); + + -- Do not display the mapping file argument automatically + -- created when using a project file. + + if Main_Project = No_Project + or else Args (J)'Length /= 7 + Temp_File_Name'Length + or else Args (J)'First /= 1 + or else Args (J)(1 .. 7) /= "-gnatem" + then + Write_Str (" "); + Write_Str (Args (J).all); + end if; end loop; Write_Eol; @@ -2496,6 +2618,8 @@ package body Make is Compilation_Failures : Natural; + Total_Compilation_Failures : Natural := 0; + Is_Main_Unit : Boolean; -- Set to True by Compile_Sources if the Main_Source_File can be a -- main unit. @@ -2506,7 +2630,7 @@ package body Make is Executable : File_Name_Type := No_File; -- The file name of an executable - Non_Std_Executable : Boolean := False; + Non_Std_Executable : Boolean := False; -- Non_Std_Executable is set to True when there is a possibility -- that the linker will not choose the correct executable file name. @@ -2516,9 +2640,10 @@ package body Make is -- be rebuild (if we rebuild mains), even in the case when it is not -- really necessary, because it is too hard to decide. - Mapping_File_Name : Temp_File_Name; - -- The name of the temporary mapping file that is copmmunicated - -- to the compiler through a -gnatem switch, when using project files. + Current_Work_Dir : constant String_Access := + new String'(Get_Current_Dir); + -- The current working directory, used to modify some relative path + -- switches on the command line when a project file is used. begin Do_Compile_Step := True; @@ -2539,10 +2664,17 @@ package body Make is end if; if Opt.Verbose_Mode then + Targparm.Get_Target_Parameters; + Write_Eol; Write_Str ("GNATMAKE "); + + if Targparm.High_Integrity_Mode_On_Target then + Write_Str ("Pro High Integrity "); + end if; + Write_Str (Gnatvsn.Gnat_Version_String); - Write_Str (" Copyright 1995-2001 Free Software Foundation, Inc."); + Write_Str (" Copyright 1995-2002 Free Software Foundation, Inc."); Write_Eol; end if; @@ -2578,6 +2710,10 @@ package body Make is Do_Bind_Step := False; Do_Link_Step := False; + -- Set Unique_Compile if it was not already set + + Unique_Compile := True; + -- Put all the sources in the queue Insert_Project_Sources @@ -2608,7 +2744,7 @@ package body Make is end if; - -- If -l was specified behave as if -n was specified + -- If -M was specified, behave as if -n was specified if Opt.List_Dependencies then Opt.Do_Not_Execute := True; @@ -2830,6 +2966,43 @@ package body Make is Display_Commands (not Opt.Quiet_Output); + -- If we are using a project file, relative paths are forbidden in the + -- project file, but we add the current working directory for any + -- relative path on the command line. + + if Main_Project /= No_Project then + + for J in 1 .. Binder_Switches.Last loop + Test_If_Relative_Path + (Binder_Switches.Table (J), Parent => null); + end loop; + + for J in 1 .. Saved_Binder_Switches.Last loop + Test_If_Relative_Path + (Saved_Binder_Switches.Table (J), Parent => Current_Work_Dir); + end loop; + + for J in 1 .. Linker_Switches.Last loop + Test_If_Relative_Path + (Linker_Switches.Table (J), Parent => null); + end loop; + + for J in 1 .. Saved_Linker_Switches.Last loop + Test_If_Relative_Path + (Saved_Linker_Switches.Table (J), Parent => Current_Work_Dir); + end loop; + + for J in 1 .. Gcc_Switches.Last loop + Test_If_Relative_Path + (Gcc_Switches.Table (J), Parent => null); + end loop; + + for J in 1 .. Saved_Gcc_Switches.Last loop + Test_If_Relative_Path + (Saved_Gcc_Switches.Table (J), Parent => Current_Work_Dir); + end loop; + end if; + -- We now put in the Binder_Switches and Linker_Switches tables, -- the binder and linker switches of the command line that have been -- put in the Saved_ tables. If a project file was used, then the @@ -2866,39 +3039,16 @@ package body Make is -- in procedure Compile_Sources. The_Saved_Gcc_Switches := - new Argument_List (1 .. Saved_Gcc_Switches.Last + 2); + new Argument_List (1 .. Saved_Gcc_Switches.Last + 1); for J in 1 .. Saved_Gcc_Switches.Last loop The_Saved_Gcc_Switches (J) := Saved_Gcc_Switches.Table (J); - Test_If_Relative_Path (The_Saved_Gcc_Switches (J)); end loop; -- We never use gnat.adc when a project file is used - The_Saved_Gcc_Switches (The_Saved_Gcc_Switches'Last - 1) := - No_gnat_adc; - - -- Create a temporary mapping file and add the switch -gnatem - -- with its name to the compiler. - - Prj.Env.Create_Mapping_File (Name => Mapping_File_Name); The_Saved_Gcc_Switches (The_Saved_Gcc_Switches'Last) := - new String'("-gnatem" & Mapping_File_Name); - - -- Check if there are any relative search paths in the switches. - -- Fail if there is one. - - for J in 1 .. Gcc_Switches.Last loop - Test_If_Relative_Path (Gcc_Switches.Table (J)); - end loop; - - for J in 1 .. Binder_Switches.Last loop - Test_If_Relative_Path (Binder_Switches.Table (J)); - end loop; - - for J in 1 .. Linker_Switches.Last loop - Test_If_Relative_Path (Linker_Switches.Table (J)); - end loop; + No_gnat_adc; end if; @@ -2930,6 +3080,12 @@ package body Make is Saved_Maximum_Processes := Opt.Maximum_Processes; end if; + -- Allocate as many temporary mapping file names as the maximum + -- number of compilation processed. + + The_Mapping_File_Names := + new Temp_File_Names (1 .. Saved_Maximum_Processes); + -- If either -c, -b or -l has been specified, we will not necessarily -- execute all steps. @@ -2945,6 +3101,8 @@ package body Make is end if; end if; + Bad_Compilation.Init; + -- Here is where the make process is started -- We do the same process for each main @@ -3137,9 +3295,17 @@ package body Make is Write_Eol; end if; - if Compilation_Failures /= 0 then - List_Bad_Compilations; - raise Compilation_Failed; + Total_Compilation_Failures := + Total_Compilation_Failures + Compilation_Failures; + + if Total_Compilation_Failures /= 0 then + if Opt.Keep_Going then + goto Next_Main; + + else + List_Bad_Compilations; + raise Compilation_Failed; + end if; end if; -- Regenerate libraries, if any and if object files @@ -3192,7 +3358,7 @@ package body Make is -- 1) -n (Do_Not_Execute) specified - -- 2) -l (List_Dependencies) specified (also sets + -- 2) -M (List_Dependencies) specified (also sets -- Do_Not_Execute above, so this is probably superfluous). -- 3) -c (Compile_Only) specified, but not -b (Bind_Only) @@ -3499,31 +3665,33 @@ package body Make is end if; end loop Multiple_Main_Loop; + if Total_Compilation_Failures /= 0 then + List_Bad_Compilations; + raise Compilation_Failed; + end if; + -- Delete the temporary mapping file that was created if we are -- using project files. - if Main_Project /= No_Project then - declare - Success : Boolean; - - begin - Delete_File (Name => Mapping_File_Name, Success => Success); - end; - end if; + Delete_Mapping_Files; Exit_Program (E_Success); exception when Bind_Failed => + Delete_Mapping_Files; Osint.Fail ("*** bind failed."); when Compilation_Failed => + Delete_Mapping_Files; Exit_Program (E_Fatal); when Link_Failed => + Delete_Mapping_Files; Osint.Fail ("*** link failed."); when X : others => + Delete_Mapping_Files; Write_Line (Exception_Information (X)); Osint.Fail ("INTERNAL ERROR. Please report."); @@ -3561,6 +3729,27 @@ package body Make is Write_Eol; end Inform; + ----------------------- + -- Init_Mapping_File -- + ----------------------- + + procedure Init_Mapping_File (File_Name : in out Temp_File_Name) is + FD : File_Descriptor; + begin + if Main_Project /= No_Project then + Prj.Env.Create_Mapping_File (File_Name); + + else + Create_Temp_File (FD, File_Name); + + if FD = Invalid_FD then + Fail ("disk full"); + end if; + + Close (FD); + end if; + end Init_Mapping_File; + ------------ -- Init_Q -- ------------ @@ -3590,7 +3779,6 @@ package body Make is -- Package initializations. The order of calls is important here. Output.Set_Standard_Error; - Osint.Initialize (Osint.Make); Gcc_Switches.Init; Binder_Switches.Init; @@ -3867,6 +4055,8 @@ package body Make is Get_Name_String (ALI_File); Link_Args (Args'Last + 1) := new String'(Name_Buffer (1 .. Name_Len)); + GNAT.OS_Lib.Normalize_Arguments (Link_Args); + Display (Gnatlink.all, Link_Args); if Gnatlink_Path = null then @@ -3973,28 +4163,6 @@ package body Make is Set_Name_Table_Byte (Source_File, 1); end Mark; - ------------------- - -- Mark_Dir_Path -- - ------------------- - - procedure Mark_Dir_Path - (Path : String_Access; - Mark : Lib_Mark_Type) - is - Dir : String_Access; - - begin - if Path /= null then - Osint.Get_Next_Dir_In_Path_Init (Path); - - loop - Dir := Osint.Get_Next_Dir_In_Path (Path); - exit when Dir = null; - Mark_Directory (Dir.all, Mark); - end loop; - end if; - end Mark_Dir_Path; - -------------------- -- Mark_Directory -- -------------------- @@ -4029,19 +4197,20 @@ package body Make is ---------------------- function Object_File_Name (Source : String) return String is - Pos : Natural := Source'Last; - begin - while Pos >= Source'First and then - Source (Pos) /= '.' loop - Pos := Pos - 1; + -- If the source name has an extension, then replace it with + -- the object suffix. + + for Index in reverse Source'First + 1 .. Source'Last loop + if Source (Index) = '.' then + return Source (Source'First .. Index - 1) & Object_Suffix; + end if; end loop; - if Pos >= Source'First then - Pos := Pos - 1; - end if; + -- If there is no dot, or if it is the first character, just add the + -- object suffix. - return Source (Source'First .. Pos) & Object_Suffix; + return Source & Object_Suffix; end Object_File_Name; ------------------- @@ -4063,8 +4232,9 @@ package body Make is if Opt.Output_File_Name_Present and then not Output_File_Name_Seen then Output_File_Name_Seen := True; - if Argv (1) = Switch_Character or else Argv (1) = '-' then + if Argv (1) = '-' then Fail ("output file name missing after -o"); + else Add_Switch ("-o", Linker, And_Save => And_Save); @@ -4084,12 +4254,13 @@ package body Make is end if; end if; - -- Then check if we are dealing with a -cargs, -bargs or -largs + -- Then check if we are dealing with -cargs/-bargs/-largs - elsif (Argv (1) = Switch_Character or else Argv (1) = '-') - and then (Argv (2 .. Argv'Last) = "cargs" - or else Argv (2 .. Argv'Last) = "bargs" - or else Argv (2 .. Argv'Last) = "largs") + elsif Argv = "-bargs" + or else + Argv = "-cargs" + or else + Argv = "-largs" then if not File_Name_Seen then Fail ("-cargs, -bargs, -largs ", @@ -4110,8 +4281,7 @@ package body Make is -- executable. elsif Program_Args = Linker - and then (Argv (1) = Switch_Character or else Argv (1) = '-') - and then Argv (2 .. Argv'Last) = "o" + and then Argv = "-o" then Fail ("switch -o not allowed within a -largs. Use -o directly."); @@ -4141,7 +4311,7 @@ package body Make is Add_Switch (Argv, Program_Args, And_Save => And_Save); - -- Handle non-default compiler, binder, linker + -- Handle non-default compiler, binder, linker, and handle --RTS switch elsif Argv'Length > 2 and then Argv (1 .. 2) = "--" then if Argv'Length > 6 @@ -4207,13 +4377,60 @@ package body Make is end loop; end; + elsif Argv'Length >= 5 and then + Argv (1 .. 5) = "--RTS" + then + Add_Switch (Argv, Compiler, And_Save => And_Save); + Add_Switch (Argv, Binder, And_Save => And_Save); + + if Argv'Length <= 6 or else Argv (6) /= '=' then + Osint.Fail ("missing path for --RTS"); + + else + -- Valid --RTS switch + + Opt.No_Stdinc := True; + Opt.No_Stdlib := True; + Opt.RTS_Switch := True; + + declare + Src_Path_Name : String_Ptr := + Get_RTS_Search_Dir + (Argv (7 .. Argv'Last), Include); + Lib_Path_Name : String_Ptr := + Get_RTS_Search_Dir + (Argv (7 .. Argv'Last), Objects); + + begin + if Src_Path_Name /= null and then + Lib_Path_Name /= null + then + Add_Search_Dirs (Src_Path_Name, Include); + Add_Search_Dirs (Lib_Path_Name, Objects); + + elsif Src_Path_Name = null + and Lib_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adainclude and adalib directories"); + + elsif Src_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adainclude directory"); + + elsif Lib_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adalib directory"); + end if; + end; + end if; + else Fail ("unknown switch: ", Argv); end if; -- If we have seen a regular switch process it - elsif Argv (1) = Switch_Character or else Argv (1) = '-' then + elsif Argv (1) = '-' then if Argv'Length = 1 then Fail ("switch character cannot be followed by a blank"); @@ -4401,11 +4618,10 @@ package body Make is null; -- If -gnath is present, then generate the usage information - -- right now for the compiler, and do not pass this option - -- on to the compiler calls. + -- right now and do not pass this option on to the compiler calls. elsif Argv = "-gnath" then - null; + Usage; -- If -gnatc is specified, make sure the bind step and the link -- step are not executed. @@ -4440,11 +4656,12 @@ package body Make is -- By default all switches with more than one character -- or one character switches which are not in 'a' .. 'z' - -- (except 'M') are passed to the compiler, unless we are dealing - -- with a debug switch (starts with 'd') + -- (except 'C' and 'M') are passed to the compiler, unless we are + -- dealing with a debug switch (starts with 'd') elsif Argv (2) /= 'd' and then Argv (2 .. Argv'Last) /= "M" + and then Argv (2 .. Argv'Last) /= "C" and then (Argv'Length > 2 or else Argv (2) not in 'a' .. 'z') then Add_Switch (Argv, Compiler, And_Save => And_Save); @@ -4459,7 +4676,7 @@ package body Make is else File_Name_Seen := True; - Set_Main_File_Name (Argv); + Add_File (Argv); end if; end Scan_Make_Arg; @@ -4682,7 +4899,9 @@ package body Make is (Index => Name_Find, In_Array => Switches_Array); - if Switches = Nil_Variable_Value then + if Switches = Nil_Variable_Value + and then Allow_ALI + then Last := Source_File_Name'Length; while Name (Last) /= '.' loop @@ -4692,10 +4911,10 @@ package body Make is Name (Last + 1 .. Last + 3) := "ali"; Name_Len := Last + 3; Name_Buffer (1 .. Name_Len) := Name (1 .. Name_Len); - Switches := - Prj.Util.Value_Of - (Index => Name_Find, - In_Array => Switches_Array); + Switches := + Prj.Util.Value_Of + (Index => Name_Find, + In_Array => Switches_Array); end if; end if; end; @@ -4713,7 +4932,10 @@ package body Make is -- Test_If_Relative_Path -- --------------------------- - procedure Test_If_Relative_Path (Switch : String_Access) is + procedure Test_If_Relative_Path + (Switch : in out String_Access; + Parent : String_Access) + is begin if Switch /= null then @@ -4743,27 +4965,44 @@ package body Make is then Start := 4; + elsif Sw'Length >= 7 + and then Sw (2 .. 6) = "-RTS=" + then + Start := 7; else return; end if; if not Is_Absolute_Path (Sw (Start .. Sw'Last)) then - Fail ("relative search path switches (""" & - Sw & """) are not allowed when using project files"); + if Parent = null then + Fail ("relative search path switches (""" & Sw & + """) are not allowed inside project files"); + + else + Switch := + new String' + (Sw (1 .. Start - 1) & + Parent.all & + Directory_Separator & + Sw (Start .. Sw'Last)); + end if; end if; end if; end; end if; end Test_If_Relative_Path; - ------------ - -- Unmark -- - ------------ + ----------- + -- Usage -- + ----------- - procedure Unmark (Source_File : File_Name_Type) is + procedure Usage is begin - Set_Name_Table_Byte (Source_File, 0); - end Unmark; + if Usage_Needed then + Usage_Needed := False; + Makeusg; + end if; + end Usage; ----------------- -- Verbose_Msg -- |