with GNAT.Heap_Sort_G;
with GNAT.Table;
+with Osint;
with Switch; use Switch;
with Types;
Config_File_Name : constant String_Access := new String'("gnat.adc");
-- The name of the file holding the GNAT configuration pragmas
- Gcc : String_Access := new String'("gcc");
+ Gcc : String_Access := null;
-- May be modified by switch --GCC=
- Gcc_Set : Boolean := False;
- -- True if a switch --GCC= is used
-
Gnat_Cmd : String_Access;
-- Command to execute the GNAT compiler
Integer'Image
(Maximum_File_Name_Length);
- function Locate_Executable
- (Program_Name : String;
- Look_For_Prefix : Boolean := True) return String_Access;
- -- Locate executable for given program name. This takes into account
- -- the target-prefix of the current command, if Look_For_Prefix is True.
-
subtype EOL_Length is Natural range 0 .. 2;
-- Possible lengths of end of line sequence
Unit.Table (Sorted_Units.Table (U + 1)).File_Name.all;
end Is_Duplicated;
- -----------------------
- -- Locate_Executable --
- -----------------------
-
- function Locate_Executable
- (Program_Name : String;
- Look_For_Prefix : Boolean := True) return String_Access
- is
- Gnatchop_Str : constant String := "gnatchop";
- Current_Command : constant String := Normalize_Pathname (Command_Name);
- End_Of_Prefix : Natural;
- Start_Of_Prefix : Positive;
- Start_Of_Suffix : Positive;
- Result : String_Access;
-
- begin
- Start_Of_Prefix := Current_Command'First;
- Start_Of_Suffix := Current_Command'Last + 1;
- End_Of_Prefix := Start_Of_Prefix - 1;
-
- if Look_For_Prefix then
-
- -- Find Start_Of_Prefix
-
- for J in reverse Current_Command'Range loop
- if Current_Command (J) = '/' or else
- Current_Command (J) = Directory_Separator or else
- Current_Command (J) = ':'
- then
- Start_Of_Prefix := J + 1;
- exit;
- end if;
- end loop;
-
- -- Find End_Of_Prefix
-
- for J in Start_Of_Prefix ..
- Current_Command'Last - Gnatchop_Str'Length + 1
- loop
- if Current_Command (J .. J + Gnatchop_Str'Length - 1) =
- Gnatchop_Str
- then
- End_Of_Prefix := J - 1;
- exit;
- end if;
- end loop;
- end if;
-
- if End_Of_Prefix > Current_Command'First then
- Start_Of_Suffix := End_Of_Prefix + Gnatchop_Str'Length + 1;
- end if;
-
- declare
- Command : constant String :=
- Current_Command (Start_Of_Prefix .. End_Of_Prefix)
- & Program_Name
- & Current_Command (Start_Of_Suffix ..
- Current_Command'Last);
- begin
- Result := Locate_Exec_On_Path (Command);
-
- if Result = null then
- Error_Msg
- (Command & ": installation problem, executable not found");
- end if;
- end;
-
- return Result;
- end Locate_Executable;
-
---------------
-- Parse_EOL --
---------------
exit;
when '-' =>
- Gcc := new String'(Parameter);
- Gcc_Set := True;
+ Free (Gcc);
+ Gcc := new String'(Parameter);
when 'c' =>
Compilation_Mode := True;
-- Check presence of required executables
- Gnat_Cmd := Locate_Executable (Gcc.all, not Gcc_Set);
+ if Gcc = null then
+ Gcc := Osint.Program_Name ("gcc", "gnatchop");
+ end if;
+ Gnat_Cmd := Locate_Exec_On_Path (Gcc.all);
if Gnat_Cmd = null then
+ Error_Msg (Gcc.all & ": installation problem, executable not found");
goto No_Files_Written;
end if;