OSDN Git Service

2009-04-29 Bob Duff <duff@adacore.com>
[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-2008, 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; In_Tree : Project_Tree_Ref) return Boolean;
144    --  Return True if the library file for a library project already exists.
145    --  This function can only be called for library projects.
146
147    function Library_File_Name_For
148      (Project : Project_Id;
149       In_Tree : Project_Tree_Ref) return File_Name_Type;
150    --  Returns the file name of the library file of a library project.
151    --  This function can only be called for library projects.
152
153    function Library_Major_Minor_Id_Supported return Boolean;
154    --  Indicates if major and minor ids are supported for libraries.
155    --  If they are supported, then a Library_Version such as libtoto.so.1.2
156    --  will have a major id of 1 and a minor id of 2. Then libtoto.so,
157    --  libtoto.so.1 and libtoto.so.1.2 will be created, all three designating
158    --  the same file.
159
160 private
161    No_Argument_List : constant Argument_List := (1 .. 0 => null);
162
163    --  Access to subprogram types for indirection
164
165    type String_Function is access function return String;
166    type Is_Ext_Function is access function (Ext : String) return Boolean;
167    type String_List_Access_Function is access function
168      return String_List_Access;
169    type Build_Dynamic_Library_Function is access procedure
170      (Ofiles       : Argument_List;
171       Options      : Argument_List;
172       Interfaces   : Argument_List;
173       Lib_Filename : String;
174       Lib_Dir      : String;
175       Symbol_Data  : Symbol_Record;
176       Driver_Name  : Name_Id := No_Name;
177       Lib_Version  : String  := "";
178       Auto_Init    : Boolean := False);
179    type Library_Exists_For_Function is access function
180      (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean;
181    type Library_File_Name_For_Function is access function
182      (Project : Project_Id;
183       In_Tree : Project_Tree_Ref) return File_Name_Type;
184    type Boolean_Function is access function return Boolean;
185    type Library_Support_Function is access function return Library_Support;
186
187    function Archive_Builder_Default return String;
188    Archive_Builder_Ptr : String_Function := Archive_Builder_Default'Access;
189
190    function Archive_Builder_Options_Default return String_List_Access;
191    Archive_Builder_Options_Ptr : String_List_Access_Function :=
192                                    Archive_Builder_Options_Default'Access;
193
194    function Archive_Builder_Append_Options_Default return String_List_Access;
195    Archive_Builder_Append_Options_Ptr : String_List_Access_Function :=
196                                 Archive_Builder_Append_Options_Default'Access;
197
198    function Archive_Ext_Default return String;
199    Archive_Ext_Ptr : String_Function := Archive_Ext_Default'Access;
200
201    function Archive_Indexer_Default return String;
202    Archive_Indexer_Ptr : String_Function := Archive_Indexer_Default'Access;
203
204    function Archive_Indexer_Options_Default return String_List_Access;
205    Archive_Indexer_Options_Ptr : String_List_Access_Function :=
206                                    Archive_Indexer_Options_Default'Access;
207
208    function Default_Symbol_File_Name_Default return String;
209    Default_Symbol_File_Name_Ptr : String_Function :=
210                                     Default_Symbol_File_Name_Default'Access;
211
212    Build_Dynamic_Library_Ptr : Build_Dynamic_Library_Function;
213
214    function DLL_Ext_Default return String;
215    DLL_Ext_Ptr : String_Function := DLL_Ext_Default'Access;
216
217    function DLL_Prefix_Default return String;
218    DLL_Prefix_Ptr : String_Function := DLL_Prefix_Default'Access;
219
220    function Dynamic_Option_Default return String;
221    Dynamic_Option_Ptr : String_Function := Dynamic_Option_Default'Access;
222
223    function Is_Object_Ext_Default (Ext : String) return Boolean;
224    Is_Object_Ext_Ptr : Is_Ext_Function := Is_Object_Ext_Default'Access;
225
226    function Is_C_Ext_Default (Ext : String) return Boolean;
227    Is_C_Ext_Ptr : Is_Ext_Function := Is_C_Ext_Default'Access;
228
229    function Is_Archive_Ext_Default (Ext : String) return Boolean;
230    Is_Archive_Ext_Ptr : Is_Ext_Function := Is_Archive_Ext_Default'Access;
231
232    function Libgnat_Default return String;
233    Libgnat_Ptr : String_Function := Libgnat_Default'Access;
234
235    function Library_Exists_For_Default
236      (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean;
237    Library_Exists_For_Ptr : Library_Exists_For_Function :=
238                               Library_Exists_For_Default'Access;
239
240    function Library_File_Name_For_Default
241      (Project : Project_Id; In_Tree : Project_Tree_Ref) return File_Name_Type;
242    Library_File_Name_For_Ptr : Library_File_Name_For_Function :=
243                                  Library_File_Name_For_Default'Access;
244
245    function Object_Ext_Default return String;
246    Object_Ext_Ptr : String_Function := Object_Ext_Default'Access;
247
248    function PIC_Option_Default return String;
249    PIC_Option_Ptr : String_Function := PIC_Option_Default'Access;
250
251    function Standalone_Library_Auto_Init_Is_Supported_Default return Boolean;
252    Standalone_Library_Auto_Init_Is_Supported_Ptr : Boolean_Function :=
253             Standalone_Library_Auto_Init_Is_Supported_Default'Access;
254
255    function Support_For_Libraries_Default return Library_Support;
256    Support_For_Libraries_Ptr : Library_Support_Function :=
257                                  Support_For_Libraries_Default'Access;
258
259    function Library_Major_Minor_Id_Supported_Default return Boolean;
260    Library_Major_Minor_Id_Supported_Ptr : Boolean_Function :=
261              Library_Major_Minor_Id_Supported_Default'Access;
262 end MLib.Tgt;