# Copyright (c) 2001, Adam Dunkels.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#      This product includes software developed by Adam Dunkels.
# 4. The name of the author may not be used to endorse or promote
#    products derived from this software without specific prior
#    written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# This file is part of the uIP TCP/IP stack.
#
# $Id: Makefile,v 1.2 2001/11/24 16:03:59 adam Exp $
#

# Change the target system type here
SYS=z80

CC=sdcc
AS=as-$(SYS)
LN=link-$(SYS)
CFLAGS=-m$(SYS)

UIP.CMD: main.ihx
	sed s/:00000001FF/:00520001AD/ main.ihx | \
	hex2cmd > UIP.CMD

main.ihx: main.o ../uip/uip.o ../apps/httpd/httpd.o ../apps/httpd/fs.o ../apps/httpd/cgi.o uip_arch.o rs232dev.o rs232.o conio.o io.o
	$(LN) -n -c -- -b_CODE=0x5200 -m -j -k/usr/share/sdcc/lib/z80 -lz80.lib -i main.ihx /usr/share/sdcc/lib/z80/crt0.o $^

main.o: main.c
	$(CC) $(CFLAGS) -I ../uip -I ../apps/httpd -c main.c

uip_arch.o: uip_arch.c uip_arch.h
	$(CC) $(CFLAGS) -I ../uip -I ../apps/httpd -c uip_arch.c

rs232dev.o: rs232dev.c rs232dev.h
	$(CC) $(CFLAGS) -I ../uip -I ../apps/httpd -c rs232dev.c

rs232.o: rs232.c rs232.h
	$(CC) $(CFLAGS) -c rs232.c

conio.o: conio.c conio.h
	$(CC) $(CFLAGS) -c conio.c

io.o: io.c io.h
	$(CC) $(CFLAGS) -c io.c

../uip/uip.o: ../uip/uip.c ../uip/uip.h
	cd ../uip; \
	$(CC) $(CFLAGS) -I ../apps/httpd -I ../trs80-3 -c uip.c

../apps/httpd/httpd.o: ../apps/httpd/httpd.c ../apps/httpd/httpd.h
	cd ../apps/httpd; \
	$(CC) $(CFLAGS) -I ../../uip -I ../../trs80-3 -c httpd.c

../apps/httpd/fs.o: ../apps/httpd/fs.c ../apps/httpd/fs.h ../apps/httpd/fsdata.c
	cd ../apps/httpd; \
	$(CC) $(CFLAGS) -I ../../uip -I ../../trs80-3 -c fs.c

../apps/httpd/cgi.o: ../apps/httpd/cgi.c ../apps/httpd/cgi.h
	cd ../apps/httpd; \
	$(CC) $(CFLAGS) -I ../../uip -I ../../trs80-3 -c cgi.c

clean:
	rm -f *.o *.asm *.lst *.sym *.map *.ihx UIP.CMD
	cd ../uip; rm -f *.o *.asm *.lst *.sym
	cd ../apps/httpd; rm -f *.o *.asm *.lst *.sym
