1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
6 -- (Windows Version) --
10 -- Copyright (C) 2002-2004, 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, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, 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
;
39 with GNAT
.OS_Lib
; use GNAT
.OS_Lib
;
44 package body MLib
.Tgt
is
46 package Files
renames MLib
.Fil
;
47 package Tools
renames MLib
.Utl
;
53 function Archive_Builder
return String is
58 -----------------------------
59 -- Archive_Builder_Options --
60 -----------------------------
62 function Archive_Builder_Options
return String_List_Access
is
64 return new String_List
'(1 => new String'("cr"));
65 end Archive_Builder_Options
;
71 function Archive_Ext
return String is
80 function Archive_Indexer
return String is
85 ---------------------------
86 -- Build_Dynamic_Library --
87 ---------------------------
89 procedure Build_Dynamic_Library
90 (Ofiles
: Argument_List
;
91 Foreign
: Argument_List
;
92 Afiles
: Argument_List
;
93 Options
: Argument_List
;
94 Interfaces
: Argument_List
;
95 Lib_Filename
: String;
97 Symbol_Data
: Symbol_Record
;
98 Driver_Name
: Name_Id
:= No_Name
;
99 Lib_Version
: String := "";
100 Auto_Init
: Boolean := False)
102 pragma Unreferenced
(Foreign
);
103 pragma Unreferenced
(Afiles
);
104 pragma Unreferenced
(Auto_Init
);
105 pragma Unreferenced
(Symbol_Data
);
106 pragma Unreferenced
(Interfaces
);
107 pragma Unreferenced
(Lib_Version
);
109 Lib_File
: constant String :=
110 Lib_Dir
& Directory_Separator
&
111 Files
.Ext_To
(Lib_Filename
, DLL_Ext
);
113 -- Start of processing for Build_Dynamic_Library
116 if Opt
.Verbose_Mode
then
117 Write_Str
("building relocatable shared library ");
118 Write_Line
(Lib_File
);
122 (Output_File
=> Lib_File
,
124 Options
=> Tools
.No_Argument_List
,
125 Options_2
=> Options
,
126 Driver_Name
=> Driver_Name
);
127 end Build_Dynamic_Library
;
133 function DLL_Ext
return String is
142 function Dynamic_Option
return String is
151 function Is_Object_Ext
(Ext
: String) return Boolean is
160 function Is_C_Ext
(Ext
: String) return Boolean is
169 function Is_Archive_Ext
(Ext
: String) return Boolean is
171 return Ext
= ".a" or else Ext
= ".dll";
178 function Libgnat
return String is
183 ------------------------
184 -- Library_Exists_For --
185 ------------------------
187 function Library_Exists_For
(Project
: Project_Id
) return Boolean is
189 if not Projects
.Table
(Project
).Library
then
190 Prj
.Com
.Fail
("INTERNAL ERROR: Library_Exists_For called " &
191 "for non library project");
196 Lib_Dir
: constant String :=
198 (Projects
.Table
(Project
).Library_Dir
);
199 Lib_Name
: constant String :=
201 (Projects
.Table
(Project
).Library_Name
);
204 if Projects
.Table
(Project
).Library_Kind
= Static
then
205 return Is_Regular_File
206 (Lib_Dir
& Directory_Separator
& "lib" &
207 MLib
.Fil
.Ext_To
(Lib_Name
, Archive_Ext
));
210 return Is_Regular_File
211 (Lib_Dir
& Directory_Separator
&
212 MLib
.Fil
.Ext_To
(Lib_Name
, DLL_Ext
));
216 end Library_Exists_For
;
218 ---------------------------
219 -- Library_File_Name_For --
220 ---------------------------
222 function Library_File_Name_For
(Project
: Project_Id
) return Name_Id
is
224 if not Projects
.Table
(Project
).Library
then
225 Prj
.Com
.Fail
("INTERNAL ERROR: Library_File_Name_For called " &
226 "for non library project");
231 Lib_Name
: constant String :=
232 Get_Name_String
(Projects
.Table
(Project
).Library_Name
);
235 if Projects
.Table
(Project
).Library_Kind
= Static
then
237 Name_Buffer
(1 .. Name_Len
) := "lib";
238 Add_Str_To_Name_Buffer
(Fil
.Ext_To
(Lib_Name
, Archive_Ext
));
242 Add_Str_To_Name_Buffer
(Fil
.Ext_To
(Lib_Name
, DLL_Ext
));
248 end Library_File_Name_For
;
254 function Object_Ext
return String is
263 function PIC_Option
return String is
268 -----------------------------------------------
269 -- Standalone_Library_Auto_Init_Is_Supported --
270 -----------------------------------------------
272 function Standalone_Library_Auto_Init_Is_Supported
return Boolean is
275 end Standalone_Library_Auto_Init_Is_Supported
;
277 ---------------------------
278 -- Support_For_Libraries --
279 ---------------------------
281 function Support_For_Libraries
return Library_Support
is
284 end Support_For_Libraries
;