8sa1-gcc/gcc/ada/mlib-fil.adb
Vincent Celier f95969eabc mlib-tgt-lynxos.adb, [...]: Use Append_To, instead of Ext_To, when building the library file name
2006-10-31  Vincent Celier  <celier@adacore.com>
	    Eric Botcazou  <ebotcazou@adacore.com>

	* mlib-tgt-lynxos.adb, mlib-tgt-mingw.adb, mlib-tgt-tru64.adb,
	mlib-tgt-aix.adb, mlib-tgt-irix.adb, mlib-tgt-hpux.adb,
	mlib-tgt-linux.adb, mlib-tgt-solaris.adb: Use Append_To, instead of
	Ext_To, when building the library file name

	* mlib-tgt-vxworks.adb: ditto.
	(Get_Target_Suffix): Add support for x86 targets.

	* mlib-fil.ads, mlib-fil.adb: (Append_To): New function

	* mlib-tgt-darwin.adb: 
	Use Append_To, instead of Ext_To, when building the library file name
	(Flat_Namespace): New global variable.
	(No_Shared_Libgcc_Switch): Rename to No_Shared_Libgcc_Options.
	(Shared_Libgcc_Switch): Rename to With_Shared_Libgcc_Options.
	(Link_Shared_Libgcc): Delete.
	(Build_Dynamic_Library): Adjust for above changes.
	Use Opt package.
	(Build_Dynamic_Library): Pass -shared-libgcc if GCC 4 or later.

From-SVN: r118237
2006-10-31 18:45:59 +01:00

151 lines
4.5 KiB
Ada

------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- M L I B . F I L --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2006, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides a set of routines to deal with file extensions
with Ada.Strings.Fixed;
with MLib.Tgt;
package body MLib.Fil is
use Ada;
package Target renames MLib.Tgt;
---------------
-- Append_To --
---------------
function Append_To
(Filename : String;
Ext : String) return String
is
begin
if Ext'Length = 0 then
return Filename;
elsif Filename (Filename'Last) = '.' then
if Ext (Ext'First) = '.' then
return Filename & Ext (Ext'First + 1 .. Ext'Last);
else
return Filename & Ext;
end if;
else
if Ext (Ext'First) = '.' then
return Filename & Ext;
else
return Filename & '.' & Ext;
end if;
end if;
end Append_To;
------------
-- Ext_To --
------------
function Ext_To
(Filename : String;
New_Ext : String := "") return String
is
use Strings.Fixed;
J : constant Natural :=
Index (Source => Filename,
Pattern => ".",
Going => Strings.Backward);
begin
if J = 0 then
if New_Ext = "" then
return Filename;
else
return Filename & "." & New_Ext;
end if;
else
if New_Ext = "" then
return Head (Filename, J - 1);
else
return Head (Filename, J - 1) & '.' & New_Ext;
end if;
end if;
end Ext_To;
-------------
-- Get_Ext --
-------------
function Get_Ext (Filename : String) return String is
use Strings.Fixed;
J : constant Natural :=
Index (Source => Filename,
Pattern => ".",
Going => Strings.Backward);
begin
if J = 0 then
return "";
else
return Filename (J .. Filename'Last);
end if;
end Get_Ext;
----------------
-- Is_Archive --
----------------
function Is_Archive (Filename : String) return Boolean is
Ext : constant String := Get_Ext (Filename);
begin
return Target.Is_Archive_Ext (Ext);
end Is_Archive;
----------
-- Is_C --
----------
function Is_C (Filename : String) return Boolean is
Ext : constant String := Get_Ext (Filename);
begin
return Target.Is_C_Ext (Ext);
end Is_C;
------------
-- Is_Obj --
------------
function Is_Obj (Filename : String) return Boolean is
Ext : constant String := Get_Ext (Filename);
begin
return Target.Is_Object_Ext (Ext);
end Is_Obj;
end MLib.Fil;