mlib-tgt-tru64.adb, [...] (Build_Dynamic_Library): New parameter Options_2.

2004-10-04  Vincent Celier  <celier@gnat.com>

	* mlib-tgt-tru64.adb, mlib-tgt-aix.adb, mlib-tgt-irix.adb,
	mlib-tgt-hpux.adb, mlib-tgt-linux.adb, mlib-tgt-solaris.adb,
	mlib-tgt-vms-alpha.adb, mlib-tgt-vms-ia64.adb, mlib-tgt-mingw.adb,
	mlib-tgt-vxworks.adb, mlib-tgt.adb (Build_Dynamic_Library): New
	parameter Options_2.

	* mlib-prj.ads, mlib-prj.adb (Build_Library): Call
	Build_Dynamic_Library with an empty Options_2.

	* mlib-utl.ads, mlib-utl.adb (Gcc): Parameter Options_2 has no
	default anymore.

	* makegpr.adb (Get_Imported_Directories.add): Remove trailing
	directory separator, if any.
	(Gprmake): Do not allow mains on the command line for library projects.
	Do not attempt to link when the project is a library project.
	(Library_Opts): New table to store Library_Options.
	(Build_Library): If Library_Options is specified, pass these options
	when building a shared library.

From-SVN: r88490
This commit is contained in:
Vincent Celier 2004-10-04 14:53:52 +00:00 committed by Arnaud Charlet
parent 3b37ffbf15
commit 51004cb583
16 changed files with 169 additions and 47 deletions

View File

@ -1,3 +1,25 @@
2004-10-04 Vincent Celier <celier@gnat.com>
* mlib-tgt-tru64.adb, mlib-tgt-aix.adb, mlib-tgt-irix.adb,
mlib-tgt-hpux.adb, mlib-tgt-linux.adb, mlib-tgt-solaris.adb,
mlib-tgt-vms-alpha.adb, mlib-tgt-vms-ia64.adb, mlib-tgt-mingw.adb,
mlib-tgt-vxworks.adb, mlib-tgt.adb (Build_Dynamic_Library): New
parameter Options_2.
* mlib-prj.ads, mlib-prj.adb (Build_Library): Call
Build_Dynamic_Library with an empty Options_2.
* mlib-utl.ads, mlib-utl.adb (Gcc): Parameter Options_2 has no
default anymore.
* makegpr.adb (Get_Imported_Directories.add): Remove trailing
directory separator, if any.
(Gprmake): Do not allow mains on the command line for library projects.
Do not attempt to link when the project is a library project.
(Library_Opts): New table to store Library_Options.
(Build_Library): If Library_Options is specified, pass these options
when building a shared library.
2004-10-04 Jose Ruiz <ruiz@act-europe.fr>
* s-tposen.adb (Service_Entry): The object must be always unlocked at

View File

@ -65,7 +65,7 @@ package body Makegpr is
-- The name of a linking script, built one the fly, when there are C++
-- sources and the C++ compiler is not g++.
No_Argument : constant Argument_List := (1 .. 0 => null);
No_Argument : aliased Argument_List := (1 .. 0 => null);
-- Null argument list representing case of no arguments
FD : Process_Descriptor;
@ -184,6 +184,15 @@ package body Makegpr is
Table_Name => "Makegpr.Linker_Options");
-- Table to store the linking options
package Library_Opts 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 => "Makegpr.Library_Opts");
-- Table to store the linking options
package Ada_Mains is new Table.Table
(Table_Component_Type => String_Access,
Table_Index_Type => Integer,
@ -1339,6 +1348,7 @@ package body Makegpr is
Time_Stamp : Time_Stamp_Type;
Driver_Name : Name_Id := No_Name;
Lib_Opts : Argument_List_Access := No_Argument'Unrestricted_Access;
begin
Check_Archive_Builder;
@ -1571,11 +1581,47 @@ package body Makegpr is
end if;
end if;
-- If Library_Options is specified, add these options
declare
Library_Options : constant Variable_Value :=
Value_Of
(Name_Library_Options,
Data.Decl.Attributes);
begin
if not Library_Options.Default then
declare
Current : String_List_Id := Library_Options.Values;
Element : String_Element;
begin
while Current /= Nil_String loop
Element := String_Elements.Table (Current);
Get_Name_String (Element.Value);
if Name_Len /= 0 then
Library_Opts.Increment_Last;
Library_Opts.Table (Library_Opts.Last) :=
new String'(Name_Buffer (1 .. Name_Len));
end if;
Current := Element.Next;
end loop;
end;
end if;
Lib_Opts :=
new Argument_List'(Argument_List
(Library_Opts.Table (1 .. Library_Opts.Last)));
end;
MLib.Tgt.Build_Dynamic_Library
(Ofiles => Arguments (1 .. Last_Argument),
Foreign => Arguments (1 .. Last_Argument),
Afiles => No_Argument,
Options => No_Argument,
Options_2 => Lib_Opts.all,
Interfaces => No_Argument,
Lib_Filename => Get_Name_String (Data.Library_Name),
Lib_Dir => Get_Name_String (Data.Library_Dir),
@ -2827,6 +2873,15 @@ package body Makegpr is
Get_Name_String (Element.Value);
if Name_Len > 0 then
-- Remove a trailing directory separator: this may cause
-- problems on Windows.
if Name_Len > 1
and then Name_Buffer (Name_Len) = Directory_Separator
then
Name_Len := Name_Len - 1;
end if;
declare
Arg : constant String :=
"-I" & Name_Buffer (1 .. Name_Len);
@ -3002,32 +3057,44 @@ package body Makegpr is
end if;
else
-- First check for C++, to link libraries with g++, rather than gcc
declare
Data : constant Prj.Project_Data := Projects.Table (Main_Project);
begin
if Data.Library and then Mains.Number_Of_Mains /= 0 then
Osint.Fail
("Cannot specify mains on the command line " &
"for a Library Project");
end if;
Check_For_C_Plus_Plus;
-- First check for C++, to link libraries with g++,
-- rather than gcc.
-- Compile sources and build archives for library project,
-- if necessary.
Check_For_C_Plus_Plus;
Compile_Sources;
-- Compile sources and build archives for library project,
-- if necessary.
-- When Keep_Going is True, if we had some errors, fail now,
-- reporting the number of compilation errors.
-- Do not attempt to link.
Compile_Sources;
Report_Total_Errors ("compilation");
-- When Keep_Going is True, if we had some errors, fail now,
-- reporting the number of compilation errors.
-- Do not attempt to link.
-- If -c was not specified, link the executables, if there are any.
Report_Total_Errors ("compilation");
if not Compile_Only then
Build_Global_Archive;
Link_Executables;
end if;
-- If -c was not specified, link the executables,
-- if there are any.
-- When Keep_Going is True, if we had some errors, fail, reporting
-- the number of linking errors.
if not Compile_Only and then not Data.Library then
Build_Global_Archive;
Link_Executables;
end if;
Report_Total_Errors ("linking");
-- When Keep_Going is True, if we had some errors, fail, reporting
-- the number of linking errors.
Report_Total_Errors ("linking");
end;
end if;
end Gprmake;

View File

@ -1465,6 +1465,7 @@ package body MLib.Prj is
Foreign => Foreign_Objects.all,
Afiles => Ali_Files.all,
Options => Options.all,
Options_2 => No_Argument_List,
Interfaces => Arguments (1 .. Argument_Number),
Lib_Filename => Lib_Filename.all,
Lib_Dir => Lib_Dirpath.all,

View File

@ -69,7 +69,7 @@ package body MLib.Tgt is
-- The switches to use when linking a library against libgnarl when using
-- FSU threads.
Thread_Options : Argument_List_Access := null;
Thread_Options : Argument_List_Access := Empty_Argument_List;
-- Designate the thread switches to used when linking a library against
-- libgnarl. Depends on the thread library (Native or FSU). Resolved for
-- the first library linked against libgnarl.
@ -119,6 +119,7 @@ package body MLib.Tgt is
Foreign : Argument_List;
Afiles : Argument_List;
Options : Argument_List;
Options_2 : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
@ -142,8 +143,8 @@ package body MLib.Tgt is
-- The switch for automatic initialization of Stand-Alone Libraries.
-- Changed to a real switch when Auto_Init is True.
Options_2 : Argument_List_Access := Empty_Argument_List;
-- Changed to the thread options, if -lgnarl is specified
Thread_Opts : Argument_List_Access := Empty_Argument_List;
-- Set to Thread_Options if -lgnarl is found in the Options
begin
if Opt.Verbose_Mode then
@ -203,7 +204,7 @@ package body MLib.Tgt is
end;
end if;
Options_2 := Thread_Options;
Thread_Opts := Thread_Options;
exit;
end if;
end loop;
@ -211,11 +212,11 @@ package body MLib.Tgt is
-- Finally, call GCC (or the driver specified) to build the library
MLib.Utl.Gcc
(Output_File => Lib_File,
Objects => Ofiles,
Options => Options & Bexpall_Option & Init_Fini.all,
Driver_Name => Driver_Name,
Options_2 => Options_2.all);
(Output_File => Lib_File,
Objects => Ofiles,
Options => Options & Bexpall_Option & Init_Fini.all,
Driver_Name => Driver_Name,
Options_2 => Options_2 & Thread_Opts.all);
end Build_Dynamic_Library;
-------------

View File

@ -99,6 +99,7 @@ package body MLib.Tgt is
Foreign : Argument_List;
Afiles : Argument_List;
Options : Argument_List;
Options_2 : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
@ -147,6 +148,7 @@ package body MLib.Tgt is
(Output_File => Lib_File,
Objects => Ofiles,
Options => Common_Options & Init_Fini.all,
Options_2 => Options_2,
Driver_Name => Driver_Name);
else
@ -157,6 +159,7 @@ package body MLib.Tgt is
(Output_File => Lib_Version,
Objects => Ofiles,
Options => Common_Options & Version_Arg & Init_Fini.all,
Options_2 => Options_2,
Driver_Name => Driver_Name);
Symbolic_Link_Needed := Lib_Version /= Lib_File;
@ -165,6 +168,7 @@ package body MLib.Tgt is
(Output_File => Lib_Dir & Directory_Separator & Lib_Version,
Objects => Ofiles,
Options => Common_Options & Version_Arg & Init_Fini.all,
Options_2 => Options_2,
Driver_Name => Driver_Name);
Symbolic_Link_Needed :=
Lib_Dir & Directory_Separator & Lib_Version /= Lib_File;

View File

@ -100,6 +100,7 @@ package body MLib.Tgt is
Foreign : Argument_List;
Afiles : Argument_List;
Options : Argument_List;
Options_2 : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
@ -127,10 +128,10 @@ package body MLib.Tgt is
-- After moving -lxxx to Options_2, N_Options up to index Options_Last
-- will contain the Options to pass to MLib.Utl.Gcc.
Options_2 : Argument_List (Options'Range);
Options_2_Last : Natural := Options_2'First - 1;
-- Options_2 up to index Options_2_Last will contain the Options_2 to
-- pass to MLib.Utl.Gcc.
Real_Options_2 : Argument_List (1 .. Options'Length + Options_2'Length);
Real_Options_2_Last : Natural := 0;
-- Real_Options_2 up to index Real_Options_2_Last will contain the
-- Options_2 to pass to MLib.Utl.Gcc.
begin
if Opt.Verbose_Mode then
@ -159,8 +160,8 @@ package body MLib.Tgt is
if Arg'Length > 2
and then Arg (Arg'First .. Arg'First + 1) = "-l"
then
Options_2_Last := Options_2_Last + 1;
Options_2 (Options_2_Last) := Arg;
Real_Options_2_Last := Real_Options_2_Last + 1;
Real_Options_2 (Real_Options_2_Last) := Arg;
N_Options (Index .. Options_Last - 1) :=
N_Options (Index + 1 .. Options_Last);
Options_Last := Options_Last - 1;
@ -171,6 +172,13 @@ package body MLib.Tgt is
end loop;
end;
-- Add to Real_Options_2 the argument Options_2
Real_Options_2
(Real_Options_2_Last + 1 .. Real_Options_2_Last + Options_2'Length) :=
Options_2;
Real_Options_2_Last := Real_Options_2_Last + Options_2'Length;
if Lib_Version = "" then
MLib.Utl.Gcc
(Output_File => Lib_File,
@ -178,7 +186,7 @@ package body MLib.Tgt is
Options => N_Options (N_Options'First .. Options_Last) &
Init_Fini.all,
Driver_Name => Driver_Name,
Options_2 => Options_2 (Options_2'First .. Options_2_Last));
Options_2 => Real_Options_2 (1 .. Real_Options_2_Last));
else
Version_Arg := new String'("-Wl,-soname," & Lib_Version);
@ -190,7 +198,7 @@ package body MLib.Tgt is
Options => N_Options (N_Options'First .. Options_Last) &
Version_Arg & Init_Fini.all,
Driver_Name => Driver_Name,
Options_2 => Options_2 (Options_2'First .. Options_2_Last));
Options_2 => Real_Options_2 (1 .. Real_Options_2_Last));
Symbolic_Link_Needed := Lib_Version /= Lib_File;
else
@ -200,7 +208,7 @@ package body MLib.Tgt is
Options => N_Options (N_Options'First .. Options_Last) &
Version_Arg & Init_Fini.all,
Driver_Name => Driver_Name,
Options_2 => Options_2 (Options_2'First .. Options_2_Last));
Options_2 => Real_Options_2 (1 .. Real_Options_2_Last));
Symbolic_Link_Needed :=
Lib_Dir & Directory_Separator & Lib_Version /= Lib_File;
end if;

View File

@ -103,6 +103,7 @@ package body MLib.Tgt is
Foreign : Argument_List;
Afiles : Argument_List;
Options : Argument_List;
Options_2 : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
@ -144,7 +145,8 @@ package body MLib.Tgt is
(Output_File => Lib_File,
Objects => Ofiles,
Options => Options & Init_Fini.all,
Driver_Name => Driver_Name);
Driver_Name => Driver_Name,
Options_2 => Options_2);
else
Version_Arg := new String'("-Wl,-soname," & Lib_Version);
@ -154,7 +156,8 @@ package body MLib.Tgt is
(Output_File => Lib_Version,
Objects => Ofiles,
Options => Options & Version_Arg & Init_Fini.all,
Driver_Name => Driver_Name);
Driver_Name => Driver_Name,
Options_2 => Options_2);
Symbolic_Link_Needed := Lib_Version /= Lib_File;
else
@ -162,7 +165,8 @@ package body MLib.Tgt is
(Output_File => Lib_Dir & Directory_Separator & Lib_Version,
Objects => Ofiles,
Options => Options & Version_Arg & Init_Fini.all,
Driver_Name => Driver_Name);
Driver_Name => Driver_Name,
Options_2 => Options_2);
Symbolic_Link_Needed :=
Lib_Dir & Directory_Separator & Lib_Version /= Lib_File;
end if;

View File

@ -91,6 +91,7 @@ package body MLib.Tgt is
Foreign : Argument_List;
Afiles : Argument_List;
Options : Argument_List;
Options_2 : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
@ -122,7 +123,7 @@ package body MLib.Tgt is
(Output_File => Lib_File,
Objects => Ofiles,
Options => Tools.No_Argument_List,
Options_2 => Options,
Options_2 => Options & Options_2,
Driver_Name => Driver_Name);
end Build_Dynamic_Library;

View File

@ -97,6 +97,7 @@ package body MLib.Tgt is
Foreign : Argument_List;
Afiles : Argument_List;
Options : Argument_List;
Options_2 : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
@ -140,6 +141,7 @@ package body MLib.Tgt is
(Output_File => Lib_File,
Objects => Ofiles,
Options => Options & Init_Fini.all,
Options_2 => Options_2,
Driver_Name => Driver_Name);
else
@ -150,6 +152,7 @@ package body MLib.Tgt is
(Output_File => Lib_Version,
Objects => Ofiles,
Options => Options & Version_Arg & Init_Fini.all,
Options_2 => Options_2,
Driver_Name => Driver_Name);
Symbolic_Link_Needed := Lib_Version /= Lib_File;
@ -158,6 +161,7 @@ package body MLib.Tgt is
(Output_File => Lib_Dir & Directory_Separator & Lib_Version,
Objects => Ofiles,
Options => Options & Version_Arg & Init_Fini.all,
Options_2 => Options_2,
Driver_Name => Driver_Name);
Symbolic_Link_Needed :=
Lib_Dir & Directory_Separator & Lib_Version /= Lib_File;

View File

@ -105,6 +105,7 @@ package body MLib.Tgt is
Foreign : Argument_List;
Afiles : Argument_List;
Options : Argument_List;
Options_2 : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
@ -149,6 +150,7 @@ package body MLib.Tgt is
Options &
Expect_Unresolved'Access &
Init_Fini.all,
Options_2 => Options_2,
Driver_Name => Driver_Name);
else
@ -163,6 +165,7 @@ package body MLib.Tgt is
Version_Arg &
Expect_Unresolved'Access &
Init_Fini.all,
Options_2 => Options_2,
Driver_Name => Driver_Name);
Symbolic_Link_Needed := Lib_Version /= Lib_File;
@ -175,6 +178,7 @@ package body MLib.Tgt is
Version_Arg &
Expect_Unresolved'Access &
Init_Fini.all,
Options_2 => Options_2,
Driver_Name => Driver_Name);
Symbolic_Link_Needed :=
Lib_Dir & Directory_Separator & Lib_Version /= Lib_File;

View File

@ -127,6 +127,7 @@ package body MLib.Tgt is
Foreign : Argument_List;
Afiles : Argument_List;
Options : Argument_List;
Options_2 : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
@ -499,7 +500,7 @@ package body MLib.Tgt is
Options => VMS_Options,
Options_2 => Link_With_Shared_Libgcc.all &
Opts (Opts'First .. Last_Opt) &
Opts2 (Opts2'First .. Last_Opt2),
Opts2 (Opts2'First .. Last_Opt2) & Options_2,
Driver_Name => Driver_Name);
-- The auto-init object file need to be deleted, so that it will not

View File

@ -127,6 +127,7 @@ package body MLib.Tgt is
Foreign : Argument_List;
Afiles : Argument_List;
Options : Argument_List;
Options_2 : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
@ -532,7 +533,7 @@ package body MLib.Tgt is
Options => VMS_Options,
Options_2 => Link_With_Shared_Libgcc.all &
Opts (Opts'First .. Last_Opt) &
Opts2 (Opts2'First .. Last_Opt2),
Opts2 (Opts2'First .. Last_Opt2) & Options_2,
Driver_Name => Driver_Name);
-- The auto-init object file need to be deleted, so that it will not

View File

@ -90,6 +90,7 @@ package body MLib.Tgt is
Foreign : Argument_List;
Afiles : Argument_List;
Options : Argument_List;
Options_2 : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
@ -102,6 +103,7 @@ package body MLib.Tgt is
pragma Unreferenced (Foreign);
pragma Unreferenced (Afiles);
pragma Unreferenced (Options);
pragma Unreferenced (Options_2);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Lib_Filename);
pragma Unreferenced (Lib_Dir);

View File

@ -76,6 +76,7 @@ package body MLib.Tgt is
Foreign : Argument_List;
Afiles : Argument_List;
Options : Argument_List;
Options_2 : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
@ -88,6 +89,7 @@ package body MLib.Tgt is
pragma Unreferenced (Foreign);
pragma Unreferenced (Afiles);
pragma Unreferenced (Options);
pragma Unreferenced (Options_2);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Lib_Filename);
pragma Unreferenced (Lib_Dir);

View File

@ -156,8 +156,8 @@ package body MLib.Utl is
(Output_File : String;
Objects : Argument_List;
Options : Argument_List;
Driver_Name : Name_Id := No_Name;
Options_2 : Argument_List := No_Argument_List)
Options_2 : Argument_List;
Driver_Name : Name_Id := No_Name)
is
Arguments :
OS_Lib.Argument_List

View File

@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2001-2003, Ada Core Technologies, Inc --
-- Copyright (C) 2001-2004, Ada Core Technologies, 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- --
@ -40,8 +40,8 @@ package MLib.Utl is
(Output_File : String;
Objects : Argument_List;
Options : Argument_List;
Driver_Name : Name_Id := No_Name;
Options_2 : Argument_List := No_Argument_List);
Options_2 : Argument_List;
Driver_Name : Name_Id := No_Name);
-- Driver_Name indicates the "driver" to invoke; by default, the "driver"
-- is gcc.
-- This procedure invokes the driver to create a shared library.