# Usermake - a Makefile template for compiling a new version of GENESIS
#
# GENESIS/XODUS : network simulator - top level user makefile
# this makefile compiles a version of the simulator containing
# additional user-defined libraries. See the document makelib.doc
# in the genesis Doc directory (usually /usr/genesis/Doc) for details
# on adding a new library.
#
#
# NOTE: This file should be copied into the directory from which you are
# compiling the new version of GENESIS and given the name 'Makefile'.
# Before doing a "make", you must edit the file as defined below:
#
#
#
# 1) set MACHINE= one of {sun3, sun4, i386, mips, irix, hpux}
# 2) set XVERSION= one of {X11R3,X11R4,X11R5}
# 3) for mips or irix machines add '-G 6' (excluding quotes) to the TOPFLAGS 
# 4) for 'X11R3' installs, remove the XLIBS line:
#		$(XLIB)/libXext.a 
#
# 5) type 'make'
#

#
# 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
#	hpux			- for Hewlett Packard HPUX's
#	irix			- for Silicon Graphics IRIX's
#
# If you are compiling using X11R3
# remove  "libXext.a" from the library inclusion list 
# a few lines below...
#
#
MACHINE = 	sun4
XVERSION=	X11R4

# If you want to use the debug option (which will cost you in both
# speed and memory), use the alternate CFLAGS = -g.
# Otherwise use "-O" to optimize.
CFLAGS	=	-O
#TOPFLAGS =	"-G 6"
XLIB 	= 	/usr/lib
SIMLIB 	= 	/usr/genesis/lib
SIMSRC 	= 	/usr/genesis/src
SIMNAME =	genesis

#
# the user should place the directories of any user library
# modules in the USERDIR variable
# e.g. USERDIR = newlib1 newlib2
#
USERDIR	=

#
# The user should place the pathnames of any library object modules other
# than the basic system libraries in the USERLIB variable.  These should be
# the same as those used for the TARGET_OBJ variable in the 'Libmake' file.
# e.g. USERLIB = newlib1/newlib1.o newlib2/newlib2.o
#
USERLIB	=

#
# The user should place any additional system dependent libraries in the
# SYSLIBS variable.  Known system dependent libraries include:
#
# irix
#	SYSLIBS = -lmalloc
#
SYSLIBS =

###################################################################
# nothing beyond this point should have to be modified by the user
# with the possible exception of "libXext.a" being added if you
# are running X11R4
###################################################################

XLIBS	=	$(XLIB)/libXaw.a \
		$(XLIB)/libXt.a \
		$(XLIB)/libXmu.a \
		$(XLIB)/libXext.a \
		$(XLIB)/libX11.a 


GENESIS = 	$(SIMLIB)/simlib.o \
		$(SIMLIB)/ss.o \
		$(SIMLIB)/shelllib.o \
		$(SIMLIB)/utillib.o \
		$(SIMLIB)/buflib.o \
		$(SIMLIB)/seglib.o \
		$(SIMLIB)/synlib.o \
		$(SIMLIB)/axonlib.o \
		$(SIMLIB)/hhlib.o \
		$(SIMLIB)/devlib.o \
		$(SIMLIB)/perlib.o \
		$(SIMLIB)/outlib.o \
		$(SIMLIB)/olflib.o \
		$(SIMLIB)/toollib.o \
		$(SIMLIB)/conclib.o \
		$(SIMLIB)/userlib.o \
                $(SIMLIB)/hineslib.o \
                $(SIMLIB)/porelib.o \
		loadlib.o


XODUS 	=	$(SIMLIB)/comlib.o \
		$(SIMLIB)/drawlib.o \
		$(SIMLIB)/genlib.o \
		$(SIMLIB)/widglib.o \
		$(SIMLIB)/xolib.o
LIBS 	= 	$(XLIBS) -ll -lm $(SYSLIBS)

default: userlibs $(SIMNAME)

userlibs:
	@(for i in $(USERDIR); do echo cd $$i; cd $$i; make MACHINE=$(MACHINE) TOPFLAGS=$(TOPFLAGS); cd ..;done)

loadlib.c: liblist
	$(SIMSRC)/libsh < liblist > loadlib.c

clean:
	@(for i in $(USERDIR); do echo cd $$i; cd $$i; make clean; cd ..;done)

$(SIMNAME): $(GENESIS) $(XODUS) $(USERLIB)
	$(CC) $(CFLAGS) $(GENESIS) $(XODUS) $(USERLIB) $(LIBS) -o $(SIMNAME)
