aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/mlib-tgt-linux.adb
diff options
context:
space:
mode:
authorVincent Celier <celier@adacore.com>2006-10-31 18:45:59 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2006-10-31 18:45:59 +0100
commitf95969eabcd42f10aa4b4ae3c13015e417031523 (patch)
tree9eefa1d8fa112714d0415cc8df0ba158cd0c34c3 /gcc/ada/mlib-tgt-linux.adb
parentf28ded01c65008b47ef62f0be2a3e987ec1c5b61 (diff)
downloadgcc-f95969eabcd42f10aa4b4ae3c13015e417031523.zip
gcc-f95969eabcd42f10aa4b4ae3c13015e417031523.tar.gz
gcc-f95969eabcd42f10aa4b4ae3c13015e417031523.tar.bz2
mlib-tgt-lynxos.adb, [...]: Use Append_To, instead of Ext_To, when building the library file name
2006-10-31 Vincent Celier <celier@adacore.com> Eric Botcazou <ebotcazou@adacore.com> * mlib-tgt-lynxos.adb, mlib-tgt-mingw.adb, mlib-tgt-tru64.adb, mlib-tgt-aix.adb, mlib-tgt-irix.adb, mlib-tgt-hpux.adb, mlib-tgt-linux.adb, mlib-tgt-solaris.adb: Use Append_To, instead of Ext_To, when building the library file name * mlib-tgt-vxworks.adb: ditto. (Get_Target_Suffix): Add support for x86 targets. * mlib-fil.ads, mlib-fil.adb: (Append_To): New function * mlib-tgt-darwin.adb: Use Append_To, instead of Ext_To, when building the library file name (Flat_Namespace): New global variable. (No_Shared_Libgcc_Switch): Rename to No_Shared_Libgcc_Options. (Shared_Libgcc_Switch): Rename to With_Shared_Libgcc_Options. (Link_Shared_Libgcc): Delete. (Build_Dynamic_Library): Adjust for above changes. Use Opt package. (Build_Dynamic_Library): Pass -shared-libgcc if GCC 4 or later. From-SVN: r118237
Diffstat (limited to 'gcc/ada/mlib-tgt-linux.adb')
-rw-r--r--gcc/ada/mlib-tgt-linux.adb179
1 files changed, 114 insertions, 65 deletions
diff --git a/gcc/ada/mlib-tgt-linux.adb b/gcc/ada/mlib-tgt-linux.adb
index ca205b6..737a40a 100644
--- a/gcc/ada/mlib-tgt-linux.adb
+++ b/gcc/ada/mlib-tgt-linux.adb
@@ -7,7 +7,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2001-2005, Free Software Foundation, Inc. --
+-- Copyright (C) 2001-2006, Free Software Foundation, 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- --
@@ -115,7 +115,7 @@ package body MLib.Tgt is
Lib_File : constant String :=
Lib_Dir & Directory_Separator & "lib" &
- Fil.Ext_To (Lib_Filename, DLL_Ext);
+ Fil.Append_To (Lib_Filename, DLL_Ext);
Version_Arg : String_Access;
Symbolic_Link_Needed : Boolean := False;
@@ -135,53 +135,104 @@ package body MLib.Tgt is
Options_2 => Options_2);
else
- Version_Arg := new String'("-Wl,-soname," & Lib_Version);
-
- if Is_Absolute_Path (Lib_Version) then
- Utl.Gcc
- (Output_File => Lib_Version,
- Objects => Ofiles,
- Options => Options & Version_Arg,
- Driver_Name => Driver_Name,
- Options_2 => Options_2);
- Symbolic_Link_Needed := Lib_Version /= Lib_File;
-
- else
- Utl.Gcc
- (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
- Objects => Ofiles,
- Options => Options & Version_Arg,
- Driver_Name => Driver_Name,
- Options_2 => Options_2);
- Symbolic_Link_Needed :=
- Lib_Dir & Directory_Separator & Lib_Version /= Lib_File;
- end if;
-
- if Symbolic_Link_Needed then
- declare
- Success : Boolean;
- Oldpath : String (1 .. Lib_Version'Length + 1);
- Newpath : String (1 .. Lib_File'Length + 1);
-
- Result : Integer;
- pragma Unreferenced (Result);
-
- function Symlink
- (Oldpath : System.Address;
- Newpath : System.Address) return Integer;
- pragma Import (C, Symlink, "__gnat_symlink");
-
- begin
- Oldpath (1 .. Lib_Version'Length) := Lib_Version;
- Oldpath (Oldpath'Last) := ASCII.NUL;
- Newpath (1 .. Lib_File'Length) := Lib_File;
- Newpath (Newpath'Last) := ASCII.NUL;
-
- Delete_File (Lib_File, Success);
-
- Result := Symlink (Oldpath'Address, Newpath'Address);
- end;
- end if;
+ declare
+ Maj_Version : constant String := Lib_Version;
+ Last_Maj : Positive := Maj_Version'Last;
+ Last : Positive;
+ Ok_Maj : Boolean := False;
+ begin
+ while Last_Maj > Maj_Version'First loop
+ if Maj_Version (Last_Maj) in '0' .. '9' then
+ Last_Maj := Last_Maj - 1;
+
+ else
+ Ok_Maj := Last_Maj /= Maj_Version'Last and then
+ Maj_Version (Last_Maj) = '.';
+
+ if Ok_Maj then
+ Last_Maj := Last_Maj - 1;
+ end if;
+
+ exit;
+ end if;
+ end loop;
+
+ if Ok_Maj then
+ Last := Last_Maj;
+
+ while Last > Maj_Version'First loop
+ if Maj_Version (Last) in '0' .. '9' then
+ Last := Last - 1;
+
+ else
+ Ok_Maj := Last /= Last_Maj and then
+ Maj_Version (Last) = '.';
+
+ if Ok_Maj then
+ Last := Last - 1;
+
+ Ok_Maj := Maj_Version (1 .. Last) = Lib_File;
+ end if;
+
+ exit;
+ end if;
+ end loop;
+ end if;
+
+ if Ok_Maj then
+ Version_Arg := new String'("-Wl,-soname," &
+ Maj_Version (1 .. Last_Maj));
+
+ else
+ Version_Arg := new String'("-Wl,-soname," & Lib_Version);
+ end if;
+
+ if Is_Absolute_Path (Lib_Version) then
+ Utl.Gcc
+ (Output_File => Lib_Version,
+ Objects => Ofiles,
+ Options => Options & Version_Arg,
+ Driver_Name => Driver_Name,
+ Options_2 => Options_2);
+ Symbolic_Link_Needed := Lib_Version /= Lib_File;
+
+ else
+ Utl.Gcc
+ (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
+ Objects => Ofiles,
+ Options => Options & Version_Arg,
+ Driver_Name => Driver_Name,
+ Options_2 => Options_2);
+ Symbolic_Link_Needed :=
+ Lib_Dir & Directory_Separator & Lib_Version /= Lib_File;
+ end if;
+
+ if Symbolic_Link_Needed then
+ declare
+ Success : Boolean;
+ Oldpath : String (1 .. Lib_Version'Length + 1);
+ Newpath : String (1 .. Lib_File'Length + 1);
+
+ Result : Integer;
+ pragma Unreferenced (Result);
+
+ function Symlink
+ (Oldpath : System.Address;
+ Newpath : System.Address) return Integer;
+ pragma Import (C, Symlink, "__gnat_symlink");
+
+ begin
+ Oldpath (1 .. Lib_Version'Length) := Lib_Version;
+ Oldpath (Oldpath'Last) := ASCII.NUL;
+ Newpath (1 .. Lib_File'Length) := Lib_File;
+ Newpath (Newpath'Last) := ASCII.NUL;
+
+ Delete_File (Lib_File, Success);
+
+ Result := Symlink (Oldpath'Address, Newpath'Address);
+ end;
+ end if;
+ end;
end if;
end Build_Dynamic_Library;
@@ -253,7 +304,8 @@ package body MLib.Tgt is
------------------------
function Library_Exists_For
- (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean
+ (Project : Project_Id;
+ In_Tree : Project_Tree_Ref) return Boolean
is
begin
if not In_Tree.Projects.Table (Project).Library then
@@ -263,25 +315,23 @@ package body MLib.Tgt is
else
declare
- Lib_Dir : constant String :=
- Get_Name_String
- (In_Tree.Projects.Table (Project).Library_Dir);
+ Lib_Dir : constant String :=
+ Get_Name_String
+ (In_Tree.Projects.Table (Project).Library_Dir);
Lib_Name : constant String :=
- Get_Name_String
- (In_Tree.Projects.Table (Project).Library_Name);
+ Get_Name_String
+ (In_Tree.Projects.Table (Project).Library_Name);
begin
- if In_Tree.Projects.Table (Project).Library_Kind =
- Static
- then
+ if In_Tree.Projects.Table (Project).Library_Kind = Static then
return Is_Regular_File
(Lib_Dir & Directory_Separator & "lib" &
- Fil.Ext_To (Lib_Name, Archive_Ext));
+ Fil.Append_To (Lib_Name, Archive_Ext));
else
return Is_Regular_File
(Lib_Dir & Directory_Separator & "lib" &
- Fil.Ext_To (Lib_Name, DLL_Ext));
+ Fil.Append_To (Lib_Name, DLL_Ext));
end if;
end;
end if;
@@ -304,8 +354,8 @@ package body MLib.Tgt is
else
declare
Lib_Name : constant String :=
- Get_Name_String
- (In_Tree.Projects.Table (Project).Library_Name);
+ Get_Name_String
+ (In_Tree.Projects.Table (Project).Library_Name);
begin
Name_Len := 3;
@@ -314,10 +364,9 @@ package body MLib.Tgt is
if In_Tree.Projects.Table (Project).Library_Kind =
Static
then
- Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, Archive_Ext));
-
+ Add_Str_To_Name_Buffer (Fil.Append_To (Lib_Name, Archive_Ext));
else
- Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, DLL_Ext));
+ Add_Str_To_Name_Buffer (Fil.Append_To (Lib_Name, DLL_Ext));
end if;
return Name_Find;