]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/ada/mlib-tgt-aix.adb
exp_atag.ads, [...]: Replace headers with GPL v3 headers.
[thirdparty/gcc.git] / gcc / ada / mlib-tgt-aix.adb
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- M L I B . T G T . S P E C I F I C --
6 -- (AIX Version) --
7 -- --
8 -- B o d y --
9 -- --
10 -- Copyright (C) 2003-2007, AdaCore --
11 -- --
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. --
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 is the AIX version of the body
28
29 with Ada.Strings.Fixed; use Ada.Strings.Fixed;
30
31 with MLib.Fil;
32 with MLib.Utl;
33 with Opt;
34 with Output; use Output;
35 with Prj.Com;
36 with Prj.Util; use Prj.Util;
37
38 package body MLib.Tgt.Specific is
39
40 -- Non default subprograms
41
42 procedure Build_Dynamic_Library
43 (Ofiles : Argument_List;
44 Options : Argument_List;
45 Interfaces : Argument_List;
46 Lib_Filename : String;
47 Lib_Dir : String;
48 Symbol_Data : Symbol_Record;
49 Driver_Name : Name_Id := No_Name;
50 Lib_Version : String := "";
51 Auto_Init : Boolean := False);
52
53 function DLL_Ext return String;
54
55 function Library_Major_Minor_Id_Supported return Boolean;
56
57 function Support_For_Libraries return Library_Support;
58
59 -- Local variables
60
61 No_Arguments : aliased Argument_List := (1 .. 0 => null);
62 Empty_Argument_List : constant Argument_List_Access := No_Arguments'Access;
63
64 Bexpall : aliased String := "-Wl,-bexpall";
65 Bexpall_Option : constant String_Access := Bexpall'Access;
66 -- The switch to export all symbols
67
68 Lpthreads : aliased String := "-lpthreads";
69 Native_Thread_Options : aliased Argument_List := (1 => Lpthreads'Access);
70 -- The switch to use when linking a library against libgnarl when using
71 -- Native threads.
72
73 Lgthreads : aliased String := "-lgthreads";
74 Lmalloc : aliased String := "-lmalloc";
75 FSU_Thread_Options : aliased Argument_List :=
76 (1 => Lgthreads'Access, 2 => Lmalloc'Access);
77 -- The switches to use when linking a library against libgnarl when using
78 -- FSU threads.
79
80 Thread_Options : Argument_List_Access := Empty_Argument_List;
81 -- Designate the thread switches to used when linking a library against
82 -- libgnarl. Depends on the thread library (Native or FSU). Resolved for
83 -- the first library linked against libgnarl.
84
85 ---------------------------
86 -- Build_Dynamic_Library --
87 ---------------------------
88
89 procedure Build_Dynamic_Library
90 (Ofiles : Argument_List;
91 Options : Argument_List;
92 Interfaces : Argument_List;
93 Lib_Filename : String;
94 Lib_Dir : String;
95 Symbol_Data : Symbol_Record;
96 Driver_Name : Name_Id := No_Name;
97 Lib_Version : String := "";
98 Auto_Init : Boolean := False)
99 is
100 pragma Unreferenced (Interfaces);
101 pragma Unreferenced (Symbol_Data);
102 pragma Unreferenced (Lib_Version);
103 pragma Unreferenced (Auto_Init);
104
105 Lib_File : constant String :=
106 Lib_Dir & Directory_Separator & "lib" &
107 MLib.Fil.Append_To (Lib_Filename, DLL_Ext);
108 -- The file name of the library
109
110 Thread_Opts : Argument_List_Access := Empty_Argument_List;
111 -- Set to Thread_Options if -lgnarl is found in the Options
112
113 begin
114 if Opt.Verbose_Mode then
115 Write_Str ("building relocatable shared library ");
116 Write_Line (Lib_File);
117 end if;
118
119 -- Look for -lgnarl in Options. If found, set the thread options
120
121 for J in Options'Range loop
122 if Options (J).all = "-lgnarl" then
123
124 -- If Thread_Options is null, read s-osinte.ads to discover the
125 -- thread library and set Thread_Options accordingly.
126
127 if Thread_Options = null then
128 declare
129 File : Text_File;
130 Line : String (1 .. 100);
131 Last : Natural;
132
133 begin
134 Open
135 (File, Include_Dir_Default_Prefix & "/s-osinte.ads");
136
137 while not End_Of_File (File) loop
138 Get_Line (File, Line, Last);
139
140 if Index (Line (1 .. Last), "-lpthreads") /= 0 then
141 Thread_Options := Native_Thread_Options'Access;
142 exit;
143
144 elsif Index (Line (1 .. Last), "-lgthreads") /= 0 then
145 Thread_Options := FSU_Thread_Options'Access;
146 exit;
147 end if;
148 end loop;
149
150 Close (File);
151
152 if Thread_Options = null then
153 Prj.Com.Fail ("cannot find the thread library in use");
154 end if;
155
156 exception
157 when others =>
158 Prj.Com.Fail ("cannot open s-osinte.ads");
159 end;
160 end if;
161
162 Thread_Opts := Thread_Options;
163 exit;
164 end if;
165 end loop;
166
167 -- Finally, call GCC (or the driver specified) to build the library
168
169 MLib.Utl.Gcc
170 (Output_File => Lib_File,
171 Objects => Ofiles,
172 Options => Options & Bexpall_Option,
173 Driver_Name => Driver_Name,
174 Options_2 => Thread_Opts.all);
175 end Build_Dynamic_Library;
176
177 -------------
178 -- DLL_Ext --
179 -------------
180
181 function DLL_Ext return String is
182 begin
183 return "a";
184 end DLL_Ext;
185
186 --------------------------------------
187 -- Library_Major_Minor_Id_Supported --
188 --------------------------------------
189
190 function Library_Major_Minor_Id_Supported return Boolean is
191 begin
192 return False;
193 end Library_Major_Minor_Id_Supported;
194
195 ---------------------------
196 -- Support_For_Libraries --
197 ---------------------------
198
199 function Support_For_Libraries return Library_Support is
200 begin
201 return Static_Only;
202 end Support_For_Libraries;
203
204 begin
205 Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
206 DLL_Ext_Ptr := DLL_Ext'Access;
207 Library_Major_Minor_Id_Supported_Ptr :=
208 Library_Major_Minor_Id_Supported'Access;
209 Support_For_Libraries_Ptr := Support_For_Libraries'Access;
210
211 end MLib.Tgt.Specific;