OSDN Git Service

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