OSDN Git Service

2007-04-20 Eric Botcazou <ebotcazou@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / mlib-tgt-mingw.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 --                            (Windows 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 Windows version of the body. Works only with GCC versions
29 --  supporting the "-shared" option.
30
31 with Opt;
32 with Output; use Output;
33
34 with MLib.Fil;
35 with MLib.Utl;
36
37 package body MLib.Tgt.Specific is
38
39    package Files renames MLib.Fil;
40    package Tools renames MLib.Utl;
41
42    --  Non default subprograms
43
44    procedure Build_Dynamic_Library
45      (Ofiles       : Argument_List;
46       Foreign      : Argument_List;
47       Afiles       : Argument_List;
48       Options      : Argument_List;
49       Options_2    : Argument_List;
50       Interfaces   : Argument_List;
51       Lib_Filename : String;
52       Lib_Dir      : String;
53       Symbol_Data  : Symbol_Record;
54       Driver_Name  : Name_Id := No_Name;
55       Lib_Version  : String  := "";
56       Auto_Init    : Boolean := False);
57
58    function DLL_Ext return String;
59
60    function DLL_Prefix return String;
61
62    function Is_Archive_Ext (Ext : String) return Boolean;
63
64    function PIC_Option return String;
65
66    No_Argument_List : constant String_List := (1 .. 0 => null);
67    --  Used as value of parameter Options or Options2 in calls to Gcc
68
69    ---------------------------
70    -- Build_Dynamic_Library --
71    ---------------------------
72
73    procedure Build_Dynamic_Library
74      (Ofiles       : Argument_List;
75       Foreign      : Argument_List;
76       Afiles       : Argument_List;
77       Options      : Argument_List;
78       Options_2    : Argument_List;
79       Interfaces   : Argument_List;
80       Lib_Filename : String;
81       Lib_Dir      : String;
82       Symbol_Data  : Symbol_Record;
83       Driver_Name  : Name_Id := No_Name;
84       Lib_Version  : String  := "";
85       Auto_Init    : Boolean := False)
86    is
87       pragma Unreferenced (Foreign);
88       pragma Unreferenced (Afiles);
89       pragma Unreferenced (Symbol_Data);
90       pragma Unreferenced (Interfaces);
91       pragma Unreferenced (Lib_Version);
92       pragma Unreferenced (Auto_Init);
93
94       Lib_File : constant String :=
95                    Lib_Dir & Directory_Separator &
96                    Files.Append_To (Lib_Filename, DLL_Ext);
97
98    --  Start of processing for Build_Dynamic_Library
99
100    begin
101       if Opt.Verbose_Mode then
102          Write_Str ("building relocatable shared library ");
103          Write_Line (Lib_File);
104       end if;
105
106       Tools.Gcc
107         (Output_File => Lib_File,
108          Objects     => Ofiles,
109          Options     => No_Argument_List,
110          Options_2   => Options & Options_2,
111          Driver_Name => Driver_Name);
112    end Build_Dynamic_Library;
113
114    -------------
115    -- DLL_Ext --
116    -------------
117
118    function DLL_Ext return String is
119    begin
120       return "dll";
121    end DLL_Ext;
122
123    ----------------
124    -- DLL_Prefix --
125    ----------------
126
127    function DLL_Prefix return String is
128    begin
129       return "";
130    end DLL_Prefix;
131
132    --------------------
133    -- Is_Archive_Ext --
134    --------------------
135
136    function Is_Archive_Ext (Ext : String) return Boolean is
137    begin
138       return Ext = ".a" or else Ext = ".dll";
139    end Is_Archive_Ext;
140
141    ----------------
142    -- PIC_Option --
143    ----------------
144
145    function PIC_Option return String is
146    begin
147       return "";
148    end PIC_Option;
149
150 begin
151    Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
152    DLL_Ext_Ptr := DLL_Ext'Access;
153    DLL_Prefix_Ptr := DLL_Prefix'Access;
154    Is_Archive_Ext_Ptr := Is_Archive_Ext'Access;
155    PIC_Option_Ptr := PIC_Option'Access;
156 end MLib.Tgt.Specific;