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-2007, 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
40 -- Non default subprograms
42 procedure Build_Dynamic_Library
43 (Ofiles : Argument_List;
44 Options : Argument_List;
45 Interfaces : Argument_List;
46 Lib_Filename : String;
48 Symbol_Data : Symbol_Record;
49 Driver_Name : Name_Id := No_Name;
50 Lib_Version : String := "";
51 Auto_Init : Boolean := False);
53 function DLL_Ext return String;
55 function Library_Major_Minor_Id_Supported return Boolean;
57 function Support_For_Libraries return Library_Support;
61 No_Arguments : aliased Argument_List := (1 .. 0 => null);
62 Empty_Argument_List : constant Argument_List_Access := No_Arguments'Access;
64 Bexpall : aliased String := "-Wl,-bexpall";
65 Bexpall_Option : constant String_Access := Bexpall'Access;
66 -- The switch to export all symbols
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
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
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.
85 ---------------------------
86 -- Build_Dynamic_Library --
87 ---------------------------
89 procedure Build_Dynamic_Library
90 (Ofiles : Argument_List;
91 Options : Argument_List;
92 Interfaces : Argument_List;
93 Lib_Filename : String;
95 Symbol_Data : Symbol_Record;
96 Driver_Name : Name_Id := No_Name;
97 Lib_Version : String := "";
98 Auto_Init : Boolean := False)
100 pragma Unreferenced (Interfaces);
101 pragma Unreferenced (Symbol_Data);
102 pragma Unreferenced (Lib_Version);
103 pragma Unreferenced (Auto_Init);
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
110 Thread_Opts : Argument_List_Access := Empty_Argument_List;
111 -- Set to Thread_Options if -lgnarl is found in the Options
114 if Opt.Verbose_Mode then
115 Write_Str ("building relocatable shared library ");
116 Write_Line (Lib_File);
119 -- Look for -lgnarl in Options. If found, set the thread options
121 for J in Options'Range loop
122 if Options (J).all = "-lgnarl" then
124 -- If Thread_Options is null, read s-osinte.ads to discover the
125 -- thread library and set Thread_Options accordingly.
127 if Thread_Options = null then
130 Line : String (1 .. 100);
135 (File, Include_Dir_Default_Prefix & "/s-osinte.ads");
137 while not End_Of_File (File) loop
138 Get_Line (File, Line, Last);
140 if Index (Line (1 .. Last), "-lpthreads") /= 0 then
141 Thread_Options := Native_Thread_Options'Access;
144 elsif Index (Line (1 .. Last), "-lgthreads") /= 0 then
145 Thread_Options := FSU_Thread_Options'Access;
152 if Thread_Options = null then
153 Prj.Com.Fail ("cannot find the thread library in use");
158 Prj.Com.Fail ("cannot open s-osinte.ads");
162 Thread_Opts := Thread_Options;
167 -- Finally, call GCC (or the driver specified) to build the library
170 (Output_File => Lib_File,
172 Options => Options & Bexpall_Option,
173 Driver_Name => Driver_Name,
174 Options_2 => Thread_Opts.all);
175 end Build_Dynamic_Library;
181 function DLL_Ext return String is
186 --------------------------------------
187 -- Library_Major_Minor_Id_Supported --
188 --------------------------------------
190 function Library_Major_Minor_Id_Supported return Boolean is
193 end Library_Major_Minor_Id_Supported;
195 ---------------------------
196 -- Support_For_Libraries --
197 ---------------------------
199 function Support_For_Libraries return Library_Support is
202 end Support_For_Libraries;
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;
211 end MLib.Tgt.Specific;