OSDN Git Service

2004-06-14 Pascal Obry <obry@gnat.com>
[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-2004 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,  59 Temple Place - Suite 330,  Boston, --
21 -- MA 02111-1307, 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    -- Build_Dynamic_Library --
86    ---------------------------
87
88    procedure Build_Dynamic_Library
89      (Ofiles       : Argument_List;
90       Foreign      : Argument_List;
91       Afiles       : Argument_List;
92       Options      : Argument_List;
93       Interfaces   : Argument_List;
94       Lib_Filename : String;
95       Lib_Dir      : String;
96       Symbol_Data  : Symbol_Record;
97       Driver_Name  : Name_Id := No_Name;
98       Lib_Address  : String  := "";
99       Lib_Version  : String  := "";
100       Relocatable  : Boolean := False;
101       Auto_Init    : Boolean := False)
102    is
103       pragma Unreferenced (Ofiles);
104       pragma Unreferenced (Foreign);
105       pragma Unreferenced (Afiles);
106       pragma Unreferenced (Options);
107       pragma Unreferenced (Interfaces);
108       pragma Unreferenced (Lib_Filename);
109       pragma Unreferenced (Lib_Dir);
110       pragma Unreferenced (Symbol_Data);
111       pragma Unreferenced (Driver_Name);
112       pragma Unreferenced (Lib_Address);
113       pragma Unreferenced (Lib_Version);
114       pragma Unreferenced (Relocatable);
115       pragma Unreferenced (Auto_Init);
116
117    begin
118       null;
119    end Build_Dynamic_Library;
120
121    -------------------------
122    -- Default_DLL_Address --
123    -------------------------
124
125    function Default_DLL_Address return String is
126    begin
127       return "";
128    end Default_DLL_Address;
129
130    -------------
131    -- DLL_Ext --
132    -------------
133
134    function DLL_Ext return String is
135    begin
136       return "";
137    end DLL_Ext;
138
139    --------------------
140    -- Dynamic_Option --
141    --------------------
142
143    function Dynamic_Option return String is
144    begin
145       return "";
146    end Dynamic_Option;
147
148    -----------------------------
149    -- Get_Target_Suffix --
150    -----------------------------
151
152    function Get_Target_Suffix return String is
153       Target_Name : constant String_Ptr := Sdefault.Target_Name;
154       Index       : Positive   := Target_Name'First;
155
156    begin
157       while Index < Target_Name'Last
158         and then Target_Name (Index + 1) /= '-'
159       loop
160          Index := Index + 1;
161       end loop;
162
163       if Target_Name (Target_Name'First .. Index) = "m68k" then
164          return "68k";
165       elsif Target_Name (Target_Name'First .. Index) = "mips" then
166          return "mips";
167       elsif Target_Name (Target_Name'First .. Index) = "powerpc" then
168          return "ppc";
169       elsif Target_Name (Target_Name'First .. Index) = "sparc" then
170          return "sparc";
171       elsif Target_Name (Target_Name'First .. Index) = "sparc64" then
172          return "sparc64";
173       elsif Target_Name (Target_Name'First .. Index) = "xscale" then
174          return "arm";
175       else
176          return "";
177       end if;
178    end Get_Target_Suffix;
179
180    -------------------
181    -- Is_Object_Ext --
182    -------------------
183
184    function Is_Object_Ext (Ext : String) return Boolean is
185    begin
186       return Ext = ".o";
187    end Is_Object_Ext;
188
189    --------------
190    -- Is_C_Ext --
191    --------------
192
193    function Is_C_Ext (Ext : String) return Boolean is
194    begin
195       return Ext = ".c";
196    end Is_C_Ext;
197
198    --------------------
199    -- Is_Archive_Ext --
200    --------------------
201
202    function Is_Archive_Ext (Ext : String) return Boolean is
203    begin
204       return Ext = ".a";
205    end Is_Archive_Ext;
206
207    -------------
208    -- Libgnat --
209    -------------
210
211    function Libgnat return String is
212    begin
213       return "libgnat.a";
214    end Libgnat;
215
216    ------------------------
217    -- Library_Exists_For --
218    ------------------------
219
220    function Library_Exists_For (Project : Project_Id) return Boolean is
221    begin
222       if not Projects.Table (Project).Library then
223          Prj.Com.Fail ("INTERNAL ERROR: Library_Exists_For called " &
224                        "for non library project");
225          return False;
226
227       else
228          declare
229             Lib_Dir : constant String :=
230               Get_Name_String (Projects.Table (Project).Library_Dir);
231             Lib_Name : constant String :=
232               Get_Name_String (Projects.Table (Project).Library_Name);
233
234          begin
235             if Projects.Table (Project).Library_Kind = Static then
236                return Is_Regular_File
237                  (Lib_Dir & Directory_Separator & "lib" &
238                   Fil.Ext_To (Lib_Name, Archive_Ext));
239
240             else
241                return Is_Regular_File
242                  (Lib_Dir & Directory_Separator & "lib" &
243                   Fil.Ext_To (Lib_Name, DLL_Ext));
244             end if;
245          end;
246       end if;
247    end Library_Exists_For;
248
249    ---------------------------
250    -- Library_File_Name_For --
251    ---------------------------
252
253    function Library_File_Name_For (Project : Project_Id) return Name_Id is
254    begin
255       if not Projects.Table (Project).Library then
256          Prj.Com.Fail ("INTERNAL ERROR: Library_File_Name_For called " &
257                        "for non library project");
258          return No_Name;
259
260       else
261          declare
262             Lib_Name : constant String :=
263               Get_Name_String (Projects.Table (Project).Library_Name);
264
265          begin
266             Name_Len := 3;
267             Name_Buffer (1 .. Name_Len) := "lib";
268
269             if Projects.Table (Project).Library_Kind = Static then
270                Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, Archive_Ext));
271
272             else
273                Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, DLL_Ext));
274             end if;
275
276             return Name_Find;
277          end;
278       end if;
279    end Library_File_Name_For;
280
281    ----------------
282    -- Object_Ext --
283    ----------------
284
285    function Object_Ext return String is
286    begin
287       return "o";
288    end Object_Ext;
289
290    ----------------
291    -- PIC_Option --
292    ----------------
293
294    function PIC_Option return String is
295    begin
296       return "";
297    end PIC_Option;
298
299    -----------------------------------------------
300    -- Standalone_Library_Auto_Init_Is_Supported --
301    -----------------------------------------------
302
303    function Standalone_Library_Auto_Init_Is_Supported return Boolean is
304    begin
305       return False;
306    end Standalone_Library_Auto_Init_Is_Supported;
307
308    ---------------------------
309    -- Support_For_Libraries --
310    ---------------------------
311
312    function Support_For_Libraries return Library_Support is
313    begin
314       return Static_Only;
315    end Support_For_Libraries;
316
317 end MLib.Tgt;