Commit 8aa0b2c6 by Vincent Celier Committed by Arnaud Charlet

mlib-prj.adb (Index): New function

2006-02-13  Vincent Celier  <celier@adacore.com>

	* mlib-prj.adb (Index): New function
	(Build_Library): When building a shared library, add to the run path
	the directory of the shared version of libgcc.
	(Build_Library): Output shared decgnat library.
	(Process_Binder_File): Test for shared decgnat library.

From-SVN: r111079
parent f2c573b1
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2001-2005, AdaCore -- -- Copyright (C) 2001-2006, AdaCore --
-- -- -- --
-- 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- --
...@@ -229,6 +229,9 @@ package body MLib.Prj is ...@@ -229,6 +229,9 @@ package body MLib.Prj is
-- Display invocation of gnatbind and of the compiler with the arguments -- Display invocation of gnatbind and of the compiler with the arguments
-- in Arguments, except when Quiet_Output is True. -- in Arguments, except when Quiet_Output is True.
function Index (S, Pattern : String) return Natural;
-- Return the last occurrence of Pattern in S, or 0 if none
procedure Process_Binder_File (Name : String); procedure Process_Binder_File (Name : String);
-- For Stand-Alone libraries, get the Linker Options in the binder -- For Stand-Alone libraries, get the Linker Options in the binder
-- generated file. -- generated file.
...@@ -1282,7 +1285,31 @@ package body MLib.Prj is ...@@ -1282,7 +1285,31 @@ package body MLib.Prj is
-- Rpath. -- Rpath.
if Path_Option /= null then if Path_Option /= null then
Add_Rpath (Lib_Directory); declare
Libdir : constant String := Lib_Directory;
GCC_Index : Natural := 0;
begin
Add_Rpath (Libdir);
-- For shared libraries, add to the Path Option the directory
-- of the shared version of libgcc.
if The_Build_Mode /= Static then
GCC_Index := Index (Libdir, "/lib/");
if GCC_Index = 0 then
GCC_Index :=
Index
(Libdir,
Directory_Separator & "lib" & Directory_Separator);
end if;
if GCC_Index /= 0 then
Add_Rpath (Libdir (Libdir'First .. GCC_Index + 3));
end if;
end if;
end;
end if; end if;
if Libgnarl_Needed then if Libgnarl_Needed then
...@@ -1303,10 +1330,17 @@ package body MLib.Prj is ...@@ -1303,10 +1330,17 @@ package body MLib.Prj is
if Libdecgnat_Needed then if Libdecgnat_Needed then
Opts.Increment_Last; Opts.Increment_Last;
Opts.Table (Opts.Last) := Opts.Table (Opts.Last) :=
new String'("-L" & Lib_Directory & "/../declib"); new String'("-L" & Lib_Directory & "/../declib");
Opts.Increment_Last; Opts.Increment_Last;
Opts.Table (Opts.Last) := new String'("-ldecgnat");
if The_Build_Mode = Static then
Opts.Table (Opts.Last) := new String'("-ldecgnat");
else
Opts.Table (Opts.Last) := new String'(Shared_Lib ("decgnat"));
end if;
end if; end if;
Opts.Increment_Last; Opts.Increment_Last;
...@@ -2021,6 +2055,23 @@ package body MLib.Prj is ...@@ -2021,6 +2055,23 @@ package body MLib.Prj is
end if; end if;
end Display; end Display;
-----------
-- Index --
-----------
function Index (S, Pattern : String) return Natural is
Len : constant Natural := Pattern'Length;
begin
for J in reverse S'First .. S'Last - Len + 1 loop
if Pattern = S (J .. J + Len - 1) then
return J;
end if;
end loop;
return 0;
end Index;
------------------------- -------------------------
-- Process_Binder_File -- -- Process_Binder_File --
------------------------- -------------------------
...@@ -2129,6 +2180,9 @@ package body MLib.Prj is ...@@ -2129,6 +2180,9 @@ package body MLib.Prj is
Next_Line (1 .. Nlast) /= "-lgnarl" and then Next_Line (1 .. Nlast) /= "-lgnarl" and then
Next_Line (1 .. Nlast) /= "-lgnat" and then Next_Line (1 .. Nlast) /= "-lgnat" and then
Next_Line Next_Line
(1 .. Natural'Min (Nlast, 10 + Library_Version'Length)) /=
Shared_Lib ("decgnat") and then
Next_Line
(1 .. Natural'Min (Nlast, 8 + Library_Version'Length)) /= (1 .. Natural'Min (Nlast, 8 + Library_Version'Length)) /=
Shared_Lib ("gnarl") and then Shared_Lib ("gnarl") and then
Next_Line Next_Line
......
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