mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 05:40:28 +02:00
* Search config file in same directory as actual compiler binary
This commit is contained in:
parent
a028486325
commit
04b28ed587
@ -265,7 +265,7 @@ Const
|
||||
end;
|
||||
end;
|
||||
|
||||
Function FindConfigFile(const aFile : string) : String;
|
||||
Function FindConfigFile(const aFile : string; const aCompiler : String) : String;
|
||||
// Adapted from check_configfile(fn:string; var foundfn:string):boolean;
|
||||
{
|
||||
Order to read configuration file :
|
||||
@ -286,6 +286,7 @@ Function FindConfigFile(const aFile : string) : String;
|
||||
}
|
||||
|
||||
var
|
||||
{$ifdef unix}sl : rawbytestring;{$endif}
|
||||
{$ifdef unix}hs,{$endif} aSearchPath,exepath,configpath : string;
|
||||
|
||||
Procedure AddToPath(aDir : String);
|
||||
@ -313,7 +314,22 @@ begin
|
||||
exit;
|
||||
end;
|
||||
if configpath='' then
|
||||
begin
|
||||
{
|
||||
We need to search relative to compiler binary, not relative to FPC binary.
|
||||
Beware of symlinks !
|
||||
}
|
||||
hs:=aCompiler;
|
||||
While FileGetSymLinkTarget(hs,sl) do
|
||||
begin
|
||||
if copy(sl,1,1)<>'/' then
|
||||
hs:=ExpandFileName(ExtractFilePath(hs)+sl)
|
||||
else
|
||||
hs:=sl;
|
||||
end;
|
||||
ExePath:=ExtractFilePath(hs);
|
||||
configpath:=ExpandFileName(ExePath+'../etc/');
|
||||
end;
|
||||
{$endif}
|
||||
AddToPath(ConfigPath);
|
||||
{$ifdef WINDOWS}
|
||||
@ -467,16 +483,16 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
ppcbin := findcompiler(ppcbin, cpusuffix, exesuffix);
|
||||
if (TargetName<>'') then
|
||||
begin
|
||||
S:='fpc-'+lowercase(TargetName)+'.cfg';
|
||||
CfgFile:=FindConfigFile(s);
|
||||
CfgFile:=FindConfigFile(s,ppcbin);
|
||||
if CfgFile='' then
|
||||
Error('Cannot find subtarget config file: '+s);
|
||||
ProcessConfigFile(CfgFile,ExeSuffix);
|
||||
end;
|
||||
SetLength(ppccommandline, ppccommandlinelen);
|
||||
ppcbin := findcompiler(ppcbin, cpusuffix, exesuffix);
|
||||
|
||||
{ call ppcXXX }
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user