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 2, 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 COPYING. If not, write --
20 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
21 -- Boston, MA 02110-1301, USA. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
26 ------------------------------------------------------------------------------
28 -- This is the AIX version of the body
30 with Ada.Strings.Fixed; use Ada.Strings.Fixed;
35 with Output; use Output;
37 with Prj.Util; use Prj.Util;
39 package body MLib.Tgt.Specific is
41 -- Non default subprograms
43 procedure Build_Dynamic_Library
44 (Ofiles : Argument_List;
45 Options : Argument_List;
46 Interfaces : Argument_List;
47 Lib_Filename : String;
49 Symbol_Data : Symbol_Record;
50 Driver_Name : Name_Id := No_Name;
51 Lib_Version : String := "";
52 Auto_Init : Boolean := False);
54 function DLL_Ext return String;
56 function Library_Major_Minor_Id_Supported return Boolean;
58 function Support_For_Libraries return Library_Support;
62 No_Arguments : aliased Argument_List := (1 .. 0 => null);
63 Empty_Argument_List : constant Argument_List_Access := No_Arguments'Access;
65 Bexpall : aliased String := "-Wl,-bexpall";
66 Bexpall_Option : constant String_Access := Bexpall'Access;
67 -- The switch to export all symbols
69 Lpthreads : aliased String := "-lpthreads";
70 Native_Thread_Options : aliased Argument_List := (1 => Lpthreads'Access);
71 -- The switch to use when linking a library against libgnarl when using
74 Lgthreads : aliased String := "-lgthreads";
75 Lmalloc : aliased String := "-lmalloc";
76 FSU_Thread_Options : aliased Argument_List :=
77 (1 => Lgthreads'Access, 2 => Lmalloc'Access);
78 -- The switches to use when linking a library against libgnarl when using
81 Thread_Options : Argument_List_Access := Empty_Argument_List;
82 -- Designate the thread switches to used when linking a library against
83 -- libgnarl. Depends on the thread library (Native or FSU). Resolved for
84 -- the first library linked against libgnarl.
86 ---------------------------
87 -- Build_Dynamic_Library --
88 ---------------------------
90 procedure Build_Dynamic_Library
91 (Ofiles : Argument_List;
92 Options : Argument_List;
93 Interfaces : Argument_List;
94 Lib_Filename : String;
96 Symbol_Data : Symbol_Record;
97 Driver_Name : Name_Id := No_Name;
98 Lib_Version : String := "";
99 Auto_Init : Boolean := False)
101 pragma Unreferenced (Interfaces);
102 pragma Unreferenced (Symbol_Data);
103 pragma Unreferenced (Lib_Version);
104 pragma Unreferenced (Auto_Init);
106 Lib_File : constant String :=
107 Lib_Dir & Directory_Separator & "lib" &
108 MLib.Fil.Append_To (Lib_Filename, DLL_Ext);
109 -- The file name of the library
111 Thread_Opts : Argument_List_Access := Empty_Argument_List;
112 -- Set to Thread_Options if -lgnarl is found in the Options
115 if Opt.Verbose_Mode then
116 Write_Str ("building relocatable shared library ");
117 Write_Line (Lib_File);
120 -- Look for -lgnarl in Options. If found, set the thread options
122 for J in Options'Range loop
123 if Options (J).all = "-lgnarl" then
125 -- If Thread_Options is null, read s-osinte.ads to discover the
126 -- thread library and set Thread_Options accordingly.
128 if Thread_Options = null then
131 Line : String (1 .. 100);
136 (File, Include_Dir_Default_Prefix & "/s-osinte.ads");
138 while not End_Of_File (File) loop
139 Get_Line (File, Line, Last);
141 if Index (Line (1 .. Last), "-lpthreads") /= 0 then
142 Thread_Options := Native_Thread_Options'Access;
145 elsif Index (Line (1 .. Last), "-lgthreads") /= 0 then
146 Thread_Options := FSU_Thread_Options'Access;
153 if Thread_Options = null then
154 Prj.Com.Fail ("cannot find the thread library in use");
159 Prj.Com.Fail ("cannot open s-osinte.ads");
163 Thread_Opts := Thread_Options;
168 -- Finally, call GCC (or the driver specified) to build the library
171 (Output_File => Lib_File,
173 Options => Options & Bexpall_Option,
174 Driver_Name => Driver_Name,
175 Options_2 => Thread_Opts.all);
176 end Build_Dynamic_Library;
182 function DLL_Ext return String is
187 --------------------------------------
188 -- Library_Major_Minor_Id_Supported --
189 --------------------------------------
191 function Library_Major_Minor_Id_Supported return Boolean is
194 end Library_Major_Minor_Id_Supported;
196 ---------------------------
197 -- Support_For_Libraries --
198 ---------------------------
200 function Support_For_Libraries return Library_Support is
203 end Support_For_Libraries;
206 Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
207 DLL_Ext_Ptr := DLL_Ext'Access;
208 Library_Major_Minor_Id_Supported_Ptr :=
209 Library_Major_Minor_Id_Supported'Access;
210 Support_For_Libraries_Ptr := Support_For_Libraries'Access;
212 end MLib.Tgt.Specific;