gcc:
[official-gcc.git] / gcc / ada / mlib-tgt-vxworks.adb
blobb9e24afb22727cf4e12283875a798fca02471eee
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-2006 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 ------------------------------------------------------------------------------
28 -- This package provides a set of target dependent routines to build
29 -- static libraries.
31 -- This is the VxWorks version of the body
33 with MLib.Fil;
34 with Namet; use Namet;
35 with Prj.Com;
36 with Sdefault;
38 package body MLib.Tgt is
40 -----------------------
41 -- Local Subprograms --
42 -----------------------
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.
48 ---------------------
49 -- Archive_Builder --
50 ---------------------
52 function Archive_Builder return String is
53 begin
54 return "ar" & Get_Target_Suffix;
55 end Archive_Builder;
57 -----------------------------
58 -- Archive_Builder_Options --
59 -----------------------------
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;
66 -----------------
67 -- Archive_Ext --
68 -----------------
70 function Archive_Ext return String is
71 begin
72 return "a";
73 end Archive_Ext;
75 ---------------------
76 -- Archive_Indexer --
77 ---------------------
79 function Archive_Indexer return String is
80 begin
81 return "ranlib" & Get_Target_Suffix;
82 end Archive_Indexer;
84 -----------------------------
85 -- Archive_Indexer_Options --
86 -----------------------------
88 function Archive_Indexer_Options return String_List_Access is
89 begin
90 return new String_List (1 .. 0);
91 end Archive_Indexer_Options;
93 ---------------------------
94 -- Build_Dynamic_Library --
95 ---------------------------
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)
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);
124 begin
125 null;
126 end Build_Dynamic_Library;
128 -------------
129 -- DLL_Ext --
130 -------------
132 function DLL_Ext return String is
133 begin
134 return "";
135 end DLL_Ext;
137 ----------------
138 -- DLL_Prefix --
139 ----------------
141 function DLL_Prefix return String is
142 begin
143 return "lib";
144 end DLL_Prefix;
146 --------------------
147 -- Dynamic_Option --
148 --------------------
150 function Dynamic_Option return String is
151 begin
152 return "";
153 end Dynamic_Option;
155 -----------------------------
156 -- Get_Target_Suffix --
157 -----------------------------
159 function Get_Target_Suffix return String is
160 Target_Name : constant String_Ptr := Sdefault.Target_Name;
161 Index : Positive := Target_Name'First;
163 begin
164 while Index < Target_Name'Last
165 and then Target_Name (Index + 1) /= '-'
166 loop
167 Index := Index + 1;
168 end loop;
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 elsif Target_Name (Target_Name'First .. Index) = "i586" then
183 return "pentium";
184 else
185 return "";
186 end if;
187 end Get_Target_Suffix;
189 -------------------
190 -- Is_Object_Ext --
191 -------------------
193 function Is_Object_Ext (Ext : String) return Boolean is
194 begin
195 return Ext = ".o";
196 end Is_Object_Ext;
198 --------------
199 -- Is_C_Ext --
200 --------------
202 function Is_C_Ext (Ext : String) return Boolean is
203 begin
204 return Ext = ".c";
205 end Is_C_Ext;
207 --------------------
208 -- Is_Archive_Ext --
209 --------------------
211 function Is_Archive_Ext (Ext : String) return Boolean is
212 begin
213 return Ext = ".a";
214 end Is_Archive_Ext;
216 -------------
217 -- Libgnat --
218 -------------
220 function Libgnat return String is
221 begin
222 return "libgnat.a";
223 end Libgnat;
225 ------------------------
226 -- Library_Exists_For --
227 ------------------------
229 function Library_Exists_For
230 (Project : Project_Id;
231 In_Tree : Project_Tree_Ref) return Boolean
233 begin
234 if not In_Tree.Projects.Table (Project).Library then
235 Prj.Com.Fail ("INTERNAL ERROR: Library_Exists_For called " &
236 "for non library project");
237 return False;
239 else
240 declare
241 Lib_Dir : constant String :=
242 Get_Name_String
243 (In_Tree.Projects.Table (Project).Library_Dir);
244 Lib_Name : constant String :=
245 Get_Name_String
246 (In_Tree.Projects.Table (Project).Library_Name);
248 begin
249 if In_Tree.Projects.Table (Project).Library_Kind = Static then
250 return Is_Regular_File
251 (Lib_Dir & Directory_Separator & "lib" &
252 Fil.Append_To (Lib_Name, Archive_Ext));
254 else
255 return Is_Regular_File
256 (Lib_Dir & Directory_Separator & "lib" &
257 Fil.Append_To (Lib_Name, DLL_Ext));
258 end if;
259 end;
260 end if;
261 end Library_Exists_For;
263 ---------------------------
264 -- Library_File_Name_For --
265 ---------------------------
267 function Library_File_Name_For
268 (Project : Project_Id;
269 In_Tree : Project_Tree_Ref) return Name_Id
271 begin
272 if not In_Tree.Projects.Table (Project).Library then
273 Prj.Com.Fail ("INTERNAL ERROR: Library_File_Name_For called " &
274 "for non library project");
275 return No_Name;
277 else
278 declare
279 Lib_Name : constant String :=
280 Get_Name_String
281 (In_Tree.Projects.Table (Project).Library_Name);
283 begin
284 Name_Len := 3;
285 Name_Buffer (1 .. Name_Len) := "lib";
287 if In_Tree.Projects.Table (Project).Library_Kind =
288 Static
289 then
290 Add_Str_To_Name_Buffer (Fil.Append_To (Lib_Name, Archive_Ext));
291 else
292 Add_Str_To_Name_Buffer (Fil.Append_To (Lib_Name, DLL_Ext));
293 end if;
295 return Name_Find;
296 end;
297 end if;
298 end Library_File_Name_For;
300 ----------------
301 -- Object_Ext --
302 ----------------
304 function Object_Ext return String is
305 begin
306 return "o";
307 end Object_Ext;
309 ----------------
310 -- PIC_Option --
311 ----------------
313 function PIC_Option return String is
314 begin
315 return "";
316 end PIC_Option;
318 -----------------------------------------------
319 -- Standalone_Library_Auto_Init_Is_Supported --
320 -----------------------------------------------
322 function Standalone_Library_Auto_Init_Is_Supported return Boolean is
323 begin
324 return False;
325 end Standalone_Library_Auto_Init_Is_Supported;
327 ---------------------------
328 -- Support_For_Libraries --
329 ---------------------------
331 function Support_For_Libraries return Library_Support is
332 begin
333 return Static_Only;
334 end Support_For_Libraries;
336 end MLib.Tgt;