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-mingw.adb] - Blame information for rev 12

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
--                            (Windows 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 Windows version of the body. Works only with GCC versions
32
--  supporting the "-shared" option.
33
 
34
with Namet;  use Namet;
35
with Opt;
36
with Output; use Output;
37
with Prj.Com;
38
 
39
with MLib.Fil;
40
with MLib.Utl;
41
 
42
package body MLib.Tgt is
43
 
44
   package Files renames MLib.Fil;
45
   package Tools renames MLib.Utl;
46
 
47
   No_Argument_List : constant String_List := (1 .. 0 => null);
48
   --  Used as value of parameter Options or Options2 in calls to Gcc
49
 
50
   ---------------------
51
   -- Archive_Builder --
52
   ---------------------
53
 
54
   function Archive_Builder return String is
55
   begin
56
      return "ar";
57
   end Archive_Builder;
58
 
59
   -----------------------------
60
   -- Archive_Builder_Options --
61
   -----------------------------
62
 
63
   function Archive_Builder_Options return String_List_Access is
64
   begin
65
      return new String_List'(1 => new String'("cr"));
66
   end Archive_Builder_Options;
67
 
68
   -----------------
69
   -- Archive_Ext --
70
   -----------------
71
 
72
   function Archive_Ext return  String is
73
   begin
74
      return "a";
75
   end Archive_Ext;
76
 
77
   ---------------------
78
   -- Archive_Indexer --
79
   ---------------------
80
 
81
   function Archive_Indexer return String is
82
   begin
83
      return "ranlib";
84
   end Archive_Indexer;
85
 
86
   -----------------------------
87
   -- Archive_Indexer_Options --
88
   -----------------------------
89
 
90
   function Archive_Indexer_Options return String_List_Access is
91
   begin
92
      return new String_List (1 .. 0);
93
   end Archive_Indexer_Options;
94
 
95
   ---------------------------
96
   -- Build_Dynamic_Library --
97
   ---------------------------
98
 
99
   procedure Build_Dynamic_Library
100
     (Ofiles       : Argument_List;
101
      Foreign      : Argument_List;
102
      Afiles       : Argument_List;
103
      Options      : Argument_List;
104
      Options_2    : Argument_List;
105
      Interfaces   : Argument_List;
106
      Lib_Filename : String;
107
      Lib_Dir      : String;
108
      Symbol_Data  : Symbol_Record;
109
      Driver_Name  : Name_Id := No_Name;
110
      Lib_Version  : String  := "";
111
      Auto_Init    : Boolean := False)
112
   is
113
      pragma Unreferenced (Foreign);
114
      pragma Unreferenced (Afiles);
115
      pragma Unreferenced (Symbol_Data);
116
      pragma Unreferenced (Interfaces);
117
      pragma Unreferenced (Lib_Version);
118
      pragma Unreferenced (Auto_Init);
119
 
120
      Lib_File : constant String :=
121
                   Lib_Dir & Directory_Separator &
122
                   Files.Ext_To (Lib_Filename, DLL_Ext);
123
 
124
   --  Start of processing for Build_Dynamic_Library
125
 
126
   begin
127
      if Opt.Verbose_Mode then
128
         Write_Str ("building relocatable shared library ");
129
         Write_Line (Lib_File);
130
      end if;
131
 
132
      Tools.Gcc
133
        (Output_File => Lib_File,
134
         Objects     => Ofiles,
135
         Options     => No_Argument_List,
136
         Options_2   => Options & Options_2,
137
         Driver_Name => Driver_Name);
138
   end Build_Dynamic_Library;
139
 
140
   -------------
141
   -- DLL_Ext --
142
   -------------
143
 
144
   function DLL_Ext return String is
145
   begin
146
      return "dll";
147
   end DLL_Ext;
148
 
149
   ----------------
150
   -- DLL_Prefix --
151
   ----------------
152
 
153
   function DLL_Prefix return String is
154
   begin
155
      return "";
156
   end DLL_Prefix;
157
 
158
   --------------------
159
   -- Dynamic_Option --
160
   --------------------
161
 
162
   function Dynamic_Option return String is
163
   begin
164
      return "-shared";
165
   end Dynamic_Option;
166
 
167
   -------------------
168
   -- Is_Object_Ext --
169
   -------------------
170
 
171
   function Is_Object_Ext (Ext : String) return Boolean is
172
   begin
173
      return Ext = ".o";
174
   end Is_Object_Ext;
175
 
176
   --------------
177
   -- Is_C_Ext --
178
   --------------
179
 
180
   function Is_C_Ext (Ext : String) return Boolean is
181
   begin
182
      return Ext = ".c";
183
   end Is_C_Ext;
184
 
185
   --------------------
186
   -- Is_Archive_Ext --
187
   --------------------
188
 
189
   function Is_Archive_Ext (Ext : String) return Boolean is
190
   begin
191
      return Ext = ".a" or else Ext = ".dll";
192
   end Is_Archive_Ext;
193
 
194
   -------------
195
   -- Libgnat --
196
   -------------
197
 
198
   function Libgnat return String is
199
   begin
200
      return "libgnat.a";
201
   end Libgnat;
202
 
203
   ------------------------
204
   -- Library_Exists_For --
205
   ------------------------
206
 
207
   function Library_Exists_For
208
     (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean is
209
   begin
210
      if not In_Tree.Projects.Table (Project).Library then
211
         Prj.Com.Fail ("INTERNAL ERROR: Library_Exists_For called " &
212
                       "for non library project");
213
         return False;
214
 
215
      else
216
         declare
217
            Lib_Dir : constant String :=
218
              Get_Name_String
219
                (In_Tree.Projects.Table (Project).Library_Dir);
220
            Lib_Name : constant String :=
221
              Get_Name_String
222
                (In_Tree.Projects.Table (Project).Library_Name);
223
 
224
         begin
225
            if In_Tree.Projects.Table (Project).Library_Kind =
226
              Static
227
            then
228
               return Is_Regular_File
229
                 (Lib_Dir & Directory_Separator & "lib" &
230
                  MLib.Fil.Ext_To (Lib_Name, Archive_Ext));
231
 
232
            else
233
               return Is_Regular_File
234
                 (Lib_Dir & Directory_Separator &
235
                  MLib.Fil.Ext_To (Lib_Name, DLL_Ext));
236
            end if;
237
         end;
238
      end if;
239
   end Library_Exists_For;
240
 
241
   ---------------------------
242
   -- Library_File_Name_For --
243
   ---------------------------
244
 
245
   function Library_File_Name_For
246
     (Project : Project_Id;
247
      In_Tree : Project_Tree_Ref) return Name_Id is
248
   begin
249
      if not In_Tree.Projects.Table (Project).Library then
250
         Prj.Com.Fail ("INTERNAL ERROR: Library_File_Name_For called " &
251
                       "for non library project");
252
         return No_Name;
253
 
254
      else
255
         declare
256
            Lib_Name : constant String :=
257
              Get_Name_String
258
                (In_Tree.Projects.Table (Project).Library_Name);
259
 
260
         begin
261
            if In_Tree.Projects.Table (Project).Library_Kind =
262
              Static
263
            then
264
               Name_Len := 3;
265
               Name_Buffer (1 .. Name_Len) := "lib";
266
               Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, Archive_Ext));
267
 
268
            else
269
               Name_Len := 0;
270
               Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, DLL_Ext));
271
            end if;
272
 
273
            return Name_Find;
274
         end;
275
      end if;
276
   end Library_File_Name_For;
277
 
278
   ----------------
279
   -- Object_Ext --
280
   ----------------
281
 
282
   function Object_Ext return String is
283
   begin
284
      return "o";
285
   end Object_Ext;
286
 
287
   ----------------
288
   -- PIC_Option --
289
   ----------------
290
 
291
   function PIC_Option return String is
292
   begin
293
      return "";
294
   end PIC_Option;
295
 
296
   -----------------------------------------------
297
   -- Standalone_Library_Auto_Init_Is_Supported --
298
   -----------------------------------------------
299
 
300
   function Standalone_Library_Auto_Init_Is_Supported return Boolean is
301
   begin
302
      return True;
303
   end Standalone_Library_Auto_Init_Is_Supported;
304
 
305
   ---------------------------
306
   -- Support_For_Libraries --
307
   ---------------------------
308
 
309
   function Support_For_Libraries return Library_Support is
310
   begin
311
      return Full;
312
   end Support_For_Libraries;
313
 
314
end MLib.Tgt;

powered by: WebSVN 2.1.0

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