2010-07-27 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc/alias-decl.git] / gcc / ada / mlib-tgt-specific-tru64.adb
blobb5f5a13712253e49af39747be8b8e235cc0adc77
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- M L I B . T G T . S P E C I F I C --
6 -- (Tru64 Version) --
7 -- --
8 -- B o d y --
9 -- --
10 -- Copyright (C) 2002-2008, Free Software Foundation, Inc. --
11 -- --
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 3, 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 COPYING3. If not, go to --
20 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 -- This is the Tru64 version of the body
29 with MLib.Fil;
30 with MLib.Utl;
31 with Opt;
32 with Output; use Output;
34 package body MLib.Tgt.Specific is
36 use MLib;
38 -- Non default subprogram
40 procedure Build_Dynamic_Library
41 (Ofiles : Argument_List;
42 Options : Argument_List;
43 Interfaces : Argument_List;
44 Lib_Filename : String;
45 Lib_Dir : String;
46 Symbol_Data : Symbol_Record;
47 Driver_Name : Name_Id := No_Name;
48 Lib_Version : String := "";
49 Auto_Init : Boolean := False);
51 function Is_Archive_Ext (Ext : String) return Boolean;
53 function PIC_Option return String;
55 -- Local variables
57 Expect_Unresolved : aliased String := "-Wl,-expect_unresolved,*";
59 ---------------------------
60 -- Build_Dynamic_Library --
61 ---------------------------
63 procedure Build_Dynamic_Library
64 (Ofiles : Argument_List;
65 Options : Argument_List;
66 Interfaces : Argument_List;
67 Lib_Filename : String;
68 Lib_Dir : 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 (Interfaces);
75 pragma Unreferenced (Symbol_Data);
76 pragma Unreferenced (Auto_Init);
77 -- Initialization is done through the constructor mechanism
79 Lib_File : constant String :=
80 "lib" & Fil.Append_To (Lib_Filename, DLL_Ext);
82 Lib_Path : constant String :=
83 Lib_Dir & Directory_Separator & Lib_File;
85 Version_Arg : String_Access;
86 Symbolic_Link_Needed : Boolean := False;
88 begin
89 if Opt.Verbose_Mode then
90 Write_Str ("building relocatable shared library ");
91 Write_Line (Lib_Path);
92 end if;
94 -- If specified, add automatic elaboration/finalization
96 if Lib_Version = "" then
97 Utl.Gcc
98 (Output_File => Lib_Path,
99 Objects => Ofiles,
100 Options => Options & Expect_Unresolved'Access,
101 Options_2 => No_Argument_List,
102 Driver_Name => Driver_Name);
104 else
105 declare
106 Maj_Version : constant String :=
107 Major_Id_Name (Lib_File, Lib_Version);
108 begin
109 if Maj_Version'Length /= 0 then
110 Version_Arg := new String'("-Wl,-soname," & Maj_Version);
112 else
113 Version_Arg := new String'("-Wl,-soname," & Lib_Version);
114 end if;
116 if Is_Absolute_Path (Lib_Version) then
117 Utl.Gcc
118 (Output_File => Lib_Version,
119 Objects => Ofiles,
120 Options =>
121 Options & Version_Arg & Expect_Unresolved'Access,
122 Options_2 => No_Argument_List,
123 Driver_Name => Driver_Name);
124 Symbolic_Link_Needed := Lib_Version /= Lib_Path;
126 else
127 Utl.Gcc
128 (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
129 Objects => Ofiles,
130 Options =>
131 Options & Version_Arg & Expect_Unresolved'Access,
132 Options_2 => No_Argument_List,
133 Driver_Name => Driver_Name);
134 Symbolic_Link_Needed :=
135 Lib_Dir & Directory_Separator & Lib_Version /= Lib_Path;
136 end if;
138 if Symbolic_Link_Needed then
139 Create_Sym_Links
140 (Lib_Path, Lib_Version, Lib_Dir, Maj_Version);
141 end if;
142 end;
143 end if;
144 end Build_Dynamic_Library;
146 --------------------
147 -- Is_Archive_Ext --
148 --------------------
150 function Is_Archive_Ext (Ext : String) return Boolean is
151 begin
152 return Ext = ".a" or else Ext = ".so";
153 end Is_Archive_Ext;
155 ----------------
156 -- PIC_Option --
157 ----------------
159 function PIC_Option return String is
160 begin
161 return "";
162 end PIC_Option;
164 begin
165 Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
166 Is_Archive_Ext_Ptr := Is_Archive_Ext'Access;
167 PIC_Option_Ptr := PIC_Option'Access;
168 end MLib.Tgt.Specific;