OSDN Git Service

Minor reformatting.
[pf3gnuchains/gcc-fork.git] / gcc / ada / mlib-utl.adb
index 0381a41..78378a6 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                     Copyright (C) 2002-2007, AdaCore                     --
+--                     Copyright (C) 2002-2008, 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- --
@@ -35,6 +35,10 @@ with System;
 
 package body MLib.Utl is
 
+   Adalib_Path : String_Access := null;
+   --  Path of the GNAT adalib directory, specified in procedure
+   --  Specify_Adalib_Dir. Used in function Lib_Directory.
+
    Gcc_Name : String_Access;
    --  Default value of the "gcc" executable used in procedure Gcc
 
@@ -136,7 +140,7 @@ package body MLib.Utl is
 
    begin
       if Ar_Exec = null then
-         Ar_Name := Osint.Program_Name (Archive_Builder);
+         Ar_Name := Osint.Program_Name (Archive_Builder, "gnatmake");
          Ar_Exec := Locate_Exec_On_Path (Ar_Name.all);
 
          if Ar_Exec = null then
@@ -146,7 +150,7 @@ package body MLib.Utl is
          end if;
 
          if Ar_Exec = null then
-            Fail (Ar_Name.all, " not found in path");
+            Fail (Ar_Name.all & " not found in path");
 
          elsif Opt.Verbose_Mode then
             Write_Str  ("found ");
@@ -177,7 +181,7 @@ package body MLib.Utl is
 
          --  ranlib
 
-         Ranlib_Name := Osint.Program_Name (Archive_Indexer);
+         Ranlib_Name := Osint.Program_Name (Archive_Indexer, "gnatmake");
 
          if Ranlib_Name'Length > 0 then
             Ranlib_Exec := Locate_Exec_On_Path (Ranlib_Name.all);
@@ -271,7 +275,7 @@ package body MLib.Utl is
       end if;
 
       if not Success then
-         Fail (Ar_Name.all, " execution error.");
+         Fail (Ar_Name.all & " execution error.");
       end if;
 
       --  If we have found ranlib, run it over the library
@@ -289,7 +293,7 @@ package body MLib.Utl is
             Success);
 
          if not Success then
-            Fail (Ranlib_Name.all, " execution error.");
+            Fail (Ranlib_Name.all & " execution error.");
          end if;
       end if;
    end Ar;
@@ -299,7 +303,7 @@ package body MLib.Utl is
    -----------------
 
    procedure Delete_File (Filename : String) is
-      File    : constant String := Filename & ASCII.Nul;
+      File    : constant String := Filename & ASCII.NUL;
       Success : Boolean;
 
    begin
@@ -408,13 +412,13 @@ package body MLib.Utl is
       if Driver_Name = No_Name then
          if Gcc_Exec = null then
             if Gcc_Name = null then
-               Gcc_Name :=  Osint.Program_Name ("gcc");
+               Gcc_Name := Osint.Program_Name ("gcc", "gnatmake");
             end if;
 
             Gcc_Exec := Locate_Exec_On_Path (Gcc_Name.all);
 
             if Gcc_Exec = null then
-               Fail (Gcc_Name.all, " not found in path");
+               Fail (Gcc_Name.all & " not found in path");
             end if;
          end if;
 
@@ -424,7 +428,7 @@ package body MLib.Utl is
          Driver := Locate_Exec_On_Path (Get_Name_String (Driver_Name));
 
          if Driver = null then
-            Fail (Get_Name_String (Driver_Name), " not found in path");
+            Fail (Get_Name_String (Driver_Name) & " not found in path");
          end if;
       end if;
 
@@ -582,9 +586,9 @@ package body MLib.Utl is
 
       if not Success then
          if Driver_Name = No_Name then
-            Fail (Gcc_Name.all, " execution error");
+            Fail (Gcc_Name.all & " execution error");
          else
-            Fail (Get_Name_String (Driver_Name), " execution error");
+            Fail (Get_Name_String (Driver_Name) & " execution error");
          end if;
       end if;
    end Gcc;
@@ -597,6 +601,13 @@ package body MLib.Utl is
       Libgnat : constant String := Tgt.Libgnat;
 
    begin
+      --  If procedure Specify_Adalib_Dir has been called, used the specified
+      --  value.
+
+      if Adalib_Path /= null then
+         return Adalib_Path.all;
+      end if;
+
       Name_Len := Libgnat'Length;
       Name_Buffer (1 .. Name_Len) := Libgnat;
       Get_Name_String (Osint.Find_File (Name_Enter, Osint.Library));
@@ -606,4 +617,17 @@ package body MLib.Utl is
       return Name_Buffer (1 .. Name_Len - Libgnat'Length);
    end Lib_Directory;
 
+   ------------------------
+   -- Specify_Adalib_Dir --
+   ------------------------
+
+   procedure Specify_Adalib_Dir (Path : String) is
+   begin
+      if Path'Length = 0 then
+         Adalib_Path := null;
+      else
+         Adalib_Path := new String'(Path);
+      end if;
+   end Specify_Adalib_Dir;
+
 end MLib.Utl;