File : mlib-tgt-specific-ia64-hpux.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 --                           (IA64 HP-UX Version)                           --
   7 --                                                                          --
   8 --                                 B o d y                                  --
   9 --                                                                          --
  10 --                     Copyright (C) 2003-2014, 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 IA64 HP-UX 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 subprograms
  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 Archive_Indexer return String;
  50 
  51    ---------------------
  52    -- Archive_Indexer --
  53    ---------------------
  54 
  55    function Archive_Indexer return String is
  56    begin
  57       return "";
  58    end Archive_Indexer;
  59 
  60    ---------------------------
  61    -- Build_Dynamic_Library --
  62    ---------------------------
  63 
  64    procedure Build_Dynamic_Library
  65      (Ofiles       : Argument_List;
  66       Options      : Argument_List;
  67       Interfaces   : Argument_List;
  68       Lib_Filename : String;
  69       Lib_Dir      : String;
  70       Symbol_Data  : Symbol_Record;
  71       Driver_Name  : Name_Id := No_Name;
  72       Lib_Version  : String  := "";
  73       Auto_Init    : Boolean := False)
  74    is
  75       pragma Unreferenced (Interfaces);
  76       pragma Unreferenced (Symbol_Data);
  77       pragma Unreferenced (Auto_Init);
  78 
  79       Lib_File : constant String :=
  80                    "lib" & Fil.Append_To (Lib_Filename, DLL_Ext);
  81 
  82       Lib_Path : constant String :=
  83                    Lib_Dir & Directory_Separator & Lib_File;
  84 
  85       Version_Arg          : String_Access;
  86       Symbolic_Link_Needed : Boolean := False;
  87 
  88       Common_Options : constant Argument_List :=
  89                          Options & new String'(PIC_Option);
  90       --  Common set of options to the gcc command performing the link. On
  91       --  HPUX, this command eventually resorts to collect2, which may generate
  92       --  a C file and compile it on the fly. This compilation also generates
  93       --  position independent code for the final link to succeed.
  94    begin
  95       if Opt.Verbose_Mode then
  96          Write_Str ("building relocatable shared library ");
  97          Write_Line (Lib_Path);
  98       end if;
  99 
 100       if Lib_Version = "" then
 101          MLib.Utl.Gcc
 102            (Output_File => Lib_Path,
 103             Objects     => Ofiles,
 104             Options     => Common_Options,
 105             Options_2   => No_Argument_List,
 106             Driver_Name => Driver_Name);
 107 
 108       else
 109          declare
 110             Maj_Version : constant String :=
 111                             Major_Id_Name (Lib_File, Lib_Version);
 112          begin
 113             if Maj_Version'Length /= 0 then
 114                Version_Arg := new String'("-Wl,+h," & Maj_Version);
 115 
 116             else
 117                Version_Arg := new String'("-Wl,+h," & Lib_Version);
 118             end if;
 119 
 120             if Is_Absolute_Path (Lib_Version) then
 121                MLib.Utl.Gcc
 122                  (Output_File => Lib_Version,
 123                   Objects     => Ofiles,
 124                   Options     => Common_Options & Version_Arg,
 125                   Options_2   => No_Argument_List,
 126                   Driver_Name => Driver_Name);
 127                Symbolic_Link_Needed := Lib_Version /= Lib_Path;
 128 
 129             else
 130                MLib.Utl.Gcc
 131                  (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
 132                   Objects     => Ofiles,
 133                   Options     => Common_Options & Version_Arg,
 134                   Options_2   => No_Argument_List,
 135                   Driver_Name => Driver_Name);
 136                Symbolic_Link_Needed :=
 137                  Lib_Dir & Directory_Separator & Lib_Version /= Lib_Path;
 138             end if;
 139 
 140             if Symbolic_Link_Needed then
 141                Create_Sym_Links
 142                  (Lib_Path, Lib_Version, Lib_Dir, Maj_Version);
 143             end if;
 144          end;
 145       end if;
 146    end Build_Dynamic_Library;
 147 
 148 begin
 149    Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
 150    Archive_Indexer_Ptr := Archive_Indexer'Access;
 151 end MLib.Tgt.Specific;