1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- M L I B . T G T . S P E C I F I C --
10 -- Copyright (C) 2003-2008, AdaCore --
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 3, 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 COPYING3. If not, go to --
20 -- http://www.gnu.org/licenses for a complete copy of the license. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- This is the AIX version of the body
29 with Ada
.Strings
.Fixed
; use Ada
.Strings
.Fixed
;
34 with Output
; use Output
;
36 with Prj
.Util
; use Prj
.Util
;
38 package body MLib
.Tgt
.Specific
is
41 -- These *ALL* require comments ???
43 function Archive_Indexer
return String;
46 procedure Build_Dynamic_Library
47 (Ofiles
: Argument_List
;
48 Options
: Argument_List
;
49 Interfaces
: Argument_List
;
50 Lib_Filename
: String;
52 Symbol_Data
: Symbol_Record
;
53 Driver_Name
: Name_Id
:= No_Name
;
54 Lib_Version
: String := "";
55 Auto_Init
: Boolean := False);
57 function DLL_Ext
return String;
59 function Library_Major_Minor_Id_Supported
return Boolean;
61 function Support_For_Libraries
return Library_Support
;
65 No_Arguments
: aliased Argument_List
:= (1 .. 0 => null);
66 Empty_Argument_List
: constant Argument_List_Access
:= No_Arguments
'Access;
68 Bexpall
: aliased String := "-Wl,-bexpall";
69 Bexpall_Option
: constant String_Access
:= Bexpall
'Access;
70 -- The switch to export all symbols
72 Lpthreads
: aliased String := "-lpthreads";
73 Native_Thread_Options
: aliased Argument_List
:= (1 => Lpthreads
'Access);
74 -- The switch to use when linking a library against libgnarl when using
77 Lgthreads
: aliased String := "-lgthreads";
78 Lmalloc
: aliased String := "-lmalloc";
79 FSU_Thread_Options
: aliased Argument_List
:=
80 (1 => Lgthreads
'Access, 2 => Lmalloc
'Access);
81 -- The switches to use when linking a library against libgnarl when using
84 Thread_Options
: Argument_List_Access
:= Empty_Argument_List
;
85 -- Designate the thread switches to used when linking a library against
86 -- libgnarl. Depends on the thread library (Native or FSU). Resolved for
87 -- the first library linked against libgnarl.
93 function Archive_Indexer
return String is
98 ---------------------------
99 -- Build_Dynamic_Library --
100 ---------------------------
102 procedure Build_Dynamic_Library
103 (Ofiles
: Argument_List
;
104 Options
: Argument_List
;
105 Interfaces
: Argument_List
;
106 Lib_Filename
: String;
108 Symbol_Data
: Symbol_Record
;
109 Driver_Name
: Name_Id
:= No_Name
;
110 Lib_Version
: String := "";
111 Auto_Init
: Boolean := False)
113 pragma Unreferenced
(Interfaces
);
114 pragma Unreferenced
(Symbol_Data
);
115 pragma Unreferenced
(Lib_Version
);
116 pragma Unreferenced
(Auto_Init
);
118 Lib_File
: constant String :=
119 Lib_Dir
& Directory_Separator
& "lib" &
120 MLib
.Fil
.Append_To
(Lib_Filename
, DLL_Ext
);
121 -- The file name of the library
123 Thread_Opts
: Argument_List_Access
:= Empty_Argument_List
;
124 -- Set to Thread_Options if -lgnarl is found in the Options
127 if Opt
.Verbose_Mode
then
128 Write_Str
("building relocatable shared library ");
129 Write_Line
(Lib_File
);
132 -- Look for -lgnarl in Options. If found, set the thread options
134 for J
in Options
'Range loop
135 if Options
(J
).all = "-lgnarl" then
137 -- If Thread_Options is null, read s-osinte.ads to discover the
138 -- thread library and set Thread_Options accordingly.
140 if Thread_Options
= null then
143 Line
: String (1 .. 100);
148 (File
, Include_Dir_Default_Prefix
& "/s-osinte.ads");
150 while not End_Of_File
(File
) loop
151 Get_Line
(File
, Line
, Last
);
153 if Index
(Line
(1 .. Last
), "-lpthreads") /= 0 then
154 Thread_Options
:= Native_Thread_Options
'Access;
157 elsif Index
(Line
(1 .. Last
), "-lgthreads") /= 0 then
158 Thread_Options
:= FSU_Thread_Options
'Access;
165 if Thread_Options
= null then
166 Prj
.Com
.Fail
("cannot find the thread library in use");
171 Prj
.Com
.Fail
("cannot open s-osinte.ads");
175 Thread_Opts
:= Thread_Options
;
180 -- Finally, call GCC (or the driver specified) to build the library
183 (Output_File
=> Lib_File
,
185 Options
=> Options
& Bexpall_Option
,
186 Driver_Name
=> Driver_Name
,
187 Options_2
=> Thread_Opts
.all);
188 end Build_Dynamic_Library
;
194 function DLL_Ext
return String is
199 --------------------------------------
200 -- Library_Major_Minor_Id_Supported --
201 --------------------------------------
203 function Library_Major_Minor_Id_Supported
return Boolean is
206 end Library_Major_Minor_Id_Supported
;
208 ---------------------------
209 -- Support_For_Libraries --
210 ---------------------------
212 function Support_For_Libraries
return Library_Support
is
215 end Support_For_Libraries
;
218 Archive_Indexer_Ptr
:= Archive_Indexer
'Access;
219 Build_Dynamic_Library_Ptr
:= Build_Dynamic_Library
'Access;
220 DLL_Ext_Ptr
:= DLL_Ext
'Access;
221 Library_Major_Minor_Id_Supported_Ptr
:=
222 Library_Major_Minor_Id_Supported
'Access;
223 Support_For_Libraries_Ptr
:= Support_For_Libraries
'Access;
225 end MLib
.Tgt
.Specific
;