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 HP-UX version of the body
33 with Output; use Output;
35 package body MLib.Tgt.Specific is
37 -- Non default subprograms
39 procedure Build_Dynamic_Library
40 (Ofiles : Argument_List;
41 Options : Argument_List;
42 Interfaces : Argument_List;
43 Lib_Filename : String;
45 Symbol_Data : Symbol_Record;
46 Driver_Name : Name_Id := No_Name;
47 Lib_Version : String := "";
48 Auto_Init : Boolean := False);
50 function DLL_Ext return String;
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);
73 Lib_File : constant String :=
74 "lib" & Fil.Append_To (Lib_Filename, DLL_Ext);
76 Lib_Path : constant String :=
77 Lib_Dir & Directory_Separator & Lib_File;
79 Version_Arg : String_Access;
80 Symbolic_Link_Needed : Boolean := False;
82 Common_Options : constant Argument_List :=
83 Options & new String'(PIC_Option);
84 -- Common set of options to the gcc command performing the link.
85 -- On HPUX, this command eventually resorts to collect2, which may
86 -- generate a C file and compile it on the fly. This compilation shall
87 -- also generate position independant code for the final link to
90 if Opt.Verbose_Mode then
91 Write_Str ("building relocatable shared library ");
92 Write_Line (Lib_Path);
95 if Lib_Version = "" then
97 (Output_File => Lib_Path,
99 Options => Common_Options,
100 Options_2 => No_Argument_List,
101 Driver_Name => Driver_Name);
105 Maj_Version : constant String :=
106 Major_Id_Name (Lib_File, Lib_Version);
108 if Maj_Version'Length /= 0 then
109 Version_Arg := new String'("-Wl,+h," & Maj_Version);
112 Version_Arg := new String'("-Wl,+h," & Lib_Version);
115 if Is_Absolute_Path (Lib_Version) then
117 (Output_File => Lib_Version,
119 Options => Common_Options & Version_Arg,
120 Options_2 => No_Argument_List,
121 Driver_Name => Driver_Name);
122 Symbolic_Link_Needed := Lib_Version /= Lib_Path;
126 (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
128 Options => Common_Options & Version_Arg,
129 Options_2 => No_Argument_List,
130 Driver_Name => Driver_Name);
131 Symbolic_Link_Needed :=
132 Lib_Dir & Directory_Separator & Lib_Version /= Lib_Path;
135 if Symbolic_Link_Needed then
137 (Lib_Path, Lib_Version, Lib_Dir, Maj_Version);
141 end Build_Dynamic_Library;
147 function DLL_Ext return String is
156 function Is_Archive_Ext (Ext : String) return Boolean is
158 return Ext = ".a" or else Ext = ".so";
162 Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
163 DLL_Ext_Ptr := DLL_Ext'Access;
164 Is_Archive_Ext_Ptr := Is_Archive_Ext'Access;
165 end MLib.Tgt.Specific;