diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-02-15 09:42:01 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-02-15 09:42:01 +0000 |
commit | 46a6512843d081c846154b512ecd3a67e2b29204 (patch) | |
tree | fa3e9dd6bf6aa7a21cc2b0136d8eaf9ebdd1aae7 /gcc/ada/mlib-prj.adb | |
parent | 1dd2a030c8675931415288235168f062a512bcd2 (diff) | |
download | gcc-46a6512843d081c846154b512ecd3a67e2b29204.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111079 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/mlib-prj.adb')
-rw-r--r-- | gcc/ada/mlib-prj.adb | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/gcc/ada/mlib-prj.adb b/gcc/ada/mlib-prj.adb index 6cae545c2de..89100728621 100644 --- a/gcc/ada/mlib-prj.adb +++ b/gcc/ada/mlib-prj.adb @@ -6,7 +6,7 @@ -- -- -- 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 -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -229,6 +229,9 @@ package body MLib.Prj is -- Display invocation of gnatbind and of the compiler with the arguments -- 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); -- For Stand-Alone libraries, get the Linker Options in the binder -- generated file. @@ -1282,7 +1285,31 @@ package body MLib.Prj is -- Rpath. 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; if Libgnarl_Needed then @@ -1303,10 +1330,17 @@ package body MLib.Prj is if Libdecgnat_Needed then Opts.Increment_Last; + Opts.Table (Opts.Last) := new String'("-L" & Lib_Directory & "/../declib"); + 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; Opts.Increment_Last; @@ -2021,6 +2055,23 @@ package body MLib.Prj is end if; 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 -- ------------------------- @@ -2129,6 +2180,9 @@ package body MLib.Prj is Next_Line (1 .. Nlast) /= "-lgnarl" and then Next_Line (1 .. Nlast) /= "-lgnat" and then 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)) /= Shared_Lib ("gnarl") and then Next_Line |