-- Called by Sigint_Intercepted to kill all spawned compilation processes
type Sigint_Handler is access procedure;
+ pragma Convention (C, Sigint_Handler);
procedure Install_Int_Handler (Handler : Sigint_Handler);
pragma Import (C, Install_Int_Handler, "__gnat_install_int_handler");
-- Called by Gnatmake to install the SIGINT handler below
procedure Sigint_Intercepted;
+ pragma Convention (C, Sigint_Intercepted);
-- Called when the program is interrupted by Ctrl-C to delete the
-- temporary mapping files and configuration pragmas files.
-- added at the beginning of the command line.
procedure Check
- (Source_File : File_Name_Type;
- Source_Index : Int;
- The_Args : Argument_List;
- Lib_File : File_Name_Type;
- Read_Only : Boolean;
- ALI : out ALI_Id;
- O_File : out File_Name_Type;
- O_Stamp : out Time_Stamp_Type);
+ (Source_File : File_Name_Type;
+ Source_Index : Int;
+ Is_Main_Source : Boolean;
+ The_Args : Argument_List;
+ Lib_File : File_Name_Type;
+ Read_Only : Boolean;
+ ALI : out ALI_Id;
+ O_File : out File_Name_Type;
+ O_Stamp : out Time_Stamp_Type);
-- Determines whether the library file Lib_File is up-to-date or not. The
-- full name (with path information) of the object file corresponding to
-- Lib_File is returned in O_File. Its time stamp is saved in O_Stamp.
-- Otherwise O_File is No_File.
procedure Collect_Arguments
- (Source_File : File_Name_Type;
- Source_Index : Int;
- Args : Argument_List);
+ (Source_File : File_Name_Type;
+ Source_Index : Int;
+ Is_Main_Source : Boolean;
+ Args : Argument_List);
-- Collect all arguments for a source to be compiled, including those
-- that come from a project file.
-----------
procedure Check
- (Source_File : File_Name_Type;
- Source_Index : Int;
- The_Args : Argument_List;
- Lib_File : File_Name_Type;
- Read_Only : Boolean;
- ALI : out ALI_Id;
- O_File : out File_Name_Type;
- O_Stamp : out Time_Stamp_Type)
+ (Source_File : File_Name_Type;
+ Source_Index : Int;
+ Is_Main_Source : Boolean;
+ The_Args : Argument_List;
+ Lib_File : File_Name_Type;
+ Read_Only : Boolean;
+ ALI : out ALI_Id;
+ O_File : out File_Name_Type;
+ O_Stamp : out Time_Stamp_Type)
is
function First_New_Spec (A : ALI_Id) return File_Name_Type;
-- Looks in the with table entries of A and returns the spec file name
-- First, collect all the switches
- Collect_Arguments (Source_File, Source_Index, The_Args);
+ Collect_Arguments
+ (Source_File, Source_Index, Is_Main_Source, The_Args);
Prev_Switch := Dummy_Switch;
-----------------------
procedure Collect_Arguments
- (Source_File : File_Name_Type;
- Source_Index : Int;
- Args : Argument_List)
+ (Source_File : File_Name_Type;
+ Source_Index : Int;
+ Is_Main_Source : Boolean;
+ Args : Argument_List)
is
begin
Arguments_Collected := True;
end;
end if;
+ -- For VMS, when compiling the main source, add switch
+ -- -mdebug-main=_ada_ so that the executable can be debugged
+ -- by the standard VMS debugger.
+
+ if not No_Main_Subprogram
+ and then Targparm.OpenVMS_On_Target
+ and then Is_Main_Source
+ then
+ -- First, check if compilation will be invoked with -g
+
+ for J in 1 .. Last_Argument loop
+ if Arguments (J)'Length >= 2
+ and then Arguments (J) (1 .. 2) = "-g"
+ and then (Arguments (J)'Length < 5
+ or else Arguments (J) (1 .. 5) /= "-gnat")
+ then
+ Add_Arguments
+ ((1 => new String'("-mdebug-main=_ada_")));
+ exit;
+ end if;
+ end loop;
+ end if;
+
-- Set Output_Is_Object, depending if there is a -S switch.
-- If the bind step is not performed, and there is a -S switch,
-- then we will not check for a valid object file.
-- If arguments not yet collected (in Check), collect them now
if not Arguments_Collected then
- Collect_Arguments (Source_File, Source_Index, Args);
- end if;
-
- -- For VMS, when compiling the main source, add switch
- -- -mdebug-main=_ada_ so that the executable can be debugged
- -- by the standard VMS debugger.
-
- if not No_Main_Subprogram
- and then Targparm.OpenVMS_On_Target
- and then Source_File = Main_Source
- then
- -- First, check if compilation will be invoked with -g
-
- for J in 1 .. Last_Argument loop
- if Arguments (J)'Length >= 2
- and then Arguments (J) (1 .. 2) = "-g"
- and then (Arguments (J)'Length < 5
- or else Arguments (J) (1 .. 5) /= "-gnat")
- then
- Add_Arguments
- ((1 => new String'("-mdebug-main=_ada_")));
- exit;
- end if;
- end loop;
+ Collect_Arguments
+ (Source_File, Source_Index, Source_File = Main_Source, Args);
end if;
-- If we use mapping file (-P or -C switches), then get one
else
Arguments_Collected := False;
- -- Do nothing if project of source is externally built
+ Collect_Arguments (Source_File, Source_Index,
+ Source_File = Main_Source, Args);
- Collect_Arguments (Source_File, Source_Index, Args);
+ -- Do nothing if project of source is externally built
if Arguments_Project = No_Project
or else not Project_Tree.Projects.Table
Full_Lib_File /= No_File
and then not Check_Readonly_Files
and then Is_Readonly_Library (Full_Lib_File);
- Check (Source_File, Source_Index, Args, Lib_File,
+ Check (Source_File, Source_Index,
+ Source_File = Main_Source, Args, Lib_File,
Read_Only, ALI, Obj_File, Obj_Stamp);
Need_To_Compile := (ALI = No_ALI_Id);
end if;
begin
Targparm.Get_Target_Parameters;
-
exception
when Unrecoverable_Error =>
Make_Failed ("*** make failed.");
if Targparm.VM_Target /= No_VM then
- -- Do not check for an object file (".o") when compiling to VM
- -- machine since ".class" files are generated instead.
-
- Check_Object_Consistency := False;
-
-- Set proper processing commands
case Targparm.VM_Target is
when Targparm.JVM_Target =>
+
+ -- Do not check for an object file (".o") when compiling to
+ -- JVM machine since ".class" files are generated instead.
+
+ Check_Object_Consistency := False;
+
Gcc := new String'("jgnat");
Gnatbind := new String'("jgnatbind");
Gnatlink := new String'("jgnatlink");
if Main_Project /= No_Project then
- -- For all library project, if the library file does not exist
- -- put all the project sources in the queue, and flag the project
- -- so that the library is generated.
+ -- For all library project, if the library file does not exist, put
+ -- all the project sources in the queue, and flag the project so that
+ -- the library is generated.
if not Unique_Compile
and then MLib.Tgt.Support_For_Libraries /= Prj.None
end loop;
else
- -- And we put the command line gcc switches in the variable
- -- The_Saved_Gcc_Switches. They are going to be used later
+ -- If there is a project, put the command line gcc switches in the
+ -- variable The_Saved_Gcc_Switches. They are going to be used later
-- in procedure Compile_Sources.
The_Saved_Gcc_Switches :=
The_Saved_Gcc_Switches (The_Saved_Gcc_Switches'Last) :=
No_gnat_adc;
-
end if;
-- If there was a --GCC, --GNATBIND or --GNATLINK switch on
Non_Std_Executable :=
Targparm.Executable_Extension_On_Target /= No_Name;
- -- Look inside the linker switches to see if the name
- -- of the final executable program was specified.
+ -- Look inside the linker switches to see if the name of the final
+ -- executable program was specified.
for
J in reverse Linker_Switches.First .. Linker_Switches.Last
end if;
end loop;
- -- If the name of the final executable program was not
- -- specified then construct it from the main input file.
+ -- If the name of the final executable program was not specified
+ -- then construct it from the main input file.
if Executable = No_File then
if Main_Project = No_Project then
Executable_Name (Strip_Suffix (Main_Source_File));
else
- -- If we are using a project file, we attempt to
- -- remove the body (or spec) termination of the main
- -- subprogram. We find it the the naming scheme of the
- -- project file. This will avoid to generate an
- -- executable "main.2" for a main subprogram
+ -- If we are using a project file, we attempt to remove the
+ -- body (or spec) termination of the main subprogram. We find
+ -- it the the naming scheme of the project file. This avoids
+ -- generating an executable "main.2" for a main subprogram
-- "main.2.ada", when the body termination is ".2.ada".
Executable :=
begin
if not Is_Absolute_Path (Exec_File_Name) then
-
Get_Name_String (Project_Tree.Projects.Table
(Main_Project).Display_Exec_Dir);
- if
- Name_Buffer (Name_Len) /= Directory_Separator
- then
+ if Name_Buffer (Name_Len) /= Directory_Separator then
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := Directory_Separator;
end if;
Youngest_Obj_File : File_Name_Type;
Youngest_Obj_Stamp : Time_Stamp_Type;
- Executable_Stamp : Time_Stamp_Type;
+ Executable_Stamp : Time_Stamp_Type;
-- Executable is the final executable program
- Library_Rebuilt : Boolean := False;
+ Library_Rebuilt : Boolean := False;
begin
for J in 1 .. Gcc_Switches.Last loop
end if;
end if;
- -- Regenerate libraries, if any, and if object files
+ -- Regenerate libraries, if there are any and if object files
-- have been regenerated.
if Main_Project /= No_Project
Current : Natural;
procedure Add_To_Library_Projs (Proj : Project_Id);
- -- Add project Project to table Library_Projs
- -- in decreasing depth order.
+ -- Add project Project to table Library_Projs in
+ -- decreasing depth order.
--------------------------
-- Add_To_Library_Projs --
Library_Projs.Increment_Last;
Depth := Project_Tree.Projects.Table (Proj).Depth;
- -- Put the projects in decreasing depth order,
- -- so that if libA depends on libB, libB is first
- -- in order.
+ -- Put the projects in decreasing depth order, so that
+ -- if libA depends on libB, libB is first in order.
Current := Library_Projs.Last;
while Current > 1 loop
end Add_To_Library_Projs;
-- Start of processing for ??? (should name declare block
- -- or probably better, break this out as a nested proc.
+ -- or probably better, break this out as a nested proc).
begin
-- Put in Library_Projs table all library project
-- since there is currently no simple way to check the
-- up-to-date status of objects
- if Targparm.VM_Target = No_VM
+ if Targparm.VM_Target /= JVM_Target
and then First_Compiled_File = No_File
then
Executable_Stamp := File_Stamp (Executable);
-- When In_Place_Mode, the library file can be located in the
-- Main_Source_File directory which may not be present in the
- -- library path. In this case, use the corresponding library file
- -- name.
+ -- library path. If it is not present then use the corresponding
+ -- library file name.
if Main_ALI_File = No_File and then In_Place_Mode then
Get_Name_String (Get_Directory (Full_Source_Name (Src_File)));
end loop;
end if;
- -- If there are shared libraries, invoke gnatlink with
+ -- If shared libraries present, invoke gnatlink with
-- -shared-libgcc.
if Shared_Libs then
if Main_Project /= No_Project then
-- 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.
Prj.Env.Set_Ada_Paths (Main_Project, Project_Tree, False);
Library_Projs.Init;
if MLib.Tgt.Support_For_Libraries /= Prj.None then
+
-- Check for library projects
for Proj1 in Project_Table.First ..
end loop;
for Index in 1 .. Library_Projs.Last loop
+
-- Add the -L switch
Linker_Switches.Increment_Last;
----------------
procedure Initialize is
+
+ procedure Check_Version_And_Help is
+ new Check_Version_And_Help_G (Makeusg);
+
+ -- Start of processing for Initialize
+
begin
Prj.Set_Mode (Ada_Only);
- -- Override default initialization of Check_Object_Consistency
- -- since this is normally False for GNATBIND, but is True for
- -- GNATMAKE since we do not need to check source consistency
- -- again once GNATMAKE has looked at the sources to check.
+ -- Override default initialization of Check_Object_Consistency since
+ -- this is normally False for GNATBIND, but is True for GNATMAKE since
+ -- we do not need to check source consistency again once GNATMAKE has
+ -- looked at the sources to check.
Check_Object_Consistency := True;
-- First, scan to detect --version and/or --help
- Check_Version_And_Help ("GNATMAKE", "1995", Makeusg'Access);
+ Check_Version_And_Help ("GNATMAKE", "1995");
- -- Scan again the switch and arguments, now that we are sure that
- -- they do not include --version or --help.
+ -- Scan again the switch and arguments, now that we are sure that they
+ -- do not include --version or --help.
Scan_Args : for Next_Arg in 1 .. Argument_Count loop
Scan_Make_Arg (Argument (Next_Arg), And_Save => True);
-- Deal with -C= switch
if Gnatmake_Mapping_File /= null then
+
-- First, check compatibility with other switches
if Project_File_Name /= null then
-- If we have seen a regular switch process it
elsif Argv (1) = '-' then
-
if Argv'Length = 1 then
Make_Failed ("switch character cannot be followed by a blank");
Binder,
And_Save => And_Save);
+ -- -aamp_target=...
+
+ elsif Argv'Length >= 13 and then Argv (2 .. 13) = "aamp_target=" then
+ Add_Switch (Argv, Compiler, And_Save => And_Save);
+
+ -- Set the aamp_target environment variable so that the binder and
+ -- linker will use the proper target library. This is consistent
+ -- with how things work when -aamp_target is passed on the command
+ -- line to gnaampmake.
+
+ Setenv ("aamp_target", Argv (14 .. Argv'Last));
+
-- -Adir (to gnatbind this is like a -aO switch, to gcc like a -I)
elsif Argv (2) = 'A' then
if Project_File_Name /= null then
Make_Failed ("-i cannot be used in conjunction with a " &
"project file");
-
else
Scan_Make_Switches (Argv, Success);
end if;