OSDN Git Service

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