OSDN Git Service

2007-08-14 Robert Dewar <dewar@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       Options      : Argument_List;
47       Interfaces   : Argument_List;
48       Lib_Filename : String;
49       Lib_Dir      : String;
50       Symbol_Data  : Symbol_Record;
51       Driver_Name  : Name_Id := No_Name;
52       Lib_Version  : String  := "";
53       Auto_Init    : Boolean := False);
54
55    function DLL_Ext return String;
56
57    function DLL_Prefix return String;
58
59    function Is_Archive_Ext (Ext : String) return Boolean;
60
61    function Library_Major_Minor_Id_Supported return Boolean;
62
63    function PIC_Option return String;
64
65    No_Argument_List : constant String_List := (1 .. 0 => null);
66    --  Used as value of parameter Options or Options2 in calls to Gcc
67
68    ---------------------------
69    -- Build_Dynamic_Library --
70    ---------------------------
71
72    procedure Build_Dynamic_Library
73      (Ofiles       : Argument_List;
74       Options      : Argument_List;
75       Interfaces   : Argument_List;
76       Lib_Filename : String;
77       Lib_Dir      : String;
78       Symbol_Data  : Symbol_Record;
79       Driver_Name  : Name_Id := No_Name;
80       Lib_Version  : String  := "";
81       Auto_Init    : Boolean := False)
82    is
83       pragma Unreferenced (Symbol_Data);
84       pragma Unreferenced (Interfaces);
85       pragma Unreferenced (Lib_Version);
86       pragma Unreferenced (Auto_Init);
87
88       Lib_File : constant String :=
89                    Lib_Dir & Directory_Separator &
90                    DLL_Prefix & Files.Append_To (Lib_Filename, DLL_Ext);
91
92    --  Start of processing for Build_Dynamic_Library
93
94    begin
95       if Opt.Verbose_Mode then
96          Write_Str ("building relocatable shared library ");
97          Write_Line (Lib_File);
98       end if;
99
100       Tools.Gcc
101         (Output_File => Lib_File,
102          Objects     => Ofiles,
103          Options     => No_Argument_List,
104          Options_2   => Options,
105          Driver_Name => Driver_Name);
106    end Build_Dynamic_Library;
107
108    -------------
109    -- DLL_Ext --
110    -------------
111
112    function DLL_Ext return String is
113    begin
114       return "dll";
115    end DLL_Ext;
116
117    ----------------
118    -- DLL_Prefix --
119    ----------------
120
121    function DLL_Prefix return String is
122    begin
123       return "lib";
124    end DLL_Prefix;
125
126    --------------------
127    -- Is_Archive_Ext --
128    --------------------
129
130    function Is_Archive_Ext (Ext : String) return Boolean is
131    begin
132       return Ext = ".a" or else Ext = ".dll";
133    end Is_Archive_Ext;
134
135    --------------------------------------
136    -- Library_Major_Minor_Id_Supported --
137    --------------------------------------
138
139    function Library_Major_Minor_Id_Supported return Boolean is
140    begin
141       return False;
142    end Library_Major_Minor_Id_Supported;
143
144    ----------------
145    -- PIC_Option --
146    ----------------
147
148    function PIC_Option return String is
149    begin
150       return "";
151    end PIC_Option;
152
153 begin
154    Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
155    DLL_Ext_Ptr               := DLL_Ext'Access;
156    DLL_Prefix_Ptr            := DLL_Prefix'Access;
157    Is_Archive_Ext_Ptr        := Is_Archive_Ext'Access;
158    PIC_Option_Ptr            := PIC_Option'Access;
159    Library_Major_Minor_Id_Supported_Ptr :=
160                                 Library_Major_Minor_Id_Supported'Access;
161 end MLib.Tgt.Specific;