mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-20 18:09:30 +01:00
* setting the outputfile using -o works now to create static libs
This commit is contained in:
parent
f8ab2581ff
commit
1b24a06769
@ -225,8 +225,8 @@ begin
|
||||
inc(SmartLinkFilesCnt);
|
||||
if SmartLinkFilesCnt>999999 then
|
||||
Message(assem_f_too_many_asm_files);
|
||||
AsmFile:=Path+FixFileName('as'+tostr(SmartLinkFilesCnt)+target_info.asmext);
|
||||
ObjFile:=Path+FixFileName('as'+tostr(SmartLinkFilesCnt)+target_info.objext);
|
||||
AsmFile:=Path+FixFileName(current_module^.asmprefix^+tostr(SmartLinkFilesCnt)+target_info.asmext);
|
||||
ObjFile:=Path+FixFileName(current_module^.asmprefix^+tostr(SmartLinkFilesCnt)+target_info.objext);
|
||||
end;
|
||||
|
||||
|
||||
@ -452,7 +452,10 @@ end;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.15 1998-08-14 18:16:09 peter
|
||||
Revision 1.16 1998-08-14 21:56:30 peter
|
||||
* setting the outputfile using -o works now to create static libs
|
||||
|
||||
Revision 1.15 1998/08/14 18:16:09 peter
|
||||
* return after a failed call will now add it to ppas
|
||||
|
||||
Revision 1.14 1998/08/10 14:49:41 peter
|
||||
|
||||
@ -126,7 +126,9 @@ unit files;
|
||||
objfilename, { fullname of the objectfile }
|
||||
asmfilename, { fullname of the assemblerfile }
|
||||
ppufilename, { fullname of the ppufile }
|
||||
libfilename, { fullname of the libraryfile }
|
||||
libfilename, { fullname of the libraryfile/exefile }
|
||||
exefilename, { fullname of the exefile }
|
||||
asmprefix, { prefix for the smartlink asmfiles }
|
||||
mainsource : pstring; { name of the main sourcefile }
|
||||
|
||||
constructor init(const s:string;_is_unit:boolean);
|
||||
@ -400,20 +402,28 @@ unit files;
|
||||
|
||||
procedure tmodule.setfilename(const fn:string);
|
||||
var
|
||||
p,n,e,s : string;
|
||||
p : dirstr;
|
||||
n : NameStr;
|
||||
e : ExtStr;
|
||||
s : string;
|
||||
begin
|
||||
fsplit(fn,p,n,e);
|
||||
stringdispose(objfilename);
|
||||
stringdispose(asmfilename);
|
||||
stringdispose(ppufilename);
|
||||
stringdispose(libfilename);
|
||||
stringdispose(exefilename);
|
||||
stringdispose(path);
|
||||
fsplit(fn,p,n,e);
|
||||
path:=stringdup(FixPath(p));
|
||||
s:=FixFileName(FixPath(p)+n);
|
||||
objfilename:=stringdup(s+target_info.objext);
|
||||
asmfilename:=stringdup(s+target_info.asmext);
|
||||
ppufilename:=stringdup(s+target_info.unitext);
|
||||
{ lib and exe could be loaded with a file specified with -o }
|
||||
if OutputFile<>'' then
|
||||
s:=OutputFile;
|
||||
libfilename:=stringdup(s+target_os.staticlibext);
|
||||
exefilename:=stringdup(s+target_os.exeext);
|
||||
end;
|
||||
|
||||
{$ifndef OLDPPU}
|
||||
@ -856,10 +866,18 @@ unit files;
|
||||
else
|
||||
modulename:=stringdup('PROGRAM');
|
||||
mainsource:=stringdup(s);
|
||||
ppufilename:=nil;
|
||||
objfilename:=nil;
|
||||
asmfilename:=nil;
|
||||
libfilename:=nil;
|
||||
ppufilename:=nil;
|
||||
exefilename:=nil;
|
||||
{ go32v2 has the famous 8.3 limit ;) }
|
||||
{$ifdef go32v2}
|
||||
asmprefix:=stringdup('as');
|
||||
{$else}
|
||||
asmprefix:=stringdup(Lower(n));
|
||||
{$endif}
|
||||
|
||||
path:=nil;
|
||||
setfilename(p+n);
|
||||
used_units.init;
|
||||
@ -916,9 +934,11 @@ unit files;
|
||||
stringdispose(asmfilename);
|
||||
stringdispose(ppufilename);
|
||||
stringdispose(libfilename);
|
||||
stringdispose(exefilename);
|
||||
stringdispose(path);
|
||||
stringdispose(modulename);
|
||||
stringdispose(mainsource);
|
||||
stringdispose(asmprefix);
|
||||
inherited done;
|
||||
end;
|
||||
|
||||
@ -1004,7 +1024,10 @@ unit files;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.33 1998-08-11 14:09:08 peter
|
||||
Revision 1.34 1998-08-14 21:56:31 peter
|
||||
* setting the outputfile using -o works now to create static libs
|
||||
|
||||
Revision 1.33 1998/08/11 14:09:08 peter
|
||||
* fixed some messages and smaller msgtxt.inc
|
||||
|
||||
Revision 1.32 1998/08/10 14:49:58 peter
|
||||
|
||||
@ -25,7 +25,7 @@ Unit link;
|
||||
|
||||
Interface
|
||||
|
||||
uses cobjects;
|
||||
uses cobjects,files;
|
||||
|
||||
Type
|
||||
TLinker = Object
|
||||
@ -34,20 +34,14 @@ Type
|
||||
ObjectFiles,
|
||||
SharedLibFiles,
|
||||
StaticLibFiles : TStringContainer;
|
||||
OutputName,
|
||||
LibrarySearchPath, { Search path for libraries }
|
||||
ExeName, { FileName of the exe to be created }
|
||||
SharedLibName,
|
||||
StaticLibName, { FileName of the lib to be created }
|
||||
LinkOptions : string; { Additional options to the linker }
|
||||
DynamicLinker : String[80]; { What Dynamic linker ? }
|
||||
LinkResName : String[32]; { Name of response file }
|
||||
{ Methods }
|
||||
Constructor Init;
|
||||
Destructor Done;
|
||||
Procedure SetOutputName(const s:string);
|
||||
Procedure SetExeName(const s:string);
|
||||
Procedure SetLibName(const s:string);
|
||||
procedure AddModuleFiles(hp:pmodule);
|
||||
function FindObjectFile(s : string) : string;
|
||||
function FindLibraryFile(s:string;const ext:string) : string;
|
||||
Procedure AddObject(const S : String);
|
||||
@ -100,13 +94,11 @@ begin
|
||||
LinkToC:=False;
|
||||
Strip:=false;
|
||||
LinkOptions:='';
|
||||
ExeName:='';
|
||||
OutputName:='';
|
||||
SharedLibName:='';
|
||||
StaticLibName:='';
|
||||
ObjectSearchPath:='';
|
||||
{$ifdef linux}
|
||||
DynamicLinker:='/lib/ld-linux.so.1';
|
||||
{ first try glibc2 }
|
||||
DynamicLinker:='/lib/ld-linux.so.2';
|
||||
if not FileExists(DynamicLinker) then
|
||||
DynamicLinker:='/lib/ld-linux.so.1';
|
||||
LibrarySearchPath:='/lib;/usr/lib';
|
||||
{$else}
|
||||
DynamicLinker:='';
|
||||
@ -121,44 +113,16 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Procedure TLinker.SetOutputName(const s:string);
|
||||
procedure TLinker.AddModuleFiles(hp:pmodule);
|
||||
begin
|
||||
OutputName:=s;
|
||||
end;
|
||||
|
||||
|
||||
Procedure TLinker.SetExeName(const s:string);
|
||||
var
|
||||
path : dirstr;
|
||||
name : namestr;
|
||||
ext : extstr;
|
||||
begin
|
||||
if OutputName='' then
|
||||
with hp^ do
|
||||
begin
|
||||
FSplit(s,path,name,ext);
|
||||
ExeName:=Path+Name+target_info.ExeExt;
|
||||
end
|
||||
else
|
||||
ExeName:=OutputName;
|
||||
end;
|
||||
|
||||
|
||||
Procedure TLinker.SetLibName(const s:string);
|
||||
var
|
||||
path : dirstr;
|
||||
name : namestr;
|
||||
ext : extstr;
|
||||
begin
|
||||
if OutputName='' then
|
||||
begin
|
||||
FSplit(s,path,name,ext);
|
||||
SharedLibName:=Path+Name+target_os.SharedLibExt;
|
||||
StaticLibName:=Path+Name+target_os.StaticLibExt;
|
||||
end
|
||||
else
|
||||
begin
|
||||
SharedLibName:=OutputName;
|
||||
StaticLibName:=OutputName;
|
||||
while not linkofiles.empty do
|
||||
AddObject(linkofiles.Get);
|
||||
while not linksharedlibs.empty do
|
||||
AddSharedLibrary(linksharedlibs.Get);
|
||||
while not linkstaticlibs.empty do
|
||||
AddStaticLibrary(linkstaticlibs.Get);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -230,7 +194,6 @@ end;
|
||||
Procedure TLinker.AddSharedLibrary(const S:String);
|
||||
begin
|
||||
SharedLibFiles.Insert (S);
|
||||
{ SharedLibFiles.Insert(FindLibraryFile(s,target_os.sharedlibext)); }
|
||||
end;
|
||||
|
||||
|
||||
@ -269,7 +232,7 @@ begin
|
||||
if cs_link_extern in aktglobalswitches then
|
||||
begin
|
||||
if info then
|
||||
AsmRes.AddLinkCommand(Command,Para,ExeName)
|
||||
AsmRes.AddLinkCommand(Command,Para,current_module^.libfilename^)
|
||||
else
|
||||
AsmRes.AddLinkCommand(Command,Para,'');
|
||||
end;
|
||||
@ -433,9 +396,9 @@ begin
|
||||
|
||||
{ Call linker }
|
||||
if not(cs_link_extern in aktglobalswitches) then
|
||||
Message1(exec_i_linking,ExeName);
|
||||
Message1(exec_i_linking,current_module^.exefilename^);
|
||||
s:=target_link.linkcmd;
|
||||
Replace(s,'$EXE',exename);
|
||||
Replace(s,'$EXE',current_module^.exefilename^);
|
||||
Replace(s,'$OPT',LinkOptions);
|
||||
Replace(s,'$RES',inputdir+LinkResName);
|
||||
success:=DoExec(FindLinker,s,true,false);
|
||||
@ -443,7 +406,7 @@ begin
|
||||
if target_link.bindbin<>'' then
|
||||
begin
|
||||
s:=target_link.bindcmd;
|
||||
Replace(s,'$EXE',exename);
|
||||
Replace(s,'$EXE',current_module^.exefilename^);
|
||||
Replace(s,'$HEAPKB',tostr((heapsize+1023) shr 10));
|
||||
Replace(s,'$STACKKB',tostr((stacksize+1023) shr 10));
|
||||
bindbin:=FindExe(target_link.bindbin,bindfound);
|
||||
@ -483,15 +446,15 @@ begin
|
||||
aktglobalswitches:=aktglobalswitches+[cs_link_extern];
|
||||
end;
|
||||
s:=target_ar.arcmd;
|
||||
Replace(s,'$LIB',staticlibname);
|
||||
Replace(s,'$FILES',FixPath(path)+'*'+target_info.objext);
|
||||
Replace(s,'$LIB',current_module^.libfilename^);
|
||||
Replace(s,'$FILES',FixPath(path)+current_module^.asmprefix^+'*'+target_info.objext);
|
||||
DoExec(arbin,s,false,true);
|
||||
{ Clean up }
|
||||
if not(cs_asm_leave in aktglobalswitches) and not(cs_link_extern in aktglobalswitches) then
|
||||
begin
|
||||
for cnt:=1to filescnt do
|
||||
begin
|
||||
assign(f,FixPath(path)+'as'+tostr(cnt)+target_info.objext);
|
||||
assign(f,FixPath(path)+current_module^.asmprefix^+tostr(cnt)+target_info.objext);
|
||||
{$I-}
|
||||
erase(f);
|
||||
{$I+}
|
||||
@ -507,14 +470,17 @@ end;
|
||||
|
||||
Procedure TLinker.MakeSharedLibrary;
|
||||
begin
|
||||
DoExec(FindLinker,' -shared -o '+sharedlibname+' link.res',false,false);
|
||||
DoExec(FindLinker,' -shared -o '+current_module^.libfilename^+' link.res',false,false);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.17 1998-08-14 18:16:08 peter
|
||||
Revision 1.18 1998-08-14 21:56:34 peter
|
||||
* setting the outputfile using -o works now to create static libs
|
||||
|
||||
Revision 1.17 1998/08/14 18:16:08 peter
|
||||
* return after a failed call will now add it to ppas
|
||||
|
||||
Revision 1.16 1998/08/12 19:28:15 peter
|
||||
|
||||
@ -272,15 +272,12 @@ unit parser;
|
||||
GenerateAsm(filename);
|
||||
|
||||
if (cs_smartlink in aktmoduleswitches) then
|
||||
begin
|
||||
Linker.SetLibName(current_module^.libfilename^);
|
||||
Linker.MakeStaticLibrary(SmartLinkPath(FileName),SmartLinkFilesCnt);
|
||||
end;
|
||||
Linker.MakeStaticLibrary(SmartLinkPath(FileName),SmartLinkFilesCnt);
|
||||
|
||||
{ add the files for the linker from current_module, this must be
|
||||
after the makestaticlibrary, because it will add the library
|
||||
name (PFV) }
|
||||
addlinkerfiles(current_module);
|
||||
Linker.AddModuleFiles(current_module);
|
||||
|
||||
{ Check linking => we are at first level in compile }
|
||||
if (compile_level=1) then
|
||||
@ -288,11 +285,7 @@ unit parser;
|
||||
if (cs_link_deffile in aktglobalswitches) then
|
||||
deffile.writefile;
|
||||
if (not current_module^.is_unit) then
|
||||
begin
|
||||
if Linker.ExeName='' then
|
||||
Linker.SetExeName(FileName);
|
||||
Linker.MakeExecutable;
|
||||
end;
|
||||
Linker.MakeExecutable;
|
||||
end;
|
||||
end
|
||||
else
|
||||
@ -405,7 +398,10 @@ done:
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.35 1998-08-12 19:22:09 peter
|
||||
Revision 1.36 1998-08-14 21:56:36 peter
|
||||
* setting the outputfile using -o works now to create static libs
|
||||
|
||||
Revision 1.35 1998/08/12 19:22:09 peter
|
||||
* reset also the link* lists when recompiling an existing unit
|
||||
|
||||
Revision 1.34 1998/08/10 23:58:56 peter
|
||||
|
||||
@ -29,7 +29,6 @@ unit pmodules;
|
||||
uses
|
||||
files;
|
||||
|
||||
procedure addlinkerfiles(hp:pmodule);
|
||||
procedure loadsystemunit;
|
||||
procedure proc_unit;
|
||||
procedure proc_program(islibrary : boolean);
|
||||
@ -52,19 +51,16 @@ unit pmodules;
|
||||
,scanner,pbase,psystem,pdecl,psub,parser;
|
||||
|
||||
|
||||
procedure addlinkerfiles(hp:pmodule);
|
||||
procedure setlinkerfile;
|
||||
begin
|
||||
with hp^ do
|
||||
begin
|
||||
while not linkofiles.empty do
|
||||
Linker.AddObject(linkofiles.Get);
|
||||
while not linksharedlibs.empty do
|
||||
Linker.AddSharedLibrary(linksharedlibs.Get);
|
||||
while not linkstaticlibs.empty do
|
||||
Linker.AddStaticLibrary(linkstaticlibs.Get);
|
||||
end;
|
||||
{ Add Object File }
|
||||
if (cs_smartlink in aktmoduleswitches) then
|
||||
current_module^.linkstaticlibs.insert(current_module^.libfilename^)
|
||||
else
|
||||
current_module^.linkofiles.insert(current_module^.objfilename^);
|
||||
end;
|
||||
|
||||
|
||||
procedure insertsegment;
|
||||
|
||||
procedure fixseg(p:paasmoutput;sec:tsection);
|
||||
@ -271,7 +267,7 @@ unit pmodules;
|
||||
if (current_module^.do_assemble) then
|
||||
OnlyAsm(current_module^.asmfilename^);
|
||||
{ add the files for the linker }
|
||||
addlinkerfiles(current_module);
|
||||
Linker.AddModuleFiles(current_module);
|
||||
end;
|
||||
if assigned(current_module^.ppufile) then
|
||||
begin
|
||||
@ -519,11 +515,11 @@ unit pmodules;
|
||||
Message1(unit_f_cant_compile_unit,hp^.modulename^)
|
||||
else
|
||||
begin
|
||||
if assigned(old_current_module^.current_inputfile) then
|
||||
if assigned(old_current_module^.current_inputfile) then
|
||||
old_current_module^.current_inputfile^.tempclose;
|
||||
compile(hp^.mainsource^,compile_system);
|
||||
compile(hp^.mainsource^,compile_system);
|
||||
if (not old_current_module^.compiled) and assigned(old_current_module^.current_inputfile) then
|
||||
old_current_module^.current_inputfile^.tempreopen;
|
||||
old_current_module^.current_inputfile^.tempreopen;
|
||||
end;
|
||||
end
|
||||
else
|
||||
@ -784,12 +780,6 @@ unit pmodules;
|
||||
Message(unit_w_switch_us_missed);
|
||||
dispose(s2);
|
||||
dispose(s1);
|
||||
|
||||
{ Add Object File }
|
||||
if (cs_smartlink in aktmoduleswitches) then
|
||||
current_module^.linkstaticlibs.insert(current_module^.libfilename^)
|
||||
else
|
||||
current_module^.linkofiles.insert(current_module^.objfilename^);
|
||||
end;
|
||||
|
||||
consume(ID);
|
||||
@ -981,6 +971,9 @@ unit pmodules;
|
||||
{$endif dummy}
|
||||
consume(POINT);
|
||||
|
||||
{ add files which need to be linked }
|
||||
setlinkerfile;
|
||||
|
||||
{ size of the static data }
|
||||
datasize:=symtablestack^.datasize;
|
||||
|
||||
@ -1129,10 +1122,7 @@ unit pmodules;
|
||||
|
||||
consume(POINT);
|
||||
|
||||
if (cs_smartlink in aktmoduleswitches) then
|
||||
current_module^.linkstaticlibs.insert(current_module^.libfilename^)
|
||||
else
|
||||
current_module^.linkofiles.insert(current_module^.objfilename^);
|
||||
setlinkerfile;
|
||||
|
||||
{ insert heap }
|
||||
insertheap;
|
||||
@ -1152,7 +1142,10 @@ unit pmodules;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.38 1998-08-10 14:50:13 peter
|
||||
Revision 1.39 1998-08-14 21:56:37 peter
|
||||
* setting the outputfile using -o works now to create static libs
|
||||
|
||||
Revision 1.38 1998/08/10 14:50:13 peter
|
||||
+ localswitches, moduleswitches, globalswitches splitting
|
||||
|
||||
Revision 1.37 1998/08/10 10:18:31 peter
|
||||
|
||||
Loading…
Reference in New Issue
Block a user