1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
6 -- (Windows Version) --
10 -- Copyright (C) 2002-2006, Free Software Foundation, Inc. --
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. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
26 ------------------------------------------------------------------------------
28 -- This package provides a set of target dependent routines to build
29 -- static, dynamic and shared libraries.
31 -- This is the Windows version of the body. Works only with GCC versions
32 -- supporting the "-shared" option.
34 with Namet
; use Namet
;
36 with Output
; use Output
;
42 package body MLib
.Tgt
is
44 package Files
renames MLib
.Fil
;
45 package Tools
renames MLib
.Utl
;
47 No_Argument_List
: constant String_List
:= (1 .. 0 => null);
48 -- Used as value of parameter Options or Options2 in calls to Gcc
54 function Archive_Builder
return String is
59 -----------------------------
60 -- Archive_Builder_Options --
61 -----------------------------
63 function Archive_Builder_Options
return String_List_Access
is
65 return new String_List
'(1 => new String'("cr"));
66 end Archive_Builder_Options
;
72 function Archive_Ext
return String is
81 function Archive_Indexer
return String is
86 -----------------------------
87 -- Archive_Indexer_Options --
88 -----------------------------
90 function Archive_Indexer_Options
return String_List_Access
is
92 return new String_List
(1 .. 0);
93 end Archive_Indexer_Options
;
95 ---------------------------
96 -- Build_Dynamic_Library --
97 ---------------------------
99 procedure Build_Dynamic_Library
100 (Ofiles
: Argument_List
;
101 Foreign
: Argument_List
;
102 Afiles
: Argument_List
;
103 Options
: Argument_List
;
104 Options_2
: Argument_List
;
105 Interfaces
: Argument_List
;
106 Lib_Filename
: String;
108 Symbol_Data
: Symbol_Record
;
109 Driver_Name
: Name_Id
:= No_Name
;
110 Lib_Version
: String := "";
111 Auto_Init
: Boolean := False)
113 pragma Unreferenced
(Foreign
);
114 pragma Unreferenced
(Afiles
);
115 pragma Unreferenced
(Symbol_Data
);
116 pragma Unreferenced
(Interfaces
);
117 pragma Unreferenced
(Lib_Version
);
118 pragma Unreferenced
(Auto_Init
);
120 Lib_File
: constant String :=
121 Lib_Dir
& Directory_Separator
&
122 Files
.Append_To
(Lib_Filename
, DLL_Ext
);
124 -- Start of processing for Build_Dynamic_Library
127 if Opt
.Verbose_Mode
then
128 Write_Str
("building relocatable shared library ");
129 Write_Line
(Lib_File
);
133 (Output_File
=> Lib_File
,
135 Options
=> No_Argument_List
,
136 Options_2
=> Options
& Options_2
,
137 Driver_Name
=> Driver_Name
);
138 end Build_Dynamic_Library
;
144 function DLL_Ext
return String is
153 function DLL_Prefix
return String is
162 function Dynamic_Option
return String is
171 function Is_Object_Ext
(Ext
: String) return Boolean is
180 function Is_C_Ext
(Ext
: String) return Boolean is
189 function Is_Archive_Ext
(Ext
: String) return Boolean is
191 return Ext
= ".a" or else Ext
= ".dll";
198 function Libgnat
return String is
203 ------------------------
204 -- Library_Exists_For --
205 ------------------------
207 function Library_Exists_For
208 (Project
: Project_Id
;
209 In_Tree
: Project_Tree_Ref
) return Boolean is
211 if not In_Tree
.Projects
.Table
(Project
).Library
then
212 Prj
.Com
.Fail
("INTERNAL ERROR: Library_Exists_For called " &
213 "for non library project");
218 Lib_Dir
: constant String :=
220 (In_Tree
.Projects
.Table
(Project
).Library_Dir
);
221 Lib_Name
: constant String :=
223 (In_Tree
.Projects
.Table
(Project
).Library_Name
);
226 if In_Tree
.Projects
.Table
(Project
).Library_Kind
= Static
then
227 return Is_Regular_File
228 (Lib_Dir
& Directory_Separator
& "lib" &
229 MLib
.Fil
.Append_To
(Lib_Name
, Archive_Ext
));
232 return Is_Regular_File
233 (Lib_Dir
& Directory_Separator
&
234 MLib
.Fil
.Append_To
(Lib_Name
, DLL_Ext
));
238 end Library_Exists_For
;
240 ---------------------------
241 -- Library_File_Name_For --
242 ---------------------------
244 function Library_File_Name_For
245 (Project
: Project_Id
;
246 In_Tree
: Project_Tree_Ref
) return Name_Id
is
248 if not In_Tree
.Projects
.Table
(Project
).Library
then
249 Prj
.Com
.Fail
("INTERNAL ERROR: Library_File_Name_For called " &
250 "for non library project");
255 Lib_Name
: constant String :=
257 (In_Tree
.Projects
.Table
(Project
).Library_Name
);
260 if In_Tree
.Projects
.Table
(Project
).Library_Kind
=
264 Name_Buffer
(1 .. Name_Len
) := "lib";
265 Add_Str_To_Name_Buffer
(Fil
.Append_To
(Lib_Name
, Archive_Ext
));
269 Add_Str_To_Name_Buffer
(Fil
.Append_To
(Lib_Name
, DLL_Ext
));
275 end Library_File_Name_For
;
281 function Object_Ext
return String is
290 function PIC_Option
return String is
295 -----------------------------------------------
296 -- Standalone_Library_Auto_Init_Is_Supported --
297 -----------------------------------------------
299 function Standalone_Library_Auto_Init_Is_Supported
return Boolean is
302 end Standalone_Library_Auto_Init_Is_Supported
;
304 ---------------------------
305 -- Support_For_Libraries --
306 ---------------------------
308 function Support_For_Libraries
return Library_Support
is
311 end Support_For_Libraries
;