1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- M L I B . T G T . S P E C I F I C --
6 -- (Solaris Version) --
10 -- Copyright (C) 2002-2007, Free Software Foundation, Inc. --
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 Solaris version of the body
33 with Output; use Output;
36 package body MLib.Tgt.Specific is
38 -- Non default subprograms
40 procedure Build_Dynamic_Library
41 (Ofiles : Argument_List;
42 Foreign : Argument_List;
43 Afiles : Argument_List;
44 Options : Argument_List;
45 Options_2 : 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 Is_Archive_Ext (Ext : String) return Boolean;
56 ---------------------------
57 -- Build_Dynamic_Library --
58 ---------------------------
60 procedure Build_Dynamic_Library
61 (Ofiles : Argument_List;
62 Foreign : Argument_List;
63 Afiles : Argument_List;
64 Options : Argument_List;
65 Options_2 : Argument_List;
66 Interfaces : Argument_List;
67 Lib_Filename : String;
69 Symbol_Data : Symbol_Record;
70 Driver_Name : Name_Id := No_Name;
71 Lib_Version : String := "";
72 Auto_Init : Boolean := False)
74 pragma Unreferenced (Foreign);
75 pragma Unreferenced (Afiles);
76 pragma Unreferenced (Interfaces);
77 pragma Unreferenced (Symbol_Data);
78 pragma Unreferenced (Auto_Init);
80 Lib_File : constant String :=
81 Lib_Dir & Directory_Separator & "lib" &
82 Fil.Append_To (Lib_Filename, DLL_Ext);
84 Version_Arg : String_Access;
85 Symbolic_Link_Needed : Boolean := False;
88 if Opt.Verbose_Mode then
89 Write_Str ("building relocatable shared library ");
90 Write_Line (Lib_File);
93 if Lib_Version = "" then
95 (Output_File => Lib_File,
98 Options_2 => Options_2,
99 Driver_Name => Driver_Name);
102 Version_Arg := new String'("-Wl,-h," & Lib_Version);
104 if Is_Absolute_Path (Lib_Version) then
106 (Output_File => Lib_Version,
108 Options => Options & Version_Arg,
109 Options_2 => Options_2,
110 Driver_Name => Driver_Name);
111 Symbolic_Link_Needed := Lib_Version /= Lib_File;
115 (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
117 Options => Options & Version_Arg,
118 Options_2 => Options_2,
119 Driver_Name => Driver_Name);
120 Symbolic_Link_Needed :=
121 Lib_Dir & Directory_Separator & Lib_Version /= Lib_File;
124 if Symbolic_Link_Needed then
127 Oldpath : String (1 .. Lib_Version'Length + 1);
128 Newpath : String (1 .. Lib_File'Length + 1);
131 pragma Unreferenced (Result);
134 (Oldpath : System.Address;
135 Newpath : System.Address)
137 pragma Import (C, Symlink, "__gnat_symlink");
140 Oldpath (1 .. Lib_Version'Length) := Lib_Version;
141 Oldpath (Oldpath'Last) := ASCII.NUL;
142 Newpath (1 .. Lib_File'Length) := Lib_File;
143 Newpath (Newpath'Last) := ASCII.NUL;
145 Delete_File (Lib_File, Success);
147 Result := Symlink (Oldpath'Address, Newpath'Address);
151 end Build_Dynamic_Library;
157 function Is_Archive_Ext (Ext : String) return Boolean is
159 return Ext = ".a" or else Ext = ".so";
163 Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
164 Is_Archive_Ext_Ptr := Is_Archive_Ext'Access;
165 end MLib.Tgt.Specific;