#
# makefile - for Telnet
#

SDCC=		/home/bill/Memotech/sdcc/sdcc-4.6.0/bin/sdcc
CFLAGS=
#CFLAGS=		-DDEBUG
# sdcc does not support __DATE__
VERSION=	-DVERSION=\"$(shell date +v%y%m%d)\"

.SUFFIXES:	.c .s .rel

.s.rel:
		sdasz80 -o $*.rel $*.s

.c.rel:
		$(SDCC) -c -mz80 $(VERSION) $(CFLAGS) $*.c

#

all:		telnet.com

test:		kbdtest.com ansitest.com dnstest.com cfgtest.com

#

telnet.com:	crt0.rel telnet.rel list.rel fiber.rel cpmio.rel wiz.rel net.rel dns.rel file.rel log.rel ansi.rel kbd.rel exit.rel
		$(SDCC) -mz80 -o telnet.ihx --no-std-crt0 --code-loc 0x100 --data-loc 0x8000 $+
		makebin -p telnet.ihx telnet.bin
		dd if=telnet.bin bs=256 skip=1 of=telnet.com 2> /dev/null

cfgtest.com:	crt0.rel cfgtest.rel list.rel fiber.rel cpmio.rel wiz.rel log.rel file.rel exit.rel
		$(SDCC) -mz80 -o cfgtest.ihx --no-std-crt0 --code-loc 0x100 --data-loc 0x6000 $+
		makebin -p cfgtest.ihx cfgtest.bin
		dd if=cfgtest.bin bs=256 skip=1 of=cfgtest.com 2> /dev/null

cfgtest.rel:	net.c
		$(SDCC) -c -mz80 -o cfgtest.rel -DTEST $(CFLAGS) net.c

dnstest.com:	crt0.rel dnstest.rel list.rel fiber.rel cpmio.rel wiz.rel net.rel file.rel log.rel exit.rel
		$(SDCC) -mz80 -o dnstest.ihx --no-std-crt0 --code-loc 0x100 --data-loc 0x6000 $+
		makebin -p dnstest.ihx dnstest.bin
		dd if=dnstest.bin bs=256 skip=1 of=dnstest.com 2> /dev/null

dnstest.rel:	dns.c
		$(SDCC) -c -mz80 -o dnstest.rel -DTEST $(CFLAGS) dns.c

kbdtest.com:	crt0.rel kbdtest.rel log.rel cpmio.rel list.rel exit.rel
		$(SDCC) -mz80 -o kbdtest.ihx --no-std-crt0 --code-loc 0x100 --data-loc 0x6000 $+
		makebin -p kbdtest.ihx kbdtest.bin
		dd if=kbdtest.bin bs=256 skip=1 of=kbdtest.com 2> /dev/null

kbdtest.rel:	kbd.c
		$(SDCC) -c -mz80 -o kbdtest.rel -DTEST $(CFLAGS) kbd.c

ansitest.com:	crt0.rel ansitest.rel log.rel cpmio.rel list.rel exit.rel
		$(SDCC) -mz80 -o ansitest.ihx --no-std-crt0 --code-loc 0x100 --data-loc 0x6000 $+
		makebin -p ansitest.ihx ansitest.bin
		dd if=ansitest.bin bs=256 skip=1 of=ansitest.com 2> /dev/null

ansitest.rel:	ansi.c
		$(SDCC) -c -mz80 -o ansitest.rel -DTEST $(CFLAGS) ansi.c

#

crt0.rel:	crt0.s

interrupts.rel:	interrupts.c interrupts.h

list.rel:	list.c types.h list.h

fiber.rel:	fiber.c types.h interrupts.h list.h fiber.h

cpmio.rel:	cpmio.c cpmio.h

wizio.rel:	wizio.c

wiz.rel:	wiz.c types.h wiz.h

net.rel:	net.c types.h interrupts.h list.h fiber.h cpmio.h w5100.h wiz.h net.h log.h

file.rel:	file.c file.h types.h cpmio.h

echo.rel:	echo.c types.h fiber.h cpmio.h net.h echo.h log.h

chargen.rel:	chargen.c types.h fiber.h cpmio.h net.h chargen.h log.h

http.rel:	http.c types.h fiber.h cpmio.h net.h http.h log.h

log.rel:	log.c log.h cpmio.h

ansi.rel:	ansi.c ansi.h cpmio.h types.h

exit.rel:	exit.c exit.h list.h fiber.h cpmio.h

telnet.rel:	telnet.c types.h interrupts.h fiber.h cpmio.h net.h log.h wiz.h w5100.h

#

clean:
		rm -f *~ *.ihx *.bin *.noi *.map *.lk *.rel *.lst *.sym *.asm *.bak 2>/dev/null
