1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 2002-2006 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 package provides a set of target dependent routines to build
29 -- static, dynamic and shared libraries.
31 -- This is the True64 version of the body
35 with Namet; use Namet;
37 with Output; use Output;
41 package body MLib.Tgt is
46 Expect_Unresolved : aliased String := "-Wl,-expect_unresolved,*";
52 function Archive_Builder return String is
57 -----------------------------
58 -- Archive_Builder_Options --
59 -----------------------------
61 function Archive_Builder_Options return String_List_Access is
63 return new String_List'(1 => new String'("cr"));
64 end Archive_Builder_Options;
70 function Archive_Ext return String is
79 function Archive_Indexer return String is
84 -----------------------------
85 -- Archive_Indexer_Options --
86 -----------------------------
88 function Archive_Indexer_Options return String_List_Access is
90 return new String_List (1 .. 0);
91 end Archive_Indexer_Options;
93 ---------------------------
94 -- Build_Dynamic_Library --
95 ---------------------------
97 procedure Build_Dynamic_Library
98 (Ofiles : Argument_List;
99 Foreign : Argument_List;
100 Afiles : Argument_List;
101 Options : Argument_List;
102 Options_2 : Argument_List;
103 Interfaces : Argument_List;
104 Lib_Filename : String;
106 Symbol_Data : Symbol_Record;
107 Driver_Name : Name_Id := No_Name;
108 Lib_Version : String := "";
109 Auto_Init : Boolean := False)
111 pragma Unreferenced (Foreign);
112 pragma Unreferenced (Afiles);
113 pragma Unreferenced (Interfaces);
114 pragma Unreferenced (Symbol_Data);
115 pragma Unreferenced (Auto_Init);
116 -- Initialization is done through the contructor mechanism
118 Lib_File : constant String :=
119 Lib_Dir & Directory_Separator & "lib" &
120 Fil.Append_To (Lib_Filename, DLL_Ext);
122 Version_Arg : String_Access;
123 Symbolic_Link_Needed : Boolean := False;
126 if Opt.Verbose_Mode then
127 Write_Str ("building relocatable shared library ");
128 Write_Line (Lib_File);
131 -- If specified, add automatic elaboration/finalization
133 if Lib_Version = "" then
135 (Output_File => Lib_File,
137 Options => Options & Expect_Unresolved'Access,
138 Options_2 => Options_2,
139 Driver_Name => Driver_Name);
142 Version_Arg := new String'("-Wl,-soname," & Lib_Version);
144 if Is_Absolute_Path (Lib_Version) then
146 (Output_File => Lib_Version,
149 Options & Version_Arg & Expect_Unresolved'Access,
150 Options_2 => Options_2,
151 Driver_Name => Driver_Name);
152 Symbolic_Link_Needed := Lib_Version /= Lib_File;
156 (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
159 Options & Version_Arg & Expect_Unresolved'Access,
160 Options_2 => Options_2,
161 Driver_Name => Driver_Name);
162 Symbolic_Link_Needed :=
163 Lib_Dir & Directory_Separator & Lib_Version /= Lib_File;
166 if Symbolic_Link_Needed then
169 Oldpath : String (1 .. Lib_Version'Length + 1);
170 Newpath : String (1 .. Lib_File'Length + 1);
173 pragma Unreferenced (Result);
176 (Oldpath : System.Address;
177 Newpath : System.Address)
179 pragma Import (C, Symlink, "__gnat_symlink");
182 Oldpath (1 .. Lib_Version'Length) := Lib_Version;
183 Oldpath (Oldpath'Last) := ASCII.NUL;
184 Newpath (1 .. Lib_File'Length) := Lib_File;
185 Newpath (Newpath'Last) := ASCII.NUL;
187 Delete_File (Lib_File, Success);
189 Result := Symlink (Oldpath'Address, Newpath'Address);
193 end Build_Dynamic_Library;
199 function DLL_Ext return String is
208 function DLL_Prefix return String is
217 function Dynamic_Option return String is
226 function Is_Object_Ext (Ext : String) return Boolean is
235 function Is_C_Ext (Ext : String) return Boolean is
244 function Is_Archive_Ext (Ext : String) return Boolean is
246 return Ext = ".a" or else Ext = ".so";
253 function Libgnat return String is
258 ------------------------
259 -- Library_Exists_For --
260 ------------------------
262 function Library_Exists_For
263 (Project : Project_Id;
264 In_Tree : Project_Tree_Ref) return Boolean
267 if not In_Tree.Projects.Table (Project).Library then
268 Prj.Com.Fail ("INTERNAL ERROR: Library_Exists_For called " &
269 "for non library project");
274 Lib_Dir : constant String :=
276 (In_Tree.Projects.Table (Project).Library_Dir);
277 Lib_Name : constant String :=
279 (In_Tree.Projects.Table (Project).Library_Name);
282 if In_Tree.Projects.Table (Project).Library_Kind = Static then
283 return Is_Regular_File
284 (Lib_Dir & Directory_Separator & "lib" &
285 Fil.Append_To (Lib_Name, Archive_Ext));
288 return Is_Regular_File
289 (Lib_Dir & Directory_Separator & "lib" &
290 Fil.Append_To (Lib_Name, DLL_Ext));
294 end Library_Exists_For;
296 ---------------------------
297 -- Library_File_Name_For --
298 ---------------------------
300 function Library_File_Name_For
301 (Project : Project_Id;
302 In_Tree : Project_Tree_Ref) return Name_Id
305 if not In_Tree.Projects.Table (Project).Library then
306 Prj.Com.Fail ("INTERNAL ERROR: Library_File_Name_For called " &
307 "for non library project");
312 Lib_Name : constant String :=
314 (In_Tree.Projects.Table (Project).Library_Name);
318 Name_Buffer (1 .. Name_Len) := "lib";
320 if In_Tree.Projects.Table (Project).Library_Kind =
323 Add_Str_To_Name_Buffer (Fil.Append_To (Lib_Name, Archive_Ext));
325 Add_Str_To_Name_Buffer (Fil.Append_To (Lib_Name, DLL_Ext));
331 end Library_File_Name_For;
337 function Object_Ext return String is
346 function PIC_Option return String is
351 -----------------------------------------------
352 -- Standalone_Library_Auto_Init_Is_Supported --
353 -----------------------------------------------
355 function Standalone_Library_Auto_Init_Is_Supported return Boolean is
358 end Standalone_Library_Auto_Init_Is_Supported;
360 ---------------------------
361 -- Support_For_Libraries --
362 ---------------------------
364 function Support_For_Libraries return Library_Support is
367 end Support_For_Libraries;