]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/ada/mlib-tgt-mingw.adb
0dddb89a6bdfaf176bd45ffb9598cedc6e8cc3e9
[thirdparty/gcc.git] / gcc / ada / mlib-tgt-mingw.adb
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- M L I B . T G T --
6 -- (Windows Version) --
7 -- --
8 -- B o d y --
9 -- --
10 -- Copyright (C) 2002-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, dynamic and shared libraries.
30
31 -- This is the Windows version of the body. Works only with GCC versions
32 -- supporting the "-shared" option.
33
34 with Namet; use Namet;
35 with Opt;
36 with Output; use Output;
37 with Prj.Com;
38
39 with GNAT.OS_Lib; use GNAT.OS_Lib;
40
41 with MLib.Fil;
42 with MLib.Utl;
43
44 package body MLib.Tgt is
45
46 package Files renames MLib.Fil;
47 package Tools renames MLib.Utl;
48
49 ---------------------
50 -- Archive_Builder --
51 ---------------------
52
53 function Archive_Builder return String is
54 begin
55 return "ar";
56 end Archive_Builder;
57
58 -----------------------------
59 -- Archive_Builder_Options --
60 -----------------------------
61
62 function Archive_Builder_Options return String_List_Access is
63 begin
64 return new String_List'(1 => new String'("cr"));
65 end Archive_Builder_Options;
66
67 -----------------
68 -- Archive_Ext --
69 -----------------
70
71 function Archive_Ext return String is
72 begin
73 return "a";
74 end Archive_Ext;
75
76 ---------------------
77 -- Archive_Indexer --
78 ---------------------
79
80 function Archive_Indexer return String is
81 begin
82 return "ranlib";
83 end Archive_Indexer;
84
85 ---------------------------
86 -- Build_Dynamic_Library --
87 ---------------------------
88
89 procedure Build_Dynamic_Library
90 (Ofiles : Argument_List;
91 Foreign : Argument_List;
92 Afiles : Argument_List;
93 Options : Argument_List;
94 Options_2 : Argument_List;
95 Interfaces : Argument_List;
96 Lib_Filename : String;
97 Lib_Dir : String;
98 Symbol_Data : Symbol_Record;
99 Driver_Name : Name_Id := No_Name;
100 Lib_Version : String := "";
101 Auto_Init : Boolean := False)
102 is
103 pragma Unreferenced (Foreign);
104 pragma Unreferenced (Afiles);
105 pragma Unreferenced (Auto_Init);
106 pragma Unreferenced (Symbol_Data);
107 pragma Unreferenced (Interfaces);
108 pragma Unreferenced (Lib_Version);
109
110 Lib_File : constant String :=
111 Lib_Dir & Directory_Separator &
112 Files.Ext_To (Lib_Filename, DLL_Ext);
113
114 -- Start of processing for Build_Dynamic_Library
115
116 begin
117 if Opt.Verbose_Mode then
118 Write_Str ("building relocatable shared library ");
119 Write_Line (Lib_File);
120 end if;
121
122 Tools.Gcc
123 (Output_File => Lib_File,
124 Objects => Ofiles,
125 Options => Tools.No_Argument_List,
126 Options_2 => Options & Options_2,
127 Driver_Name => Driver_Name);
128 end Build_Dynamic_Library;
129
130 -------------
131 -- DLL_Ext --
132 -------------
133
134 function DLL_Ext return String is
135 begin
136 return "dll";
137 end DLL_Ext;
138
139 --------------------
140 -- Dynamic_Option --
141 --------------------
142
143 function Dynamic_Option return String is
144 begin
145 return "-shared";
146 end Dynamic_Option;
147
148 -------------------
149 -- Is_Object_Ext --
150 -------------------
151
152 function Is_Object_Ext (Ext : String) return Boolean is
153 begin
154 return Ext = ".o";
155 end Is_Object_Ext;
156
157 --------------
158 -- Is_C_Ext --
159 --------------
160
161 function Is_C_Ext (Ext : String) return Boolean is
162 begin
163 return Ext = ".c";
164 end Is_C_Ext;
165
166 --------------------
167 -- Is_Archive_Ext --
168 --------------------
169
170 function Is_Archive_Ext (Ext : String) return Boolean is
171 begin
172 return Ext = ".a" or else Ext = ".dll";
173 end Is_Archive_Ext;
174
175 -------------
176 -- Libgnat --
177 -------------
178
179 function Libgnat return String is
180 begin
181 return "libgnat.a";
182 end Libgnat;
183
184 ------------------------
185 -- Library_Exists_For --
186 ------------------------
187
188 function Library_Exists_For (Project : Project_Id) return Boolean is
189 begin
190 if not Projects.Table (Project).Library then
191 Prj.Com.Fail ("INTERNAL ERROR: Library_Exists_For called " &
192 "for non library project");
193 return False;
194
195 else
196 declare
197 Lib_Dir : constant String :=
198 Get_Name_String
199 (Projects.Table (Project).Library_Dir);
200 Lib_Name : constant String :=
201 Get_Name_String
202 (Projects.Table (Project).Library_Name);
203
204 begin
205 if Projects.Table (Project).Library_Kind = Static then
206 return Is_Regular_File
207 (Lib_Dir & Directory_Separator & "lib" &
208 MLib.Fil.Ext_To (Lib_Name, Archive_Ext));
209
210 else
211 return Is_Regular_File
212 (Lib_Dir & Directory_Separator &
213 MLib.Fil.Ext_To (Lib_Name, DLL_Ext));
214 end if;
215 end;
216 end if;
217 end Library_Exists_For;
218
219 ---------------------------
220 -- Library_File_Name_For --
221 ---------------------------
222
223 function Library_File_Name_For (Project : Project_Id) return Name_Id is
224 begin
225 if not Projects.Table (Project).Library then
226 Prj.Com.Fail ("INTERNAL ERROR: Library_File_Name_For called " &
227 "for non library project");
228 return No_Name;
229
230 else
231 declare
232 Lib_Name : constant String :=
233 Get_Name_String (Projects.Table (Project).Library_Name);
234
235 begin
236 if Projects.Table (Project).Library_Kind = Static then
237 Name_Len := 3;
238 Name_Buffer (1 .. Name_Len) := "lib";
239 Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, Archive_Ext));
240
241 else
242 Name_Len := 0;
243 Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, DLL_Ext));
244 end if;
245
246 return Name_Find;
247 end;
248 end if;
249 end Library_File_Name_For;
250
251 ----------------
252 -- Object_Ext --
253 ----------------
254
255 function Object_Ext return String is
256 begin
257 return "o";
258 end Object_Ext;
259
260 ----------------
261 -- PIC_Option --
262 ----------------
263
264 function PIC_Option return String is
265 begin
266 return "";
267 end PIC_Option;
268
269 -----------------------------------------------
270 -- Standalone_Library_Auto_Init_Is_Supported --
271 -----------------------------------------------
272
273 function Standalone_Library_Auto_Init_Is_Supported return Boolean is
274 begin
275 return False;
276 end Standalone_Library_Auto_Init_Is_Supported;
277
278 ---------------------------
279 -- Support_For_Libraries --
280 ---------------------------
281
282 function Support_For_Libraries return Library_Support is
283 begin
284 return Full;
285 end Support_For_Libraries;
286
287 end MLib.Tgt;