1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- M L I B . T G T . S P E C I F I C --
10 -- Copyright (C) 2002-2007, Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
21 -- Boston, MA 02110-1301, USA. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
26 ------------------------------------------------------------------------------
28 -- This is the True64 version of the body
33 with Output; use Output;
36 package body MLib.Tgt.Specific is
40 -- Non default subprogram
42 procedure Build_Dynamic_Library
43 (Ofiles : Argument_List;
44 Foreign : Argument_List;
45 Afiles : Argument_List;
46 Options : Argument_List;
47 Options_2 : Argument_List;
48 Interfaces : Argument_List;
49 Lib_Filename : String;
51 Symbol_Data : Symbol_Record;
52 Driver_Name : Name_Id := No_Name;
53 Lib_Version : String := "";
54 Auto_Init : Boolean := False);
56 function Is_Archive_Ext (Ext : String) return Boolean;
58 function PIC_Option return String;
62 Expect_Unresolved : aliased String := "-Wl,-expect_unresolved,*";
64 ---------------------------
65 -- Build_Dynamic_Library --
66 ---------------------------
68 procedure Build_Dynamic_Library
69 (Ofiles : Argument_List;
70 Foreign : Argument_List;
71 Afiles : Argument_List;
72 Options : Argument_List;
73 Options_2 : Argument_List;
74 Interfaces : Argument_List;
75 Lib_Filename : String;
77 Symbol_Data : Symbol_Record;
78 Driver_Name : Name_Id := No_Name;
79 Lib_Version : String := "";
80 Auto_Init : Boolean := False)
82 pragma Unreferenced (Foreign);
83 pragma Unreferenced (Afiles);
84 pragma Unreferenced (Interfaces);
85 pragma Unreferenced (Symbol_Data);
86 pragma Unreferenced (Auto_Init);
87 -- Initialization is done through the contructor mechanism
89 Lib_File : constant String :=
90 Lib_Dir & Directory_Separator & "lib" &
91 Fil.Append_To (Lib_Filename, DLL_Ext);
93 Version_Arg : String_Access;
94 Symbolic_Link_Needed : Boolean := False;
97 if Opt.Verbose_Mode then
98 Write_Str ("building relocatable shared library ");
99 Write_Line (Lib_File);
102 -- If specified, add automatic elaboration/finalization
104 if Lib_Version = "" then
106 (Output_File => Lib_File,
108 Options => Options & Expect_Unresolved'Access,
109 Options_2 => Options_2,
110 Driver_Name => Driver_Name);
113 Version_Arg := new String'("-Wl,-soname," & Lib_Version);
115 if Is_Absolute_Path (Lib_Version) then
117 (Output_File => Lib_Version,
120 Options & Version_Arg & Expect_Unresolved'Access,
121 Options_2 => Options_2,
122 Driver_Name => Driver_Name);
123 Symbolic_Link_Needed := Lib_Version /= Lib_File;
127 (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
130 Options & Version_Arg & Expect_Unresolved'Access,
131 Options_2 => Options_2,
132 Driver_Name => Driver_Name);
133 Symbolic_Link_Needed :=
134 Lib_Dir & Directory_Separator & Lib_Version /= Lib_File;
137 if Symbolic_Link_Needed then
140 Oldpath : String (1 .. Lib_Version'Length + 1);
141 Newpath : String (1 .. Lib_File'Length + 1);
144 pragma Unreferenced (Result);
147 (Oldpath : System.Address;
148 Newpath : System.Address)
150 pragma Import (C, Symlink, "__gnat_symlink");
153 Oldpath (1 .. Lib_Version'Length) := Lib_Version;
154 Oldpath (Oldpath'Last) := ASCII.NUL;
155 Newpath (1 .. Lib_File'Length) := Lib_File;
156 Newpath (Newpath'Last) := ASCII.NUL;
158 Delete_File (Lib_File, Success);
160 Result := Symlink (Oldpath'Address, Newpath'Address);
164 end Build_Dynamic_Library;
170 function Is_Archive_Ext (Ext : String) return Boolean is
172 return Ext = ".a" or else Ext = ".so";
179 function PIC_Option return String is
185 Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
186 Is_Archive_Ext_Ptr := Is_Archive_Ext'Access;
187 PIC_Option_Ptr := PIC_Option'Access;
188 end MLib.Tgt.Specific;