OSDN Git Service

PR target/32335
[pf3gnuchains/gcc-fork.git] / gcc / ada / mlib-tgt.ads
1 ------------------------------------------------------------------------------
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-2007, 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 2,  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 COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 --  This package provides a set of target dependent routines to build
28 --  static, dynamic and shared libraries.
29
30 --  There are several versions for the body of this package
31
32 --  In the default version, libraries are not supported, so function
33 --  Support_For_Libraries return None.
34
35 with Prj; use Prj;
36
37 package MLib.Tgt is
38
39    type Library_Support is (None, Static_Only, Full);
40    --  Support for Library Project File.
41    --  - None: Library Project Files are not supported at all
42    --  - Static_Only: Library Project Files are only supported for static
43    --    libraries.
44    --  - Full: Library Project Files are supported for static and dynamic
45    --    (shared) libraries.
46
47    function Support_For_Libraries return Library_Support;
48    --  Indicates how building libraries by gnatmake is supported by the GNAT
49    --  implementation for the platform.
50
51    function Standalone_Library_Auto_Init_Is_Supported return Boolean;
52    --  Indicates if when building a dynamic Standalone Library,
53    --  automatic initialization is supported. If it is, then it is the default,
54    --  unless attribute Library_Auto_Init has the value "false".
55
56    function Archive_Builder return String;
57    --  Returns the name of the archive builder program, usually "ar"
58
59    function Archive_Builder_Options return String_List_Access;
60    --  A list of options to invoke the Archive_Builder, usually "cr" for "ar"
61
62    function Archive_Builder_Append_Options return String_List_Access;
63    --  A list of options to use with the archive builder to append object
64    --  files ("q", for example).
65
66    function Archive_Indexer return String;
67    --  Returns the name of the program, if any, that generates an index to the
68    --  contents of an archive, usually "ranlib". If there is no archive indexer
69    --  to be used, returns an empty string.
70
71    function Archive_Indexer_Options return String_List_Access;
72    --  A list of options to invoke the Archive_Indexer, usually empty
73
74    function Dynamic_Option return String;
75    --  gcc option to create a dynamic library.
76    --  For Unix, returns "-shared", for Windows returns "-mdll".
77
78    function Libgnat return String;
79    --  System dependent static GNAT library
80
81    function Archive_Ext return  String;
82    --  System dependent static library extension, without leading dot.
83    --  For Unix and Windows, return "a".
84
85    function Object_Ext return String;
86    --  System dependent object extension, without leading dot.
87    --  On Unix, returns "o".
88
89    function DLL_Prefix return String;
90    --  System dependent dynamic library prefix.
91    --  On Windows, returns "". On other platforms, returns "lib".
92
93    function DLL_Ext return String;
94    --  System dependent dynamic library extension, without leading dot.
95    --  On Windows, returns "dll". On Unix, usually returns "so", but not
96    --  always, e.g. on HP-UX the extension for shared libraries is "sl".
97
98    function PIC_Option return String;
99    --  Position independent code option
100
101    function Is_Object_Ext (Ext : String) return Boolean;
102    --  Returns True iff Ext is an object file extension
103
104    function Is_C_Ext (Ext : String) return Boolean;
105    --  Returns True iff Ext is a C file extension
106
107    function Is_Archive_Ext (Ext : String) return Boolean;
108    --  Returns True iff Ext is an extension for a library
109
110    function Default_Symbol_File_Name return String;
111    --  Returns the name of the symbol file when Library_Symbol_File is not
112    --  specified. Return the empty string when symbol files are not supported.
113
114    procedure Build_Dynamic_Library
115      (Ofiles       : Argument_List;
116       Foreign      : Argument_List;
117       Afiles       : Argument_List;
118       Options      : Argument_List;
119       Options_2    : Argument_List;
120       Interfaces   : Argument_List;
121       Lib_Filename : String;
122       Lib_Dir      : String;
123       Symbol_Data  : Symbol_Record;
124       Driver_Name  : Name_Id  := No_Name;
125       Lib_Version  : String   := "";
126       Auto_Init    : Boolean  := False);
127    --  Build a dynamic/relocatable library
128    --
129    --  Ofiles is the list of all object files in the library
130    --
131    --  Foreign is the list of non Ada object files (also included in Ofiles)
132    --
133    --  Afiles is the list of ALI files for the Ada object files
134    --
135    --  Options and Options_2 are lists of options to be passed to the tool
136    --  (gcc or other) that effectively builds the dynamic library. Options
137    --  are passed before the object files, Options_2 are passed after the
138    --  object files.
139    --
140    --  Interfaces is the list of ALI files for the interfaces of a SAL.
141    --  It is empty if the library is not a SAL.
142    --
143    --  Lib_Filename is the name of the library, without any prefix or
144    --  extension. For example, on Unix, if Lib_Filename is "toto", the
145    --  name of the library file will be "libtoto.so".
146    --
147    --  Lib_Dir is the directory path where the library will be located
148    --
149    --  For OSes that support symbolic links, Lib_Version, if non null,
150    --  is the actual file name of the library. For example on Unix, if
151    --  Lib_Filename is "toto" and Lib_Version is "libtoto.so.2.1",
152    --  "libtoto.so" will be a symbolic link to "libtoto.so.2.1" which
153    --  will be the actual library file.
154    --
155    --  Symbol_Data is used for some patforms, including VMS, to generate
156    --  the symbols to be exported by the library.
157    --
158    --  Note: Depending on the OS, some of the parameters may not be taken
159    --  into account. For example, on Linux, Foreign, Afiles Lib_Address and
160    --  Relocatable are ignored.
161
162    function Library_Exists_For
163      (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean;
164    --  Return True if the library file for a library project already exists.
165    --  This function can only be called for library projects.
166
167    function Library_File_Name_For
168      (Project : Project_Id;
169       In_Tree : Project_Tree_Ref) return File_Name_Type;
170    --  Returns the file name of the library file of a library project.
171    --  This function can only be called for library projects.
172
173 private
174    --  Access to subprogram types for indirection
175
176    type String_Function is access function return String;
177    type Is_Ext_Function is access function (Ext : String) return Boolean;
178    type String_List_Access_Function is access function
179      return String_List_Access;
180    type Build_Dynamic_Library_Function is access procedure
181      (Ofiles       : Argument_List;
182       Foreign      : Argument_List;
183       Afiles       : Argument_List;
184       Options      : Argument_List;
185       Options_2    : Argument_List;
186       Interfaces   : Argument_List;
187       Lib_Filename : String;
188       Lib_Dir      : String;
189       Symbol_Data  : Symbol_Record;
190       Driver_Name  : Name_Id := No_Name;
191       Lib_Version  : String  := "";
192       Auto_Init    : Boolean := False);
193
194    type Library_Exists_For_Function is access function
195      (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean;
196
197    type Library_File_Name_For_Function is access function
198      (Project : Project_Id;
199       In_Tree : Project_Tree_Ref) return File_Name_Type;
200
201    type Boolean_Function is access function return Boolean;
202
203    type Library_Support_Function is access function return Library_Support;
204
205    function Archive_Builder_Default return String;
206    Archive_Builder_Ptr : String_Function := Archive_Builder_Default'Access;
207
208    function Archive_Builder_Options_Default return String_List_Access;
209    Archive_Builder_Options_Ptr : String_List_Access_Function :=
210                                    Archive_Builder_Options_Default'Access;
211
212    function Archive_Builder_Append_Options_Default return String_List_Access;
213
214    Archive_Builder_Append_Options_Ptr :
215      String_List_Access_Function :=
216        Archive_Builder_Append_Options_Default'Access;
217
218    function Archive_Ext_Default return String;
219    Archive_Ext_Ptr : String_Function := Archive_Ext_Default'Access;
220
221    function Archive_Indexer_Default return String;
222    Archive_Indexer_Ptr : String_Function := Archive_Indexer_Default'Access;
223
224    function Archive_Indexer_Options_Default return String_List_Access;
225    Archive_Indexer_Options_Ptr : String_List_Access_Function :=
226                                    Archive_Indexer_Options_Default'Access;
227
228    function Default_Symbol_File_Name_Default return String;
229    Default_Symbol_File_Name_Ptr : String_Function :=
230                                     Default_Symbol_File_Name_Default'Access;
231
232    Build_Dynamic_Library_Ptr : Build_Dynamic_Library_Function;
233
234    function DLL_Ext_Default return String;
235    DLL_Ext_Ptr : String_Function := DLL_Ext_Default'Access;
236
237    function DLL_Prefix_Default return String;
238    DLL_Prefix_Ptr : String_Function := DLL_Prefix_Default'Access;
239
240    function Dynamic_Option_Default return String;
241    Dynamic_Option_Ptr : String_Function := Dynamic_Option_Default'Access;
242
243    function Is_Object_Ext_Default (Ext : String) return Boolean;
244    Is_Object_Ext_Ptr : Is_Ext_Function := Is_Object_Ext_Default'Access;
245
246    function Is_C_Ext_Default (Ext : String) return Boolean;
247    Is_C_Ext_Ptr : Is_Ext_Function := Is_C_Ext_Default'Access;
248
249    function Is_Archive_Ext_Default (Ext : String) return Boolean;
250    Is_Archive_Ext_Ptr : Is_Ext_Function := Is_Archive_Ext_Default'Access;
251
252    function Libgnat_Default return String;
253    Libgnat_Ptr : String_Function := Libgnat_Default'Access;
254
255    function Library_Exists_For_Default
256      (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean;
257    Library_Exists_For_Ptr : Library_Exists_For_Function :=
258                               Library_Exists_For_Default'Access;
259
260    function Library_File_Name_For_Default
261      (Project : Project_Id;
262       In_Tree : Project_Tree_Ref) return File_Name_Type;
263    Library_File_Name_For_Ptr : Library_File_Name_For_Function :=
264                                  Library_File_Name_For_Default'Access;
265
266    function Object_Ext_Default return String;
267    Object_Ext_Ptr : String_Function := Object_Ext_Default'Access;
268
269    function PIC_Option_Default return String;
270    PIC_Option_Ptr : String_Function := PIC_Option_Default'Access;
271
272    function Standalone_Library_Auto_Init_Is_Supported_Default return Boolean;
273    Standalone_Library_Auto_Init_Is_Supported_Ptr : Boolean_Function :=
274             Standalone_Library_Auto_Init_Is_Supported_Default'Access;
275
276    function Support_For_Libraries_Default return Library_Support;
277    Support_For_Libraries_Ptr : Library_Support_Function :=
278                                  Support_For_Libraries_Default'Access;
279 end MLib.Tgt;