OSDN Git Service

69ed03b372ca169af636d286a421ca32490f3f6c
[pf3gnuchains/gcc-fork.git] / gcc / ada / mlib-tgt-vxworks.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                             M L I B . T G T                              --
6 --                            (VxWorks Version)                             --
7 --                                                                          --
8 --                                 B o d y                                  --
9 --                                                                          --
10 --           Copyright (C) 2003-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 ------------------------------------------------------------------------------
27
28 --  This package provides a set of target dependent routines to build
29 --  static libraries.
30
31 --  This is the VxWorks version of the body
32
33 with MLib.Fil;
34 with Namet;  use Namet;
35 with Prj.Com;
36 with Sdefault;
37
38 package body MLib.Tgt is
39
40    -----------------------
41    -- Local Subprograms --
42    -----------------------
43
44    function Get_Target_Suffix return String;
45    --  Returns the required suffix for some utilities
46    --  (such as ar and ranlib) that depend on the real target.
47
48    ---------------------
49    -- Archive_Builder --
50    ---------------------
51
52    function Archive_Builder return String is
53    begin
54       return "ar" & Get_Target_Suffix;
55    end Archive_Builder;
56
57    -----------------------------
58    -- Archive_Builder_Options --
59    -----------------------------
60
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;
65
66    -----------------
67    -- Archive_Ext --
68    -----------------
69
70    function Archive_Ext return String is
71    begin
72       return "a";
73    end Archive_Ext;
74
75    ---------------------
76    -- Archive_Indexer --
77    ---------------------
78
79    function Archive_Indexer return String is
80    begin
81       return "ranlib" & Get_Target_Suffix;
82    end Archive_Indexer;
83
84    -----------------------------
85    -- Archive_Indexer_Options --
86    -----------------------------
87
88    function Archive_Indexer_Options return String_List_Access is
89    begin
90       return new String_List (1 .. 0);
91    end Archive_Indexer_Options;
92
93    ---------------------------
94    -- Build_Dynamic_Library --
95    ---------------------------
96
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)
110    is
111       pragma Unreferenced (Ofiles);
112       pragma Unreferenced (Foreign);
113       pragma Unreferenced (Afiles);
114       pragma Unreferenced (Options);
115       pragma Unreferenced (Options_2);
116       pragma Unreferenced (Interfaces);
117       pragma Unreferenced (Lib_Filename);
118       pragma Unreferenced (Lib_Dir);
119       pragma Unreferenced (Symbol_Data);
120       pragma Unreferenced (Driver_Name);
121       pragma Unreferenced (Lib_Version);
122       pragma Unreferenced (Auto_Init);
123
124    begin
125       null;
126    end Build_Dynamic_Library;
127
128    -------------
129    -- DLL_Ext --
130    -------------
131
132    function DLL_Ext return String is
133    begin
134       return "";
135    end DLL_Ext;
136
137    ----------------
138    -- DLL_Prefix --
139    ----------------
140
141    function DLL_Prefix return String is
142    begin
143       return "lib";
144    end DLL_Prefix;
145
146    --------------------
147    -- Dynamic_Option --
148    --------------------
149
150    function Dynamic_Option return String is
151    begin
152       return "";
153    end Dynamic_Option;
154
155    -----------------------------
156    -- Get_Target_Suffix --
157    -----------------------------
158
159    function Get_Target_Suffix return String is
160       Target_Name : constant String_Ptr := Sdefault.Target_Name;
161       Index       : Positive   := Target_Name'First;
162
163    begin
164       while Index < Target_Name'Last
165         and then Target_Name (Index + 1) /= '-'
166       loop
167          Index := Index + 1;
168       end loop;
169
170       if Target_Name (Target_Name'First .. Index) = "m68k" then
171          return "68k";
172       elsif Target_Name (Target_Name'First .. Index) = "mips" then
173          return "mips";
174       elsif Target_Name (Target_Name'First .. Index) = "powerpc" then
175          return "ppc";
176       elsif Target_Name (Target_Name'First .. Index) = "sparc" then
177          return "sparc";
178       elsif Target_Name (Target_Name'First .. Index) = "sparc64" then
179          return "sparc64";
180       elsif Target_Name (Target_Name'First .. Index) = "xscale" then
181          return "arm";
182       else
183          return "";
184       end if;
185    end Get_Target_Suffix;
186
187    -------------------
188    -- Is_Object_Ext --
189    -------------------
190
191    function Is_Object_Ext (Ext : String) return Boolean is
192    begin
193       return Ext = ".o";
194    end Is_Object_Ext;
195
196    --------------
197    -- Is_C_Ext --
198    --------------
199
200    function Is_C_Ext (Ext : String) return Boolean is
201    begin
202       return Ext = ".c";
203    end Is_C_Ext;
204
205    --------------------
206    -- Is_Archive_Ext --
207    --------------------
208
209    function Is_Archive_Ext (Ext : String) return Boolean is
210    begin
211       return Ext = ".a";
212    end Is_Archive_Ext;
213
214    -------------
215    -- Libgnat --
216    -------------
217
218    function Libgnat return String is
219    begin
220       return "libgnat.a";
221    end Libgnat;
222
223    ------------------------
224    -- Library_Exists_For --
225    ------------------------
226
227    function Library_Exists_For
228      (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean
229    is
230    begin
231       if not In_Tree.Projects.Table (Project).Library then
232          Prj.Com.Fail ("INTERNAL ERROR: Library_Exists_For called " &
233                        "for non library project");
234          return False;
235
236       else
237          declare
238             Lib_Dir : constant String :=
239               Get_Name_String
240                 (In_Tree.Projects.Table (Project).Library_Dir);
241             Lib_Name : constant String :=
242               Get_Name_String
243                 (In_Tree.Projects.Table (Project).Library_Name);
244
245          begin
246             if In_Tree.Projects.Table (Project).Library_Kind =
247               Static
248             then
249                return Is_Regular_File
250                  (Lib_Dir & Directory_Separator & "lib" &
251                   Fil.Ext_To (Lib_Name, Archive_Ext));
252
253             else
254                return Is_Regular_File
255                  (Lib_Dir & Directory_Separator & "lib" &
256                   Fil.Ext_To (Lib_Name, DLL_Ext));
257             end if;
258          end;
259       end if;
260    end Library_Exists_For;
261
262    ---------------------------
263    -- Library_File_Name_For --
264    ---------------------------
265
266    function Library_File_Name_For
267      (Project : Project_Id;
268       In_Tree : Project_Tree_Ref) return Name_Id
269    is
270    begin
271       if not In_Tree.Projects.Table (Project).Library then
272          Prj.Com.Fail ("INTERNAL ERROR: Library_File_Name_For called " &
273                        "for non library project");
274          return No_Name;
275
276       else
277          declare
278             Lib_Name : constant String :=
279               Get_Name_String
280                 (In_Tree.Projects.Table (Project).Library_Name);
281
282          begin
283             Name_Len := 3;
284             Name_Buffer (1 .. Name_Len) := "lib";
285
286             if In_Tree.Projects.Table (Project).Library_Kind =
287               Static
288             then
289                Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, Archive_Ext));
290
291             else
292                Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, DLL_Ext));
293             end if;
294
295             return Name_Find;
296          end;
297       end if;
298    end Library_File_Name_For;
299
300    ----------------
301    -- Object_Ext --
302    ----------------
303
304    function Object_Ext return String is
305    begin
306       return "o";
307    end Object_Ext;
308
309    ----------------
310    -- PIC_Option --
311    ----------------
312
313    function PIC_Option return String is
314    begin
315       return "";
316    end PIC_Option;
317
318    -----------------------------------------------
319    -- Standalone_Library_Auto_Init_Is_Supported --
320    -----------------------------------------------
321
322    function Standalone_Library_Auto_Init_Is_Supported return Boolean is
323    begin
324       return False;
325    end Standalone_Library_Auto_Init_Is_Supported;
326
327    ---------------------------
328    -- Support_For_Libraries --
329    ---------------------------
330
331    function Support_For_Libraries return Library_Support is
332    begin
333       return Static_Only;
334    end Support_For_Libraries;
335
336 end MLib.Tgt;