ow-build: use wlink directly without utils/wlinker.bat and ms2wlink

this construct is used to create kernel.exe only
now LINK variable contains real linker name with basic options that can be used anywhere and XLINK and XLINKFILE contains transformed linker command spcific for kernel build only
for Borland tools response file is created as before and for OW direct command line is used without useless double transformation

I think utils/wlinker.bat solution was introduced to fix problem with DOS long line and probably as result of port original Borland build response file to OW.

OW is capable to pass long command line to tools through environment variable.
OW wmake includes feature on DOS to overcome this issue by passing command line through auxiliary environment variable.
this feature is control in make files by start character (*) before tool name
Wmake create internaly auxiliary environment variable with original command line arguments and pass it as @<name> argument on tool command line, it is used only on DOS because for other OS is not command line limit for 127 characters
this feature can be used generally for most of OW tools as compilers, linker, librarian etc.
This commit is contained in:
Jiri Malak 2024-07-18 16:41:10 +02:00
parent db43a4b343
commit adb57a43a8
18 changed files with 107 additions and 96 deletions

View File

@ -80,12 +80,12 @@ set XUPX=upx --8086 --best
:-**********************************************************************
:- Turbo Link
:- set XLINK=tlink /m/c/s/l
:- set LINK=tlink /m/c/s/l
:- Microsoft Link
:- set XLINK=d:\qb\link /ma
:- set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo
:- set LINK=d:\qb\link /ma
:- set LINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo
:- WATCOM Link (wlinker is a batch file calling ms2wlink and wlink)
:- set XLINK=..\utils\wlinker /ma /nologo
:- set LINK=*wlink OP Q,M
:- set path for Turbo Link - use OLDPATH to restore normal path
:- set OLDPATH=%PATH%

View File

@ -37,7 +37,7 @@ XUPX=upx --8086 --best
# (otherwise will be determined automatically)
# WATCOM Link
#XLINK=wlink
#LINK=*wlink OP Q,M
#*********************************************************************
# optionally define your MAKE type here, if not then

View File

@ -35,20 +35,20 @@ echo Make is %MAKE%.
:-----------------------------------------------------------------------
if not "%XLINK%" == "" goto skip_xlink
if not "%LINK%" == "" goto skip_link
if "%COMPILER%" == "TC2" set XLINK=%TC2_BASE%\tlink /m/c
if "%COMPILER%" == "TURBOCPP" set XLINK=%TP1_BASE%\bin\tlink /m/c
if "%COMPILER%" == "TC3" set XLINK=%TC3_BASE%\bin\tlink /m/c
if "%COMPILER%" == "BC3" set XLINK=%BC3_BASE%\bin\tlink /m/c
if "%COMPILER%" == "BC5" set XLINK=%BC5_BASE%\bin\tlink /m/c
if "%COMPILER%" == "WATCOM" set XLINK=..\utils\wlinker /ma/nologo
if "%COMPILER%" == "OWWIN" set XLINK=..\utils\wlinker /ma/nologo
if "%COMPILER%" == "MSCL8" set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo
if "%COMPILER%" == "TC2" set LINK=%TC2_BASE%\tlink /m/c
if "%COMPILER%" == "TURBOCPP" set LINK=%TP1_BASE%\bin\tlink /m/c
if "%COMPILER%" == "TC3" set LINK=%TC3_BASE%\bin\tlink /m/c
if "%COMPILER%" == "BC3" set LINK=%BC3_BASE%\bin\tlink /m/c
if "%COMPILER%" == "BC5" set LINK=%BC5_BASE%\bin\tlink /m/c
if "%COMPILER%" == "WATCOM" set LINK=*wlink OP Q,M
if "%COMPILER%" == "OWWIN" set LINK=*wlink OP Q,M
if "%COMPILER%" == "MSCL8" set LINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo
echo Linker is %XLINK%.
echo Linker is %LINK%.
:skip_xlink
:skip_link
:-----------------------------------------------------------------------
@ -71,7 +71,7 @@ set CFLAGS=
set XCPU=
set XCPU_EX=
set XFAT=
set XLINK=
set LINK=
set TC2_BASE=
set TP1_BASE=
set TC3_BASE=

View File

@ -150,4 +150,3 @@
*/*/utils/proto.bat
*/*/utils/relocinf.c
*/*/utils/rmfiles.bat
*/*/utils/wlinker.bat

View File

@ -37,8 +37,8 @@ production: ../bin/$(TARGET).sys
kernel.sys: kernel.exe ../utils/exeflat.exe ../utils/upxentry.bin ../utils/upxdevic.bin exeflat.rsp
..$(DIRSEP)utils$(DIRSEP)exeflat.exe kernel.exe kernel.sys $(LOADSEG) @exeflat.rsp
kernel.exe: $(TARGET).lnk $(OBJS) $(LIBS)
$(LINK) @$(TARGET).lnk;
kernel.exe: $(XLINKFILE) $(OBJS) $(LIBS)
$(XLINK)
clobber: clean
-$(RM) kernel.exe kernel.sys status.me
@ -61,39 +61,39 @@ exeflat.rsp: makefile
$(ECHOTO) exeflat.rsp $(UPXOPT)
$(ECHOTO) exeflat.rsp $(XUPX)
$(TARGET).lnk: turboc.cfg makefile ../mkfiles/generic.mak ../mkfiles/$(COMPILER).mak
-$(RM) *.lnk
$(ECHOTO) $(TARGET).lnk $(OBJS1)+
$(ECHOTO) $(TARGET).lnk $(OBJS2)+
$(ECHOTO) $(TARGET).lnk $(OBJS3)+
$(ECHOTO) $(TARGET).lnk $(OBJS4)+
$(ECHOTO) $(TARGET).lnk $(OBJS5)+
$(ECHOTO) $(TARGET).lnk $(OBJS6)+
$(ECHOTO) $(TARGET).lnk $(OBJS7)+
$(ECHOTO) $(TARGET).lnk $(OBJS8)
$(ECHOTO) $(TARGET).lnk kernel.exe
$(ECHOTO) $(TARGET).lnk kernel.map
$(ECHOTO) $(TARGET).lnk $(LIBS)
kernel.lnk: turboc.cfg makefile ../mkfiles/generic.mak ../mkfiles/$(COMPILER).mak
-$(RM) kernel.lnk
$(ECHOTO) kernel.lnk $(OBJS1)+
$(ECHOTO) kernel.lnk $(OBJS2)+
$(ECHOTO) kernel.lnk $(OBJS3)+
$(ECHOTO) kernel.lnk $(OBJS4)+
$(ECHOTO) kernel.lnk $(OBJS5)+
$(ECHOTO) kernel.lnk $(OBJS6)+
$(ECHOTO) kernel.lnk $(OBJS7)+
$(ECHOTO) kernel.lnk $(OBJS8)
$(ECHOTO) kernel.lnk kernel.exe
$(ECHOTO) kernel.lnk kernel.map
$(ECHOTO) kernel.lnk $(LIBS)
# *Individual File Dependencies*
apisupt.obj: apisupt.asm segs.inc $(TARGET).lnk
asmsupt.obj: asmsupt.asm segs.inc $(TARGET).lnk
console.obj: console.asm io.inc $(TARGET).lnk
cpu.obj: cpu.asm segs.inc $(TARGET).lnk
dosidle.obj: dosidle.asm segs.inc $(TARGET).lnk
entry.obj: entry.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk
execrh.obj: execrh.asm segs.inc $(TARGET).lnk
int2f.obj: int2f.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk
intr.obj: intr.asm segs.inc $(TARGET).lnk
io.obj: io.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk
irqstack.obj: irqstack.asm segs.inc $(TARGET).lnk
kernel.obj: kernel.asm segs.inc ludivmul.inc $(TARGET).lnk
memdisk.obj: memdisk.asm segs.inc $(TARGET).lnk
nls_hc.obj: nls_hc.asm segs.inc $(TARGET).lnk
nlssupt.obj: nlssupt.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk
printer.obj: printer.asm io.inc $(TARGET).lnk
procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk
serial.obj: serial.asm io.inc $(TARGET).lnk
apisupt.obj: apisupt.asm segs.inc $(XLINKFILE)
asmsupt.obj: asmsupt.asm segs.inc $(XLINKFILE)
console.obj: console.asm io.inc $(XLINKFILE)
cpu.obj: cpu.asm segs.inc $(XLINKFILE)
dosidle.obj: dosidle.asm segs.inc $(XLINKFILE)
entry.obj: entry.asm segs.inc $(HDR)stacks.inc $(XLINKFILE)
execrh.obj: execrh.asm segs.inc $(XLINKFILE)
int2f.obj: int2f.asm segs.inc $(HDR)stacks.inc $(XLINKFILE)
intr.obj: intr.asm segs.inc $(XLINKFILE)
io.obj: io.asm segs.inc $(HDR)stacks.inc $(XLINKFILE)
irqstack.obj: irqstack.asm segs.inc $(XLINKFILE)
kernel.obj: kernel.asm segs.inc ludivmul.inc $(XLINKFILE)
memdisk.obj: memdisk.asm segs.inc $(XLINKFILE)
nls_hc.obj: nls_hc.asm segs.inc $(XLINKFILE)
nlssupt.obj: nlssupt.asm segs.inc $(HDR)stacks.inc $(XLINKFILE)
printer.obj: printer.asm io.inc $(XLINKFILE)
procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc $(XLINKFILE)
serial.obj: serial.asm io.inc $(XLINKFILE)
HDRS=\
$(HDR)portab.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h \
@ -104,30 +104,30 @@ HDRS=\
HEADERS=$(HDRS) globals.h proto.h
INITHEADERS=$(HDRS) init-mod.h init-dat.h
blockio.obj: blockio.c $(HEADERS) $(TARGET).lnk
break.obj: break.c $(HEADERS) $(TARGET).lnk
chario.obj: chario.c $(HEADERS) $(TARGET).lnk
dosfns.obj: dosfns.c $(HEADERS) $(TARGET).lnk
dsk.obj: dsk.c $(HEADERS) $(TARGET).lnk
error.obj: error.c $(HEADERS) $(TARGET).lnk
fatdir.obj: fatdir.c $(HEADERS) $(TARGET).lnk
fatfs.obj: fatfs.c $(HEADERS) $(TARGET).lnk
fattab.obj: fattab.c $(HEADERS) $(TARGET).lnk
fcbfns.obj: fcbfns.c $(HEADERS) $(TARGET).lnk
inthndlr.obj: inthndlr.c $(HEADERS) $(TARGET).lnk
ioctl.obj: ioctl.c $(HEADERS) $(TARGET).lnk
memmgr.obj: memmgr.c $(HEADERS) $(TARGET).lnk
misc.obj: misc.c $(HEADERS) $(TARGET).lnk
lfnapi.obj: lfnapi.c $(HEADERS) $(TARGET).lnk
newstuff.obj: newstuff.c $(HEADERS) $(TARGET).lnk
network.obj: network.c $(HEADERS) $(TARGET).lnk
nls.obj: nls.c $(HEADERS) $(TARGET).lnk
prf.obj: prf.c $(HDR)portab.h $(TARGET).lnk
strings.obj: strings.c $(TARGET).lnk
sysclk.obj: sysclk.c $(HEADERS) $(TARGET).lnk
syspack.obj: syspack.c $(HEADERS) $(TARGET).lnk
systime.obj: systime.c $(HEADERS) $(TARGET).lnk
task.obj: task.c $(HEADERS) $(TARGET).lnk
blockio.obj: blockio.c $(HEADERS) $(XLINKFILE)
break.obj: break.c $(HEADERS) $(XLINKFILE)
chario.obj: chario.c $(HEADERS) $(XLINKFILE)
dosfns.obj: dosfns.c $(HEADERS) $(XLINKFILE)
dsk.obj: dsk.c $(HEADERS) $(XLINKFILE)
error.obj: error.c $(HEADERS) $(XLINKFILE)
fatdir.obj: fatdir.c $(HEADERS) $(XLINKFILE)
fatfs.obj: fatfs.c $(HEADERS) $(XLINKFILE)
fattab.obj: fattab.c $(HEADERS) $(XLINKFILE)
fcbfns.obj: fcbfns.c $(HEADERS) $(XLINKFILE)
inthndlr.obj: inthndlr.c $(HEADERS) $(XLINKFILE)
ioctl.obj: ioctl.c $(HEADERS) $(XLINKFILE)
memmgr.obj: memmgr.c $(HEADERS) $(XLINKFILE)
misc.obj: misc.c $(HEADERS) $(XLINKFILE)
lfnapi.obj: lfnapi.c $(HEADERS) $(XLINKFILE)
newstuff.obj: newstuff.c $(HEADERS) $(XLINKFILE)
network.obj: network.c $(HEADERS) $(XLINKFILE)
nls.obj: nls.c $(HEADERS) $(XLINKFILE)
prf.obj: prf.c $(HDR)portab.h $(XLINKFILE)
strings.obj: strings.c $(XLINKFILE)
sysclk.obj: sysclk.c $(HEADERS) $(XLINKFILE)
syspack.obj: syspack.c $(HEADERS) $(XLINKFILE)
systime.obj: systime.c $(HEADERS) $(XLINKFILE)
task.obj: task.c $(HEADERS) $(XLINKFILE)
# now the funny stuff :-)
# Files in the INIT segment
@ -135,39 +135,39 @@ task.obj: task.c $(HEADERS) $(TARGET).lnk
# XXX: Special handling for initialization modules -- this is required because
# TC 2.01 cannot handle `#pragma option' like TC 3 can. -- ror4
config.obj: config.c $(INITHEADERS) $(TARGET).lnk
config.obj: config.c $(INITHEADERS) $(XLINKFILE)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
initoem.obj: initoem.c $(INITHEADERS) $(TARGET).lnk
initoem.obj: initoem.c $(INITHEADERS) $(XLINKFILE)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
main.obj: main.c $(INITHEADERS) $(TARGET).lnk
main.obj: main.c $(INITHEADERS) $(XLINKFILE)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
inithma.obj: inithma.c $(INITHEADERS) $(TARGET).lnk
inithma.obj: inithma.c $(INITHEADERS) $(XLINKFILE)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
dyninit.obj: dyninit.c $(INITHEADERS) $(TARGET).lnk
dyninit.obj: dyninit.c $(INITHEADERS) $(XLINKFILE)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
initdisk.obj: initdisk.c $(INITHEADERS) $(TARGET).lnk
initdisk.obj: initdisk.c $(INITHEADERS) $(XLINKFILE)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
initclk.obj: initclk.c $(INITHEADERS) $(TARGET).lnk
initclk.obj: initclk.c $(INITHEADERS) $(XLINKFILE)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
#the string functions for INIT_TEXT
iasmsupt.obj: asmsupt.asm $(TARGET).lnk
iasmsupt.obj: asmsupt.asm $(XLINKFILE)
$(NASM) -D$(COMPILER) -D_INIT -f obj $(NASMFLAGS) -o iasmsupt.obj asmsupt.asm
#the printf for INIT_TEXT - yet another special case, this file includes prf.c
iprf.obj: iprf.c prf.c $(HDR)portab.h $(TARGET).lnk
iprf.obj: iprf.c prf.c $(HDR)portab.h $(XLINKFILE)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj

View File

@ -97,12 +97,12 @@ ifeq ($(COMPILER),gcc)
MAKE=make
MAKEADJUST=for i in utils lib drivers boot sys kernel setver; do sed 's@!include "\(.*\)"@include ../mkfiles/gcc.mak@' < $$i/makefile > $$i/GNUmakefile; done
MAKEREMOVE=for i in utils lib drivers boot sys kernel setver; do rm -f $$i/GNUmakefile; done
XLINK=ia16-elf-gcc
LINK=ia16-elf-gcc
else
MAKE=wmake -ms -h
MAKEADJUST=
MAKEREMOVE=
XLINK=wlink
LINK=*wlink OP Q,M
endif
#ALLCFLAGS=-DDEBUG

View File

@ -51,3 +51,6 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL
ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS)
INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP
CFLAGS=$(ALLCFLAGS)
XLINKFILE=kernel.lnk
XLINK=$(LINK) @$(XLINKFILE)

View File

@ -51,3 +51,6 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL
ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS)
INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP
CFLAGS=$(ALLCFLAGS)
XLINKFILE=kernel.lnk
XLINK=$(LINK) @$(XLINKFILE)

View File

@ -72,7 +72,8 @@ INITPATCH=ia16-elf-objcopy --redefine-sym ___umodsi3=_init_umodsi3 --redefine-sy
CLDEF=1
CLT=gcc -Wall -I../hdr -o $@
CLC=$(CLT)
LINK=$(XLINK) -Tkernel.ld -nostdlib -Wl,-Map,kernel.map -o kernel.exe $(OBJS) -Wl,--whole-archive ../drivers/device.lib -Wl,--no-whole-archive \#
XLINK=$(LINK) -Tkernel.ld -nostdlib -Wl,-Map,kernel.map -o kernel.exe $(OBJS) -Wl,--whole-archive ../drivers/device.lib -Wl,--no-whole-archive \#
.SUFFIXES: .obj .asm

View File

@ -24,8 +24,6 @@ NASMFLAGS=$(NASMFLAGS) -DWITHFAT32
NASM=$(XNASM)
NASMFLAGS = $(NASMFLAGS) -i../hdr/ -DXCPU=$(XCPU)
LINK=$(XLINK)
INITPATCH=@rem
DIRSEP=\ #a backslash
RM=..\utils\rmfiles

View File

@ -45,3 +45,6 @@ ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -Zl -Fc -WX -Gr -f- -Os -Gs
INITCFLAGS=$(ALLCFLAGS) -NTINIT_TEXT
CFLAGS=$(ALLCFLAGS) -NTHMA_TEXT
INITPATCH = ..\utils\patchobj _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC
XLINKFILE=kernel.lnk
XLINK=$(LINK) @$(XLINKFILE)

View File

@ -16,4 +16,3 @@ INITPATCH=@echo > /dev/null
CLDEF=1
CLT=wcl386 -zq -fo=.obj -bcl=linux -I../hdr -fe=$@ -I$(COMPILERPATH)/lh
CLC=$(CLT)
XLINK=$(XLINK) debug all format dos opt quiet,symfile,map,statics,verbose F { $(OBJS) } L ../lib/device.lib N kernel.exe $#

View File

@ -16,4 +16,3 @@ CLDEF=1
CLT=wcl386 -zq -bcl=nt -I..\hdr -fe=$@ -I$(COMPILERPATH)\h -I$(COMPILERPATH)\h\nt
CLC=$(CLT)
NASMFLAGS=-DWATCOM $(NASMFLAGS)
XLINK=$(XLINK) debug all format dos opt quiet,symfile,map,statics,verbose F { $(OBJS) } L ..$(DIRSEP)lib$(DIRSEP)device.lib N kernel.exe $#

View File

@ -51,3 +51,6 @@ MATH_INSERT=+LDIV +LXMUL +LURSH +LLSH +LRSH
ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS)
INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP
CFLAGS=$(ALLCFLAGS)
XLINKFILE=kernel.lnk
XLINK=$(LINK) @$(XLINKFILE)

View File

@ -51,3 +51,6 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL
ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS)
INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP
CFLAGS=$(ALLCFLAGS)
XLINKFILE=kernel.lnk
XLINK=$(LINK) @$(XLINKFILE)

View File

@ -51,3 +51,6 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL
ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS)
INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP
CFLAGS=$(ALLCFLAGS)
XLINKFILE=kernel.lnk
XLINK=$(LINK) @$(XLINKFILE)

View File

@ -6,7 +6,7 @@
COMPILERPATH=$(WATCOM)
CC=*wcc -zq
CL=wcl -zq
INCLUDEPATH=$(COMPILERPATH)\H
INCLUDEPATH=$(COMPILERPATH)\h
INCLUDE=$(COMPILERPATH)\h
EDPATH=$(COMPILERPATH)\EDDAT
@ -65,3 +65,4 @@ ALLCFLAGS=-I..$(DIRSEP)hdr $(TARGETOPT) $(ALLCFLAGS) -os-s-e5-j-zl-zp1-wx-we-zgf
INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-gTGROUP-ndI
CFLAGS=$(ALLCFLAGS)-ntHMA_TEXT
XLINK=$(LINK) D A FORM dos OP SYMF,STAT,V F{$(OBJS)} L{$(LIBS)} N kernel.exe

View File

@ -1,4 +0,0 @@
@echo off
ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9 ,,,, > kernel.lnk
echo op map,statics,verbose >> kernel.lnk
call wlink @kernel.lnk