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 -- Archive_Indexer_Options --
87 -----------------------------
89 function Archive_Indexer_Options
return String_List_Access
is
91 return new String_List
(1 .. 0);
92 end Archive_Indexer_Options
;
94 ---------------------------
95 -- Build_Dynamic_Library --
96 ---------------------------
98 procedure Build_Dynamic_Library
99 (Ofiles
: Argument_List
;
100 Foreign
: Argument_List
;
101 Afiles
: Argument_List
;
102 Options
: Argument_List
;
103 Options_2
: Argument_List
;
104 Interfaces
: Argument_List
;
105 Lib_Filename
: String;
107 Symbol_Data
: Symbol_Record
;
108 Driver_Name
: Name_Id
:= No_Name
;
109 Lib_Version
: String := "";
110 Auto_Init
: Boolean := False)
112 pragma Unreferenced
(Foreign
);
113 pragma Unreferenced
(Afiles
);
114 pragma Unreferenced
(Auto_Init
);
115 pragma Unreferenced
(Symbol_Data
);
116 pragma Unreferenced
(Interfaces
);
117 pragma Unreferenced
(Lib_Version
);
119 Lib_File
: constant String :=
120 Lib_Dir
& Directory_Separator
&
121 Files
.Ext_To
(Lib_Filename
, DLL_Ext
);
123 -- Start of processing for Build_Dynamic_Library
126 if Opt
.Verbose_Mode
then
127 Write_Str
("building relocatable shared library ");
128 Write_Line
(Lib_File
);
132 (Output_File
=> Lib_File
,
134 Options
=> Tools
.No_Argument_List
,
135 Options_2
=> Options
& Options_2
,
136 Driver_Name
=> Driver_Name
);
137 end Build_Dynamic_Library
;
143 function DLL_Ext
return String is
152 function Dynamic_Option
return String is
161 function Is_Object_Ext
(Ext
: String) return Boolean is
170 function Is_C_Ext
(Ext
: String) return Boolean is
179 function Is_Archive_Ext
(Ext
: String) return Boolean is
181 return Ext
= ".a" or else Ext
= ".dll";
188 function Libgnat
return String is
193 ------------------------
194 -- Library_Exists_For --
195 ------------------------
197 function Library_Exists_For
(Project
: Project_Id
) return Boolean is
199 if not Projects
.Table
(Project
).Library
then
200 Prj
.Com
.Fail
("INTERNAL ERROR: Library_Exists_For called " &
201 "for non library project");
206 Lib_Dir
: constant String :=
208 (Projects
.Table
(Project
).Library_Dir
);
209 Lib_Name
: constant String :=
211 (Projects
.Table
(Project
).Library_Name
);
214 if Projects
.Table
(Project
).Library_Kind
= Static
then
215 return Is_Regular_File
216 (Lib_Dir
& Directory_Separator
& "lib" &
217 MLib
.Fil
.Ext_To
(Lib_Name
, Archive_Ext
));
220 return Is_Regular_File
221 (Lib_Dir
& Directory_Separator
&
222 MLib
.Fil
.Ext_To
(Lib_Name
, DLL_Ext
));
226 end Library_Exists_For
;
228 ---------------------------
229 -- Library_File_Name_For --
230 ---------------------------
232 function Library_File_Name_For
(Project
: Project_Id
) return Name_Id
is
234 if not Projects
.Table
(Project
).Library
then
235 Prj
.Com
.Fail
("INTERNAL ERROR: Library_File_Name_For called " &
236 "for non library project");
241 Lib_Name
: constant String :=
242 Get_Name_String
(Projects
.Table
(Project
).Library_Name
);
245 if Projects
.Table
(Project
).Library_Kind
= Static
then
247 Name_Buffer
(1 .. Name_Len
) := "lib";
248 Add_Str_To_Name_Buffer
(Fil
.Ext_To
(Lib_Name
, Archive_Ext
));
252 Add_Str_To_Name_Buffer
(Fil
.Ext_To
(Lib_Name
, DLL_Ext
));
258 end Library_File_Name_For
;
264 function Object_Ext
return String is
273 function PIC_Option
return String is
278 -----------------------------------------------
279 -- Standalone_Library_Auto_Init_Is_Supported --
280 -----------------------------------------------
282 function Standalone_Library_Auto_Init_Is_Supported
return Boolean is
285 end Standalone_Library_Auto_Init_Is_Supported
;
287 ---------------------------
288 -- Support_For_Libraries --
289 ---------------------------
291 function Support_For_Libraries
return Library_Support
is
294 end Support_For_Libraries
;