OSDN Git Service

2007-08-14 Vincent Celier <celier@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / mlib-tgt.adb
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-2007, 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 2,  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 COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 --  This is the default version which does not support libraries.
28 --  All subprograms are dummies, because they are never called,
29 --  except Support_For_Libraries which returns None.
30
31 with MLib.Fil;
32 with Prj.Com;
33
34 with MLib.Tgt.Specific;
35 pragma Warnings (Off, MLib.Tgt.Specific);
36 --  MLib.Tgt.Specific is with'ed only for elaboration purposes
37
38 package body MLib.Tgt is
39
40    ---------------------
41    -- Archive_Builder --
42    ---------------------
43
44    function Archive_Builder return String is
45    begin
46       return Archive_Builder_Ptr.all;
47    end Archive_Builder;
48
49    -----------------------------
50    -- Archive_Builder_Default --
51    -----------------------------
52
53    function Archive_Builder_Default return String is
54    begin
55       return "ar";
56    end Archive_Builder_Default;
57
58    -----------------------------
59    -- Archive_Builder_Options --
60    -----------------------------
61
62    function Archive_Builder_Options return String_List_Access is
63    begin
64       return Archive_Builder_Options_Ptr.all;
65    end Archive_Builder_Options;
66
67    -------------------------------------
68    -- Archive_Builder_Options_Default --
69    -------------------------------------
70
71    function Archive_Builder_Options_Default return String_List_Access is
72    begin
73       return new String_List'(1 => new String'("cr"));
74    end Archive_Builder_Options_Default;
75
76    ------------------------------------
77    -- Archive_Builder_Append_Options --
78    ------------------------------------
79
80    function Archive_Builder_Append_Options return String_List_Access is
81    begin
82       return Archive_Builder_Append_Options_Ptr.all;
83    end Archive_Builder_Append_Options;
84
85    --------------------------------------------
86    -- Archive_Builder_Append_Options_Default --
87    --------------------------------------------
88
89    function Archive_Builder_Append_Options_Default return String_List_Access is
90    begin
91       return new String_List'(1 => new String'("q"));
92    end Archive_Builder_Append_Options_Default;
93
94    -----------------
95    -- Archive_Ext --
96    -----------------
97
98    function Archive_Ext return String is
99    begin
100       return Archive_Ext_Ptr.all;
101    end Archive_Ext;
102
103    -------------------------
104    -- Archive_Ext_Default --
105    -------------------------
106
107    function Archive_Ext_Default return String is
108    begin
109       return "a";
110    end Archive_Ext_Default;
111
112    ---------------------
113    -- Archive_Indexer --
114    ---------------------
115
116    function Archive_Indexer return String is
117    begin
118       return Archive_Indexer_Ptr.all;
119    end Archive_Indexer;
120
121    -----------------------------
122    -- Archive_Indexer_Default --
123    -----------------------------
124
125    function Archive_Indexer_Default return String is
126    begin
127       return "ranlib";
128    end Archive_Indexer_Default;
129
130    -----------------------------
131    -- Archive_Indexer_Options --
132    -----------------------------
133
134    function Archive_Indexer_Options return String_List_Access is
135    begin
136       return Archive_Indexer_Options_Ptr.all;
137    end Archive_Indexer_Options;
138
139    -------------------------------------
140    -- Archive_Indexer_Options_Default --
141    -------------------------------------
142
143    function Archive_Indexer_Options_Default return String_List_Access is
144    begin
145       return new String_List (1 .. 0);
146    end Archive_Indexer_Options_Default;
147
148    ---------------------------
149    -- Build_Dynamic_Library --
150    ---------------------------
151
152    procedure Build_Dynamic_Library
153      (Ofiles       : Argument_List;
154       Options      : Argument_List;
155       Interfaces   : Argument_List;
156       Lib_Filename : String;
157       Lib_Dir      : String;
158       Symbol_Data  : Symbol_Record;
159       Driver_Name  : Name_Id := No_Name;
160       Lib_Version  : String  := "";
161       Auto_Init    : Boolean := False)
162    is
163    begin
164       Build_Dynamic_Library_Ptr
165         (Ofiles,
166          Options,
167          Interfaces,
168          Lib_Filename,
169          Lib_Dir,
170          Symbol_Data,
171          Driver_Name,
172          Lib_Version,
173          Auto_Init);
174    end Build_Dynamic_Library;
175
176    ------------------------------
177    -- Default_Symbol_File_Name --
178    ------------------------------
179
180    function Default_Symbol_File_Name return String is
181    begin
182       return Default_Symbol_File_Name_Ptr.all;
183    end Default_Symbol_File_Name;
184
185    --------------------------------------
186    -- Default_Symbol_File_Name_Default --
187    --------------------------------------
188
189    function Default_Symbol_File_Name_Default return String is
190    begin
191       return "";
192    end Default_Symbol_File_Name_Default;
193
194    -------------
195    -- DLL_Ext --
196    -------------
197
198    function DLL_Ext return String is
199    begin
200       return DLL_Ext_Ptr.all;
201    end DLL_Ext;
202
203    ---------------------
204    -- DLL_Ext_Default --
205    ---------------------
206
207    function DLL_Ext_Default return String is
208    begin
209       return "so";
210    end DLL_Ext_Default;
211
212    ----------------
213    -- DLL_Prefix --
214    ----------------
215
216    function DLL_Prefix return String is
217    begin
218       return DLL_Prefix_Ptr.all;
219    end DLL_Prefix;
220
221    ------------------------
222    -- DLL_Prefix_Default --
223    ------------------------
224
225    function DLL_Prefix_Default return String is
226    begin
227       return "lib";
228    end DLL_Prefix_Default;
229
230    --------------------
231    -- Dynamic_Option --
232    --------------------
233
234    function Dynamic_Option return String is
235    begin
236       return Dynamic_Option_Ptr.all;
237    end Dynamic_Option;
238
239    ----------------------------
240    -- Dynamic_Option_Default --
241    ----------------------------
242
243    function Dynamic_Option_Default return String is
244    begin
245       return "-shared";
246    end Dynamic_Option_Default;
247
248    -------------------
249    -- Is_Object_Ext --
250    -------------------
251
252    function Is_Object_Ext (Ext : String) return Boolean is
253    begin
254       return Is_Object_Ext_Ptr (Ext);
255    end Is_Object_Ext;
256
257    ---------------------------
258    -- Is_Object_Ext_Default --
259    ---------------------------
260
261    function Is_Object_Ext_Default (Ext : String) return Boolean is
262    begin
263       return Ext = ".o";
264    end Is_Object_Ext_Default;
265
266    --------------
267    -- Is_C_Ext --
268    --------------
269
270    function Is_C_Ext (Ext : String) return Boolean is
271    begin
272       return Is_C_Ext_Ptr (Ext);
273    end Is_C_Ext;
274
275    ----------------------
276    -- Is_C_Ext_Default --
277    ----------------------
278
279    function Is_C_Ext_Default (Ext : String) return Boolean is
280    begin
281       return Ext = ".c";
282    end Is_C_Ext_Default;
283
284    --------------------
285    -- Is_Archive_Ext --
286    --------------------
287
288    function Is_Archive_Ext (Ext : String) return Boolean is
289    begin
290       return Is_Archive_Ext_Ptr (Ext);
291    end Is_Archive_Ext;
292
293    ----------------------------
294    -- Is_Archive_Ext_Default --
295    ----------------------------
296
297    function Is_Archive_Ext_Default (Ext : String) return Boolean is
298    begin
299       return Ext = ".a";
300    end Is_Archive_Ext_Default;
301
302    -------------
303    -- Libgnat --
304    -------------
305
306    function Libgnat return String is
307    begin
308       return Libgnat_Ptr.all;
309    end Libgnat;
310
311    ---------------------
312    -- Libgnat_Default --
313    ---------------------
314
315    function Libgnat_Default return String is
316    begin
317       return "libgnat.a";
318    end Libgnat_Default;
319
320    ------------------------
321    -- Library_Exists_For --
322    ------------------------
323
324    function Library_Exists_For
325      (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean
326    is
327    begin
328       return Library_Exists_For_Ptr (Project, In_Tree);
329    end Library_Exists_For;
330
331    --------------------------------
332    -- Library_Exists_For_Default --
333    --------------------------------
334
335    function Library_Exists_For_Default
336      (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean
337    is
338    begin
339       if not In_Tree.Projects.Table (Project).Library then
340          Prj.Com.Fail ("INTERNAL ERROR: Library_Exists_For called " &
341                        "for non library project");
342          return False;
343
344       else
345          declare
346             Lib_Dir  : constant String :=
347                          Get_Name_String
348                            (In_Tree.Projects.Table (Project).Library_Dir);
349             Lib_Name : constant String :=
350                          Get_Name_String
351                            (In_Tree.Projects.Table (Project).Library_Name);
352
353          begin
354             if In_Tree.Projects.Table (Project).Library_Kind = Static then
355                return Is_Regular_File
356                  (Lib_Dir & Directory_Separator & "lib" &
357                   Fil.Append_To (Lib_Name, Archive_Ext));
358
359             else
360                return Is_Regular_File
361                  (Lib_Dir & Directory_Separator & DLL_Prefix &
362                   Fil.Append_To (Lib_Name, DLL_Ext));
363             end if;
364          end;
365       end if;
366    end Library_Exists_For_Default;
367
368    ---------------------------
369    -- Library_File_Name_For --
370    ---------------------------
371
372    function Library_File_Name_For
373      (Project : Project_Id;
374       In_Tree : Project_Tree_Ref) return File_Name_Type
375    is
376    begin
377       return Library_File_Name_For_Ptr (Project, In_Tree);
378    end Library_File_Name_For;
379
380    -----------------------------------
381    -- Library_File_Name_For_Default --
382    -----------------------------------
383
384    function Library_File_Name_For_Default
385      (Project : Project_Id;
386       In_Tree : Project_Tree_Ref) return File_Name_Type
387    is
388    begin
389       if not In_Tree.Projects.Table (Project).Library then
390          Prj.Com.Fail ("INTERNAL ERROR: Library_File_Name_For called " &
391                        "for non library project");
392          return No_File;
393
394       else
395          declare
396             Lib_Name : constant String :=
397                          Get_Name_String
398                            (In_Tree.Projects.Table (Project).Library_Name);
399
400          begin
401             if In_Tree.Projects.Table (Project).Library_Kind =
402                  Static
403             then
404                Name_Len := 3;
405                Name_Buffer (1 .. Name_Len) := "lib";
406                Add_Str_To_Name_Buffer (Fil.Append_To (Lib_Name, Archive_Ext));
407             else
408                Name_Len := 0;
409                Add_Str_To_Name_Buffer (DLL_Prefix);
410                Add_Str_To_Name_Buffer (Fil.Append_To (Lib_Name, DLL_Ext));
411             end if;
412
413             return Name_Find;
414          end;
415       end if;
416    end Library_File_Name_For_Default;
417
418    --------------------------------------
419    -- Library_Major_Minor_Id_Supported --
420    --------------------------------------
421
422    function Library_Major_Minor_Id_Supported return Boolean is
423    begin
424       return Library_Major_Minor_Id_Supported_Ptr.all;
425    end Library_Major_Minor_Id_Supported;
426
427    ----------------------------------------------
428    -- Library_Major_Minor_Id_Supported_Default --
429    ----------------------------------------------
430
431    function Library_Major_Minor_Id_Supported_Default return Boolean is
432    begin
433       return True;
434    end Library_Major_Minor_Id_Supported_Default;
435
436    ----------------
437    -- Object_Ext --
438    ----------------
439
440    function Object_Ext return String is
441    begin
442       return Object_Ext_Ptr.all;
443    end Object_Ext;
444
445    ------------------------
446    -- Object_Ext_Default --
447    ------------------------
448
449    function Object_Ext_Default return String is
450    begin
451       return "o";
452    end Object_Ext_Default;
453
454    ----------------
455    -- PIC_Option --
456    ----------------
457
458    function PIC_Option return String is
459    begin
460       return PIC_Option_Ptr.all;
461    end PIC_Option;
462
463    ------------------------
464    -- PIC_Option_Default --
465    ------------------------
466
467    function PIC_Option_Default return String is
468    begin
469       return "-fPIC";
470    end PIC_Option_Default;
471
472    -----------------------------------------------
473    -- Standalone_Library_Auto_Init_Is_Supported --
474    -----------------------------------------------
475
476    function Standalone_Library_Auto_Init_Is_Supported return Boolean is
477    begin
478       return Standalone_Library_Auto_Init_Is_Supported_Ptr.all;
479    end Standalone_Library_Auto_Init_Is_Supported;
480
481    -------------------------------------------------------
482    -- Standalone_Library_Auto_Init_Is_Supported_Default --
483    -------------------------------------------------------
484
485    function Standalone_Library_Auto_Init_Is_Supported_Default return Boolean is
486    begin
487       return True;
488    end Standalone_Library_Auto_Init_Is_Supported_Default;
489
490    ---------------------------
491    -- Support_For_Libraries --
492    ---------------------------
493
494    function Support_For_Libraries return Library_Support is
495    begin
496       return Support_For_Libraries_Ptr.all;
497    end Support_For_Libraries;
498
499    -----------------------------------
500    -- Support_For_Libraries_Default --
501    -----------------------------------
502
503    function Support_For_Libraries_Default return Library_Support is
504    begin
505       return Full;
506    end Support_For_Libraries_Default;
507 end MLib.Tgt;