Commit 7ffa903f by Vincent Celier Committed by Geert Bosch

gnatcmd.adb: (MAKE): Add new translations: -b /BIND_ONLY, -c /COMPILE_ONLY, -l /LINK_ONLY

	* gnatcmd.adb: (MAKE): Add new translations: -b /BIND_ONLY,
	-c /COMPILE_ONLY, -l /LINK_ONLY

	* opt.ads:
	(Bind_Only): New Flag
	(Link_Only): New flag

	* switch.adb (Scan_Make_Switches): Add processing for -b (Bind_Only)
	and -l (Link_Only)

	* makeusg.adb: Add new switches -b and -l. Update Copyright notice.

	* make.adb:
	(Do_Compile_Step, Do_Bind_Step, Do_Link_Step): New flags.
	(Gnatmake): Set the step flags. Only perform a step if the
	corresponding step flag is True.
	(Scan_Make_Arg): Reset the bind and link step flags when -u
	or -gnatc has been specified.

From-SVN: r47694
parent 578316b9
2001-12-05 Vincent Celier <celier@gnat.com>
* gnatcmd.adb: (MAKE): Add new translations: -b /BIND_ONLY,
-c /COMPILE_ONLY, -l /LINK_ONLY
* opt.ads:
(Bind_Only): New Flag
(Link_Only): New flag
* switch.adb (Scan_Make_Switches): Add processing for -b (Bind_Only)
and -l (Link_Only)
* makeusg.adb: Add new switches -b and -l. Update Copyright notice.
* make.adb:
(Do_Compile_Step, Do_Bind_Step, Do_Link_Step): New flags.
(Gnatmake): Set the step flags. Only perform a step if the
corresponding step flag is True.
(Scan_Make_Arg): Reset the bind and link step flags when -u
or -gnatc has been specified.
2001-12-05 Ed Schonberg <schonber@gnat.com> 2001-12-05 Ed Schonberg <schonber@gnat.com>
* sem_eval.adb (Eval_Concatenation): If left operand is a null string, * sem_eval.adb (Eval_Concatenation): If left operand is a null string,
......
...@@ -1014,9 +1014,15 @@ procedure GNATCmd is ...@@ -1014,9 +1014,15 @@ procedure GNATCmd is
S_Make_All : aliased constant S := "/ALL_FILES " & S_Make_All : aliased constant S := "/ALL_FILES " &
"-a"; "-a";
S_Make_Bind_Only : aliased constant S := "/BIND_ONLY " &
"-b";
S_Make_Bind : aliased constant S := "/BINDER_QUALIFIERS=?" & S_Make_Bind : aliased constant S := "/BINDER_QUALIFIERS=?" &
"-bargs BIND"; "-bargs BIND";
S_Make_Compile_Only : aliased constant S := "/COMPILE_ONLY " &
"-c";
S_Make_Comp : aliased constant S := "/COMPILER_QUALIFIERS=?" & S_Make_Comp : aliased constant S := "/COMPILER_QUALIFIERS=?" &
"-cargs COMPILE"; "-cargs COMPILE";
...@@ -1050,6 +1056,9 @@ procedure GNATCmd is ...@@ -1050,6 +1056,9 @@ procedure GNATCmd is
S_Make_Link : aliased constant S := "/LINKER_QUALIFIERS=?" & S_Make_Link : aliased constant S := "/LINKER_QUALIFIERS=?" &
"-largs LINK"; "-largs LINK";
S_Make_Link_Only : aliased constant S := "/LINK_ONLY " &
"-l";
S_Make_Minimal : aliased constant S := "/MINIMAL_RECOMPILATION " & S_Make_Minimal : aliased constant S := "/MINIMAL_RECOMPILATION " &
"-m"; "-m";
...@@ -1092,7 +1101,9 @@ procedure GNATCmd is ...@@ -1092,7 +1101,9 @@ procedure GNATCmd is
Make_Switches : aliased constant Switches := ( Make_Switches : aliased constant Switches := (
S_Make_All 'Access, S_Make_All 'Access,
S_Make_Bind 'Access, S_Make_Bind 'Access,
S_Make_Bind_Only'Access,
S_Make_Comp 'Access, S_Make_Comp 'Access,
S_Make_Compile_Only'Access,
S_Make_Cond 'Access, S_Make_Cond 'Access,
S_Make_Cont 'Access, S_Make_Cont 'Access,
S_Make_Current 'Access, S_Make_Current 'Access,
...@@ -1104,6 +1115,7 @@ procedure GNATCmd is ...@@ -1104,6 +1115,7 @@ procedure GNATCmd is
S_Make_Inplace 'Access, S_Make_Inplace 'Access,
S_Make_Library 'Access, S_Make_Library 'Access,
S_Make_Link 'Access, S_Make_Link 'Access,
S_Make_Link_Only'Access,
S_Make_Minimal 'Access, S_Make_Minimal 'Access,
S_Make_Nolink 'Access, S_Make_Nolink 'Access,
S_Make_Nostinc 'Access, S_Make_Nostinc 'Access,
......
...@@ -263,6 +263,13 @@ package body Make is ...@@ -263,6 +263,13 @@ package body Make is
Max_Line_Length : constant := 127; Max_Line_Length : constant := 127;
-- Maximum number of characters per line, when displaying a path -- Maximum number of characters per line, when displaying a path
Do_Compile_Step : Boolean := True;
Do_Bind_Step : Boolean := True;
Do_Link_Step : Boolean := True;
-- Flags to indicate what step should be executed.
-- Can be set to False with the switches -c, -b and -l.
-- These flags are reset to True for each invokation of procedure Gnatmake.
---------------------- ----------------------
-- Marking Routines -- -- Marking Routines --
---------------------- ----------------------
...@@ -2507,6 +2514,10 @@ package body Make is ...@@ -2507,6 +2514,10 @@ package body Make is
-- really necessary, because it is too hard to decide. -- really necessary, because it is too hard to decide.
begin begin
Do_Compile_Step := True;
Do_Bind_Step := True;
Do_Link_Step := True;
Make.Initialize; Make.Initialize;
if Hostparm.Java_VM then if Hostparm.Java_VM then
...@@ -2557,7 +2568,8 @@ package body Make is ...@@ -2557,7 +2568,8 @@ package body Make is
-- First make sure that the binder and the linker -- First make sure that the binder and the linker
-- will not be invoked. -- will not be invoked.
Opt.Compile_Only := True; Do_Bind_Step := False;
Do_Link_Step := False;
-- Put all the sources in the queue -- Put all the sources in the queue
...@@ -2875,296 +2887,333 @@ package body Make is ...@@ -2875,296 +2887,333 @@ package body Make is
Gnatbind_Path := GNAT.OS_Lib.Locate_Exec_On_Path (Gnatbind.all); Gnatbind_Path := GNAT.OS_Lib.Locate_Exec_On_Path (Gnatbind.all);
Gnatlink_Path := GNAT.OS_Lib.Locate_Exec_On_Path (Gnatlink.all); Gnatlink_Path := GNAT.OS_Lib.Locate_Exec_On_Path (Gnatlink.all);
-- If we have specified -j switch both from the project file
-- and on the command line, the one from the command line takes
-- precedence.
if Saved_Maximum_Processes = 0 then
Saved_Maximum_Processes := Opt.Maximum_Processes;
end if;
-- If either -c, -b or -l has been specified, we will not necessarily
-- execute all steps.
if Compile_Only or else Bind_Only or else Link_Only then
Do_Compile_Step := Do_Compile_Step and Compile_Only;
Do_Bind_Step := Do_Bind_Step and Bind_Only;
Do_Link_Step := Do_Link_Step and Link_Only;
-- If -c has been specified, but not -b, ignore any potential -l
if Do_Compile_Step and then not Do_Bind_Step then
Do_Link_Step := False;
end if;
end if;
-- Here is where the make process is started -- Here is where the make process is started
-- We do the same process for each main -- We do the same process for each main
Multiple_Main_Loop : for N_File in 1 .. Osint.Number_Of_Files loop Multiple_Main_Loop : for N_File in 1 .. Osint.Number_Of_Files loop
Recursive_Compilation_Step : declare if Do_Compile_Step then
Args : Argument_List (1 .. Gcc_Switches.Last); Recursive_Compilation_Step : declare
Args : Argument_List (1 .. Gcc_Switches.Last);
First_Compiled_File : Name_Id; First_Compiled_File : Name_Id;
Youngest_Obj_File : Name_Id; Youngest_Obj_File : Name_Id;
Youngest_Obj_Stamp : Time_Stamp_Type; Youngest_Obj_Stamp : Time_Stamp_Type;
Executable_Stamp : Time_Stamp_Type; Executable_Stamp : Time_Stamp_Type;
-- Executable is the final executable program. -- Executable is the final executable program.
begin begin
Executable := No_File; Executable := No_File;
Non_Std_Executable := False; Non_Std_Executable := False;
for J in 1 .. Gcc_Switches.Last loop for J in 1 .. Gcc_Switches.Last loop
Args (J) := Gcc_Switches.Table (J); Args (J) := Gcc_Switches.Table (J);
end loop; end loop;
-- Look inside the linker switches to see if the name of the final -- Look inside the linker switches to see if the name
-- executable program was specified. -- of the final executable program was specified.
for J in Linker_Switches.First .. Linker_Switches.Last loop for J in Linker_Switches.First .. Linker_Switches.Last loop
if Linker_Switches.Table (J).all = Output_Flag.all then if Linker_Switches.Table (J).all = Output_Flag.all then
pragma Assert (J < Linker_Switches.Last); pragma Assert (J < Linker_Switches.Last);
-- We cannot specify a single executable for several -- We cannot specify a single executable for several
-- main subprograms! -- main subprograms!
if Osint.Number_Of_Files > 1 then if Osint.Number_Of_Files > 1 then
Fail Fail
("cannot specify a single executable for several mains"); ("cannot specify a single executable " &
end if; "for several mains");
end if;
Name_Len := Linker_Switches.Table (J + 1)'Length; Name_Len := Linker_Switches.Table (J + 1)'Length;
Name_Buffer (1 .. Name_Len) := Name_Buffer (1 .. Name_Len) :=
Linker_Switches.Table (J + 1).all; Linker_Switches.Table (J + 1).all;
-- If target has an executable suffix and it has not been -- If target has an executable suffix and it has not been
-- specified then it is added here. -- specified then it is added here.
if Executable_Suffix'Length /= 0 if Executable_Suffix'Length /= 0
and then Linker_Switches.Table (J + 1) and then Linker_Switches.Table (J + 1)
(Name_Len - Executable_Suffix'Length + 1 (Name_Len - Executable_Suffix'Length + 1
.. Name_Len) /= Executable_Suffix .. Name_Len) /= Executable_Suffix
then then
Name_Buffer (Name_Len + 1 .. Name_Buffer (Name_Len + 1 ..
Name_Len + Executable_Suffix'Length) := Name_Len + Executable_Suffix'Length) :=
Executable_Suffix; Executable_Suffix;
Name_Len := Name_Len + Executable_Suffix'Length; Name_Len := Name_Len + Executable_Suffix'Length;
end if; end if;
Executable := Name_Enter; Executable := Name_Enter;
Verbose_Msg (Executable, "final executable"); Verbose_Msg (Executable, "final executable");
end if; end if;
end loop; end loop;
-- If the name of the final executable program was not specified -- If the name of the final executable program was not
-- then construct it from the main input file. -- specified then construct it from the main input file.
if Executable = No_File then if Executable = No_File then
if Main_Project = No_Project then if Main_Project = No_Project then
Executable := Executable :=
Executable_Name (Strip_Suffix (Main_Source_File)); Executable_Name (Strip_Suffix (Main_Source_File));
else else
-- If we are using a project file, we attempt to -- If we are using a project file, we attempt to
-- remove the body (or spec) termination of the main -- remove the body (or spec) termination of the main
-- subprogram. We find it the the naming scheme of the -- subprogram. We find it the the naming scheme of the
-- project file. This will avoid to generate an executable -- project file. This will avoid to generate an
-- "main.2" for a main subprogram "main.2.ada", when the -- executable "main.2" for a main subprogram
-- body termination is ".2.ada". -- "main.2.ada", when the body termination is ".2.ada".
declare declare
Body_Append : constant String := Body_Append : constant String :=
Get_Name_String Get_Name_String
(Projects.Table (Projects.Table
(Main_Project). (Main_Project).
Naming.Current_Impl_Suffix); Naming.Current_Impl_Suffix);
Spec_Append : constant String := Spec_Append : constant String :=
Get_Name_String Get_Name_String
(Projects.Table (Projects.Table
(Main_Project). (Main_Project).
Naming.Current_Spec_Suffix); Naming.Current_Spec_Suffix);
begin begin
Get_Name_String (Main_Source_File); Get_Name_String (Main_Source_File);
if Name_Len > Body_Append'Length if Name_Len > Body_Append'Length
and then Name_Buffer and then Name_Buffer
(Name_Len - Body_Append'Length + 1 .. Name_Len) = (Name_Len - Body_Append'Length + 1 .. Name_Len) =
Body_Append Body_Append
then then
-- We have found the body termination. We remove it -- We have found the body termination. We remove it
-- add the executable termination (if any) and set -- add the executable termination (if any) and set
-- Non_Std_Executable. -- Non_Std_Executable.
Name_Len := Name_Len - Body_Append'Length; Name_Len := Name_Len - Body_Append'Length;
Executable := Executable_Name (Name_Find); Executable := Executable_Name (Name_Find);
Non_Std_Executable := True; Non_Std_Executable := True;
elsif Name_Len > Spec_Append'Length elsif Name_Len > Spec_Append'Length
and then and then
Name_Buffer Name_Buffer
(Name_Len - Spec_Append'Length + 1 .. Name_Len) = (Name_Len - Spec_Append'Length + 1 .. Name_Len) =
Spec_Append Spec_Append
then then
-- We have found the spec termination. We remove it, -- We have found the spec termination. We remove
-- add the executable termination (if any), and set -- it, add the executable termination (if any),
-- Non_Std_Executable. -- and set Non_Std_Executable.
Name_Len := Name_Len - Spec_Append'Length;
Executable := Executable_Name (Name_Find);
Non_Std_Executable := True;
else
Executable :=
Executable_Name (Strip_Suffix (Main_Source_File));
end if;
end;
end if;
end if;
Name_Len := Name_Len - Spec_Append'Length; -- Now we invoke Compile_Sources for the current main
Executable := Executable_Name (Name_Find);
Non_Std_Executable := True; Compile_Sources
(Main_Source => Main_Source_File,
Args => Args,
First_Compiled_File => First_Compiled_File,
Most_Recent_Obj_File => Youngest_Obj_File,
Most_Recent_Obj_Stamp => Youngest_Obj_Stamp,
Main_Unit => Is_Main_Unit,
Compilation_Failures => Compilation_Failures,
Check_Readonly_Files => Opt.Check_Readonly_Files,
Do_Not_Execute => Opt.Do_Not_Execute,
Force_Compilations => Opt.Force_Compilations,
In_Place_Mode => Opt.In_Place_Mode,
Keep_Going => Opt.Keep_Going,
Initialize_ALI_Data => True,
Max_Process => Saved_Maximum_Processes);
else if Opt.Verbose_Mode then
Executable := Write_Str ("End of compilation");
Executable_Name (Strip_Suffix (Main_Source_File)); Write_Eol;
end if;
end;
end if; end if;
end if;
-- Now we invoke Compile_Sources for the current main
Compile_Sources
(Main_Source => Main_Source_File,
Args => Args,
First_Compiled_File => First_Compiled_File,
Most_Recent_Obj_File => Youngest_Obj_File,
Most_Recent_Obj_Stamp => Youngest_Obj_Stamp,
Main_Unit => Is_Main_Unit,
Compilation_Failures => Compilation_Failures,
Check_Readonly_Files => Opt.Check_Readonly_Files,
Do_Not_Execute => Opt.Do_Not_Execute,
Force_Compilations => Opt.Force_Compilations,
In_Place_Mode => Opt.In_Place_Mode,
Keep_Going => Opt.Keep_Going,
Initialize_ALI_Data => True,
Max_Process => Opt.Maximum_Processes);
if Opt.Verbose_Mode then if Compilation_Failures /= 0 then
Write_Str ("End of compilation"); List_Bad_Compilations;
Write_Eol; raise Compilation_Failed;
end if; end if;
if Compilation_Failures /= 0 then -- Regenerate libraries, if any and if object files
List_Bad_Compilations; -- have been regenerated
raise Compilation_Failed;
end if;
-- Regenerate libraries, if any and if object files if Main_Project /= No_Project
-- have been regenerated and then MLib.Tgt.Libraries_Are_Supported
then
if Main_Project /= No_Project for Proj in Projects.First .. Projects.Last loop
and then MLib.Tgt.Libraries_Are_Supported
then
for Proj in Projects.First .. Projects.Last loop if Proj /= Main_Project
and then Projects.Table (Proj).Flag1
then
MLib.Prj.Build_Library (For_Project => Proj);
end if;
if Proj /= Main_Project end loop;
and then Projects.Table (Proj).Flag1
then
MLib.Prj.Build_Library (For_Project => Proj);
end if;
end loop; end if;
end if; if Opt.List_Dependencies then
if First_Compiled_File /= No_File then
Inform
(First_Compiled_File,
"must be recompiled. Can't generate dependence list.");
else
List_Depend;
end if;
if Opt.List_Dependencies then elsif First_Compiled_File = No_File
if First_Compiled_File /= No_File then and then not Do_Bind_Step
Inform and then not Opt.Quiet_Output
(First_Compiled_File, and then Osint.Number_Of_Files = 1
"must be recompiled. Can't generate dependence list."); then
else if Unique_Compile then
List_Depend; Inform (Msg => "object up to date.");
end if; else
Inform (Msg => "objects up to date.");
end if;
elsif First_Compiled_File = No_File elsif Opt.Do_Not_Execute
and then Opt.Compile_Only and then First_Compiled_File /= No_File
and then not Opt.Quiet_Output then
and then Osint.Number_Of_Files = 1 Write_Name (First_Compiled_File);
then Write_Eol;
if Unique_Compile then
Inform (Msg => "object up to date.");
else
Inform (Msg => "objects up to date.");
end if; end if;
elsif Opt.Do_Not_Execute -- Stop after compile step if any of:
and then First_Compiled_File /= No_File
then
Write_Name (First_Compiled_File);
Write_Eol;
end if;
-- Stop after compile step if any of:
-- 1) -n (Do_Not_Execute) specified -- 1) -n (Do_Not_Execute) specified
-- 2) -l (List_Dependencies) specified (also sets Do_Not_Execute -- 2) -l (List_Dependencies) specified (also sets
-- above, so this is probably superfluous). -- Do_Not_Execute above, so this is probably superfluous).
-- 3) -c (Compile_Only) specified -- 3) -c (Compile_Only) specified, but not -b (Bind_Only)
-- 4) Made unit cannot be a main unit -- 4) Made unit cannot be a main unit
if (Opt.Do_Not_Execute if (Opt.Do_Not_Execute
or Opt.List_Dependencies or Opt.List_Dependencies
or Opt.Compile_Only or not Do_Bind_Step
or not Is_Main_Unit) or not Is_Main_Unit)
and then not No_Main_Subprogram and then not No_Main_Subprogram
then then
if Osint.Number_Of_Files = 1 then if Osint.Number_Of_Files = 1 then
return; return;
else else
goto Next_Main; goto Next_Main;
end if;
end if; end if;
end if;
-- If the objects were up-to-date check if the executable file -- If the objects were up-to-date check if the executable file
-- is also up-to-date. For now always bind and link on the JVM -- is also up-to-date. For now always bind and link on the JVM
-- since there is currently no simple way to check the up-to-date -- since there is currently no simple way to check the
-- status of objects -- up-to-date status of objects
if not Hostparm.Java_VM and then First_Compiled_File = No_File then if not Hostparm.Java_VM
Executable_Stamp := File_Stamp (Executable); and then First_Compiled_File = No_File
then
Executable_Stamp := File_Stamp (Executable);
-- Once Executable_Obsolete is set to True, it is never reset -- Once Executable_Obsolete is set to True, it is never
-- to False, because it is too hard to accurately decide if -- reset to False, because it is too hard to accurately
-- a subsequent main need to be rebuilt or not. -- decide if a subsequent main need to be rebuilt or not.
Executable_Obsolete := Executable_Obsolete :=
Executable_Obsolete Executable_Obsolete
or else Youngest_Obj_Stamp > Executable_Stamp; or else Youngest_Obj_Stamp > Executable_Stamp;
if not Executable_Obsolete then if not Executable_Obsolete then
-- If no Ada object files obsolete the executable, check -- If no Ada object files obsolete the executable, check
-- for younger or missing linker files. -- for younger or missing linker files.
Check_Linker_Options Check_Linker_Options
(Executable_Stamp, Youngest_Obj_File, Youngest_Obj_Stamp); (Executable_Stamp,
Youngest_Obj_File,
Youngest_Obj_Stamp);
Executable_Obsolete := Youngest_Obj_File /= No_File; Executable_Obsolete := Youngest_Obj_File /= No_File;
end if; end if;
-- Return if the executable is up to date -- Return if the executable is up to date
-- and otherwise motivate the relink/rebind. -- and otherwise motivate the relink/rebind.
if not Executable_Obsolete then if not Executable_Obsolete then
if not Opt.Quiet_Output then if not Opt.Quiet_Output then
Inform (Executable, "up to date."); Inform (Executable, "up to date.");
end if; end if;
if Osint.Number_Of_Files = 1 then if Osint.Number_Of_Files = 1 then
return; return;
else else
goto Next_Main; goto Next_Main;
end if;
end if; end if;
end if;
if Executable_Stamp (1) = ' ' then if Executable_Stamp (1) = ' ' then
Verbose_Msg (Executable, "missing.", Prefix => " "); Verbose_Msg (Executable, "missing.", Prefix => " ");
elsif Youngest_Obj_Stamp (1) = ' ' then elsif Youngest_Obj_Stamp (1) = ' ' then
Verbose_Msg (Youngest_Obj_File, "missing.", Prefix => " "); Verbose_Msg
(Youngest_Obj_File,
"missing.",
Prefix => " ");
elsif Youngest_Obj_Stamp > Executable_Stamp then elsif Youngest_Obj_Stamp > Executable_Stamp then
Verbose_Msg (Youngest_Obj_File, Verbose_Msg
"(" & String (Youngest_Obj_Stamp) & ") newer than", (Youngest_Obj_File,
Executable, "(" & String (Executable_Stamp) & ")"); "(" & String (Youngest_Obj_Stamp) & ") newer than",
Executable,
"(" & String (Executable_Stamp) & ")");
else else
Verbose_Msg (Executable, "needs to be rebuild.", Verbose_Msg
Prefix => " "); (Executable, "needs to be rebuild.",
Prefix => " ");
end if;
end if; end if;
end if; end Recursive_Compilation_Step;
end Recursive_Compilation_Step;
end if;
-- If we are here, it means that we need to rebuilt the current -- If we are here, it means that we need to rebuilt the current
-- main. So we set Executable_Obsolete to True to make sure that -- main. So we set Executable_Obsolete to True to make sure that
...@@ -3197,103 +3246,111 @@ package body Make is ...@@ -3197,103 +3246,111 @@ package body Make is
pragma Assert (Main_ALI_File /= No_File); pragma Assert (Main_ALI_File /= No_File);
end Main_ALI_In_Place_Mode_Step; end Main_ALI_In_Place_Mode_Step;
Bind_Step : declare if Do_Bind_Step then
Args : Argument_List Bind_Step : declare
(Binder_Switches.First .. Binder_Switches.Last); Args : Argument_List
(Binder_Switches.First .. Binder_Switches.Last);
begin begin
-- Get all the binder switches -- Get all the binder switches
for J in Binder_Switches.First .. Binder_Switches.Last loop for J in Binder_Switches.First .. Binder_Switches.Last loop
Args (J) := Binder_Switches.Table (J); Args (J) := Binder_Switches.Table (J);
end loop; end loop;
if Main_Project /= No_Project then if Main_Project /= No_Project then
-- Put all the source directories in ADA_INCLUDE_PATH, -- Put all the source directories in ADA_INCLUDE_PATH,
-- and all the object directories in ADA_OBJECTS_PATH -- and all the object directories in ADA_OBJECTS_PATH
Set_Ada_Paths (Main_Project, False); Set_Ada_Paths (Main_Project, False);
end if; end if;
Bind (Main_ALI_File, Args); Bind (Main_ALI_File, Args);
end Bind_Step; end Bind_Step;
Link_Step : declare end if;
There_Are_Libraries : Boolean := False;
Linker_Switches_Last : constant Integer := Linker_Switches.Last;
begin if Do_Link_Step then
if Main_Project /= No_Project then Link_Step : declare
There_Are_Libraries : Boolean := False;
Linker_Switches_Last : constant Integer := Linker_Switches.Last;
if MLib.Tgt.Libraries_Are_Supported then begin
Set_Libraries (Main_Project, There_Are_Libraries);
end if;
if There_Are_Libraries then if Main_Project /= No_Project then
-- Add -L<lib_dir> -lgnarl -lgnat -Wl,-rpath,<lib_dir> if MLib.Tgt.Libraries_Are_Supported then
Set_Libraries (Main_Project, There_Are_Libraries);
end if;
Linker_Switches.Increment_Last; if There_Are_Libraries then
Linker_Switches.Table (Linker_Switches.Last) :=
new String'("-L" & MLib.Utl.Lib_Directory);
Linker_Switches.Increment_Last;
Linker_Switches.Table (Linker_Switches.Last) :=
new String'("-lgnarl");
Linker_Switches.Increment_Last;
Linker_Switches.Table (Linker_Switches.Last) :=
new String'("-lgnat");
declare -- Add -L<lib_dir> -lgnarl -lgnat -Wl,-rpath,<lib_dir>
Option : constant String_Access :=
MLib.Tgt.Linker_Library_Path_Option
(MLib.Utl.Lib_Directory);
begin Linker_Switches.Increment_Last;
if Option /= null then Linker_Switches.Table (Linker_Switches.Last) :=
Linker_Switches.Increment_Last; new String'("-L" & MLib.Utl.Lib_Directory);
Linker_Switches.Table (Linker_Switches.Last) := Option; Linker_Switches.Increment_Last;
end if; Linker_Switches.Table (Linker_Switches.Last) :=
new String'("-lgnarl");
Linker_Switches.Increment_Last;
Linker_Switches.Table (Linker_Switches.Last) :=
new String'("-lgnat");
end; declare
Option : constant String_Access :=
MLib.Tgt.Linker_Library_Path_Option
(MLib.Utl.Lib_Directory);
end if; begin
if Option /= null then
Linker_Switches.Increment_Last;
Linker_Switches.Table (Linker_Switches.Last) :=
Option;
end if;
-- Put the object directories in ADA_OBJECTS_PATH end;
Set_Ada_Paths (Main_Project, False); end if;
end if;
declare -- Put the object directories in ADA_OBJECTS_PATH
Args : Argument_List
(Linker_Switches.First .. Linker_Switches.Last + 2);
begin Set_Ada_Paths (Main_Project, False);
-- Get all the linker switches end if;
for J in Linker_Switches.First .. Linker_Switches.Last loop declare
Args (J) := Linker_Switches.Table (J); Args : Argument_List
end loop; (Linker_Switches.First .. Linker_Switches.Last + 2);
-- And invoke the linker begin
-- Get all the linker switches
if Non_Std_Executable then for J in Linker_Switches.First .. Linker_Switches.Last loop
Args (Linker_Switches.Last + 1) := new String'("-o"); Args (J) := Linker_Switches.Table (J);
Args (Linker_Switches.Last + 2) := end loop;
new String'(Get_Name_String (Executable));
Link (Main_ALI_File, Args);
else -- And invoke the linker
Link
(Main_ALI_File,
Args (Linker_Switches.First .. Linker_Switches.Last));
end if;
end; if Non_Std_Executable then
Args (Linker_Switches.Last + 1) := new String'("-o");
Args (Linker_Switches.Last + 2) :=
new String'(Get_Name_String (Executable));
Link (Main_ALI_File, Args);
else
Link
(Main_ALI_File,
Args (Linker_Switches.First .. Linker_Switches.Last));
end if;
Linker_Switches.Set_Last (Linker_Switches_Last); end;
end Link_Step;
Linker_Switches.Set_Last (Linker_Switches_Last);
end Link_Step;
end if;
-- We go to here when we skip the bind and link steps. -- We go to here when we skip the bind and link steps.
...@@ -4172,6 +4229,8 @@ package body Make is ...@@ -4172,6 +4229,8 @@ package body Make is
then then
Unique_Compile := True; Unique_Compile := True;
Opt.Compile_Only := True; Opt.Compile_Only := True;
Do_Bind_Step := False;
Do_Link_Step := False;
-- -Pprj (only once, and only on the command line) -- -Pprj (only once, and only on the command line)
...@@ -4251,19 +4310,20 @@ package body Make is ...@@ -4251,19 +4310,20 @@ package body Make is
elsif Argv = "-gnath" then elsif Argv = "-gnath" then
null; null;
-- By default all switches with more than one character -- If -gnatc is specified, make sure the bind step and the link
-- or one character switches which are not in 'a' .. 'z' -- step are not executed.
-- are passed to the compiler, unless we are dealing
-- with a -jnum switch or a debug switch (starts with 'd') elsif Argv'Length >= 6 and then Argv (2 .. 6) = "gnatc" then
-- If -gnatc is specified, make sure the bind step and the link
-- step are not executed.
elsif Argv'Length > 5
and then Argv (2 .. 5) = "gnat"
and then Argv (6) = 'c'
then
Add_Switch (Argv, Compiler, And_Save => And_Save); Add_Switch (Argv, Compiler, And_Save => And_Save);
Opt.Operating_Mode := Opt.Check_Semantics; Opt.Operating_Mode := Opt.Check_Semantics;
Opt.Check_Object_Consistency := False; Opt.Check_Object_Consistency := False;
Opt.Compile_Only := True; Opt.Compile_Only := True;
Do_Bind_Step := False;
Do_Link_Step := False;
elsif Argv (2 .. Argv'Last) = "nostdlib" then elsif Argv (2 .. Argv'Last) = "nostdlib" then
...@@ -4274,10 +4334,18 @@ package body Make is ...@@ -4274,10 +4334,18 @@ package body Make is
Add_Switch (Argv, Binder, And_Save => And_Save); Add_Switch (Argv, Binder, And_Save => And_Save);
elsif Argv (2 .. Argv'Last) = "nostdinc" then elsif Argv (2 .. Argv'Last) = "nostdinc" then
-- Pass -nostdinv to the Compiler and to gnatbind
Opt.No_Stdinc := True; Opt.No_Stdinc := True;
Add_Switch (Argv, Compiler, And_Save => And_Save); Add_Switch (Argv, Compiler, And_Save => And_Save);
Add_Switch (Argv, Binder, And_Save => And_Save); Add_Switch (Argv, Binder, And_Save => And_Save);
-- 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')
elsif Argv (2) /= 'd' elsif Argv (2) /= 'd'
and then Argv (2 .. Argv'Last) /= "M" and then Argv (2 .. Argv'Last) /= "M"
and then (Argv'Length > 2 or else Argv (2) not in 'a' .. 'z') and then (Argv'Length > 2 or else Argv (2) not in 'a' .. 'z')
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- $Revision: 1.14 $ -- $Revision$
-- -- -- --
-- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -68,10 +68,16 @@ begin ...@@ -68,10 +68,16 @@ begin
Write_Str ("a Consider all files, even readonly ali files"); Write_Str ("a Consider all files, even readonly ali files");
Write_Eol; Write_Eol;
-- Line for -b
Write_Switch_Char;
Write_Str ("b Bind only");
Write_Eol;
-- Line for -c -- Line for -c
Write_Switch_Char; Write_Switch_Char;
Write_Str ("c Compile only, do not bind and link"); Write_Str ("c Compile only");
Write_Eol; Write_Eol;
-- Line for -f -- Line for -f
...@@ -99,6 +105,12 @@ begin ...@@ -99,6 +105,12 @@ begin
Write_Str ("k Keep going after compilation errors"); Write_Str ("k Keep going after compilation errors");
Write_Eol; Write_Eol;
-- Line for -l
Write_Switch_Char;
Write_Str ("l Link only");
Write_Eol;
-- Line for -m -- Line for -m
Write_Switch_Char; Write_Switch_Char;
......
...@@ -143,6 +143,11 @@ package Opt is ...@@ -143,6 +143,11 @@ package Opt is
-- Set to True if the binder needs to generate a file designed for -- Set to True if the binder needs to generate a file designed for
-- building a library. May be set to True by Gnatbind.Scan_Bind_Arg. -- building a library. May be set to True by Gnatbind.Scan_Bind_Arg.
Bind_Only : Boolean := False;
-- GNATMAKE
-- Set to True to skip compile and link steps
-- (except when Compile_Only and/or Link_Only are True).
Brief_Output : Boolean := False; Brief_Output : Boolean := False;
-- GNAT, GNATBIND -- GNAT, GNATBIND
-- Force brief error messages to standard error, even if verbose mode is -- Force brief error messages to standard error, even if verbose mode is
...@@ -188,7 +193,7 @@ package Opt is ...@@ -188,7 +193,7 @@ package Opt is
Compile_Only : Boolean := False; Compile_Only : Boolean := False;
-- GNATMAKE -- GNATMAKE
-- Set to True to skip bind and link step. -- Set to True to skip bind and link steps (except when Bind_Only is True)
Compress_Debug_Names : Boolean := False; Compress_Debug_Names : Boolean := False;
-- GNATMAKE -- GNATMAKE
...@@ -428,6 +433,11 @@ package Opt is ...@@ -428,6 +433,11 @@ package Opt is
-- When True signals gnatmake to ignore compilation errors and keep -- When True signals gnatmake to ignore compilation errors and keep
-- processing sources until there is no more work. -- processing sources until there is no more work.
Link_Only : Boolean := False;
-- GNATMAKE
-- Set to True to skip compile and bind steps
-- (except when Bind_Only is set to True).
List_Units : Boolean := False; List_Units : Boolean := False;
-- GNAT -- GNAT
-- List units in the active library -- List units in the active library
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- $Revision: 1.194 $ -- $Revision$
-- -- -- --
-- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. --
-- -- -- --
...@@ -1164,6 +1164,12 @@ package body Switch is ...@@ -1164,6 +1164,12 @@ package body Switch is
Ptr := Ptr + 1; Ptr := Ptr + 1;
Check_Readonly_Files := True; Check_Readonly_Files := True;
-- Processing for b switch
when 'b' =>
Ptr := Ptr + 1;
Bind_Only := True;
-- Processing for c switch -- Processing for c switch
when 'c' => when 'c' =>
...@@ -1245,6 +1251,12 @@ package body Switch is ...@@ -1245,6 +1251,12 @@ package body Switch is
Ptr := Ptr + 1; Ptr := Ptr + 1;
Keep_Going := True; Keep_Going := True;
-- Processing for l switch
when 'l' =>
Ptr := Ptr + 1;
Link_Only := True;
when 'M' => when 'M' =>
Ptr := Ptr + 1; Ptr := Ptr + 1;
List_Dependencies := True; List_Dependencies := True;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment