#
# GENESIS/XODUS : network simulator
#
# YOU MUST EDIT THIS FILE BEFORE DOING A "make" AS DEFINED BELOW:
#
#
#
# 1) set MACHINE= one of {sun3, sun4, i386, mips}
# 2) set XVERSION= one of {X11R3,X11R4}
# 3) for 'mips' machines comment in the lines
#		DEC_HACK= 	"-G 6"
#		LOCAL_DEC_HACK= -G 6
# 4) for 'X11R3' installs, comment OUT the LIBS line:
#		$(XLIB)/libXext.a 
#
# 5) execute a 'make'
# 6) execute a 'make install'
#

#
# Define "MACHINE" to be one of:
#
#	sun3			- for Sun 3's
#	sun4			- for Sun 4's and Sparcstations
#	i386			- for Sun 386i's
#	MASSCOMP		- for Masscomp's
#	mips			- for decstation 3100's
#
# If you are compiling using X11R4 comment out the XVERSION flag
# here and put "libXext.a" into the library inclusion list 
# a few lines below...
#
#
MACHINE = 	sun4
XVERSION=	X11R3

# The following should be defined if you are compiling on a DECstation 3100
# or a DECstation 5000 using Ultrix version 3.1 or below.  It makes the 
# compiler happy.
#DEC_HACK= 	"-G 6"
#LOCAL_DEC_HACK= -G 6

#
# That's all folks!  Write the file and type 'make' to build genesis.  Type
# "make install" to install it.
#
CFLAGS	=	-g
XLIB 	= 	/usr/lib
INSTALL = 	/usr/genesis
SIMLIB 	= 	../lib
XODUSLIB = 	xodus
USERLIB=	user
INTERP	=	ss/ss.o shell/shelllib.o

LIBS 	= 	-ll -lm 

#
# ADD THIS LINE IF YOU'RE USING R4
#
#
XLIBS	=	$(XLIB)/libXaw.a \
		$(XLIB)/libXt.a \
		$(XLIB)/libXmu.a \
		$(XLIB)/libXext.a \
		$(XLIB)/libX11.a 


GENESIS = 	sim/simlib.o \
		$(INTERP) \
		sys/utillib.o \
		buffer/buflib.o \
		segment/seglib.o \
		synapse/synlib.o \
		axon/axonlib.o \
		hh/hhlib.o \
		device/devlib.o \
		personal/perlib.o \
		out/outlib.o \
		olf/olflib.o \
		tools/toollib.o \
		loadlib.o

#		bogus.o

XODUS 	=	$(XODUSLIB)/comlib/comlib.o \
		$(XODUSLIB)/drawlib/drawlib.o \
		$(XODUSLIB)/genlib/genlib.o \
		$(XODUSLIB)/widglib/widglib.o \
		$(XODUSLIB)/xolib/xolib.o \
		$(USERLIB)/userlib.o  

SUBDIR =	sim shell buffer segment out \
		synapse axon sys hh device personal user ss olf tools xodus

FULLDIR = 	$(SUBDIR) startup


# =========================================================================

default: libs genesis

nxdefault: libs nxgenesis

genesis: $(GENESIS) $(XODUS)
	$(CC)  $(CFLAGS) $(LOCAL_DEC_HACK) $(GENESIS) $(XODUS) $(XLIBS) $(LIBS) -o genesis
	-(echo "GENESIS Compiled -- All Done")

nxgenesis: $(GENESIS)
	$(CC) $(DEC_HACK) $(CFLAGS) $(GENESIS) bogus.o $(LIBS) -o nxgenesis


libs:
	@(for i in $(SUBDIR); do echo cd $$i; cd $$i; make MACHINE=$(MACHINE) XVERSION=$(XVERSION) INSTALL=$(INSTALL) DEC_HACK=$(DEC_HACK); cd ..;done)
	-(echo "Libs Compiled")

loadlib.c: liblist
	libsh < liblist > loadlib.c

cleandist: clean
	-(rm -rf $(INSTALL)/startup/*)
	-(rm -rf $(INSTALL)/lib/*)
	-(rm -rf $(INSTALL)/include/*)
	-(rm -rf $(INSTALL)/loadlib.o $(INSTALL)/loadlib)
	-(rm -rf $(INSTALL)/genesis)
	echo "Done will full clean"
	
clean:
	@(for i in $(SUBDIR); do echo cd $$i; cd $$i; make clean; cd ..;done)
	-(rm -rf genesis loadlib.o)
	-(echo "Done with Cleaning")

install:
	@(for i in $(FULLDIR); do echo cd $$i; cd $$i; make MACHINE=$(MACHINE) XVERSION=$(XVERSION) INSTALL=$(INSTALL) DEC_HACK=$(DEC_HACK) install; cd ..;done)
	- (cp genesis $(INSTALL))
	-(echo "Done with full install")

