pa.h (BIGGEST_ALIGNMENT): Adjust comment.
[official-gcc.git] / gcc / ada / mlib-tgt.adb
blob4d8597c1f73099af4f6f5b4cbf9e78ecb4b3f11c
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- M L I B . T G T --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2001-2010, AdaCore --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 with MLib.Fil;
27 with Prj.Com;
29 with MLib.Tgt.Specific;
30 pragma Warnings (Off, MLib.Tgt.Specific);
31 -- MLib.Tgt.Specific is with'ed only for elaboration purposes
33 package body MLib.Tgt is
35 ---------------------
36 -- Archive_Builder --
37 ---------------------
39 function Archive_Builder return String is
40 begin
41 return Archive_Builder_Ptr.all;
42 end Archive_Builder;
44 -----------------------------
45 -- Archive_Builder_Default --
46 -----------------------------
48 function Archive_Builder_Default return String is
49 begin
50 return "ar";
51 end Archive_Builder_Default;
53 -----------------------------
54 -- Archive_Builder_Options --
55 -----------------------------
57 function Archive_Builder_Options return String_List_Access is
58 begin
59 return Archive_Builder_Options_Ptr.all;
60 end Archive_Builder_Options;
62 -------------------------------------
63 -- Archive_Builder_Options_Default --
64 -------------------------------------
66 function Archive_Builder_Options_Default return String_List_Access is
67 begin
68 return new String_List'(1 => new String'("cr"));
69 end Archive_Builder_Options_Default;
71 ------------------------------------
72 -- Archive_Builder_Append_Options --
73 ------------------------------------
75 function Archive_Builder_Append_Options return String_List_Access is
76 begin
77 return Archive_Builder_Append_Options_Ptr.all;
78 end Archive_Builder_Append_Options;
80 --------------------------------------------
81 -- Archive_Builder_Append_Options_Default --
82 --------------------------------------------
84 function Archive_Builder_Append_Options_Default return String_List_Access is
85 begin
86 return new String_List'(1 => new String'("q"));
87 end Archive_Builder_Append_Options_Default;
89 -----------------
90 -- Archive_Ext --
91 -----------------
93 function Archive_Ext return String is
94 begin
95 return Archive_Ext_Ptr.all;
96 end Archive_Ext;
98 -------------------------
99 -- Archive_Ext_Default --
100 -------------------------
102 function Archive_Ext_Default return String is
103 begin
104 return "a";
105 end Archive_Ext_Default;
107 ---------------------
108 -- Archive_Indexer --
109 ---------------------
111 function Archive_Indexer return String is
112 begin
113 return Archive_Indexer_Ptr.all;
114 end Archive_Indexer;
116 -----------------------------
117 -- Archive_Indexer_Default --
118 -----------------------------
120 function Archive_Indexer_Default return String is
121 begin
122 return "ranlib";
123 end Archive_Indexer_Default;
125 -----------------------------
126 -- Archive_Indexer_Options --
127 -----------------------------
129 function Archive_Indexer_Options return String_List_Access is
130 begin
131 return Archive_Indexer_Options_Ptr.all;
132 end Archive_Indexer_Options;
134 -------------------------------------
135 -- Archive_Indexer_Options_Default --
136 -------------------------------------
138 function Archive_Indexer_Options_Default return String_List_Access is
139 begin
140 return new String_List (1 .. 0);
141 end Archive_Indexer_Options_Default;
143 ---------------------------
144 -- Build_Dynamic_Library --
145 ---------------------------
147 procedure Build_Dynamic_Library
148 (Ofiles : Argument_List;
149 Options : Argument_List;
150 Interfaces : Argument_List;
151 Lib_Filename : String;
152 Lib_Dir : String;
153 Symbol_Data : Symbol_Record;
154 Driver_Name : Name_Id := No_Name;
155 Lib_Version : String := "";
156 Auto_Init : Boolean := False)
158 begin
159 Build_Dynamic_Library_Ptr
160 (Ofiles,
161 Options,
162 Interfaces,
163 Lib_Filename,
164 Lib_Dir,
165 Symbol_Data,
166 Driver_Name,
167 Lib_Version,
168 Auto_Init);
169 end Build_Dynamic_Library;
171 ------------------------------
172 -- Default_Symbol_File_Name --
173 ------------------------------
175 function Default_Symbol_File_Name return String is
176 begin
177 return Default_Symbol_File_Name_Ptr.all;
178 end Default_Symbol_File_Name;
180 --------------------------------------
181 -- Default_Symbol_File_Name_Default --
182 --------------------------------------
184 function Default_Symbol_File_Name_Default return String is
185 begin
186 return "";
187 end Default_Symbol_File_Name_Default;
189 -------------
190 -- DLL_Ext --
191 -------------
193 function DLL_Ext return String is
194 begin
195 return DLL_Ext_Ptr.all;
196 end DLL_Ext;
198 ---------------------
199 -- DLL_Ext_Default --
200 ---------------------
202 function DLL_Ext_Default return String is
203 begin
204 return "so";
205 end DLL_Ext_Default;
207 ----------------
208 -- DLL_Prefix --
209 ----------------
211 function DLL_Prefix return String is
212 begin
213 return DLL_Prefix_Ptr.all;
214 end DLL_Prefix;
216 ------------------------
217 -- DLL_Prefix_Default --
218 ------------------------
220 function DLL_Prefix_Default return String is
221 begin
222 return "lib";
223 end DLL_Prefix_Default;
225 --------------------
226 -- Dynamic_Option --
227 --------------------
229 function Dynamic_Option return String is
230 begin
231 return Dynamic_Option_Ptr.all;
232 end Dynamic_Option;
234 ----------------------------
235 -- Dynamic_Option_Default --
236 ----------------------------
238 function Dynamic_Option_Default return String is
239 begin
240 return "-shared";
241 end Dynamic_Option_Default;
243 -------------------
244 -- Is_Object_Ext --
245 -------------------
247 function Is_Object_Ext (Ext : String) return Boolean is
248 begin
249 return Is_Object_Ext_Ptr (Ext);
250 end Is_Object_Ext;
252 ---------------------------
253 -- Is_Object_Ext_Default --
254 ---------------------------
256 function Is_Object_Ext_Default (Ext : String) return Boolean is
257 begin
258 return Ext = ".o";
259 end Is_Object_Ext_Default;
261 --------------
262 -- Is_C_Ext --
263 --------------
265 function Is_C_Ext (Ext : String) return Boolean is
266 begin
267 return Is_C_Ext_Ptr (Ext);
268 end Is_C_Ext;
270 ----------------------
271 -- Is_C_Ext_Default --
272 ----------------------
274 function Is_C_Ext_Default (Ext : String) return Boolean is
275 begin
276 return Ext = ".c";
277 end Is_C_Ext_Default;
279 --------------------
280 -- Is_Archive_Ext --
281 --------------------
283 function Is_Archive_Ext (Ext : String) return Boolean is
284 begin
285 return Is_Archive_Ext_Ptr (Ext);
286 end Is_Archive_Ext;
288 ----------------------------
289 -- Is_Archive_Ext_Default --
290 ----------------------------
292 function Is_Archive_Ext_Default (Ext : String) return Boolean is
293 begin
294 return Ext = ".a";
295 end Is_Archive_Ext_Default;
297 -------------
298 -- Libgnat --
299 -------------
301 function Libgnat return String is
302 begin
303 return Libgnat_Ptr.all;
304 end Libgnat;
306 ---------------------
307 -- Libgnat_Default --
308 ---------------------
310 function Libgnat_Default return String is
311 begin
312 return "libgnat.a";
313 end Libgnat_Default;
315 ------------------------
316 -- Library_Exists_For --
317 ------------------------
319 function Library_Exists_For
320 (Project : Project_Id;
321 In_Tree : Project_Tree_Ref) return Boolean
323 begin
324 return Library_Exists_For_Ptr (Project, In_Tree);
325 end Library_Exists_For;
327 --------------------------------
328 -- Library_Exists_For_Default --
329 --------------------------------
331 function Library_Exists_For_Default
332 (Project : Project_Id;
333 In_Tree : Project_Tree_Ref) return Boolean
335 pragma Unreferenced (In_Tree);
337 begin
338 if not Project.Library then
339 Prj.Com.Fail ("INTERNAL ERROR: Library_Exists_For called " &
340 "for non library project");
341 return False;
343 else
344 declare
345 Lib_Dir : constant String :=
346 Get_Name_String (Project.Library_Dir.Display_Name);
347 Lib_Name : constant String :=
348 Get_Name_String (Project.Library_Name);
350 begin
351 if Project.Library_Kind = Static then
352 return Is_Regular_File
353 (Lib_Dir & Directory_Separator & "lib" &
354 Fil.Append_To (Lib_Name, Archive_Ext));
356 else
357 return Is_Regular_File
358 (Lib_Dir & Directory_Separator & DLL_Prefix &
359 Fil.Append_To (Lib_Name, DLL_Ext));
360 end if;
361 end;
362 end if;
363 end Library_Exists_For_Default;
365 ---------------------------
366 -- Library_File_Name_For --
367 ---------------------------
369 function Library_File_Name_For
370 (Project : Project_Id;
371 In_Tree : Project_Tree_Ref) return File_Name_Type
373 begin
374 return Library_File_Name_For_Ptr (Project, In_Tree);
375 end Library_File_Name_For;
377 -----------------------------------
378 -- Library_File_Name_For_Default --
379 -----------------------------------
381 function Library_File_Name_For_Default
382 (Project : Project_Id;
383 In_Tree : Project_Tree_Ref) return File_Name_Type
385 pragma Unreferenced (In_Tree);
386 begin
387 if not Project.Library then
388 Prj.Com.Fail ("INTERNAL ERROR: Library_File_Name_For called " &
389 "for non library project");
390 return No_File;
392 else
393 declare
394 Lib_Name : constant String :=
395 Get_Name_String (Project.Library_Name);
397 begin
398 if Project.Library_Kind =
399 Static
400 then
401 Name_Len := 3;
402 Name_Buffer (1 .. Name_Len) := "lib";
403 Add_Str_To_Name_Buffer (Fil.Append_To (Lib_Name, Archive_Ext));
404 else
405 Name_Len := 0;
406 Add_Str_To_Name_Buffer (DLL_Prefix);
407 Add_Str_To_Name_Buffer (Fil.Append_To (Lib_Name, DLL_Ext));
408 end if;
410 return Name_Find;
411 end;
412 end if;
413 end Library_File_Name_For_Default;
415 --------------------------------------
416 -- Library_Major_Minor_Id_Supported --
417 --------------------------------------
419 function Library_Major_Minor_Id_Supported return Boolean is
420 begin
421 return Library_Major_Minor_Id_Supported_Ptr.all;
422 end Library_Major_Minor_Id_Supported;
424 ----------------------------------------------
425 -- Library_Major_Minor_Id_Supported_Default --
426 ----------------------------------------------
428 function Library_Major_Minor_Id_Supported_Default return Boolean is
429 begin
430 return True;
431 end Library_Major_Minor_Id_Supported_Default;
433 ----------------
434 -- Object_Ext --
435 ----------------
437 function Object_Ext return String is
438 begin
439 return Object_Ext_Ptr.all;
440 end Object_Ext;
442 ------------------------
443 -- Object_Ext_Default --
444 ------------------------
446 function Object_Ext_Default return String is
447 begin
448 return "o";
449 end Object_Ext_Default;
451 ----------------
452 -- PIC_Option --
453 ----------------
455 function PIC_Option return String is
456 begin
457 return PIC_Option_Ptr.all;
458 end PIC_Option;
460 ------------------------
461 -- PIC_Option_Default --
462 ------------------------
464 function PIC_Option_Default return String is
465 begin
466 return "-fPIC";
467 end PIC_Option_Default;
469 -----------------------------------------------
470 -- Standalone_Library_Auto_Init_Is_Supported --
471 -----------------------------------------------
473 function Standalone_Library_Auto_Init_Is_Supported return Boolean is
474 begin
475 return Standalone_Library_Auto_Init_Is_Supported_Ptr.all;
476 end Standalone_Library_Auto_Init_Is_Supported;
478 -------------------------------------------------------
479 -- Standalone_Library_Auto_Init_Is_Supported_Default --
480 -------------------------------------------------------
482 function Standalone_Library_Auto_Init_Is_Supported_Default return Boolean is
483 begin
484 return True;
485 end Standalone_Library_Auto_Init_Is_Supported_Default;
487 ---------------------------
488 -- Support_For_Libraries --
489 ---------------------------
491 function Support_For_Libraries return Library_Support is
492 begin
493 return Support_For_Libraries_Ptr.all;
494 end Support_For_Libraries;
496 -----------------------------------
497 -- Support_For_Libraries_Default --
498 -----------------------------------
500 function Support_For_Libraries_Default return Library_Support is
501 begin
502 return Full;
503 end Support_For_Libraries_Default;
505 end MLib.Tgt;