|
@@ -177,6 +177,38 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
+ { searches a (windows) DLL file }
|
|
|
+ function FindDLL(const s:string;var founddll:string):boolean;
|
|
|
+ var
|
|
|
+ sysdir : string;
|
|
|
+ Found : boolean;
|
|
|
+ begin
|
|
|
+ Found:=false;
|
|
|
+ { Look for DLL in:
|
|
|
+ 1. Current dir
|
|
|
+ 2. Library Path
|
|
|
+ 3. windir,windir/system,windir/system32 }
|
|
|
+ Found:=FindFile(s,'.'+source_info.DirSep,founddll);
|
|
|
+ if (not found) then
|
|
|
+ Found:=librarysearchpath.FindFile(s,founddll);
|
|
|
+ if (not found) then
|
|
|
+ begin
|
|
|
+ {$IFDEF USE_SYSUTILS}
|
|
|
+ sysdir:=FixPath(GetEnvironmentVariable('windir'),false);
|
|
|
+ {$ELSE USE_SYSUTILS}
|
|
|
+ sysdir:=FixPath(GetEnv('windir'),false);
|
|
|
+ {$ENDIF USE_SYSUTILS}
|
|
|
+ Found:=FindFile(s,sysdir+';'+sysdir+'system'+source_info.DirSep+';'+sysdir+'system32'+source_info.DirSep,founddll);
|
|
|
+ end;
|
|
|
+ if (not found) then
|
|
|
+ begin
|
|
|
+ message1(exec_w_libfile_not_found,s);
|
|
|
+ FoundDll:=s;
|
|
|
+ end;
|
|
|
+ FindDll:=Found;
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
{ searches an library file }
|
|
|
function FindLibraryFile(s:string;const prefix,ext:string;var foundfile : string) : boolean;
|
|
|
var
|
|
@@ -552,10 +584,22 @@ end;
|
|
|
|
|
|
Function TExternalLinker.MakeStaticLibrary:boolean;
|
|
|
var
|
|
|
- smartpath,
|
|
|
- cmdstr : TCmdStr;
|
|
|
+ smartpath : TCmdStr;
|
|
|
+
|
|
|
+ function GetNextFiles(const maxCmdLength : AInt; var item : TStringListItem) : string;
|
|
|
+ begin
|
|
|
+ result := '';
|
|
|
+ while (assigned(item) and ((length(result) + length(item.str) + 1) < maxCmdLength)) do begin
|
|
|
+ result := result + ' ' + item.str;
|
|
|
+ item := TStringListItem(item.next);
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+
|
|
|
+var
|
|
|
binstr : string;
|
|
|
success : boolean;
|
|
|
+ cmdstr, nextcmd : TCmdStr;
|
|
|
+ current : TStringListItem;
|
|
|
begin
|
|
|
MakeStaticLibrary:=false;
|
|
|
{ remove the library, to be sure that it is rewritten }
|
|
@@ -564,8 +608,16 @@ begin
|
|
|
smartpath:=current_module.outputpath^+FixPath(lower(current_module.modulename^)+target_info.smartext,false);
|
|
|
SplitBinCmd(target_ar.arcmd,binstr,cmdstr);
|
|
|
Replace(cmdstr,'$LIB',maybequoted(current_module.staticlibfilename^));
|
|
|
- Replace(cmdstr,'$FILES',FixFileName(smartpath+current_module.asmprefix^+'*'+target_info.objext));
|
|
|
- success:=DoExec(FindUtil(binstr),cmdstr,false,true);
|
|
|
+ { create AR commands }
|
|
|
+ success := true;
|
|
|
+ nextcmd := cmdstr;
|
|
|
+ current := TStringListItem(SmartLinkOFiles.First);
|
|
|
+ repeat
|
|
|
+ Replace(nextcmd,'$FILES',GetNextFiles(240 - length(nextcmd), current));
|
|
|
+ success:=DoExec(FindUtil(binstr),nextcmd,false,true);
|
|
|
+ nextcmd := cmdstr;
|
|
|
+ until (not assigned(current)) or (not success);
|
|
|
+
|
|
|
{ Clean up }
|
|
|
if not(cs_asm_leave in aktglobalswitches) then
|
|
|
if not(cs_link_extern in aktglobalswitches) then
|