OSDN Git Service

2007-08-14 Vincent Celier <celier@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-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    function Support_For_Libraries return Library_Support;
40    --  Indicates how building libraries by gnatmake is supported by the GNAT
41    --  implementation for the platform.
42
43    function Standalone_Library_Auto_Init_Is_Supported return Boolean;
44    --  Indicates if when building a dynamic Standalone Library,
45    --  automatic initialization is supported. If it is, then it is the default,
46    --  unless attribute Library_Auto_Init has the value "false".
47
48    function Archive_Builder return String;
49    --  Returns the name of the archive builder program, usually "ar"
50
51    function Archive_Builder_Options return String_List_Access;
52    --  A list of options to invoke the Archive_Builder, usually "cr" for "ar"
53
54    function Archive_Builder_Append_Options return String_List_Access;
55    --  A list of options to use with the archive builder to append object
56    --  files ("q", for example).
57
58    function Archive_Indexer return String;
59    --  Returns the name of the program, if any, that generates an index to the
60    --  contents of an archive, usually "ranlib". If there is no archive indexer
61    --  to be used, returns an empty string.
62
63    function Archive_Indexer_Options return String_List_Access;
64    --  A list of options to invoke the Archive_Indexer, usually empty
65
66    function Dynamic_Option return String;
67    --  gcc option to create a dynamic library.
68    --  For Unix, returns "-shared", for Windows returns "-mdll".
69
70    function Libgnat return String;
71    --  System dependent static GNAT library
72
73    function Archive_Ext return  String;
74    --  System dependent static library extension, without leading dot.
75    --  For Unix and Windows, return "a".
76
77    function Object_Ext return String;
78    --  System dependent object extension, without leading dot.
79    --  On Unix, returns "o".
80
81    function DLL_Prefix return String;
82    --  System dependent dynamic library prefix.
83    --  On Windows, returns "". On other platforms, returns "lib".
84
85    function DLL_Ext return String;
86    --  System dependent dynamic library extension, without leading dot.
87    --  On Windows, returns "dll". On Unix, usually returns "so", but not
88    --  always, e.g. on HP-UX the extension for shared libraries is "sl".
89
90    function PIC_Option return String;
91    --  Position independent code option
92
93    function Is_Object_Ext (Ext : String) return Boolean;
94    --  Returns True iff Ext is an object file extension
95
96    function Is_C_Ext (Ext : String) return Boolean;
97    --  Returns True iff Ext is a C file extension
98
99    function Is_Archive_Ext (Ext : String) return Boolean;
100    --  Returns True iff Ext is an extension for a library
101
102    function Default_Symbol_File_Name return String;
103    --  Returns the name of the symbol file when Library_Symbol_File is not
104    --  specified. Return the empty string when symbol files are not supported.
105
106    procedure Build_Dynamic_Library
107      (Ofiles       : Argument_List;
108       Options      : Argument_List;
109       Interfaces   : Argument_List;
110       Lib_Filename : String;
111       Lib_Dir      : String;
112       Symbol_Data  : Symbol_Record;
113       Driver_Name  : Name_Id := No_Name;
114       Lib_Version  : String  := "";
115       Auto_Init    : Boolean := False);
116    --  Build a dynamic/relocatable library
117    --
118    --  Ofiles is the list of all object files in the library
119    --
120    --  Options is a list of options to be passed to the tool
121    --  (gcc or other) that effectively builds the dynamic library.
122    --
123    --  Interfaces is the list of ALI files for the interfaces of a SAL.
124    --  It is empty if the library is not a SAL.
125    --
126    --  Lib_Filename is the name of the library, without any prefix or
127    --  extension. For example, on Unix, if Lib_Filename is "toto", the
128    --  name of the library file will be "libtoto.so".
129    --
130    --  Lib_Dir is the directory path where the library will be located
131    --
132    --  For OSes that support symbolic links, Lib_Version, if non null,
133    --  is the actual file name of the library. For example on Unix, if
134    --  Lib_Filename is "toto" and Lib_Version is "libtoto.so.2.1",
135    --  "libtoto.so" will be a symbolic link to "libtoto.so.2.1" which
136    --  will be the actual library file.
137    --
138    --  Symbol_Data is used for some patforms, including VMS, to generate
139    --  the symbols to be exported by the library.
140    --
141    --  Note: Depending on the OS, some of the parameters may not be taken into
142    --  account. For example, on Linux, Interfaces, Symbol_Data and Auto_Init
143    --  are ignored.
144
145    function Library_Exists_For
146      (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean;
147    --  Return True if the library file for a library project already exists.
148    --  This function can only be called for library projects.
149
150    function Library_File_Name_For
151      (Project : Project_Id;
152       In_Tree : Project_Tree_Ref) return File_Name_Type;
153    --  Returns the file name of the library file of a library project.
154    --  This function can only be called for library projects.
155
156    function Library_Major_Minor_Id_Supported return Boolean;
157    --  Indicates if major and minor ids are supported for libraries.
158    --  If they are supported, then a Library_Version such as libtoto.so.1.2
159    --  will have a major id of 1 and a minor id of 2. Then litoto.so,
160    --  libtoto.so.1 and libtoto.so.1.2 will be created, all three designating
161    --  the same file.
162
163 private
164    No_Argument_List : constant Argument_List := (1 .. 0 => null);
165
166    --  Access to subprogram types for indirection
167
168    type String_Function is access function return String;
169    type Is_Ext_Function is access function (Ext : String) return Boolean;
170    type String_List_Access_Function is access function
171      return String_List_Access;
172    type Build_Dynamic_Library_Function is access procedure
173      (Ofiles       : Argument_List;
174       Options      : Argument_List;
175       Interfaces   : Argument_List;
176       Lib_Filename : String;
177       Lib_Dir      : String;
178       Symbol_Data  : Symbol_Record;
179       Driver_Name  : Name_Id := No_Name;
180       Lib_Version  : String  := "";
181       Auto_Init    : Boolean := False);
182    type Library_Exists_For_Function is access function
183      (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean;
184    type Library_File_Name_For_Function is access function
185      (Project : Project_Id;
186       In_Tree : Project_Tree_Ref) return File_Name_Type;
187    type Boolean_Function is access function return Boolean;
188    type Library_Support_Function is access function return Library_Support;
189
190    function Archive_Builder_Default return String;
191    Archive_Builder_Ptr : String_Function := Archive_Builder_Default'Access;
192
193    function Archive_Builder_Options_Default return String_List_Access;
194    Archive_Builder_Options_Ptr : String_List_Access_Function :=
195                                    Archive_Builder_Options_Default'Access;
196
197    function Archive_Builder_Append_Options_Default return String_List_Access;
198    Archive_Builder_Append_Options_Ptr : String_List_Access_Function :=
199                                 Archive_Builder_Append_Options_Default'Access;
200
201    function Archive_Ext_Default return String;
202    Archive_Ext_Ptr : String_Function := Archive_Ext_Default'Access;
203
204    function Archive_Indexer_Default return String;
205    Archive_Indexer_Ptr : String_Function := Archive_Indexer_Default'Access;
206
207    function Archive_Indexer_Options_Default return String_List_Access;
208    Archive_Indexer_Options_Ptr : String_List_Access_Function :=
209                                    Archive_Indexer_Options_Default'Access;
210
211    function Default_Symbol_File_Name_Default return String;
212    Default_Symbol_File_Name_Ptr : String_Function :=
213                                     Default_Symbol_File_Name_Default'Access;
214
215    Build_Dynamic_Library_Ptr : Build_Dynamic_Library_Function;
216
217    function DLL_Ext_Default return String;
218    DLL_Ext_Ptr : String_Function := DLL_Ext_Default'Access;
219
220    function DLL_Prefix_Default return String;
221    DLL_Prefix_Ptr : String_Function := DLL_Prefix_Default'Access;
222
223    function Dynamic_Option_Default return String;
224    Dynamic_Option_Ptr : String_Function := Dynamic_Option_Default'Access;
225
226    function Is_Object_Ext_Default (Ext : String) return Boolean;
227    Is_Object_Ext_Ptr : Is_Ext_Function := Is_Object_Ext_Default'Access;
228
229    function Is_C_Ext_Default (Ext : String) return Boolean;
230    Is_C_Ext_Ptr : Is_Ext_Function := Is_C_Ext_Default'Access;
231
232    function Is_Archive_Ext_Default (Ext : String) return Boolean;
233    Is_Archive_Ext_Ptr : Is_Ext_Function := Is_Archive_Ext_Default'Access;
234
235    function Libgnat_Default return String;
236    Libgnat_Ptr : String_Function := Libgnat_Default'Access;
237
238    function Library_Exists_For_Default
239      (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean;
240    Library_Exists_For_Ptr : Library_Exists_For_Function :=
241                               Library_Exists_For_Default'Access;
242
243    function Library_File_Name_For_Default
244      (Project : Project_Id;
245       In_Tree : Project_Tree_Ref) return File_Name_Type;
246    Library_File_Name_For_Ptr : Library_File_Name_For_Function :=
247                                  Library_File_Name_For_Default'Access;
248
249    function Object_Ext_Default return String;
250    Object_Ext_Ptr : String_Function := Object_Ext_Default'Access;
251
252    function PIC_Option_Default return String;
253    PIC_Option_Ptr : String_Function := PIC_Option_Default'Access;
254
255    function Standalone_Library_Auto_Init_Is_Supported_Default return Boolean;
256    Standalone_Library_Auto_Init_Is_Supported_Ptr : Boolean_Function :=
257             Standalone_Library_Auto_Init_Is_Supported_Default'Access;
258
259    function Support_For_Libraries_Default return Library_Support;
260    Support_For_Libraries_Ptr : Library_Support_Function :=
261                                  Support_For_Libraries_Default'Access;
262
263    function Library_Major_Minor_Id_Supported_Default return Boolean;
264    Library_Major_Minor_Id_Supported_Ptr : Boolean_Function :=
265              Library_Major_Minor_Id_Supported_Default'Access;
266 end MLib.Tgt;