From 39faeb7440ac1c5d385c61ae4fe5be7227fd5070 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 23 Jan 2000 16:36:37 +0000 Subject: [PATCH] * better auto RTL dir detection --- compiler/globals.pas | 17 ++++++++++++++++- compiler/options.pas | 34 +++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/compiler/globals.pas b/compiler/globals.pas index 578f4375df..0fbd43f0f3 100644 --- a/compiler/globals.pas +++ b/compiler/globals.pas @@ -243,6 +243,7 @@ unit globals; procedure DefaultReplacements(var s:string); function path_absolute(const s : string) : boolean; + Function PathExists ( F : String) : Boolean; Function FileExists ( Const F : String) : Boolean; Function RemoveFile(const f:string):boolean; Function RemoveDir(d:string):boolean; @@ -823,6 +824,17 @@ implementation findclose(Info); {$endif} end; + + Function PathExists ( F : String) : Boolean; + Var + Info : SearchRec; + begin + if F[Length(f)] in ['/','\'] then + Delete(f,length(f),1); + findfirst(F,readonly+archive+hidden+directory,info); + PathExists:=(doserror=0) and ((info.attr and directory)=directory); + findclose(Info); + end; {$endif} @@ -1476,7 +1488,10 @@ begin end. { $Log$ - Revision 1.47 2000-01-20 00:23:03 pierre + Revision 1.48 2000-01-23 16:36:37 peter + * better auto RTL dir detection + + Revision 1.47 2000/01/20 00:23:03 pierre * fix for GetShortName, now checks results from Win32 Revision 1.46 2000/01/07 01:14:27 peter diff --git a/compiler/options.pas b/compiler/options.pas index 2c0fbe0ac7..e5ab198b33 100644 --- a/compiler/options.pas +++ b/compiler/options.pas @@ -87,6 +87,7 @@ var read_configfile, { read config file, set when a cfgfile is found } target_is_set : boolean; { do not allow contradictory target settings } asm_is_set : boolean; { -T also change initoutputformat if not set idrectly } + fpcdir, ppccfg, msgfilename, param_file : string; { file to compile specified on the commandline } @@ -1367,12 +1368,32 @@ begin UnitSearchPath.AddPath(dos.getenv(target_info.unit_env),false); {$endif Delphi} {$ifdef linux} - UnitSearchPath.AddPath('/usr/lib/fpc/'+version_string+'/units/'+lower(target_info.short_name),false); - UnitSearchPath.AddPath('/usr/lib/fpc/'+version_string+'/units/'+lower(target_info.short_name)+'/rtl',false); + fpcdir:=FixPath(getenv('FPCDIR'),false); + if fpcdir='' then + begin + if PathExists('/usr/local/lib/fpc/'+version_string) then + fpcidr:='/usr/local/lib/fpc/'+version_string + else + fpcdir:='/usr/lib/fpc/'+version_string; + end; {$else} - UnitSearchPath.AddPath(ExePath+'../units/'+lower(target_info.short_name),false); - UnitSearchPath.AddPath(ExePath+'../units/'+lower(target_info.short_name)+'/rtl',false); + fpcdir:=FixPath(getenv('FPCDIR'),false); + if fpcdir='' then + begin + fpcdir:=ExePath+'../'; + if not(PathExists(fpcdir+'/units')) and + not(PathExists(fpcdir+'/rtl')) then + fpcdir:=fpcdir+'../'; + end; {$endif} + { first try development RTL, else use the default installation path } + if PathExists(FpcDir+'rtl/'+lower(target_info.short_name)) then + UnitSearchPath.AddPath(FpcDir+'rtl/'+lower(target_info.short_name),false) + else + begin + UnitSearchPath.AddPath(FpcDir+'units/'+lower(target_info.short_name),false); + UnitSearchPath.AddPath(FpcDir+'units/'+lower(target_info.short_name)+'/rtl',false); + end; UnitSearchPath.AddPath(ExePath,false); { Add unit dir to the object and library path } objectsearchpath.AddList(unitsearchpath,false); @@ -1406,7 +1427,10 @@ end; end. { $Log$ - Revision 1.53 2000-01-20 10:36:44 daniel + Revision 1.54 2000-01-23 16:36:37 peter + * better auto RTL dir detection + + Revision 1.53 2000/01/20 10:36:44 daniel * also support ; comments in cfg file Revision 1.52 2000/01/17 22:50:28 peter