# This is Borland MAKE makefile

# Files to fix for new version:
# file_id.diz - version and copyright
# *.doc - version, copyright, changes
# srdisk.h - VERSION
# srdisk.c - copyright year
# define.inc - SRD_VERSION, DEBUGGING
# srdisk.inc - copyright year
# srdummy.asm - copyright year
# makefile - VERSION and RELTIME

CFLAGS=-Os -Wall -DNDEBUG
CMODEL=-mcmodel=small

OBJS =\
 allocate.o \
 bitmap.o \
 cmdline.o \
 director.o \
 diskinit.o \
 diskio.o \
 env.o \
 error.o \
 fat.o \
 format.o \
 formutil.o \
 getopt.o \
 makenewf.o \
 packdata.o \
 realloc.o \
 resize.o \
 srdemsf.o \
 srdisk.o \
 srdutil.o \
 srdxmsf.o \
 writenew.o \
 asmhelp.o

all: srdxms.sys srdems.sys srdxmss.sys srdemss.sys srdems3.sys \
 srdummy.sys xmssize.exe srdiskc.exe srdmulti.sys srdisk.exe \
 srdiskx.exe srdiske.exe

.SUFFIXES: .exe .sys .obj .nas .c .o

.obj.sys:
	./warplink.sh /mx $*.obj,$*.exe,$*.map
	convlist.pl $*.map $*.lst > $*.tls
	./x2b2.sh /s $*.exe $*.sys

.nas.obj:
	nasm -Pnasm.mac -I../lmacros/ $*.nas -t -l $*.lst -o $*.obj -fobj

.c.o:
	ia16-elf-gcc $(CMODEL) $(CFLAGS) -c $*.c -masm=intel \
		-Wa,-a=$*.lst -o $*.o \
		-Wa,--listing-cont-lines=9999 -Wa,--listing-rhs-width=100 \
		-Wa,--listing-lhs-width=2 -Wa,-ag -g
	ia16-elf-objdump --reloc $*.o > $*.rel

allocate.o: srdisk.h
allocate.o: max.h
bitmap.o: bitmap.h
cmdline.o: srdisk.h
cmdline.o: getopt.h
dblspace.o: srdisk.h
director.o: director.h fat.h srdisk.h
director.o: max.h
diskinit.o: srdisk.h
diskio.o: srdisk.h
diskio.o: max.h
env.o: srdisk.h
error.o: srdisk.h
error.o: fat.h
fat.o: srdisk.h
fat.o: fat.h
format.o: srdisk.h
formutil.o: srdisk.h
getopt.o: getopt.h
makenewf.o: srdisk.h
makenewf.o: fat.h
makenewf.o: max.h
packdata.o: director.h fat.h srdisk.h
packdata.o: bitmap.h
realloc.o: srdisk.h
resize.o: fat.h srdisk.h
resize.o: max.h
srdemsf.o: srdisk.h
srdemsf.o: max.h
srdisk.o: srdisk.h
srdutil.o: srdisk.h
srdxmsf.o: srdisk.h
srdxmsf.o: max.h
writenew.o: srdisk.h

srdxms.obj srdxmss.obj: srdxms.mac srdisk.mac define.mac
srdems.obj srdemss.obj: srdems.mac srdisk.mac define.mac
srdems3.obj: srdems3.mac srdisk.mac define.mac
srdummy.obj: define.mac
srdmulti.obj: srdxms.sys srdxmss.sys srdems.sys srdems3.sys srdemss.sys srdummy.sys
asmhelp.o: asmhelp.nas
	nasm -I../lmacros/ asmhelp.nas -l asmhelp.lst -felf

srdiskc.exe: $(OBJS) srdisk.rsp Makefile
	ia16-elf-gcc $(CMODEL) $(CFLAGS) @srdisk.rsp -li86 -o srdiskc.exe -Wl,-Map,srdisk.map
	convlist.pl srdisk.map $(OBJS:.o=.lst) > srdisk.tls

getspace: getspace.c

srdisk.exe: srdiskc.exe combined.nas comstack.nas getspace srdmulti.sys
	./makcomb.sh comball
	./warplink.sh /mx comball.obj + comballs.obj,srdisk.exe,combined.map
	convlist.pl combined.map comball.lst > combined.tls

srdiskx.exe: srdiskc.exe combined.nas comstack.nas getspace srdxms.sys
	./makcomb.sh combxms -D_DEVICEPAYLOAD=srdxms.sys
	./warplink.sh /mx combxms.obj + combxmss.obj,srdiskx.exe,combxms.map
	convlist.pl combxms.map combxms.lst > combxms.tls

srdiske.exe: srdiskc.exe combined.nas comstack.nas getspace srdems.sys
	./makcomb.sh combems -D_DEVICEPAYLOAD=srdems.sys
	./warplink.sh /mx combems.obj + combemss.obj,srdiske.exe,combems.map
	convlist.pl combems.map combems.lst > combems.tls

xmssize.exe: xmssize.obj
	./warplink.sh /mx xmssize.obj,xmssize.exe,xmssize.map
	convlist.pl xmssize.map xmssize.lst > xmssize.tls
