BASEFLAGS= -DMSC -c -f- -O -Z -mt -d -DAJT 
#-Id:/SPR/TC/include
#CDEBUG= -DDEBUG
CFLAGS = $(BASEFLAGS) $(CDEBUG)
AFLAGS = /DTURBOC /DMicrosoft /DAJT
#TCD    = d:/spr/tc
#TLIB   = $(TCD)/LIB
#LIB    = $(TCD)\lib\cs $(TCD)\lib\maths $(TCD)\lib\emu
#LIB    = $(TCD)/lib/cs
CC     = d:/spr/tc/tcc 
ASM    = d:/spr/masm/masm 
LIBP   = d:/spr/mstools/lib 
LNKP   = d:/spr/mstools/link
#LDEBUG = /co
LINK   = /m $(LDEBUG)
MAPS   = nul 
ASMLIST= nul
#DOBIN  = d:/spr/mstools/exe2bin 
DOBIN  = exebin 

BOOTINC = protocol.h bootinc.h utils.h config.h

OBJS = general.obj tftp.obj bootp.obj net.obj ip.obj udp.obj arp.obj \
	romstart.obj asmstuff.obj string.obj layout.obj \
	decoder.obj driver.ok

all:	
	@echo first you must make your driver e.g. make net8003
	@echo then you can make fimage.bin for a boot floppy image
	@echo   or you can make booter.com for a dos program (not recommended)
	@echo   or you can make rom.hex for a prom image

.c.obj: 
	$(CC) $(CFLAGS) $< 
	$(LIBP) booter -+$@ ;

driver.ok :	ok
	@echo  you  must type make net8003
	@echo   or make net3com
	@echo   to make correct interface

#booter.com:	booter.obj $(OBJS)
#	tlink $(LINK) $(TLIB)\c0t.obj booter,booter,booter,booter+$(LIB);
#	exe2bin booter
#	rm -f booter.com
#	ren booter.bin booter.com

#booter.obj : booter.c bootinc.h
#	$(CC) $(CFLAGS) booter.c

decoder.obj : decoder.c bootinc.h

tftp.obj : tftp.c $(BOOTINC)

net.obj : net.c  $(BOOTINC)

udp.obj : udp.c  $(BOOTINC)

ip.obj : ip.c  $(BOOTINC)

bootp.obj : bootp.c  $(BOOTINC)

arp.obj : arp.c  $(BOOTINC)

general.obj : general.c  $(BOOTINC)

romstart.obj : romstart.c  $(BOOTINC)

string.obj : string.c utils.h

asmstuff.obj : asmstuff.asm
	$(ASM) /DTURBOC /DMicrosoft asmstuff.asm ;
	$(LIBP) booter -+$@ ;

layout.obj : layout.asm layout.inc
	$(ASM) layout.asm;
	$(LIBP) booter -+$@ ;

rom.bin : rom.asm $(OBJS)
	$(ASM) /DROM_CODE /DREALLY_ROM rom.asm;
	$(LNKP) $(LINK) rom,rom,rom,booter;
	$(DOBIN) rom

rom.hex : rom.bin dosum.exe
	dosum rom.bin
	rm -f rom.hex
	hexbin rom.bin rom.hex

booter.com:	rom.asm $(OBJS)
	$(ASM) /DUNDER_DOS rom.asm;
	$(LNKP) $(LINK) rom,booter,booter,booter;
	$(DOBIN) booter
	rm -f booter.com
	ren booter.bin booter.com

dosum.exe : dosum.c
	tcc dosum.c

floboot.obj :  floboot.asm
	$(ASM) floboot.asm;

floboot.bin : floboot.obj
	$(LNKP) $(LINK) floboot.obj;
	$(DOBIN) floboot

florom.bin : rom.asm $(OBJS)
	$(ASM) /DROM_CODE rom.asm;
	$(LNKP) $(LINK) rom,florom,florom,booter;
	$(DOBIN) florom

fimage.bin : floboot.bin florom.bin
	copy floboot.bin/B+florom.bin/B fimage.bin/B

dummy1.bin : dummy1.asm
	$(ASM) dummy1.asm;
	$(LNKP) $(LINK) dummy1.obj;
	$(DOBIN) dummy1

dummy2.bin : dummy2.asm
	$(ASM) dummy2.asm;
	$(LNKP) $(LINK) dummy2.obj;
	$(DOBIN) dummy2

dummy.bin : dummy1.bin dummy2.bin
	copy dummy1.bin/B+dummy2.bin/B dummy.bin/B

clean :
	rm -f *.obj
	rm -f *.bin
	rm -f *.hex
	rm -f *.map
	rm -f *.bak
	rm -f *.lib
	rm -f driver.ok
	rm -f net8003.*
	rm -f net3com.*
	rm -f *.~??
	rm -f florom.exe
	rm -f floboot.exe
	rm -f booter.exe
	rm -f rom.exe
	rm -f libtmp*.*

packup :
	zoo a netboot * origdriv\* newdrive\*

net8003.obj : net8003.asm
	$(ASM) /DTURBOC /DMicrosoft net8003.asm ;
	$(LIBP) booter -+$@ ;
	copy ok driver.ok

net8003.asm :
	copy newdrive\net8003.asm
	copy newdrive\net8003.inc

net3com.obj : net3com.asm
	$(ASM) /DTURBOC /DMicrosoft net3com.asm ;
	$(LIBP) booter -+$@ ;
	copy ok driver.ok

net3com.asm :
	copy newdrive\net3com.asm

# drivers

net8003 : net8003.obj

net3com : net3com.obj


