OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [ada/] [mlib-tgt-specific-irix.adb] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--                     M L I B . T G T . S P E C I F I C                    --
6
--                              (IRIX Version)                              --
7
--                                                                          --
8
--                                 B o d y                                  --
9
--                                                                          --
10
--                     Copyright (C) 2003-2008, AdaCore                     --
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
------------------------------------------------------------------------------
26
 
27
--  This is the IRIX version of the body
28
 
29
with MLib.Fil;
30
with MLib.Utl;
31
with Opt;
32
with Output; use Output;
33
 
34
package body MLib.Tgt.Specific is
35
 
36
   --  Non default subprogram
37
 
38
   procedure Build_Dynamic_Library
39
     (Ofiles       : Argument_List;
40
      Options      : Argument_List;
41
      Interfaces   : Argument_List;
42
      Lib_Filename : String;
43
      Lib_Dir      : String;
44
      Symbol_Data  : Symbol_Record;
45
      Driver_Name  : Name_Id := No_Name;
46
      Lib_Version  : String  := "";
47
      Auto_Init    : Boolean := False);
48
 
49
   function Is_Archive_Ext (Ext : String) return Boolean;
50
 
51
   ---------------------------
52
   -- Build_Dynamic_Library --
53
   ---------------------------
54
 
55
   procedure Build_Dynamic_Library
56
     (Ofiles       : Argument_List;
57
      Options      : Argument_List;
58
      Interfaces   : Argument_List;
59
      Lib_Filename : String;
60
      Lib_Dir      : String;
61
      Symbol_Data  : Symbol_Record;
62
      Driver_Name  : Name_Id := No_Name;
63
      Lib_Version  : String  := "";
64
      Auto_Init    : Boolean := False)
65
   is
66
      pragma Unreferenced (Interfaces);
67
      pragma Unreferenced (Symbol_Data);
68
      pragma Unreferenced (Auto_Init);
69
 
70
      Lib_File : constant String :=
71
                   "lib" & MLib.Fil.Append_To (Lib_Filename, DLL_Ext);
72
 
73
      Lib_Path : constant String :=
74
                   Lib_Dir & Directory_Separator & Lib_File;
75
 
76
      Version_Arg          : String_Access;
77
      Symbolic_Link_Needed : Boolean := False;
78
 
79
      N_Options    : Argument_List := Options;
80
      Options_Last : Natural := N_Options'Last;
81
      --  After moving -lxxx to Options_2, N_Options up to index Options_Last
82
      --  will contain the Options to pass to MLib.Utl.Gcc.
83
 
84
      Real_Options_2 : Argument_List (1 .. Options'Length);
85
      Real_Options_2_Last : Natural := 0;
86
      --  Real_Options_2 up to index Real_Options_2_Last will contain the
87
      --  Options_2 to pass to MLib.Utl.Gcc.
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
      --  Move all -lxxx to Options_2
96
 
97
      declare
98
         Index : Natural := N_Options'First;
99
         Arg   : String_Access;
100
 
101
      begin
102
         while Index <= Options_Last loop
103
            Arg := N_Options (Index);
104
 
105
            if Arg'Length > 2
106
              and then Arg (Arg'First .. Arg'First + 1) = "-l"
107
            then
108
               Real_Options_2_Last := Real_Options_2_Last + 1;
109
               Real_Options_2 (Real_Options_2_Last) := Arg;
110
               N_Options (Index .. Options_Last - 1) :=
111
                 N_Options (Index + 1 .. Options_Last);
112
               Options_Last := Options_Last - 1;
113
 
114
            else
115
               Index := Index + 1;
116
            end if;
117
         end loop;
118
      end;
119
 
120
      if Lib_Version = "" then
121
         MLib.Utl.Gcc
122
           (Output_File => Lib_Path,
123
            Objects     => Ofiles,
124
            Options     => N_Options (N_Options'First .. Options_Last),
125
            Driver_Name => Driver_Name,
126
            Options_2   => Real_Options_2 (1 .. Real_Options_2_Last));
127
 
128
      else
129
         declare
130
            Maj_Version : constant String :=
131
                            Major_Id_Name (Lib_File, Lib_Version);
132
         begin
133
            if Maj_Version'Length /= 0 then
134
               Version_Arg := new String'("-Wl,-soname," & Maj_Version);
135
 
136
            else
137
               Version_Arg := new String'("-Wl,-soname," & Lib_Version);
138
            end if;
139
 
140
            if Is_Absolute_Path (Lib_Version) then
141
               MLib.Utl.Gcc
142
                 (Output_File => Lib_Version,
143
                  Objects     => Ofiles,
144
                  Options     => N_Options (N_Options'First .. Options_Last) &
145
                  Version_Arg,
146
                  Driver_Name => Driver_Name,
147
                  Options_2   => Real_Options_2 (1 .. Real_Options_2_Last));
148
               Symbolic_Link_Needed := Lib_Version /= Lib_Path;
149
 
150
            else
151
               MLib.Utl.Gcc
152
                 (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
153
                  Objects     => Ofiles,
154
                  Options     => N_Options (N_Options'First .. Options_Last) &
155
                  Version_Arg,
156
                  Driver_Name => Driver_Name,
157
                  Options_2   => Real_Options_2 (1 .. Real_Options_2_Last));
158
               Symbolic_Link_Needed :=
159
                 Lib_Dir & Directory_Separator & Lib_Version /= Lib_Path;
160
            end if;
161
 
162
            if Symbolic_Link_Needed then
163
               Create_Sym_Links
164
                 (Lib_Path, Lib_Version, Lib_Dir, Maj_Version);
165
            end if;
166
         end;
167
      end if;
168
   end Build_Dynamic_Library;
169
 
170
   --------------------
171
   -- Is_Archive_Ext --
172
   --------------------
173
 
174
   function Is_Archive_Ext (Ext : String) return Boolean is
175
   begin
176
      return Ext = ".a" or else Ext = ".so";
177
   end Is_Archive_Ext;
178
 
179
begin
180
   Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
181
   Is_Archive_Ext_Ptr := Is_Archive_Ext'Access;
182
end MLib.Tgt.Specific;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.