OSDN Git Service

* gcc.dg/tree-ssa/ssa-dse-10.c: Clean up all dse dump files.
[pf3gnuchains/gcc-fork.git] / gcc / ada / mlib-tgt-tru64.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                    M L I B . T G T . S P E C I F I C                     --
6 --                             (True64 Version)                             --
7 --                                                                          --
8 --                                 B o d y                                  --
9 --                                                                          --
10 --          Copyright (C) 2002-2007, 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 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.                                              --
22 --                                                                          --
23 -- GNAT was originally developed  by the GNAT team at  New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
25 --                                                                          --
26 ------------------------------------------------------------------------------
27
28 --  This is the True64 version of the body
29
30 with MLib.Fil;
31 with MLib.Utl;
32 with Opt;
33 with Output; use Output;
34
35 package body MLib.Tgt.Specific is
36
37    use MLib;
38
39    --  Non default subprogram
40
41    procedure Build_Dynamic_Library
42      (Ofiles       : Argument_List;
43       Options      : Argument_List;
44       Interfaces   : Argument_List;
45       Lib_Filename : String;
46       Lib_Dir      : String;
47       Symbol_Data  : Symbol_Record;
48       Driver_Name  : Name_Id := No_Name;
49       Lib_Version  : String  := "";
50       Auto_Init    : Boolean := False);
51
52    function Is_Archive_Ext (Ext : String) return Boolean;
53
54    function PIC_Option return String;
55
56    --  Local variables
57
58    Expect_Unresolved : aliased String := "-Wl,-expect_unresolved,*";
59
60    ---------------------------
61    -- Build_Dynamic_Library --
62    ---------------------------
63
64    procedure Build_Dynamic_Library
65      (Ofiles       : Argument_List;
66       Options      : Argument_List;
67       Interfaces   : Argument_List;
68       Lib_Filename : String;
69       Lib_Dir      : String;
70       Symbol_Data  : Symbol_Record;
71       Driver_Name  : Name_Id := No_Name;
72       Lib_Version  : String  := "";
73       Auto_Init    : Boolean := False)
74    is
75       pragma Unreferenced (Interfaces);
76       pragma Unreferenced (Symbol_Data);
77       pragma Unreferenced (Auto_Init);
78       --  Initialization is done through the contructor mechanism
79
80       Lib_File : constant String :=
81                    "lib" & Fil.Append_To (Lib_Filename, DLL_Ext);
82
83       Lib_Path : constant String :=
84                    Lib_Dir & Directory_Separator & Lib_File;
85
86       Version_Arg          : String_Access;
87       Symbolic_Link_Needed : Boolean := False;
88
89    begin
90       if Opt.Verbose_Mode then
91          Write_Str ("building relocatable shared library ");
92          Write_Line (Lib_Path);
93       end if;
94
95       --  If specified, add automatic elaboration/finalization
96
97       if Lib_Version = "" then
98          Utl.Gcc
99            (Output_File => Lib_Path,
100             Objects     => Ofiles,
101             Options     => Options & Expect_Unresolved'Access,
102             Options_2   => No_Argument_List,
103             Driver_Name => Driver_Name);
104
105       else
106          declare
107             Maj_Version : constant String :=
108                             Major_Id_Name (Lib_File, Lib_Version);
109          begin
110             if Maj_Version'Length /= 0 then
111                Version_Arg := new String'("-Wl,-soname," & Maj_Version);
112
113             else
114                Version_Arg := new String'("-Wl,-soname," & Lib_Version);
115             end if;
116
117             if Is_Absolute_Path (Lib_Version) then
118                Utl.Gcc
119                  (Output_File => Lib_Version,
120                   Objects     => Ofiles,
121                   Options     =>
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;
126
127             else
128                Utl.Gcc
129                  (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
130                   Objects     => Ofiles,
131                   Options     =>
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;
137             end if;
138
139             if Symbolic_Link_Needed then
140                Create_Sym_Links
141                  (Lib_Path, Lib_Version, Lib_Dir, Maj_Version);
142             end if;
143          end;
144       end if;
145    end Build_Dynamic_Library;
146
147    --------------------
148    -- Is_Archive_Ext --
149    --------------------
150
151    function Is_Archive_Ext (Ext : String) return Boolean is
152    begin
153       return Ext = ".a" or else Ext = ".so";
154    end Is_Archive_Ext;
155
156    ----------------
157    -- PIC_Option --
158    ----------------
159
160    function PIC_Option return String is
161    begin
162       return "";
163    end PIC_Option;
164
165 begin
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;