# Standard makefile for telecom spine 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
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)

noarg:
	@echo Make what?

all: delwin.out binkley.out oliver.out
testgw.out: systbl.o incnf.testgw.o inpcnf.o inga.testgw.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)

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
