1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- M L I B . T G T . S P E C I F I C --
6 -- (GNU/Linux Version) --
10 -- Copyright (C) 2001-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 GNU/Linux version of the body
33 with Output; use Output;
35 package body MLib.Tgt.Specific is
39 -- Non default subprograms
41 procedure Build_Dynamic_Library
42 (Ofiles : Argument_List;
43 Options : Argument_List;
44 Interfaces : Argument_List;
45 Lib_Filename : String;
47 Symbol_Data : Symbol_Record;
48 Driver_Name : Name_Id := No_Name;
49 Lib_Version : String := "";
50 Auto_Init : Boolean := False);
52 function Is_Archive_Ext (Ext : String) return Boolean;
54 ---------------------------
55 -- Build_Dynamic_Library --
56 ---------------------------
58 procedure Build_Dynamic_Library
59 (Ofiles : Argument_List;
60 Options : Argument_List;
61 Interfaces : Argument_List;
62 Lib_Filename : String;
64 Symbol_Data : Symbol_Record;
65 Driver_Name : Name_Id := No_Name;
66 Lib_Version : String := "";
67 Auto_Init : Boolean := False)
69 pragma Unreferenced (Interfaces);
70 pragma Unreferenced (Symbol_Data);
71 pragma Unreferenced (Auto_Init);
72 -- Initialization is done through the contructor mechanism
74 Lib_File : constant String :=
75 "lib" & Fil.Append_To (Lib_Filename, DLL_Ext);
77 Lib_Path : constant String :=
78 Lib_Dir & Directory_Separator & Lib_File;
80 Version_Arg : String_Access;
81 Symbolic_Link_Needed : Boolean := False;
84 if Opt.Verbose_Mode then
85 Write_Str ("building relocatable shared library ");
86 Write_Line (Lib_Path);
89 if Lib_Version = "" then
91 (Output_File => Lib_Path,
94 Driver_Name => Driver_Name,
95 Options_2 => No_Argument_List);
99 Maj_Version : constant String :=
100 Major_Id_Name (Lib_File, Lib_Version);
102 if Maj_Version'Length /= 0 then
103 Version_Arg := new String'("-Wl,-soname," & Maj_Version);
106 Version_Arg := new String'("-Wl,-soname," & Lib_Version);
109 if Is_Absolute_Path (Lib_Version) then
111 (Output_File => Lib_Version,
113 Options => Options & Version_Arg,
114 Driver_Name => Driver_Name,
115 Options_2 => No_Argument_List);
116 Symbolic_Link_Needed := Lib_Version /= Lib_Path;
120 (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
122 Options => Options & Version_Arg,
123 Driver_Name => Driver_Name,
124 Options_2 => No_Argument_List);
125 Symbolic_Link_Needed :=
126 Lib_Dir & Directory_Separator & Lib_Version /= Lib_Path;
129 if Symbolic_Link_Needed then
131 (Lib_Path, Lib_Version, Lib_Dir, Maj_Version);
135 end Build_Dynamic_Library;
141 function Is_Archive_Ext (Ext : String) return Boolean is
143 return Ext = ".a" or else Ext = ".so";
147 Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
148 Is_Archive_Ext_Ptr := Is_Archive_Ext'Access;
149 end MLib.Tgt.Specific;