OSDN Git Service

2005-06-15 Andrew Pinski <pinskia@physics.uc.edu>
[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,  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    -- 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    -- Dynamic_Option --
139    --------------------
140
141    function Dynamic_Option return String is
142    begin
143       return "";
144    end Dynamic_Option;
145
146    -----------------------------
147    -- Get_Target_Suffix --
148    -----------------------------
149
150    function Get_Target_Suffix return String is
151       Target_Name : constant String_Ptr := Sdefault.Target_Name;
152       Index       : Positive   := Target_Name'First;
153
154    begin
155       while Index < Target_Name'Last
156         and then Target_Name (Index + 1) /= '-'
157       loop
158          Index := Index + 1;
159       end loop;
160
161       if Target_Name (Target_Name'First .. Index) = "m68k" then
162          return "68k";
163       elsif Target_Name (Target_Name'First .. Index) = "mips" then
164          return "mips";
165       elsif Target_Name (Target_Name'First .. Index) = "powerpc" then
166          return "ppc";
167       elsif Target_Name (Target_Name'First .. Index) = "sparc" then
168          return "sparc";
169       elsif Target_Name (Target_Name'First .. Index) = "sparc64" then
170          return "sparc64";
171       elsif Target_Name (Target_Name'First .. Index) = "xscale" then
172          return "arm";
173       else
174          return "";
175       end if;
176    end Get_Target_Suffix;
177
178    -------------------
179    -- Is_Object_Ext --
180    -------------------
181
182    function Is_Object_Ext (Ext : String) return Boolean is
183    begin
184       return Ext = ".o";
185    end Is_Object_Ext;
186
187    --------------
188    -- Is_C_Ext --
189    --------------
190
191    function Is_C_Ext (Ext : String) return Boolean is
192    begin
193       return Ext = ".c";
194    end Is_C_Ext;
195
196    --------------------
197    -- Is_Archive_Ext --
198    --------------------
199
200    function Is_Archive_Ext (Ext : String) return Boolean is
201    begin
202       return Ext = ".a";
203    end Is_Archive_Ext;
204
205    -------------
206    -- Libgnat --
207    -------------
208
209    function Libgnat return String is
210    begin
211       return "libgnat.a";
212    end Libgnat;
213
214    ------------------------
215    -- Library_Exists_For --
216    ------------------------
217
218    function Library_Exists_For
219      (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean
220    is
221    begin
222       if not In_Tree.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
231                 (In_Tree.Projects.Table (Project).Library_Dir);
232             Lib_Name : constant String :=
233               Get_Name_String
234                 (In_Tree.Projects.Table (Project).Library_Name);
235
236          begin
237             if In_Tree.Projects.Table (Project).Library_Kind =
238               Static
239             then
240                return Is_Regular_File
241                  (Lib_Dir & Directory_Separator & "lib" &
242                   Fil.Ext_To (Lib_Name, Archive_Ext));
243
244             else
245                return Is_Regular_File
246                  (Lib_Dir & Directory_Separator & "lib" &
247                   Fil.Ext_To (Lib_Name, DLL_Ext));
248             end if;
249          end;
250       end if;
251    end Library_Exists_For;
252
253    ---------------------------
254    -- Library_File_Name_For --
255    ---------------------------
256
257    function Library_File_Name_For
258      (Project : Project_Id;
259       In_Tree : Project_Tree_Ref) return Name_Id
260    is
261    begin
262       if not In_Tree.Projects.Table (Project).Library then
263          Prj.Com.Fail ("INTERNAL ERROR: Library_File_Name_For called " &
264                        "for non library project");
265          return No_Name;
266
267       else
268          declare
269             Lib_Name : constant String :=
270               Get_Name_String
271                 (In_Tree.Projects.Table (Project).Library_Name);
272
273          begin
274             Name_Len := 3;
275             Name_Buffer (1 .. Name_Len) := "lib";
276
277             if In_Tree.Projects.Table (Project).Library_Kind =
278               Static
279             then
280                Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, Archive_Ext));
281
282             else
283                Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, DLL_Ext));
284             end if;
285
286             return Name_Find;
287          end;
288       end if;
289    end Library_File_Name_For;
290
291    ----------------
292    -- Object_Ext --
293    ----------------
294
295    function Object_Ext return String is
296    begin
297       return "o";
298    end Object_Ext;
299
300    ----------------
301    -- PIC_Option --
302    ----------------
303
304    function PIC_Option return String is
305    begin
306       return "";
307    end PIC_Option;
308
309    -----------------------------------------------
310    -- Standalone_Library_Auto_Init_Is_Supported --
311    -----------------------------------------------
312
313    function Standalone_Library_Auto_Init_Is_Supported return Boolean is
314    begin
315       return False;
316    end Standalone_Library_Auto_Init_Is_Supported;
317
318    ---------------------------
319    -- Support_For_Libraries --
320    ---------------------------
321
322    function Support_For_Libraries return Library_Support is
323    begin
324       return Static_Only;
325    end Support_For_Libraries;
326
327 end MLib.Tgt;