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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [ada/] [mlib-tgt-tru64.adb] - Blame information for rev 20

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

Line No. Rev Author Line
1 12 jlechner
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--                             M L I B . T G T                              --
6
--                             (True64 Version)                             --
7
--                                                                          --
8
--                                 B o d y                                  --
9
--                                                                          --
10
--          Copyright (C) 2002-2005 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 package provides a set of target dependent routines to build
29
--  static, dynamic and shared libraries.
30
 
31
--  This is the True64 version of the body
32
 
33
with MLib.Fil;
34
with MLib.Utl;
35
with Namet;  use Namet;
36
with Opt;
37
with Output; use Output;
38
with Prj.Com;
39
with System;
40
 
41
package body MLib.Tgt is
42
 
43
   use GNAT;
44
   use MLib;
45
 
46
   Expect_Unresolved : aliased String := "-Wl,-expect_unresolved,*";
47
 
48
   ---------------------
49
   -- Archive_Builder --
50
   ---------------------
51
 
52
   function Archive_Builder return String is
53
   begin
54
      return "ar";
55
   end Archive_Builder;
56
 
57
   -----------------------------
58
   -- Archive_Builder_Options --
59
   -----------------------------
60
 
61
   function Archive_Builder_Options return String_List_Access is
62
   begin
63
      return new String_List'(1 => new String'("cr"));
64
   end Archive_Builder_Options;
65
 
66
   -----------------
67
   -- Archive_Ext --
68
   -----------------
69
 
70
   function Archive_Ext return  String is
71
   begin
72
      return "a";
73
   end Archive_Ext;
74
 
75
   ---------------------
76
   -- Archive_Indexer --
77
   ---------------------
78
 
79
   function Archive_Indexer return String is
80
   begin
81
      return "ranlib";
82
   end Archive_Indexer;
83
 
84
   -----------------------------
85
   -- Archive_Indexer_Options --
86
   -----------------------------
87
 
88
   function Archive_Indexer_Options return String_List_Access is
89
   begin
90
      return new String_List (1 .. 0);
91
   end Archive_Indexer_Options;
92
 
93
   ---------------------------
94
   -- Build_Dynamic_Library --
95
   ---------------------------
96
 
97
   procedure Build_Dynamic_Library
98
     (Ofiles       : Argument_List;
99
      Foreign      : Argument_List;
100
      Afiles       : Argument_List;
101
      Options      : Argument_List;
102
      Options_2    : Argument_List;
103
      Interfaces   : Argument_List;
104
      Lib_Filename : String;
105
      Lib_Dir      : String;
106
      Symbol_Data  : Symbol_Record;
107
      Driver_Name  : Name_Id := No_Name;
108
      Lib_Version  : String  := "";
109
      Auto_Init    : Boolean := False)
110
   is
111
      pragma Unreferenced (Foreign);
112
      pragma Unreferenced (Afiles);
113
      pragma Unreferenced (Interfaces);
114
      pragma Unreferenced (Symbol_Data);
115
      pragma Unreferenced (Auto_Init);
116
      --  Initialization is done through the contructor mechanism
117
 
118
      Lib_File : constant String :=
119
                   Lib_Dir & Directory_Separator & "lib" &
120
                   Fil.Ext_To (Lib_Filename, DLL_Ext);
121
 
122
      Version_Arg          : String_Access;
123
      Symbolic_Link_Needed : Boolean := False;
124
 
125
   begin
126
      if Opt.Verbose_Mode then
127
         Write_Str ("building relocatable shared library ");
128
         Write_Line (Lib_File);
129
      end if;
130
 
131
      --  If specified, add automatic elaboration/finalization
132
 
133
      if Lib_Version = "" then
134
         Utl.Gcc
135
           (Output_File => Lib_File,
136
            Objects     => Ofiles,
137
            Options     => Options & Expect_Unresolved'Access,
138
            Options_2   => Options_2,
139
            Driver_Name => Driver_Name);
140
 
141
      else
142
         Version_Arg := new String'("-Wl,-soname," & Lib_Version);
143
 
144
         if Is_Absolute_Path (Lib_Version) then
145
            Utl.Gcc
146
              (Output_File => Lib_Version,
147
               Objects     => Ofiles,
148
               Options     =>
149
                 Options & Version_Arg & Expect_Unresolved'Access,
150
               Options_2   => Options_2,
151
               Driver_Name => Driver_Name);
152
            Symbolic_Link_Needed := Lib_Version /= Lib_File;
153
 
154
         else
155
            Utl.Gcc
156
              (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
157
               Objects     => Ofiles,
158
               Options     =>
159
                 Options & Version_Arg & Expect_Unresolved'Access,
160
               Options_2   => Options_2,
161
               Driver_Name => Driver_Name);
162
            Symbolic_Link_Needed :=
163
              Lib_Dir & Directory_Separator & Lib_Version /= Lib_File;
164
         end if;
165
 
166
         if Symbolic_Link_Needed then
167
            declare
168
               Success : Boolean;
169
               Oldpath : String (1 .. Lib_Version'Length + 1);
170
               Newpath : String (1 .. Lib_File'Length + 1);
171
 
172
               Result : Integer;
173
               pragma Unreferenced (Result);
174
 
175
               function Symlink
176
                 (Oldpath : System.Address;
177
                  Newpath : System.Address)
178
                  return    Integer;
179
               pragma Import (C, Symlink, "__gnat_symlink");
180
 
181
            begin
182
               Oldpath (1 .. Lib_Version'Length) := Lib_Version;
183
               Oldpath (Oldpath'Last)            := ASCII.NUL;
184
               Newpath (1 .. Lib_File'Length)    := Lib_File;
185
               Newpath (Newpath'Last)            := ASCII.NUL;
186
 
187
               Delete_File (Lib_File, Success);
188
 
189
               Result := Symlink (Oldpath'Address, Newpath'Address);
190
            end;
191
         end if;
192
      end if;
193
   end Build_Dynamic_Library;
194
 
195
   -------------
196
   -- DLL_Ext --
197
   -------------
198
 
199
   function DLL_Ext return String is
200
   begin
201
      return "so";
202
   end DLL_Ext;
203
 
204
   ----------------
205
   -- DLL_Prefix --
206
   ----------------
207
 
208
   function DLL_Prefix return String is
209
   begin
210
      return "lib";
211
   end DLL_Prefix;
212
 
213
   --------------------
214
   -- Dynamic_Option --
215
   --------------------
216
 
217
   function Dynamic_Option return String is
218
   begin
219
      return "-shared";
220
   end Dynamic_Option;
221
 
222
   -------------------
223
   -- Is_Object_Ext --
224
   -------------------
225
 
226
   function Is_Object_Ext (Ext : String) return Boolean is
227
   begin
228
      return Ext = ".o";
229
   end Is_Object_Ext;
230
 
231
   --------------
232
   -- Is_C_Ext --
233
   --------------
234
 
235
   function Is_C_Ext (Ext : String) return Boolean is
236
   begin
237
      return Ext = ".c";
238
   end Is_C_Ext;
239
 
240
   --------------------
241
   -- Is_Archive_Ext --
242
   --------------------
243
 
244
   function Is_Archive_Ext (Ext : String) return Boolean is
245
   begin
246
      return Ext = ".a" or else Ext = ".so";
247
   end Is_Archive_Ext;
248
 
249
   -------------
250
   -- Libgnat --
251
   -------------
252
 
253
   function Libgnat return String is
254
   begin
255
      return "libgnat.a";
256
   end Libgnat;
257
 
258
   ------------------------
259
   -- Library_Exists_For --
260
   ------------------------
261
 
262
   function Library_Exists_For
263
     (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean
264
   is
265
   begin
266
      if not In_Tree.Projects.Table (Project).Library then
267
         Prj.Com.Fail ("INTERNAL ERROR: Library_Exists_For called " &
268
                       "for non library project");
269
         return False;
270
 
271
      else
272
         declare
273
            Lib_Dir : constant String :=
274
              Get_Name_String
275
                (In_Tree.Projects.Table (Project).Library_Dir);
276
            Lib_Name : constant String :=
277
              Get_Name_String
278
                (In_Tree.Projects.Table (Project).Library_Name);
279
 
280
         begin
281
            if In_Tree.Projects.Table (Project).Library_Kind =
282
              Static
283
            then
284
               return Is_Regular_File
285
                 (Lib_Dir & Directory_Separator & "lib" &
286
                  Fil.Ext_To (Lib_Name, Archive_Ext));
287
 
288
            else
289
               return Is_Regular_File
290
                 (Lib_Dir & Directory_Separator & "lib" &
291
                  Fil.Ext_To (Lib_Name, DLL_Ext));
292
            end if;
293
         end;
294
      end if;
295
   end Library_Exists_For;
296
 
297
   ---------------------------
298
   -- Library_File_Name_For --
299
   ---------------------------
300
 
301
   function Library_File_Name_For
302
     (Project : Project_Id;
303
      In_Tree : Project_Tree_Ref) return Name_Id
304
   is
305
   begin
306
      if not In_Tree.Projects.Table (Project).Library then
307
         Prj.Com.Fail ("INTERNAL ERROR: Library_File_Name_For called " &
308
                       "for non library project");
309
         return No_Name;
310
 
311
      else
312
         declare
313
            Lib_Name : constant String :=
314
              Get_Name_String
315
                (In_Tree.Projects.Table (Project).Library_Name);
316
 
317
         begin
318
            Name_Len := 3;
319
            Name_Buffer (1 .. Name_Len) := "lib";
320
 
321
            if In_Tree.Projects.Table (Project).Library_Kind =
322
              Static
323
            then
324
               Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, Archive_Ext));
325
 
326
            else
327
               Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, DLL_Ext));
328
            end if;
329
 
330
            return Name_Find;
331
         end;
332
      end if;
333
   end Library_File_Name_For;
334
 
335
   ----------------
336
   -- Object_Ext --
337
   ----------------
338
 
339
   function Object_Ext return String is
340
   begin
341
      return "o";
342
   end Object_Ext;
343
 
344
   ----------------
345
   -- PIC_Option --
346
   ----------------
347
 
348
   function PIC_Option return String is
349
   begin
350
      return "";
351
   end PIC_Option;
352
 
353
   -----------------------------------------------
354
   -- Standalone_Library_Auto_Init_Is_Supported --
355
   -----------------------------------------------
356
 
357
   function Standalone_Library_Auto_Init_Is_Supported return Boolean is
358
   begin
359
      return True;
360
   end Standalone_Library_Auto_Init_Is_Supported;
361
 
362
   ---------------------------
363
   -- Support_For_Libraries --
364
   ---------------------------
365
 
366
   function Support_For_Libraries return Library_Support is
367
   begin
368
      return Full;
369
   end Support_For_Libraries;
370
 
371
end MLib.Tgt;

powered by: WebSVN 2.1.0

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