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 Foreign : Argument_List;
46 Afiles : Argument_List;
47 Options : Argument_List;
48 Options_2 : 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 Support_For_Libraries return Library_Support;
63 No_Arguments : aliased Argument_List := (1 .. 0 => null);
64 Empty_Argument_List : constant Argument_List_Access := No_Arguments'Access;
66 Bexpall : aliased String := "-Wl,-bexpall";
67 Bexpall_Option : constant String_Access := Bexpall'Access;
68 -- The switch to export all symbols
70 Lpthreads : aliased String := "-lpthreads";
71 Native_Thread_Options : aliased Argument_List := (1 => Lpthreads'Access);
72 -- The switch to use when linking a library against libgnarl when using
75 Lgthreads : aliased String := "-lgthreads";
76 Lmalloc : aliased String := "-lmalloc";
77 FSU_Thread_Options : aliased Argument_List :=
78 (1 => Lgthreads'Access, 2 => Lmalloc'Access);
79 -- The switches to use when linking a library against libgnarl when using
82 Thread_Options : Argument_List_Access := Empty_Argument_List;
83 -- Designate the thread switches to used when linking a library against
84 -- libgnarl. Depends on the thread library (Native or FSU). Resolved for
85 -- the first library linked against libgnarl.
87 ---------------------------
88 -- Build_Dynamic_Library --
89 ---------------------------
91 procedure Build_Dynamic_Library
92 (Ofiles : Argument_List;
93 Foreign : Argument_List;
94 Afiles : Argument_List;
95 Options : Argument_List;
96 Options_2 : Argument_List;
97 Interfaces : Argument_List;
98 Lib_Filename : String;
100 Symbol_Data : Symbol_Record;
101 Driver_Name : Name_Id := No_Name;
102 Lib_Version : String := "";
103 Auto_Init : Boolean := False)
105 pragma Unreferenced (Foreign);
106 pragma Unreferenced (Afiles);
107 pragma Unreferenced (Interfaces);
108 pragma Unreferenced (Symbol_Data);
109 pragma Unreferenced (Lib_Version);
110 pragma Unreferenced (Auto_Init);
112 Lib_File : constant String :=
113 Lib_Dir & Directory_Separator & "lib" &
114 MLib.Fil.Append_To (Lib_Filename, DLL_Ext);
115 -- The file name of the library
117 Thread_Opts : Argument_List_Access := Empty_Argument_List;
118 -- Set to Thread_Options if -lgnarl is found in the Options
121 if Opt.Verbose_Mode then
122 Write_Str ("building relocatable shared library ");
123 Write_Line (Lib_File);
126 -- Look for -lgnarl in Options. If found, set the thread options
128 for J in Options'Range loop
129 if Options (J).all = "-lgnarl" then
131 -- If Thread_Options is null, read s-osinte.ads to discover the
132 -- thread library and set Thread_Options accordingly.
134 if Thread_Options = null then
137 Line : String (1 .. 100);
142 (File, Include_Dir_Default_Prefix & "/s-osinte.ads");
144 while not End_Of_File (File) loop
145 Get_Line (File, Line, Last);
147 if Index (Line (1 .. Last), "-lpthreads") /= 0 then
148 Thread_Options := Native_Thread_Options'Access;
151 elsif Index (Line (1 .. Last), "-lgthreads") /= 0 then
152 Thread_Options := FSU_Thread_Options'Access;
159 if Thread_Options = null then
160 Prj.Com.Fail ("cannot find the thread library in use");
165 Prj.Com.Fail ("cannot open s-osinte.ads");
169 Thread_Opts := Thread_Options;
174 -- Finally, call GCC (or the driver specified) to build the library
177 (Output_File => Lib_File,
179 Options => Options & Bexpall_Option,
180 Driver_Name => Driver_Name,
181 Options_2 => Options_2 & Thread_Opts.all);
182 end Build_Dynamic_Library;
188 function DLL_Ext return String is
193 ---------------------------
194 -- Support_For_Libraries --
195 ---------------------------
197 function Support_For_Libraries return Library_Support is
200 end Support_For_Libraries;
203 Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
204 DLL_Ext_Ptr := DLL_Ext'Access;
205 Support_For_Libraries_Ptr := Support_For_Libraries'Access;
207 end MLib.Tgt.Specific;