mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 11:29:41 +02:00
alink support added and enabled by default
git-svn-id: branches/i8086@23784 -
This commit is contained in:
parent
8c24a85462
commit
da37d03dd7
@ -24,6 +24,8 @@ unit t_msdos;
|
||||
|
||||
{$i fpcdefs.inc}
|
||||
|
||||
{$define USE_LINKER_ALINK}
|
||||
|
||||
interface
|
||||
|
||||
|
||||
@ -37,6 +39,7 @@ implementation
|
||||
link,aasmbase;
|
||||
|
||||
type
|
||||
{ Borland TLINK support }
|
||||
TExternalLinkerMsDosTLink=class(texternallinker)
|
||||
private
|
||||
Function WriteResponseFile(isdll:boolean) : Boolean;
|
||||
@ -46,6 +49,16 @@ implementation
|
||||
function MakeExecutable:boolean;override;
|
||||
end;
|
||||
|
||||
{ the ALINK linker from http://alink.sourceforge.net/ }
|
||||
TExternalLinkerMsDosALink=class(texternallinker)
|
||||
private
|
||||
Function WriteResponseFile(isdll:boolean) : Boolean;
|
||||
public
|
||||
constructor Create;override;
|
||||
procedure SetDefaultInfo;override;
|
||||
function MakeExecutable:boolean;override;
|
||||
end;
|
||||
|
||||
|
||||
{****************************************************************************
|
||||
TExternalLinkerMsDosTLink
|
||||
@ -72,9 +85,7 @@ end;
|
||||
Function TExternalLinkerMsDosTLink.WriteResponseFile(isdll:boolean) : Boolean;
|
||||
Var
|
||||
linkres : TLinkRes;
|
||||
i : longint;
|
||||
s : string;
|
||||
linklibc : boolean;
|
||||
begin
|
||||
WriteResponseFile:=False;
|
||||
|
||||
@ -126,11 +137,95 @@ begin
|
||||
MakeExecutable:=success; { otherwise a recursive call to link method }
|
||||
end;
|
||||
|
||||
{****************************************************************************
|
||||
TExternalLinkerMsDosALink
|
||||
****************************************************************************}
|
||||
|
||||
{ TExternalLinkerMsDosALink }
|
||||
|
||||
function TExternalLinkerMsDosALink.WriteResponseFile(isdll: boolean): Boolean;
|
||||
Var
|
||||
linkres : TLinkRes;
|
||||
s : string;
|
||||
begin
|
||||
WriteResponseFile:=False;
|
||||
|
||||
{ Open link.res file }
|
||||
LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
|
||||
|
||||
{ Add all options to link.res instead of passing them via command line:
|
||||
DOS command line is limited to 126 characters! }
|
||||
|
||||
{ add objectfiles, start with prt0 always }
|
||||
LinkRes.Add(maybequoted(FindObjectFile('prt0','',false)));
|
||||
while not ObjectFiles.Empty do
|
||||
begin
|
||||
s:=ObjectFiles.GetFirst;
|
||||
if s<>'' then
|
||||
LinkRes.Add(maybequoted(s));
|
||||
end;
|
||||
LinkRes.Add('-oEXE');
|
||||
LinkRes.Add('-o ' + maybequoted(current_module.exefilename));
|
||||
|
||||
{ Write and Close response }
|
||||
linkres.writetodisk;
|
||||
LinkRes.Free;
|
||||
|
||||
WriteResponseFile:=True;
|
||||
end;
|
||||
|
||||
constructor TExternalLinkerMsDosALink.Create;
|
||||
begin
|
||||
Inherited Create;
|
||||
{ allow duplicated libs (PM) }
|
||||
SharedLibFiles.doubles:=true;
|
||||
StaticLibFiles.doubles:=true;
|
||||
end;
|
||||
|
||||
procedure TExternalLinkerMsDosALink.SetDefaultInfo;
|
||||
begin
|
||||
with Info do
|
||||
begin
|
||||
ExeCmd[1]:='alink $RES';
|
||||
end;
|
||||
end;
|
||||
|
||||
function TExternalLinkerMsDosALink.MakeExecutable: boolean;
|
||||
var
|
||||
binstr,
|
||||
cmdstr : TCmdStr;
|
||||
success : boolean;
|
||||
begin
|
||||
if not(cs_link_nolink in current_settings.globalswitches) then
|
||||
Message1(exec_i_linking,current_module.exefilename);
|
||||
|
||||
{ Write used files and libraries and our own tlink script }
|
||||
WriteResponsefile(false);
|
||||
|
||||
{ Call linker }
|
||||
SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
|
||||
Replace(cmdstr,'$RES','@'+maybequoted(outputexedir+Info.ResName));
|
||||
success:=DoExec(FindUtil(utilsprefix+BinStr),cmdstr,true,false);
|
||||
|
||||
{ Remove ReponseFile }
|
||||
if (success) and not(cs_link_nolink in current_settings.globalswitches) then
|
||||
DeleteFile(outputexedir+Info.ResName);
|
||||
|
||||
MakeExecutable:=success; { otherwise a recursive call to link method }
|
||||
end;
|
||||
|
||||
|
||||
{*****************************************************************************
|
||||
Initialize
|
||||
*****************************************************************************}
|
||||
|
||||
initialization
|
||||
{$if defined(USE_LINKER_TLINK)}
|
||||
RegisterExternalLinker(system_i8086_msdos_info,TExternalLinkerMsDosTLink);
|
||||
{$elseif defined(USE_LINKER_ALINK)}
|
||||
RegisterExternalLinker(system_i8086_msdos_info,TExternalLinkerMsDosALink);
|
||||
{$else}
|
||||
{$fatal no linker defined}
|
||||
{$endif}
|
||||
RegisterTarget(system_i8086_msdos_info);
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user