Browse Source

* extra parameter for file searching functions
that indicate if the cache shall be used or not
* fixed compile of non-x86 targets

git-svn-id: trunk@5115 -

peter 19 năm trước cách đây
mục cha
commit
7a2e0da7bd

+ 3 - 3
compiler/assemble.pas

@@ -279,7 +279,7 @@ Implementation
         dir : TSearchRec;
         hs  : string;
       begin
-        if PathExists(s) then
+        if PathExists(s,false) then
          begin
            { the path exists, now we clean only all the .o and .s files }
            DeleteFilesWithExt(target_info.objext);
@@ -321,9 +321,9 @@ Implementation
            lastas:=ord(target_asm.id);
            { is an assembler passed ? }
            if utilsdirectory<>'' then
-             asfound:=FindFile(UtilExe,utilsdirectory,LastASBin);
+             asfound:=FindFile(UtilExe,utilsdirectory,false,LastASBin);
            if not AsFound then
-             asfound:=FindExe(UtilExe,LastASBin);
+             asfound:=FindExe(UtilExe,false,LastASBin);
            if (not asfound) and not(cs_asm_extern in current_settings.globalswitches) then
             begin
               Message1(exec_e_assembler_not_found,LastASBin);

+ 47 - 48
compiler/cfileutils.pas

@@ -85,7 +85,7 @@ interface
         procedure AddPath(s:string;addfirst:boolean);overload;
         procedure AddPath(SrcPath,s:string;addfirst:boolean);overload;
         procedure AddList(list:TSearchPathList;addfirst:boolean);
-        function  FindFile(const f : string;var foundfile:string):boolean;
+        function  FindFile(const f : string;allowcache:boolean;var foundfile:string):boolean;
       end;
 
     {Gives the absolute path to the current directory}
@@ -94,18 +94,18 @@ interface
      with a trailing dir separator. E. g. on unix ./ }
     function CurDirRelPath(systeminfo: tsysteminfo): string;
     function  path_absolute(const s : string) : boolean;
-    Function  PathExists ( F : String) : Boolean;
-    Function  FileExists ( Const F : String) : Boolean;
-    function  FileExistsNonCase(const path,fn:string;var foundfile:string):boolean;
+    Function  PathExists (const F : String;allowcache:boolean) : Boolean;
+    Function  FileExists (const F : String;allowcache:boolean) : Boolean;
+    function  FileExistsNonCase(const path,fn:string;allowcache:boolean;var foundfile:string):boolean;
     Function  RemoveDir(d:string):boolean;
     Function  FixPath(s:string;allowdot:boolean):string;
     function  FixFileName(const s:string):string;
     function  TargetFixPath(s:string;allowdot:boolean):string;
     function  TargetFixFileName(const s:string):string;
     procedure SplitBinCmd(const s:string;var bstr: String;var cstr:TCmdStr);
-    function  FindFile(const f : string;path : string;var foundfile:string):boolean;
-    function  FindFilePchar(const f : string;path : pchar;var foundfile:string):boolean;
-    function  FindExe(const bin:string;var foundfile:string):boolean;
+    function  FindFile(const f : string;path : string;allowcache:boolean;var foundfile:string):boolean;
+    function  FindFilePchar(const f : string;path : pchar;allowcache:boolean;var foundfile:string):boolean;
+    function  FindExe(const bin:string;allowcache:boolean;var foundfile:string):boolean;
     function  GetShortName(const n:string):string;
 
     procedure InitFileUtils;
@@ -233,14 +233,10 @@ implementation
       var
         CachedDir : TCachedDirectory;
       begin
-{$ifdef usedircache}
         Result:=false;
         CachedDir:=GetDirectory(ExtractFileDir(AName));
         if assigned(CachedDir) then
           Result:=CachedDir.FileExists(ExtractFileName(AName));
-{$else usedircache}
-        Result:=SysUtils.FileExists(AName);
-{$endif usedircache}
       end;
 
 
@@ -248,14 +244,10 @@ implementation
       var
         CachedDir : TCachedDirectory;
       begin
-{$ifdef usedircache}
         Result:=false;
         CachedDir:=GetDirectory(ExtractFilePath(AName));
         if assigned(CachedDir) then
           Result:=CachedDir.DirectoryExists(ExtractFileName(AName));
-{$else usedircache}
-        Result:=SysUtils.DirectoryExists(AName);
-{$endif usedircache}
       end;
 
 
@@ -349,9 +341,14 @@ implementation
 {$endif unix}
      end;
 
-    Function FileExists ( Const F : String) : Boolean;
+    Function FileExists ( Const F : String;allowcache:boolean) : Boolean;
       begin
-        Result:={$ifdef usedircache}DirCache.{$else}SysUtils.{$endif}FileExists(F);
+{$ifdef usedircache}
+        if allowcache then
+          Result:=DirCache.FileExists(F)
+        else
+{$endif usedircache}
+          Result:=SysUtils.FileExists(F);
         if assigned(do_comment) then
          begin
            if Result then
@@ -362,7 +359,7 @@ implementation
       end;
 
 
-    function FileExistsNonCase(const path,fn:string;var foundfile:string):boolean;
+    function FileExistsNonCase(const path,fn:string;allowcache:boolean;var foundfile:string):boolean;
       var
         fn2 : string;
       begin
@@ -376,7 +373,7 @@ implementation
                3. UPPERCASE
             }
             FoundFile:=path+fn;
-            If FileExists(FoundFile) then
+            If FileExists(FoundFile,allowcache) then
              begin
                result:=true;
                exit;
@@ -385,7 +382,7 @@ implementation
             if fn2<>fn then
               begin
                 FoundFile:=path+fn2;
-                If FileExists(FoundFile) then
+                If FileExists(FoundFile,allowcache) then
                  begin
                    result:=true;
                    exit;
@@ -395,7 +392,7 @@ implementation
             if fn2<>fn then
               begin
                 FoundFile:=path+fn2;
-                If FileExists(FoundFile) then
+                If FileExists(FoundFile,allowcache) then
                  begin
                    result:=true;
                    exit;
@@ -410,7 +407,7 @@ implementation
                  1. NormalCase
               }
               FoundFile:=path+fn;
-              If FileExists(FoundFile) then
+              If FileExists(FoundFile,allowcache) then
                begin
                  result:=true;
                  exit;
@@ -420,7 +417,7 @@ implementation
           begin
             { None case sensitive only lowercase }
             FoundFile:=path+Lower(fn);
-            If FileExists(FoundFile) then
+            If FileExists(FoundFile,allowcache) then
              begin
                result:=true;
                exit;
@@ -431,21 +428,27 @@ implementation
       end;
 
 
-    Function PathExists ( F : String) : Boolean;
+    Function PathExists (const F : String;allowcache:boolean) : Boolean;
       Var
-        I: longint;
+        i: longint;
+        hs : string;
       begin
         if F = '' then
           begin
             result := true;
             exit;
           end;
-        F := ExpandFileName(F);
-        I := Pos (DriveSeparator, F);
-        if (F [Length (F)] = DirectorySeparator) and
-           (((I = 0) and (Length (F) > 1)) or (I <> Length (F) - 1)) then
-          Delete (F, Length (F), 1);
-        Result:=SysUtils.DirectoryExists(F);
+        hs := ExpandFileName(F);
+        I := Pos (DriveSeparator, hs);
+        if (hs [Length (hs)] = DirectorySeparator) and
+           (((I = 0) and (Length (hs) > 1)) or (I <> Length (hs) - 1)) then
+          Delete (hs, Length (hs), 1);
+{$ifdef usedircache}
+        if allowcache then
+          Result:=DirCache.DirectoryExists(hs)
+        else
+{$endif usedircache}
+          Result:=SysUtils.DirectoryExists(hs);
       end;
 
 
@@ -828,7 +831,7 @@ implementation
                     begin
                       subdirfound:=true;
                       currpath:=prefix+dir.name+suffix;
-                      if (suffix='') or PathExists(currpath) then
+                      if (suffix='') or PathExists(currpath,true) then
                         begin
                           hp:=Find(currPath);
                           if not assigned(hp) then
@@ -848,7 +851,7 @@ implementation
                     begin
                       subdirfound:=true;
                       currpath:=prefix+dir.name+suffix;
-                      if (suffix='') or PathExists(currpath) then
+                      if (suffix='') or PathExists(currpath,false) then
                         begin
                           hp:=Find(currPath);
                           if not assigned(hp) then
@@ -864,7 +867,7 @@ implementation
           end
          else
           begin
-            if PathExists(currpath) then
+            if PathExists(currpath,true) then
              AddCurrPath
             else
              WarnNonExistingPath(currpath);
@@ -914,7 +917,7 @@ implementation
      end;
 
 
-   function TSearchPathList.FindFile(const f : string;var foundfile:string):boolean;
+   function TSearchPathList.FindFile(const f : string;allowcache:boolean;var foundfile:string):boolean;
      Var
        p : TStringListItem;
      begin
@@ -922,7 +925,7 @@ implementation
        p:=TStringListItem(first);
        while assigned(p) do
         begin
-          result:=FileExistsNonCase(p.Str,f,FoundFile);
+          result:=FileExistsNonCase(p.Str,f,allowcache,FoundFile);
           if result then
             exit;
           p:=TStringListItem(p.next);
@@ -932,7 +935,7 @@ implementation
      end;
 
 
-   function FindFile(const f : string;path : string;var foundfile:string):boolean;
+   function FindFile(const f : string;path : string;allowcache:boolean;var foundfile:string):boolean;
       Var
         singlepathstring : string;
         i : longint;
@@ -949,7 +952,7 @@ implementation
            i:=256;
           singlepathstring:=FixPath(copy(path,1,i-1),false);
           delete(path,1,i);
-          result:=FileExistsNonCase(singlepathstring,f,FoundFile);
+          result:=FileExistsNonCase(singlepathstring,f,allowcache,FoundFile);
           if result then
             exit;
        until path='';
@@ -957,7 +960,7 @@ implementation
      end;
 
 
-   function FindFilePchar(const f : string;path : pchar;var foundfile:string):boolean;
+   function FindFilePchar(const f : string;path : pchar;allowcache:boolean;var foundfile:string):boolean;
       Var
         singlepathstring : string;
         startpc,pc : pchar;
@@ -983,7 +986,7 @@ implementation
              move(startpc^,singlepathstring[1],pc-startpc);
              singlepathstring[0]:=char(longint(pc-startpc));
              singlepathstring:=FixPath(singlepathstring,false);
-             result:=FileExistsNonCase(singlepathstring,f,FoundFile);
+             result:=FileExistsNonCase(singlepathstring,f,allowcache,FoundFile);
              if result then
                exit;
              if (pc^=#0) then
@@ -995,12 +998,12 @@ implementation
      end;
 
 
-   function  FindExe(const bin:string;var foundfile:string):boolean;
+   function  FindExe(const bin:string;allowcache:boolean;var foundfile:string):boolean;
      var
        p : pchar;
        found : boolean;
      begin
-       found:=FindFile(FixFileName(ChangeFileExt(bin,source_info.exeext)),'.;'+exepath,foundfile);
+       found:=FindFile(FixFileName(ChangeFileExt(bin,source_info.exeext)),'.;'+exepath,allowcache,foundfile);
        if not found then
         begin
 {$ifdef macos}
@@ -1008,7 +1011,7 @@ implementation
 {$else}
           p:=GetEnvPchar('PATH');
 {$endif}
-          found:=FindFilePChar(FixFileName(ChangeFileExt(bin,source_info.exeext)),p,foundfile);
+          found:=FindFilePChar(FixFileName(ChangeFileExt(bin,source_info.exeext)),p,allowcache,foundfile);
           FreeEnvPChar(p);
         end;
        FindExe:=found;
@@ -1021,11 +1024,7 @@ implementation
         hs,hs2 : string;
         i : longint;
 {$endif}
-{$ifdef go32v2}
-      var
-        hs : string;
-{$endif}
-{$ifdef watcom}
+{$if defined(go32v2) or defined(watcom)}
       var
         hs : string;
 {$endif}

+ 2 - 2
compiler/comprsrc.pas

@@ -76,9 +76,9 @@ begin
   resbin:='';
   resfound:=false;
   if utilsdirectory<>'' then
-    resfound:=FindFile(utilsprefix+target_res.resbin+source_info.exeext,utilsdirectory,resbin);
+    resfound:=FindFile(utilsprefix+target_res.resbin+source_info.exeext,utilsdirectory,false,resbin);
   if not resfound then
-    resfound:=FindExe(utilsprefix+target_res.resbin,resbin);
+    resfound:=FindExe(utilsprefix+target_res.resbin,false,resbin);
   { get also the path to be searched for the windres.h }
   respath:=ExtractFilePath(resbin);
   if (not resfound) and not(cs_link_nolink in current_settings.globalswitches) then

+ 1 - 1
compiler/finput.pas

@@ -450,7 +450,7 @@ uses
       begin
         { Check if file exists, this will also check if it is
           a real file and not a directory }
-        if not fileexists(filename) then
+        if not fileexists(filename,false) then
           begin
             result:=false;
             exit;

+ 6 - 6
compiler/fppu.pas

@@ -266,7 +266,7 @@ uses
          Function UnitExists(const ext:string;var foundfile:string):boolean;
          begin
            Message1(unit_t_unitsearch,Singlepathstring+filename+ext);
-           UnitExists:=FindFile(FileName+ext,Singlepathstring,foundfile);
+           UnitExists:=FindFile(FileName+ext,Singlepathstring,true,foundfile);
          end;
 
          Function PPUSearchPath(const s:string):boolean;
@@ -380,16 +380,16 @@ uses
             { the full filename is specified so we can't use here the
               searchpath (PFV) }
             Message1(unit_t_unitsearch,ChangeFileExt(sourcefn^,sourceext));
-            fnd:=FindFile(ChangeFileExt(sourcefn^,sourceext),'',hs);
+            fnd:=FindFile(ChangeFileExt(sourcefn^,sourceext),'',true,hs);
             if not fnd then
              begin
                Message1(unit_t_unitsearch,ChangeFileExt(sourcefn^,pasext));
-               fnd:=FindFile(ChangeFileExt(sourcefn^,pasext),'',hs);
+               fnd:=FindFile(ChangeFileExt(sourcefn^,pasext),'',true,hs);
              end;
             if not fnd and ((m_mac in current_settings.modeswitches) or (tf_p_ext_support in target_info.flags)) then
              begin
                Message1(unit_t_unitsearch,ChangeFileExt(sourcefn^,pext));
-               fnd:=FindFile(ChangeFileExt(sourcefn^,pext),'',hs);
+               fnd:=FindFile(ChangeFileExt(sourcefn^,pext),'',true,hs);
              end;
             if fnd then
              begin
@@ -732,9 +732,9 @@ uses
               if (Source_Time=-1) then
                 begin
                   if is_main then
-                    found:=unitsearchpath.FindFile(hs,temp_dir)
+                    found:=unitsearchpath.FindFile(hs,true,temp_dir)
                   else
-                    found:=includesearchpath.FindFile(hs,temp_dir);
+                    found:=includesearchpath.FindFile(hs,true,temp_dir);
                   if found then
                    begin
                      Source_Time:=GetNamedFileTime(temp_dir);

+ 24 - 22
compiler/link.pas

@@ -156,7 +156,7 @@ Implementation
           the specified file exists without searching any paths }
         if not isunit then
          begin
-           if FileExists(FixFileName(s)) then
+           if FileExists(FixFileName(s),false) then
             begin
               foundfile:=ScriptFixFileName(s);
               found:=true;
@@ -172,25 +172,26 @@ Implementation
            5. unit search path
            6. local object path
            7. global object path
-           8. exepath (not when linking on target) }
+           8. exepath (not when linking on target)
+          for all finds don't use the directory caching }
         found:=false;
         if isunit and (OutputUnitDir<>'') then
-          found:=FindFile(s,OutPutUnitDir,foundfile)
+          found:=FindFile(s,OutPutUnitDir,false,foundfile)
         else
           if OutputExeDir<>'' then
-            found:=FindFile(s,OutPutExeDir,foundfile);
+            found:=FindFile(s,OutPutExeDir,false,foundfile);
         if (not found) and (unitpath<>'') then
-         found:=FindFile(s,unitpath,foundfile);
+         found:=FindFile(s,unitpath,false,foundfile);
         if (not found) then
-         found:=FindFile(s, CurDirRelPath(source_info), foundfile);
+         found:=FindFile(s, CurDirRelPath(source_info),false,foundfile);
         if (not found) then
-         found:=UnitSearchPath.FindFile(s,foundfile);
+         found:=UnitSearchPath.FindFile(s,false,foundfile);
         if (not found) then
-         found:=current_module.localobjectsearchpath.FindFile(s,foundfile);
+         found:=current_module.localobjectsearchpath.FindFile(s,false,foundfile);
         if (not found) then
-         found:=objectsearchpath.FindFile(s,foundfile);
+         found:=objectsearchpath.FindFile(s,false,foundfile);
         if not(cs_link_on_target in current_settings.globalswitches) and (not found) then
-         found:=FindFile(s,exepath,foundfile);
+         found:=FindFile(s,exepath,false,foundfile);
         if not(cs_link_nolink in current_settings.globalswitches) and (not found) then
          Message1(exec_w_objfile_not_found,s);
 
@@ -213,13 +214,13 @@ Implementation
           1. Current dir
           2. Library Path
           3. windir,windir/system,windir/system32 }
-        Found:=FindFile(s,'.'+source_info.DirSep,founddll);
+        Found:=FindFile(s,'.'+source_info.DirSep,false,founddll);
         if (not found) then
-         Found:=librarysearchpath.FindFile(s,founddll);
+         Found:=librarysearchpath.FindFile(s,false,founddll);
         if (not found) then
          begin
            sysdir:=FixPath(GetEnvironmentVariable('windir'),false);
-           Found:=FindFile(s,sysdir+';'+sysdir+'system'+source_info.DirSep+';'+sysdir+'system32'+source_info.DirSep,founddll);
+           Found:=FindFile(s,sysdir+';'+sysdir+'system'+source_info.DirSep+';'+sysdir+'system32'+source_info.DirSep,false,founddll);
          end;
         if (not found) then
          begin
@@ -251,7 +252,7 @@ Implementation
          s:=s+ext;
         { readd the split path }
         s:=paths+s;
-        if FileExists(s) then
+        if FileExists(s,false) then
          begin
            foundfile:=ScriptFixFileName(s);
            FindLibraryFile:=true;
@@ -261,16 +262,17 @@ Implementation
            1. cwd
            2. local libary dir
            3. global libary dir
-           4. exe path of the compiler (not when linking on target) }
-        found:=FindFile(s, CurDirRelPath(source_info), foundfile);
+           4. exe path of the compiler (not when linking on target)
+          for all searches don't use the directory cache }
+        found:=FindFile(s, CurDirRelPath(source_info), false,foundfile);
         if (not found) and (current_module.outputpath^<>'') then
-         found:=FindFile(s,current_module.outputpath^,foundfile);
+         found:=FindFile(s,current_module.outputpath^,false,foundfile);
         if (not found) then
-         found:=current_module.locallibrarysearchpath.FindFile(s,foundfile);
+         found:=current_module.locallibrarysearchpath.FindFile(s,false,foundfile);
         if (not found) then
-         found:=librarysearchpath.FindFile(s,foundfile);
+         found:=librarysearchpath.FindFile(s,false,foundfile);
         if not(cs_link_on_target in current_settings.globalswitches) and (not found) then
-         found:=FindFile(s,exepath,foundfile);
+         found:=FindFile(s,exepath,false,foundfile);
         foundfile:=ScriptFixFileName(foundfile);
         findlibraryfile:=found;
       end;
@@ -589,9 +591,9 @@ Implementation
         FoundBin:='';
         Found:=false;
         if utilsdirectory<>'' then
-         Found:=FindFile(utilexe,utilsdirectory,Foundbin);
+         Found:=FindFile(utilexe,utilsdirectory,false,Foundbin);
         if (not Found) then
-         Found:=FindExe(utilexe,Foundbin);
+         Found:=FindExe(utilexe,false,Foundbin);
         if (not Found) and not(cs_link_nolink in current_settings.globalswitches) then
          begin
            Message1(exec_e_util_not_found,utilexe);

+ 5 - 5
compiler/options.pas

@@ -1413,7 +1413,7 @@ begin
   If FileLevel>MaxLevel then
    Message(option_too_many_cfg_files);
 { Maybe It's Directory ?}   //Jaro Change:
-  if PathExists(filename) then
+  if PathExists(filename,false) then
     begin
        Message1(option_config_is_dir,filename);
        exit;
@@ -2112,7 +2112,7 @@ begin
 
   { Check output dir }
   if (OutputExeDir<>'') and
-     not PathExists(OutputExeDir) then
+     not PathExists(OutputExeDir,false) then
     begin
       Message1(general_e_path_does_not_exist,OutputExeDir);
       StopOptions(1);
@@ -2144,15 +2144,15 @@ begin
   if fpcdir='' then
     begin
       fpcdir:=ExePath+'../';
-      if not(PathExists(fpcdir+'/units')) and
-         not(PathExists(fpcdir+'/rtl')) then
+      if not(PathExists(fpcdir+'/units',true)) and
+         not(PathExists(fpcdir+'/rtl',true)) then
         fpcdir:=fpcdir+'../';
     end;
 {$endif unix}
   { first try development RTL, else use the default installation path }
   if not disable_configfile then
     begin
-      if PathExists(FpcDir+'rtl') then
+      if PathExists(FpcDir+'rtl',true) then
         if tf_use_8_3 in Source_Info.Flags then
           UnitSearchPath.AddPath(FpcDir+'rtl/'+target_os_string,false)
         else

+ 4 - 4
compiler/scanner.pas

@@ -1477,16 +1477,16 @@ In case not, the value returned can be arbitrary.
                  hpath:=current_scanner.inputfile.path^+path
                else
                  hpath:=path;
-               found:=FindFile(name, hpath,foundfile);
+               found:=FindFile(name, hpath,true,foundfile);
              end
            else
              begin
                hpath:=current_scanner.inputfile.path^+';'+CurDirRelPath(source_info);
-               found:=FindFile(name, hpath,foundfile);
+               found:=FindFile(name, hpath,true,foundfile);
                if not found then
-                 found:=current_module.localincludesearchpath.FindFile(name,foundfile);
+                 found:=current_module.localincludesearchpath.FindFile(name,true,foundfile);
                if not found  then
-                 found:=includesearchpath.FindFile(name,foundfile);
+                 found:=includesearchpath.FindFile(name,true,foundfile);
              end;
            result:=found;
         end;

+ 12 - 14
compiler/systems/t_amiga.pas

@@ -26,15 +26,8 @@ unit t_amiga;
 
 interface
 
-uses
-  link,
-  cutils,cclasses,cfileutils,
-{$IFNDEF USE_FAKE_SYSUTILS}
-      SysUtils,
-{$ELSE}
-      fksysutl,
-{$ENDIF}
-  globtype,globals,systems,verbose,script,fmodule,i_amiga;
+    uses
+      link;
 
 
 type
@@ -49,12 +42,17 @@ type
     public
       constructor Create; override;
       procedure SetDefaultInfo; override;
-      function  MakeExecutable: boolean; override;      
+      function  MakeExecutable: boolean; override;
   end;
 
 
 implementation
 
+    uses
+       SysUtils,
+       cutils,cfileutils,cclasses,
+       globtype,globals,systems,verbose,script,fmodule,i_amiga;
+
 {$IF DEFINED(MORPHOS) OR DEFINED(AMIGA)}
 { * PathConv is implemented in the system unit! * }
 function PathConv(path: string): string; external name 'PATHCONV';
@@ -150,8 +148,8 @@ begin
       LinkRes.AddFileName(PathConv(maybequoted(s)));
      end;
    end;
-  
-  if (cs_link_on_target in current_settings.globalswitches) then 
+
+  if (cs_link_on_target in current_settings.globalswitches) then
    begin
     LinkRes.Add(')');
 
@@ -188,7 +186,7 @@ begin
       S:=SharedLibFiles.GetFirst;
       LinkRes.Add('lib'+s+target_info.staticlibext);
      end;
-    LinkRes.Add(')');    
+    LinkRes.Add(')');
    end;
 
 { Write and Close response }
@@ -225,7 +223,7 @@ begin
 
   { Write used files and libraries }
   WriteResponseFile(false);
-  
+
   case (target_info.system) of
     system_m68k_amiga:      begin end;
     system_powerpc_amiga:   success:=MakeAmigaPPCExe;

+ 5 - 5
compiler/systems/t_beos.pas

@@ -264,9 +264,9 @@ begin
   { try to add crti and crtbegin if linking to C }
   if linklibc then
    begin
-     if librarysearchpath.FindFile('crti.o',s) then
+     if librarysearchpath.FindFile('crti.o',false,s) then
       LinkRes.AddFileName(s);
-     if librarysearchpath.FindFile('crtbegin.o',s) then
+     if librarysearchpath.FindFile('crtbegin.o',false,s) then
       LinkRes.AddFileName(s);
 {      s:=librarysearchpath.FindFile('start_dyn.o',found)+'start_dyn.o';
      if found then LinkRes.AddFileName(s+' \');}
@@ -277,7 +277,7 @@ begin
      if isdll then
       LinkRes.AddFileName(FindObjectFile('func.o','',false));
 
-     if librarysearchpath.FindFile('init_term_dyn.o',s) then
+     if librarysearchpath.FindFile('init_term_dyn.o',false,s) then
       LinkRes.AddFileName(s);
    end
   else
@@ -338,9 +338,9 @@ begin
   { objects which must be at the end }
   if linklibc then
    begin
-     if librarysearchpath.FindFile('crtend.o',s) then
+     if librarysearchpath.FindFile('crtend.o',false,s) then
       LinkRes.AddFileName(s);
-     if librarysearchpath.FindFile('crtn.o',s) then
+     if librarysearchpath.FindFile('crtn.o',false,s) then
       LinkRes.AddFileName(s);
    end;
 

+ 5 - 5
compiler/systems/t_bsd.pas

@@ -331,7 +331,7 @@ begin
       if not(isdll) then
         if not(cs_profile in current_settings.moduleswitches) then
           begin
-             if librarysearchpath.FindFile('crt1.o',s) then
+             if librarysearchpath.FindFile('crt1.o',false,s) then
              prtobj:=s
             else
              prtobj:='/usr/lib/crt1.o';
@@ -386,9 +386,9 @@ begin
   if linklibc and
      not IsDarwin Then
    begin
-     if librarysearchpath.FindFile('crtbegin.o',s) then
+     if librarysearchpath.FindFile('crtbegin.o',false,s) then
       LinkRes.AddFileName(s);
-     if librarysearchpath.FindFile('crti.o',s) then
+     if librarysearchpath.FindFile('crti.o',false,s) then
       LinkRes.AddFileName(s);
    end;
   { main objectfiles }
@@ -459,8 +459,8 @@ begin
   if linklibc and
      not IsDarwin Then
    begin
-     Fl1:=librarysearchpath.FindFile('crtend.o',s1);
-     Fl2:=librarysearchpath.FindFile('crtn.o',s2);
+     Fl1:=librarysearchpath.FindFile('crtend.o',false,s1);
+     Fl2:=librarysearchpath.FindFile('crtn.o',false,s2);
      if Fl1 or Fl2 then
       begin
         LinkRes.Add('INPUT(');

+ 6 - 6
compiler/systems/t_gba.pas

@@ -30,9 +30,9 @@ interface
 implementation
 
     uses
-       link,
-       cutils,cclasses,
-       globtype,globals,systems,verbose,script,fmodule,i_gba;
+       SysUtils,
+       cutils,cfileutils,cclasses,
+       globtype,globals,systems,verbose,script,fmodule,i_gba,link;
 
     type
        TlinkerGBA=class(texternallinker)
@@ -521,7 +521,7 @@ begin
   Replace(cmdstr,'$OPT',Info.ExtraOptions);
   if not(cs_link_on_target in current_settings.globalswitches) then
    begin
-    Replace(cmdstr,'$EXE',(maybequoted(ScriptFixFileName(ForceExtension(current_module.exefilename^,'.elf')))));
+    Replace(cmdstr,'$EXE',(maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename^,'.elf')))));
     Replace(cmdstr,'$RES',(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
     Replace(cmdstr,'$STATIC',StaticStr);
     Replace(cmdstr,'$STRIP',StripStr);
@@ -530,7 +530,7 @@ begin
    end
   else
    begin
-    Replace(cmdstr,'$EXE',maybequoted(ScriptFixFileName(ForceExtension(current_module.exefilename^,'.elf'))));
+    Replace(cmdstr,'$EXE',maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename^,'.elf'))));
     Replace(cmdstr,'$RES',maybequoted(ScriptFixFileName(outputexedir+Info.ResName)));
     Replace(cmdstr,'$STATIC',StaticStr);
     Replace(cmdstr,'$STRIP',StripStr);
@@ -547,7 +547,7 @@ begin
   if success then
     begin
       success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O binary '+
-        ForceExtension(current_module.exefilename^,'.elf')+' '+
+        ChangeFileExt(current_module.exefilename^,'.elf')+' '+
         current_module.exefilename^,true,false);
     end;
 

+ 31 - 35
compiler/systems/t_linux.pas

@@ -223,7 +223,7 @@ const
 
 {$ifdef m68k}
 var
-  St : SearchRec;
+  St : TSearchRec;
 {$endif m68k}
 begin
   with Info do
@@ -233,40 +233,36 @@ begin
      DllCmd[2]:='strip --strip-unneeded $EXE';
 {$ifdef m68k}
      libctype:=glibc2;
-     FindFirst('/lib/ld*',AnyFile,st);
-     while DosError=0 do
-      begin
-        if copy(st.name,1,5)='ld-2.' then
-         begin
-           DynamicLinker:='/lib/'+St.name;
-           if st.name[6]<>'0' then
-             libctype:=glibc21;
-           break;
-         end;
-         FindNext(St);
-      end;
+     if FindFirst('/lib/ld*',faAnyFile+faSymLink,st)<>0 then
+       begin
+         repeat
+            if copy(st.name,1,5)='ld-2.' then
+             begin
+               DynamicLinker:='/lib/'+St.name;
+               if st.name[6]<>'0' then
+                 libctype:=glibc21;
+               break;
+             end;
+         until FindNext(St)<>0;
+       end;
      FindClose(St);
 {$endif m68k}
 
 {$ifdef i386}
-     { first try glibc2 }
-     DynamicLinker:='/lib/ld-linux.so.2';
-     if FileExists(DynamicLinker) then
-       { Check for 2.0 files, else use the glibc 2.1 stub }
-       if FileExists('/lib/ld-2.0.*') then
-         libctype:=glibc2
-       else
-         libctype:=glibc21
-     else
-       if fileexists('/lib/ld-uClibc.so.0') then
-         begin
-           libctype:=uclibc;
-           dynamiclinker:='/lib/ld-uClibc.so.0';
-         end
-       else if fileexists('/lib/ld-linux.so.1') then
-         DynamicLinker:='/lib/ld-linux.so.1'
-       else
-         libctype:=glibc21;
+     { default is glibc 2.1+ compatible }
+     libctype:=glibc21;
+     if FileExists('/lib/ld-linux.so.2',false) then
+       DynamicLinker:='/lib/ld-linux.so.2'
+     else if fileexists('/lib/ld-uClibc.so.0',false) then
+       begin
+         dynamiclinker:='/lib/ld-uClibc.so.0';
+         libctype:=uclibc;
+       end
+     else if fileexists('/lib/ld-linux.so.1',false) then
+       begin
+         DynamicLinker:='/lib/ld-linux.so.1';
+         libctype:=glibc2;
+       end;
 {$endif i386}
 
 {$ifdef x86_64}
@@ -393,9 +389,9 @@ begin
       { try to add crti and crtbegin if linking to C }
       if linklibc then
        begin
-         if librarysearchpath.FindFile('crtbegin.o',s) then
+         if librarysearchpath.FindFile('crtbegin.o',false,s) then
           AddFileName(s);
-         if librarysearchpath.FindFile('crti.o',s) then
+         if librarysearchpath.FindFile('crti.o',false,s) then
           AddFileName(s);
        end;
       { main objectfiles }
@@ -458,8 +454,8 @@ begin
       { objects which must be at the end }
       if linklibc and (libctype<>uclibc) then
        begin
-         found1:=librarysearchpath.FindFile('crtend.o',s1);
-         found2:=librarysearchpath.FindFile('crtn.o',s2);
+         found1:=librarysearchpath.FindFile('crtend.o',false,s1);
+         found2:=librarysearchpath.FindFile('crtn.o',false,s2);
          if found1 or found2 then
           begin
             Add('INPUT(');

+ 2 - 9
compiler/systems/t_macos.pas

@@ -45,12 +45,8 @@ interface
 implementation
 
     uses
-       cutils,cclasses,cfileutils,
-{$IFNDEF USE_FAKE_SYSUTILS}
-      SysUtils,
-{$ELSE}
-      fksysutl,
-{$ENDIF}
+       SysUtils,
+       cutils,cfileutils,cclasses,
        globtype,globals,systems,verbose,script,fmodule,i_macos,
        ogbase,
        symconst;
@@ -193,9 +189,6 @@ var
   DynLinkStr : string[60];
   StaticStr,
   StripStr   : string[40];
-
-  s: string;
-
 begin
   //TODO Only external link in MPW is possible, otherwise yell.
 

+ 7 - 12
compiler/systems/t_morph.pas

@@ -30,14 +30,9 @@ interface
 implementation
 
     uses
-       link,
-       cutils,cclasses,cfileutils,
-{$IFNDEF USE_FAKE_SYSUTILS}
-      SysUtils,
-{$ELSE}
-      fksysutl,
-{$ENDIF}
-       globtype,globals,systems,verbose,script,fmodule,i_morph;
+       SysUtils,
+       cutils,cfileutils,cclasses,
+       globtype,globals,systems,verbose,script,fmodule,i_morph,link;
 
     type
        PlinkerMorphOS=^TlinkerMorphOS;
@@ -142,7 +137,7 @@ begin
   if not StaticLibFiles.Empty then
    begin
     { vlink doesn't need, and doesn't support GROUP }
-    if (cs_link_on_target in current_settings.globalswitches) then 
+    if (cs_link_on_target in current_settings.globalswitches) then
      begin
       LinkRes.Add(')');
       LinkRes.Add('GROUP(');
@@ -153,8 +148,8 @@ begin
       LinkRes.AddFileName(PathConv(maybequoted(s)));
      end;
    end;
-  
-  if (cs_link_on_target in current_settings.globalswitches) then 
+
+  if (cs_link_on_target in current_settings.globalswitches) then
    begin
     LinkRes.Add(')');
 
@@ -191,7 +186,7 @@ begin
       S:=SharedLibFiles.GetFirst;
       LinkRes.Add('lib'+s+target_info.staticlibext);
      end;
-    LinkRes.Add(')');    
+    LinkRes.Add(')');
    end;
 
 

+ 4 - 4
compiler/systems/t_nwl.pas

@@ -404,7 +404,7 @@ begin
            if i>0 then
              Delete(S,i,255);
            S := S + '.imp'; S2 := '';
-           librarysearchpath.FindFile(S,S2);
+           librarysearchpath.FindFile(S,false,S2);
            {$ifdef netware}
            Comment(V_Debug,'IMPORT @'+s2);
            s2 := FExpand (S2);
@@ -439,7 +439,7 @@ begin
            begin  // special, with ! only the imp will be included but no module is autoloaded, needed i.e. for netware.imp inlcuded in libc ndk
              delete (s,1,1);
              S := S + '.imp';
-             librarysearchpath.FindFile(S,S3);
+             librarysearchpath.FindFile(S,false,S3);
              {$ifdef netware}
              Comment(V_Debug,'IMPORT @'+S3);
              S3 := FExpand (S3);
@@ -449,7 +449,7 @@ begin
            end else
            begin
              S := S + '.imp';
-             librarysearchpath.FindFile(S,S3);
+             librarysearchpath.FindFile(S,false,S3);
              {$ifdef netware}
              Comment(V_Debug,'IMPORT @'+S3);
              S3 := FExpand (S3);
@@ -551,7 +551,7 @@ begin
 { if we have a xdc file, dont touch it, otherwise create a new
   one and remove it after nlmconv }
   xdcname := ChangeFileExt(current_module.exefilename^,'.xdc');
-  xdcpresent := FileExists (xdcname);
+  xdcpresent := FileExists (xdcname,false);
   if not xdcpresent then
   begin
     assign (f,xdcname);

+ 3 - 3
compiler/systems/t_nwm.pas

@@ -386,7 +386,7 @@ begin
            if i>0 then
              Delete(S,i,255);
            S := S + '.imp'; S2 := '';
-           librarysearchpath.FindFile(S,S2);
+           librarysearchpath.FindFile(S,false,S2);
            {$ifdef netware}
            Comment(V_Debug,'IMPORT @'+s2);
            s2 := FExpand (S2);
@@ -419,7 +419,7 @@ begin
            if s[1] = '!' then
            begin  // special, with ! only the imp will be included but no module is autoloaded, needed i.e. for netware.imp
              S := copy(S,2,255) + '.imp';
-             librarysearchpath.FindFile(S,S3);
+             librarysearchpath.FindFile(S,false,S3);
              {$ifdef netware}
              Comment(V_Debug,'IMPORT @'+S3);
              S3 := FExpand (S3);
@@ -429,7 +429,7 @@ begin
            end else
            begin
              S := S + '.imp';
-             librarysearchpath.FindFile(S,S3);
+             librarysearchpath.FindFile(S,false,S3);
              {$ifdef netware}
              Comment(V_Debug,'IMPORT @'+S3);
              S3 := FExpand (S3);

+ 4 - 3
compiler/systems/t_palmos.pas

@@ -43,7 +43,8 @@ interface
 implementation
 
     uses
-       cutils,cclasses,
+       SysUtils,
+       cutils,cfileutils,cclasses,
        globtype,globals,systems,verbose,script,fmodule,i_palmos;
 
 {****************************************************************************
@@ -156,8 +157,8 @@ end;
 
 function TLinkerPalmOS.MakeExecutable:boolean;
 var
-  binstr,
-  cmdstr  : string;
+  binstr  : TPathStr;
+  cmdstr  : TCmdStr;
   success : boolean;
   StripStr : string[40];
   i : longint;

+ 2 - 2
compiler/systems/t_sunos.pas

@@ -291,7 +291,7 @@ begin
    begin
 {     if librarysearchpath.FindFile('crtbegin.o',s) then
       LinkRes.AddFileName(s);}
-     if librarysearchpath.FindFile('crti.o',s) then
+     if librarysearchpath.FindFile('crti.o',false,s) then
       LinkRes.AddFileName(s);
    end;
   { main objectfiles }
@@ -351,7 +351,7 @@ begin
   if linklibc then {needed in solaris ? }
    begin
      if {librarysearchpath.FindFile('crtend.o',s1) or}
-        librarysearchpath.FindFile('crtn.o',s2) then
+        librarysearchpath.FindFile('crtn.o',false,s2) then
       begin
         LinkRes.Add('INPUT(');
 {        LinkRes.AddFileName(s1);}