1 |
281 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT COMPILER COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- M L I B . T G T --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- Copyright (C) 2001-2009, AdaCore --
|
10 |
|
|
-- --
|
11 |
|
|
-- GNAT is free software; you can redistribute it and/or modify it under --
|
12 |
|
|
-- terms of the GNU General Public License as published by the Free Soft- --
|
13 |
|
|
-- ware Foundation; either version 3, or (at your option) any later ver- --
|
14 |
|
|
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
15 |
|
|
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
16 |
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
|
17 |
|
|
-- for more details. You should have received a copy of the GNU General --
|
18 |
|
|
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
|
19 |
|
|
-- http://www.gnu.org/licenses for a complete copy of the license. --
|
20 |
|
|
-- --
|
21 |
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
22 |
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
23 |
|
|
-- --
|
24 |
|
|
------------------------------------------------------------------------------
|
25 |
|
|
|
26 |
|
|
-- This package provides a set of target dependent routines to build static,
|
27 |
|
|
-- dynamic and shared libraries. There are several packages providing
|
28 |
|
|
-- the actual routines. This package calls them indirectly by means of
|
29 |
|
|
-- access-to-subprogram values. Each target-dependent package initializes
|
30 |
|
|
-- these values in its elaboration block.
|
31 |
|
|
|
32 |
|
|
with Prj; use Prj;
|
33 |
|
|
|
34 |
|
|
package MLib.Tgt is
|
35 |
|
|
|
36 |
|
|
function Support_For_Libraries return Library_Support;
|
37 |
|
|
-- Indicates how building libraries by gnatmake is supported by the GNAT
|
38 |
|
|
-- implementation for the platform.
|
39 |
|
|
|
40 |
|
|
function Standalone_Library_Auto_Init_Is_Supported return Boolean;
|
41 |
|
|
-- Indicates if when building a dynamic Standalone Library,
|
42 |
|
|
-- automatic initialization is supported. If it is, then it is the default,
|
43 |
|
|
-- unless attribute Library_Auto_Init has the value "false".
|
44 |
|
|
|
45 |
|
|
function Archive_Builder return String;
|
46 |
|
|
-- Returns the name of the archive builder program, usually "ar"
|
47 |
|
|
|
48 |
|
|
function Archive_Builder_Options return String_List_Access;
|
49 |
|
|
-- A list of options to invoke the Archive_Builder, usually "cr" for "ar"
|
50 |
|
|
|
51 |
|
|
function Archive_Builder_Append_Options return String_List_Access;
|
52 |
|
|
-- A list of options to use with the archive builder to append object
|
53 |
|
|
-- files ("q", for example).
|
54 |
|
|
|
55 |
|
|
function Archive_Indexer return String;
|
56 |
|
|
-- Returns the name of the program, if any, that generates an index to the
|
57 |
|
|
-- contents of an archive, usually "ranlib". If there is no archive indexer
|
58 |
|
|
-- to be used, returns an empty string.
|
59 |
|
|
|
60 |
|
|
function Archive_Indexer_Options return String_List_Access;
|
61 |
|
|
-- A list of options to invoke the Archive_Indexer, usually empty
|
62 |
|
|
|
63 |
|
|
function Dynamic_Option return String;
|
64 |
|
|
-- gcc option to create a dynamic library.
|
65 |
|
|
-- For Unix, returns "-shared", for Windows returns "-mdll".
|
66 |
|
|
|
67 |
|
|
function Libgnat return String;
|
68 |
|
|
-- System dependent static GNAT library
|
69 |
|
|
|
70 |
|
|
function Archive_Ext return String;
|
71 |
|
|
-- System dependent static library extension, without leading dot.
|
72 |
|
|
-- For Unix and Windows, return "a".
|
73 |
|
|
|
74 |
|
|
function Object_Ext return String;
|
75 |
|
|
-- System dependent object extension, without leading dot.
|
76 |
|
|
-- On Unix, returns "o".
|
77 |
|
|
|
78 |
|
|
function DLL_Prefix return String;
|
79 |
|
|
-- System dependent dynamic library prefix.
|
80 |
|
|
-- On Windows, returns "". On other platforms, returns "lib".
|
81 |
|
|
|
82 |
|
|
function DLL_Ext return String;
|
83 |
|
|
-- System dependent dynamic library extension, without leading dot.
|
84 |
|
|
-- On Windows, returns "dll". On Unix, usually returns "so", but not
|
85 |
|
|
-- always, e.g. on HP-UX the extension for shared libraries is "sl".
|
86 |
|
|
|
87 |
|
|
function PIC_Option return String;
|
88 |
|
|
-- Position independent code option
|
89 |
|
|
|
90 |
|
|
function Is_Object_Ext (Ext : String) return Boolean;
|
91 |
|
|
-- Returns True iff Ext is an object file extension
|
92 |
|
|
|
93 |
|
|
function Is_C_Ext (Ext : String) return Boolean;
|
94 |
|
|
-- Returns True iff Ext is a C file extension
|
95 |
|
|
|
96 |
|
|
function Is_Archive_Ext (Ext : String) return Boolean;
|
97 |
|
|
-- Returns True iff Ext is an extension for a library
|
98 |
|
|
|
99 |
|
|
function Default_Symbol_File_Name return String;
|
100 |
|
|
-- Returns the name of the symbol file when Library_Symbol_File is not
|
101 |
|
|
-- specified. Return the empty string when symbol files are not supported.
|
102 |
|
|
|
103 |
|
|
procedure Build_Dynamic_Library
|
104 |
|
|
(Ofiles : Argument_List;
|
105 |
|
|
Options : Argument_List;
|
106 |
|
|
Interfaces : Argument_List;
|
107 |
|
|
Lib_Filename : String;
|
108 |
|
|
Lib_Dir : String;
|
109 |
|
|
Symbol_Data : Symbol_Record;
|
110 |
|
|
Driver_Name : Name_Id := No_Name;
|
111 |
|
|
Lib_Version : String := "";
|
112 |
|
|
Auto_Init : Boolean := False);
|
113 |
|
|
-- Build a dynamic/relocatable library
|
114 |
|
|
--
|
115 |
|
|
-- Ofiles is the list of all object files in the library
|
116 |
|
|
--
|
117 |
|
|
-- Options is a list of options to be passed to the tool
|
118 |
|
|
-- (gcc or other) that effectively builds the dynamic library.
|
119 |
|
|
--
|
120 |
|
|
-- Interfaces is the list of ALI files for the interfaces of a SAL.
|
121 |
|
|
-- It is empty if the library is not a SAL.
|
122 |
|
|
--
|
123 |
|
|
-- Lib_Filename is the name of the library, without any prefix or
|
124 |
|
|
-- extension. For example, on Unix, if Lib_Filename is "toto", the
|
125 |
|
|
-- name of the library file will be "libtoto.so".
|
126 |
|
|
--
|
127 |
|
|
-- Lib_Dir is the directory path where the library will be located
|
128 |
|
|
--
|
129 |
|
|
-- For OSes that support symbolic links, Lib_Version, if non null,
|
130 |
|
|
-- is the actual file name of the library. For example on Unix, if
|
131 |
|
|
-- Lib_Filename is "toto" and Lib_Version is "libtoto.so.2.1",
|
132 |
|
|
-- "libtoto.so" will be a symbolic link to "libtoto.so.2.1" which
|
133 |
|
|
-- will be the actual library file.
|
134 |
|
|
--
|
135 |
|
|
-- Symbol_Data is used for some platforms, including VMS, to generate
|
136 |
|
|
-- the symbols to be exported by the library.
|
137 |
|
|
--
|
138 |
|
|
-- Note: Depending on the OS, some of the parameters may not be taken into
|
139 |
|
|
-- account. For example, on Linux, Interfaces, Symbol_Data and Auto_Init
|
140 |
|
|
-- are ignored.
|
141 |
|
|
|
142 |
|
|
function Library_Exists_For
|
143 |
|
|
(Project : Project_Id;
|
144 |
|
|
In_Tree : Project_Tree_Ref) return Boolean;
|
145 |
|
|
-- Return True if the library file for a library project already exists.
|
146 |
|
|
-- This function can only be called for library projects.
|
147 |
|
|
|
148 |
|
|
function Library_File_Name_For
|
149 |
|
|
(Project : Project_Id;
|
150 |
|
|
In_Tree : Project_Tree_Ref) return File_Name_Type;
|
151 |
|
|
-- Returns the file name of the library file of a library project.
|
152 |
|
|
-- This function can only be called for library projects.
|
153 |
|
|
|
154 |
|
|
function Library_Major_Minor_Id_Supported return Boolean;
|
155 |
|
|
-- Indicates if major and minor ids are supported for libraries.
|
156 |
|
|
-- If they are supported, then a Library_Version such as libtoto.so.1.2
|
157 |
|
|
-- will have a major id of 1 and a minor id of 2. Then libtoto.so,
|
158 |
|
|
-- libtoto.so.1 and libtoto.so.1.2 will be created, all three designating
|
159 |
|
|
-- the same file.
|
160 |
|
|
|
161 |
|
|
private
|
162 |
|
|
No_Argument_List : constant Argument_List := (1 .. 0 => null);
|
163 |
|
|
|
164 |
|
|
-- Access to subprogram types for indirection
|
165 |
|
|
|
166 |
|
|
type String_Function is access function return String;
|
167 |
|
|
type Is_Ext_Function is access function (Ext : String) return Boolean;
|
168 |
|
|
type String_List_Access_Function is access function
|
169 |
|
|
return String_List_Access;
|
170 |
|
|
|
171 |
|
|
type Build_Dynamic_Library_Function is access procedure
|
172 |
|
|
(Ofiles : Argument_List;
|
173 |
|
|
Options : Argument_List;
|
174 |
|
|
Interfaces : Argument_List;
|
175 |
|
|
Lib_Filename : String;
|
176 |
|
|
Lib_Dir : String;
|
177 |
|
|
Symbol_Data : Symbol_Record;
|
178 |
|
|
Driver_Name : Name_Id := No_Name;
|
179 |
|
|
Lib_Version : String := "";
|
180 |
|
|
Auto_Init : Boolean := False);
|
181 |
|
|
|
182 |
|
|
type Library_Exists_For_Function is access function
|
183 |
|
|
(Project : Project_Id;
|
184 |
|
|
In_Tree : Project_Tree_Ref) return Boolean;
|
185 |
|
|
|
186 |
|
|
type Library_File_Name_For_Function is access function
|
187 |
|
|
(Project : Project_Id;
|
188 |
|
|
In_Tree : Project_Tree_Ref) return File_Name_Type;
|
189 |
|
|
|
190 |
|
|
type Boolean_Function is access function return Boolean;
|
191 |
|
|
type Library_Support_Function is access function return Library_Support;
|
192 |
|
|
|
193 |
|
|
function Archive_Builder_Default return String;
|
194 |
|
|
Archive_Builder_Ptr : String_Function := Archive_Builder_Default'Access;
|
195 |
|
|
|
196 |
|
|
function Archive_Builder_Options_Default return String_List_Access;
|
197 |
|
|
Archive_Builder_Options_Ptr : String_List_Access_Function :=
|
198 |
|
|
Archive_Builder_Options_Default'Access;
|
199 |
|
|
|
200 |
|
|
function Archive_Builder_Append_Options_Default return String_List_Access;
|
201 |
|
|
Archive_Builder_Append_Options_Ptr : String_List_Access_Function :=
|
202 |
|
|
Archive_Builder_Append_Options_Default'Access;
|
203 |
|
|
|
204 |
|
|
function Archive_Ext_Default return String;
|
205 |
|
|
Archive_Ext_Ptr : String_Function := Archive_Ext_Default'Access;
|
206 |
|
|
|
207 |
|
|
function Archive_Indexer_Default return String;
|
208 |
|
|
Archive_Indexer_Ptr : String_Function := Archive_Indexer_Default'Access;
|
209 |
|
|
|
210 |
|
|
function Archive_Indexer_Options_Default return String_List_Access;
|
211 |
|
|
Archive_Indexer_Options_Ptr : String_List_Access_Function :=
|
212 |
|
|
Archive_Indexer_Options_Default'Access;
|
213 |
|
|
|
214 |
|
|
function Default_Symbol_File_Name_Default return String;
|
215 |
|
|
Default_Symbol_File_Name_Ptr : String_Function :=
|
216 |
|
|
Default_Symbol_File_Name_Default'Access;
|
217 |
|
|
|
218 |
|
|
Build_Dynamic_Library_Ptr : Build_Dynamic_Library_Function;
|
219 |
|
|
|
220 |
|
|
function DLL_Ext_Default return String;
|
221 |
|
|
DLL_Ext_Ptr : String_Function := DLL_Ext_Default'Access;
|
222 |
|
|
|
223 |
|
|
function DLL_Prefix_Default return String;
|
224 |
|
|
DLL_Prefix_Ptr : String_Function := DLL_Prefix_Default'Access;
|
225 |
|
|
|
226 |
|
|
function Dynamic_Option_Default return String;
|
227 |
|
|
Dynamic_Option_Ptr : String_Function := Dynamic_Option_Default'Access;
|
228 |
|
|
|
229 |
|
|
function Is_Object_Ext_Default (Ext : String) return Boolean;
|
230 |
|
|
Is_Object_Ext_Ptr : Is_Ext_Function := Is_Object_Ext_Default'Access;
|
231 |
|
|
|
232 |
|
|
function Is_C_Ext_Default (Ext : String) return Boolean;
|
233 |
|
|
Is_C_Ext_Ptr : Is_Ext_Function := Is_C_Ext_Default'Access;
|
234 |
|
|
|
235 |
|
|
function Is_Archive_Ext_Default (Ext : String) return Boolean;
|
236 |
|
|
Is_Archive_Ext_Ptr : Is_Ext_Function := Is_Archive_Ext_Default'Access;
|
237 |
|
|
|
238 |
|
|
function Libgnat_Default return String;
|
239 |
|
|
Libgnat_Ptr : String_Function := Libgnat_Default'Access;
|
240 |
|
|
|
241 |
|
|
function Library_Exists_For_Default
|
242 |
|
|
(Project : Project_Id;
|
243 |
|
|
In_Tree : Project_Tree_Ref) return Boolean;
|
244 |
|
|
Library_Exists_For_Ptr : Library_Exists_For_Function :=
|
245 |
|
|
Library_Exists_For_Default'Access;
|
246 |
|
|
|
247 |
|
|
function Library_File_Name_For_Default
|
248 |
|
|
(Project : Project_Id;
|
249 |
|
|
In_Tree : Project_Tree_Ref) return File_Name_Type;
|
250 |
|
|
Library_File_Name_For_Ptr : Library_File_Name_For_Function :=
|
251 |
|
|
Library_File_Name_For_Default'Access;
|
252 |
|
|
|
253 |
|
|
function Object_Ext_Default return String;
|
254 |
|
|
Object_Ext_Ptr : String_Function := Object_Ext_Default'Access;
|
255 |
|
|
|
256 |
|
|
function PIC_Option_Default return String;
|
257 |
|
|
PIC_Option_Ptr : String_Function := PIC_Option_Default'Access;
|
258 |
|
|
|
259 |
|
|
function Standalone_Library_Auto_Init_Is_Supported_Default return Boolean;
|
260 |
|
|
Standalone_Library_Auto_Init_Is_Supported_Ptr : Boolean_Function :=
|
261 |
|
|
Standalone_Library_Auto_Init_Is_Supported_Default'Access;
|
262 |
|
|
|
263 |
|
|
function Support_For_Libraries_Default return Library_Support;
|
264 |
|
|
Support_For_Libraries_Ptr : Library_Support_Function :=
|
265 |
|
|
Support_For_Libraries_Default'Access;
|
266 |
|
|
|
267 |
|
|
function Library_Major_Minor_Id_Supported_Default return Boolean;
|
268 |
|
|
Library_Major_Minor_Id_Supported_Ptr : Boolean_Function :=
|
269 |
|
|
Library_Major_Minor_Id_Supported_Default'Access;
|
270 |
|
|
end MLib.Tgt;
|