# jon's test gateways ...

# Defs for building from experimental libraries
CFLAGS = -O -I../../sys/include
GWLIB = ../../gw/vax
VAXLIB = ../../lib.vax
SYSLIB = ../../sys/vax/syslib.a

# Defs for building out of installed libraries
#CFLAGS = -O -I../include/sys
#GWLIB = ../lib.vax
#VAXLIB = ../lib.vax/lib
#SYSLIB = ../lib.vax/syslib.a  

CRT = $(VAXLIB)/scb.o $(VAXLIB)/crt.o
CRTDDT = $(VAXLIB)/scb.o $(VAXLIB)/crtddt.o
LIB = $(VAXLIB)/libc.a
DEVLIB = $(GWLIB)/devlib.a
FLIB = $(GWLIB)/flib.a
GATE = $(GWLIB)/glib.a
PLIB = $(GWLIB)/alib.a $(GWLIB)/plib.a
NETLIB = $(GWLIB)/nlib.a
DDT = $(VAXLIB)/libddt.a
DDTST = $(VAXLIB)/isymt.o
FST = $(VAXLIB)/fst.o

PROT = incnf.$*.o inpcnf.o inga.o arpcnf.o
LINK =  ${CRTDDT} systbl.o ${GATE} $(DEVLIB) \
		$(PROT) ${PLIB} netcnf.o ${NETLIB} \
		${FLIB} ${SYSLIB} $(DDT) $(LIB) $(DDTST)
# This one uses a seperate inga.o file so fix routes can be installed.
#PROTS = incnf.$*.o inpcnf.o inga.$*.o arpcnf.o inmux.o fegp.o
PROTS = incnf.$*.o inpcnf.o inga.$*.o arpcnf.o test_cmd.o inmux.o infrg.o egp.o
LINKS =  ${CRTDDT} systbl.o ${GATE} $(DEVLIB) \
		$(PROTS) ${PLIB} netcnf.o ${NETLIB} \
		${FLIB} ${SYSLIB} $(DDT) $(LIB) $(DDTST)
# This one includes ChaosNet support as well
PROTSC = incnf.$*.o inpcnf.o inga.$*.o chcnf.$*.o arpcnf-ch.o
LINKSC = ${CRTDDT} systbl-c.o ${GATE} $(DEVLIB) \
		$(PROTSC) ${PLIB} $*.o ${NETLIB} \
		${FLIB} ${SYSLIB} $(DDT) $(LIB) $(DDTST)

all: testgw.out

testgw.out: systbl.o incnf.testgw.o inpcnf.o inga.testgw.o arpcnf.o netcnf.o testgw.st.o
#	ld -X -y_start -ystart -ymain -y_main -e start -o $@ $(LINKS) st.o
	ld -e start -o $@ $(LINKS) st.o

inmux.o:	inmux.c
	cc -O -I../../gw/in -I../../sys/include -DTESTGW -c inmux.c

infrg.o:	infrg.c
	cc -O -I../../gw/in -I../../sys/include -DTESTGW -c infrg.c

test_cmd.o:	test_cmd.c
	cc -O -I../../gw/in -I../../sys/include -I../../gw/src -DTESTGW -c test_cmd.c

egp.o:	egp.c
	cc -O -I../../gw/in -I../../sys/include -c egp.c

random.out: systbl.o incnf.random.o inpcnf.o inga.random.o arpcnf.o netcnf.o 
	ld -X -e start -o $@ $(LINKS) st.o

binkley.out: systbl.o incnf.binkley.o inpcnf.o inga.binkley.o arpcnf.o netcnf.o
	ld -X -e start -o $@ $(LINKS) st.o

oliver.out: systbl.o incnf.oliver.o inpcnf.o inga.oliver.o arpcnf.o netcnf.o
	ld -X -e start -o $@ $(LINKS) st.o

binkley.st.o: binkley.e
	nm -gn a.out | mksymt > st.s
	cc -c st.s

binkley.e: systbl.o incnf.binkley.o inpcnf.o inga.binkley.o arpcnf.o netcnf.o
	ld -X -e start -o a.out $(LINKS) $(FST)

oliver.st.o: oliver.e
	nm -gn a.out | mksymt > st.s
	cc -c st.s

oliver.e: systbl.o incnf.oliver.o inpcnf.o inga.oliver.o arpcnf.o netcnf.o
	ld -X -e start -o a.out $(LINKS) $(FST)

random.st.o: random.e
	nm -gn a.out | mksymt > st.s
	cc -c st.s

random.e: systbl.o incnf.random.o inpcnf.o inga.random.o arpcnf.o netcnf.o 
	ld -X -e start -o a.out $(LINKS) $(FST)

testgw.st.o: testgw.e
	nm -gn a.out | mksymt > st.s
	cc -c st.s

testgw.e: systbl.o incnf.testgw.o inpcnf.o inga.testgw.o arpcnf.o netcnf.o
	ld -X -e start -o a.out $(LINKS) $(FST)

.o.out:	foo
	ld -X -e start -o $@ $(LINK) st.o

in:
	cd ../../gw/in; make

src:
	cd ../../gw/src; make
