+ if In_Main_Object_Directory
+ or else Last < 5
+ or else
+ C_Filename (1 .. B_Start'Length) /= B_Start.all
+ then
+ Name_Len := Last;
+ Name_Buffer (1 .. Name_Len) :=
+ C_Filename (1 .. Last);
+ Id := Name_Find;
+
+ if not Objects_Htable.Get (Id) then
+ declare
+ ALI_File : constant String :=
+ Ext_To
+ (C_Filename
+ (1 .. Last), "ali");
+ ALI_Path : constant String :=
+ Ext_To (C_Object_Path, "ali");
+ Add_It : Boolean :=
+ There_Are_Foreign_Sources
+ or else
+ (Last > 5
+ and then
+ C_Filename
+ (1 .. B_Start'Length) =
+ B_Start.all);
+ Fname : File_Name_Type;
+ Proj : Project_Id;
+
+ begin
+ if Is_Regular_File (ALI_Path) then
+
+ -- If there is an ALI file, check if
+ -- the object file should be added to
+ -- the library. If there are foreign
+ -- sources we put all object files in
+ -- the library.
+
+ if not Add_It then
+ for Index in
+ 1 .. Unit_Table.Last
+ (In_Tree.Units)
+ loop
+ if In_Tree.Units.Table
+ (Index).File_Names
+ (Body_Part).Name /= No_File
+ then
+ Proj :=
+ In_Tree.Units.Table (Index).
+ File_Names
+ (Body_Part).Project;
+ Fname :=
+ In_Tree.Units.Table (Index).
+ File_Names (Body_Part).Name;
+
+ elsif
+ In_Tree.Units.Table
+ (Index).File_Names
+ (Specification).Name /=
+ No_File
+ then
+ Proj :=
+ In_Tree.Units.Table
+ (Index).File_Names
+ (Specification).Project;
+ Fname :=
+ In_Tree.Units.Table
+ (Index).File_Names
+ (Specification).Name;
+
+ else
+ Proj := No_Project;
+ end if;
+
+ Add_It := Proj /= No_Project;
+
+ -- If the source is in the
+ -- project or a project it
+ -- extends, we may put it in
+ -- the library.
+
+ if Add_It then
+ Add_It := Check_Project (Proj);
+ end if;
+
+ -- But we don't, if the ALI file
+ -- does not correspond to the
+ -- unit.
+
+ if Add_It then
+ declare
+ F : constant String :=
+ Ext_To
+ (Get_Name_String
+ (Fname), "ali");
+ begin
+ Add_It := F = ALI_File;
+ end;
+ end if;
+
+ exit when Add_It;
+ end loop;
+ end if;
+
+ if Add_It then
+ Objects_Htable.Set (Id, True);
+ Objects.Append
+ (new String'(Object_Path));
+
+ -- Record the ALI file
+
+ ALIs.Append (new String'(ALI_Path));
+
+ -- Find out if for this ALI file,
+ -- libgnarl or libdecgnat or
+ -- g-trasym.obj (on OpenVMS) is
+ -- necessary.
+
+ Check_Libs (ALI_Path, True);
+ end if;
+
+ elsif There_Are_Foreign_Sources then
+ Objects.Append
+ (new String'(Object_Path));
+ end if;
+ end;
+ end if;