1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- M L I B . T G T . S P E C I F I C --
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 True64 version of the body
33 with Output; use Output;
35 package body MLib.Tgt.Specific is
39 -- Non default subprogram
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 function PIC_Option return String;
58 Expect_Unresolved : aliased String := "-Wl,-expect_unresolved,*";
60 ---------------------------
61 -- Build_Dynamic_Library --
62 ---------------------------
64 procedure Build_Dynamic_Library
65 (Ofiles : Argument_List;
66 Options : Argument_List;
67 Interfaces : Argument_List;
68 Lib_Filename : String;
70 Symbol_Data : Symbol_Record;
71 Driver_Name : Name_Id := No_Name;
72 Lib_Version : String := "";
73 Auto_Init : Boolean := False)
75 pragma Unreferenced (Interfaces);
76 pragma Unreferenced (Symbol_Data);
77 pragma Unreferenced (Auto_Init);
78 -- Initialization is done through the contructor mechanism
80 Lib_File : constant String :=
81 "lib" & Fil.Append_To (Lib_Filename, DLL_Ext);
83 Lib_Path : constant String :=
84 Lib_Dir & Directory_Separator & Lib_File;
86 Version_Arg : String_Access;
87 Symbolic_Link_Needed : Boolean := False;
90 if Opt.Verbose_Mode then
91 Write_Str ("building relocatable shared library ");
92 Write_Line (Lib_Path);
95 -- If specified, add automatic elaboration/finalization
97 if Lib_Version = "" then
99 (Output_File => Lib_Path,
101 Options => Options & Expect_Unresolved'Access,
102 Options_2 => No_Argument_List,
103 Driver_Name => Driver_Name);
107 Maj_Version : constant String :=
108 Major_Id_Name (Lib_File, Lib_Version);
110 if Maj_Version'Length /= 0 then
111 Version_Arg := new String'("-Wl,-soname," & Maj_Version);
114 Version_Arg := new String'("-Wl,-soname," & Lib_Version);
117 if Is_Absolute_Path (Lib_Version) then
119 (Output_File => Lib_Version,
122 Options & Version_Arg & Expect_Unresolved'Access,
123 Options_2 => No_Argument_List,
124 Driver_Name => Driver_Name);
125 Symbolic_Link_Needed := Lib_Version /= Lib_Path;
129 (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
132 Options & Version_Arg & Expect_Unresolved'Access,
133 Options_2 => No_Argument_List,
134 Driver_Name => Driver_Name);
135 Symbolic_Link_Needed :=
136 Lib_Dir & Directory_Separator & Lib_Version /= Lib_Path;
139 if Symbolic_Link_Needed then
141 (Lib_Path, Lib_Version, Lib_Dir, Maj_Version);
145 end Build_Dynamic_Library;
151 function Is_Archive_Ext (Ext : String) return Boolean is
153 return Ext = ".a" or else Ext = ".so";
160 function PIC_Option return String is
166 Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
167 Is_Archive_Ext_Ptr := Is_Archive_Ext'Access;
168 PIC_Option_Ptr := PIC_Option'Access;
169 end MLib.Tgt.Specific;