* gimplify.c (find_single_pointer_decl_1): New static function.
[official-gcc.git] / gcc / ada / mlib-tgt-tru64.adb
blobb6d954902df236b6c3358591917aa36fc2663a21
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- M L I B . T G T --
6 -- (True64 Version) --
7 -- --
8 -- B o d y --
9 -- --
10 -- Copyright (C) 2002-2005 Free Software Foundation, Inc. --
11 -- --
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. --
22 -- --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 -- --
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.
33 with MLib.Fil;
34 with MLib.Utl;
35 with Namet; use Namet;
36 with Opt;
37 with Output; use Output;
38 with Prj.Com;
39 with System;
41 package body MLib.Tgt is
43 use GNAT;
44 use MLib;
46 Expect_Unresolved : aliased String := "-Wl,-expect_unresolved,*";
48 ---------------------
49 -- Archive_Builder --
50 ---------------------
52 function Archive_Builder return String is
53 begin
54 return "ar";
55 end Archive_Builder;
57 -----------------------------
58 -- Archive_Builder_Options --
59 -----------------------------
61 function Archive_Builder_Options return String_List_Access is
62 begin
63 return new String_List'(1 => new String'("cr"));
64 end Archive_Builder_Options;
66 -----------------
67 -- Archive_Ext --
68 -----------------
70 function Archive_Ext return String is
71 begin
72 return "a";
73 end Archive_Ext;
75 ---------------------
76 -- Archive_Indexer --
77 ---------------------
79 function Archive_Indexer return String is
80 begin
81 return "ranlib";
82 end Archive_Indexer;
84 -----------------------------
85 -- Archive_Indexer_Options --
86 -----------------------------
88 function Archive_Indexer_Options return String_List_Access is
89 begin
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;
105 Lib_Dir : 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;
125 begin
126 if Opt.Verbose_Mode then
127 Write_Str ("building relocatable shared library ");
128 Write_Line (Lib_File);
129 end if;
131 -- If specified, add automatic elaboration/finalization
133 if Lib_Version = "" then
134 Utl.Gcc
135 (Output_File => Lib_File,
136 Objects => Ofiles,
137 Options => Options & Expect_Unresolved'Access,
138 Options_2 => Options_2,
139 Driver_Name => Driver_Name);
141 else
142 Version_Arg := new String'("-Wl,-soname," & Lib_Version);
144 if Is_Absolute_Path (Lib_Version) then
145 Utl.Gcc
146 (Output_File => Lib_Version,
147 Objects => Ofiles,
148 Options =>
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;
154 else
155 Utl.Gcc
156 (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
157 Objects => Ofiles,
158 Options =>
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;
164 end if;
166 if Symbolic_Link_Needed then
167 declare
168 Success : Boolean;
169 Oldpath : String (1 .. Lib_Version'Length + 1);
170 Newpath : String (1 .. Lib_File'Length + 1);
172 Result : Integer;
173 pragma Unreferenced (Result);
175 function Symlink
176 (Oldpath : System.Address;
177 Newpath : System.Address)
178 return Integer;
179 pragma Import (C, Symlink, "__gnat_symlink");
181 begin
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);
190 end;
191 end if;
192 end if;
193 end Build_Dynamic_Library;
195 -------------
196 -- DLL_Ext --
197 -------------
199 function DLL_Ext return String is
200 begin
201 return "so";
202 end DLL_Ext;
204 --------------------
205 -- Dynamic_Option --
206 --------------------
208 function Dynamic_Option return String is
209 begin
210 return "-shared";
211 end Dynamic_Option;
213 -------------------
214 -- Is_Object_Ext --
215 -------------------
217 function Is_Object_Ext (Ext : String) return Boolean is
218 begin
219 return Ext = ".o";
220 end Is_Object_Ext;
222 --------------
223 -- Is_C_Ext --
224 --------------
226 function Is_C_Ext (Ext : String) return Boolean is
227 begin
228 return Ext = ".c";
229 end Is_C_Ext;
231 --------------------
232 -- Is_Archive_Ext --
233 --------------------
235 function Is_Archive_Ext (Ext : String) return Boolean is
236 begin
237 return Ext = ".a" or else Ext = ".so";
238 end Is_Archive_Ext;
240 -------------
241 -- Libgnat --
242 -------------
244 function Libgnat return String is
245 begin
246 return "libgnat.a";
247 end Libgnat;
249 ------------------------
250 -- Library_Exists_For --
251 ------------------------
253 function Library_Exists_For
254 (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean
256 begin
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");
260 return False;
262 else
263 declare
264 Lib_Dir : constant String :=
265 Get_Name_String
266 (In_Tree.Projects.Table (Project).Library_Dir);
267 Lib_Name : constant String :=
268 Get_Name_String
269 (In_Tree.Projects.Table (Project).Library_Name);
271 begin
272 if In_Tree.Projects.Table (Project).Library_Kind =
273 Static
274 then
275 return Is_Regular_File
276 (Lib_Dir & Directory_Separator & "lib" &
277 Fil.Ext_To (Lib_Name, Archive_Ext));
279 else
280 return Is_Regular_File
281 (Lib_Dir & Directory_Separator & "lib" &
282 Fil.Ext_To (Lib_Name, DLL_Ext));
283 end if;
284 end;
285 end if;
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
296 begin
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");
300 return No_Name;
302 else
303 declare
304 Lib_Name : constant String :=
305 Get_Name_String
306 (In_Tree.Projects.Table (Project).Library_Name);
308 begin
309 Name_Len := 3;
310 Name_Buffer (1 .. Name_Len) := "lib";
312 if In_Tree.Projects.Table (Project).Library_Kind =
313 Static
314 then
315 Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, Archive_Ext));
317 else
318 Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, DLL_Ext));
319 end if;
321 return Name_Find;
322 end;
323 end if;
324 end Library_File_Name_For;
326 ----------------
327 -- Object_Ext --
328 ----------------
330 function Object_Ext return String is
331 begin
332 return "o";
333 end Object_Ext;
335 ----------------
336 -- PIC_Option --
337 ----------------
339 function PIC_Option return String is
340 begin
341 return "";
342 end PIC_Option;
344 -----------------------------------------------
345 -- Standalone_Library_Auto_Init_Is_Supported --
346 -----------------------------------------------
348 function Standalone_Library_Auto_Init_Is_Supported return Boolean is
349 begin
350 return True;
351 end Standalone_Library_Auto_Init_Is_Supported;
353 ---------------------------
354 -- Support_For_Libraries --
355 ---------------------------
357 function Support_For_Libraries return Library_Support is
358 begin
359 return Full;
360 end Support_For_Libraries;
362 end MLib.Tgt;