#choose your c compiler
CC = cc

# MACHINE = DJGPP    # dj gcc  compiler for PC
#  MACHINE = SUN      # SUN cc compiler, gcc compiler
# MACHINE = RISC6000 # RISC6000 cc compiler
# MACHINE = XLC      # RISC6000 xlc compiler
# MACHINE = DYNIX    # DYNIX cc compiler, gcc compiler
# MACHINE = DEC5000  # DEC5000 cc compiler, gcc compiler
# MACHINE = HP9000
# MACHINE = NEXT

GJN     = gjn.o 
MCN     = mcn.o
BNET    = bnet.o  index.o  bnetio.o
CFLAGS =  -Ilib -D${MACHINE} -O 
CLIBS = -Llib -lqnet -lm -lc 


all: lib/libqnet.a  gjn  mcn bnet

lib/libqnet.a:
	(cd lib; make)

gjn:  ${GJN} 
	$(CC) $(CFLAGS) -o   gjn ${GJN} $(CLIBS)

mcn:  ${MCN} 
	$(CC) $(CFLAGS) -o   mcn ${MCN} $(CLIBS)

gjn.o: gjn.c
	$(CC) $(CFLAGS) -c gjn.c


bnet: ${BNET}
	$(CC) $(CFLAGS) -o  bnet ${BNET} $(CLIBS)

bnet.o: bnet.c
	$(CC) $(CFLAGS) -c bnet.c

bnetio.o: bnetio.c
	$(CC) $(CFLAGS) -c bnetio.c

index.o: index.c
	$(CC) $(CFLAGS) -c index.c

clean: 
	-rm *.o
	-rm lib/*.o
	
veryclean:
	-rm *.o
	-rm lib/*.o
	-rm lib/libqnet.a
	-rm lib/*~
	-rm *~
	-rm gjn
	-rm mcn
	-rm bnet

tar:
	-rm ../qnet101.tar*
	(cd ..; tar cf qnet101.tar qnet1.1; compress qnet101.tar;\
        uuencode qnet101.tar.Z qnet101.tar.Z > qnet101-src.uudecode)


	
test:
	@echo testing gjn ...
	gjn j3 | bnet
	@echo
	@echo testing mcn ...
	mcn m4 | bnet
	@echo
	@echo testing bnet ...
	bnet b2
	@echo


ship: 
	-rm ../qnet-ship.tar.Z
	(cd ..; tar cf qnet-ship.tar qnet1.1/README qnet1.1/bnet \
          qnet1.1/gjn qnet1.1/mcn qnet1.1/b? qnet1.1/j? qnet1.1/m? \
          qnet1.1/makefile.tst qnet1.1/test.out qnet1.1/doc/*.man; \
           compress qnet-ship.tar; \
         uuencode qnet-ship.tar.Z qnet101.tar.Z >qnet101-ship.uu)

