1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 2002-2005 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
.Ext_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 Dynamic_Option return String is
217 function Is_Object_Ext (Ext : String) return Boolean is
226 function Is_C_Ext (Ext : String) return Boolean is
235 function Is_Archive_Ext (Ext : String) return Boolean is
237 return Ext = ".a" or else Ext = ".so";
244 function Libgnat return String is
249 ------------------------
250 -- Library_Exists_For --
251 ------------------------
253 function Library_Exists_For
254 (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean
257 if not In_Tree.Projects.Table (Project).Library then
258 Prj.Com.Fail ("INTERNAL ERROR: Library_Exists_For called " &
259 "for non library project");
264 Lib_Dir : constant String :=
266 (In_Tree.Projects.Table (Project).Library_Dir);
267 Lib_Name : constant String :=
269 (In_Tree.Projects.Table (Project).Library_Name);
272 if In_Tree.Projects.Table (Project).Library_Kind =
275 return Is_Regular_File
276 (Lib_Dir & Directory_Separator & "lib" &
277 Fil.Ext_To (Lib_Name, Archive_Ext));
280 return Is_Regular_File
281 (Lib_Dir & Directory_Separator & "lib" &
282 Fil.Ext_To (Lib_Name, DLL_Ext));
286 end Library_Exists_For;
288 ---------------------------
289 -- Library_File_Name_For --
290 ---------------------------
292 function Library_File_Name_For
293 (Project : Project_Id;
294 In_Tree : Project_Tree_Ref) return Name_Id
297 if not In_Tree.Projects.Table (Project).Library then
298 Prj.Com.Fail ("INTERNAL ERROR: Library_File_Name_For called " &
299 "for non library project");
304 Lib_Name : constant String :=
306 (In_Tree.Projects.Table (Project).Library_Name);
310 Name_Buffer (1 .. Name_Len) := "lib";
312 if In_Tree.Projects.Table (Project).Library_Kind =
315 Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, Archive_Ext));
318 Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, DLL_Ext));
324 end Library_File_Name_For;
330 function Object_Ext return String is
339 function PIC_Option return String is
344 -----------------------------------------------
345 -- Standalone_Library_Auto_Init_Is_Supported --
346 -----------------------------------------------
348 function Standalone_Library_Auto_Init_Is_Supported return Boolean is
351 end Standalone_Library_Auto_Init_Is_Supported;
353 ---------------------------
354 -- Support_For_Libraries --
355 ---------------------------
357 function Support_For_Libraries return Library_Support is
360 end Support_For_Libraries;