#
# GENESIS/XODUS : network simulator
#
#	Make tree altered June 1991
#	Altered Wed Oct  2 18:16:15 PDT 1991
#	by David Bilitch
#	Last altered 18th October 1991
#	by Michael D. Speight
#
# YOU MUST EDIT THIS FILE BEFORE DOING A "make" AS DEFINED BELOW:
#
#
#
# 1) set MACHINE= one of {sun3, sun4, i386, mips, gamma, other}
# 2) set OS = one of {BSD, SYSV} (only really important for MACHINE=other)
# 3) set XVERSION= one of {X11R3,X11R4,X11R5,NO-X}
# 4) for 'X11R3' installs, comment OUT the LIBS line:
#		$(XLIB)/libXext.a 
# 5) if your X11 Libraries are not in '/usr/lib' then edit the 'XLIB' line
# 5a) if your X11 Includes are not in '/usr/include/X11' add -I<dir> to the
#	CFLAGS line.  Note that <dir> must have a directory X11 under it
#	which contains the include files.
# 6) execute a 'make'		( or 'make nxdefault' or 'make mindefault' )
# 7) execute a 'make install'	( or 'make nxinstall' or 'make mininstall' )
# 8) execute a 'make clean' to remove temporary files
#

#
# Define "MACHINE" to be one of:
#
#	sun3			- for Sun 3's
#	sun4			- for Sun 4's and SPARCstations
#	i386			- for Sun 386i's
#	mips			- for DECstation 3100's and 5000's
#	irix			- for Silicon Graphics IRIX
#	hpux			- for Hewlett Packard HPUX
#	gamma			- for Intel i860 based Hypercube
#	other			- for some other untested Unix machine
#
# For HP machines use MACHINE=other and OS=SYSV and see other changes
# further down in the Makefile.
#
# Define "XVERSION" to be one of:
#
#	X11R3			- Remove the XLIBS line containing libXext.a
#	X11R4			- Make sure libXext.a is in XLIBS
#	X11R5			- Make sure libXext.a is in XLIBS
#	NO-X			- For running GENESIS without X
#
#
XVERSION =	X11R4
MACHINE	=	sun4
OS =		BSD

#
# For HP machines use XLIB=/usr/lib/800X11/lib.s800 and you will need to
# obtain copies of these X libraries.  They can be ftped from
# hpcvaaz.cv.hp.com.  Get the file /readonly/MitX11R4/libs.s800.Z in binary
# transfer mode.  These libraries must be unpacked in the directory named
# in the XLIB macro.
#

XLIB	=	/usr/lib

# If you don't have the lex libraries use this
# and define a function 'yyless' in 'ss/lex.yy.c'
# as has been done for the i860, and a function
# 'yywrap' that always returns '1'. Nothing else
# is used from the lex libraries.
#LIBS 	= 	-lm
LIBS 	= 	-ll -lm

# these are the final link flags
MACH_DEP_FLAGS =

# 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.

CC =		cc
# To compile for debugging
#CFLAGS	=	-g
# To compile for profiling
#CFLAGS	=	-p
# To compile for optimisation
CFLAGS	=	-O1
#CFLAGS	=	-O2
#CFLAGS	=	-O3
#CFLAGS	=	-O4
# To compile for no optimisation
#CFLAGS	=
# By default let the compiler decide the level of optimisation to use
# If your /tmp is too small to handle the compilation, change temp to
# some other directory which has more room.
#CFLAGS	=	-g -temp=/tmp
#CFLAGS	=	-O -temp=/tmp
#CFLAGS	=	-O -p -temp=/tmp
CFLAGS	=	-O

LD =		ld

#
# ADD THIS LINE after $(XLIB)/libXmu.a IF YOU'RE USING R4 or R5
#		$(XLIB)/libXext.a \
#
# DELETE the line containing $(XLIB)/libXext.a IF YOU'RE USING R3.
# NOTE: you CANNOT just comment out the line!
#
XLIBS	=	$(XLIB)/libXaw.a \
		$(XLIB)/libXt.a \
		$(XLIB)/libXmu.a \
		$(XLIB)/libXext.a \
		$(XLIB)/libX11.a 

#
# That's all folks!  Write the file and type 'make' to build genesis.  Type
# "make install" to install it.
#

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

INSTALL	=	`pwd`/..

RCSRELEASE=GENESIS1-4-1
MF = Makefile.$(MACHINE)
SHELL = /bin/sh

SIMLIB		=	../lib
XODUSLIB	= 	xodus
INTERP		=	ss/ss.o shell/shelllib.o
BASECODE	=	sim/simlib.o sys/utillib.o $(INTERP)
OBJLIBS		=	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 \
			concen/conclib.o \
			hines/hineslib.o \
			user/userlib.o \
			pore/porelib.o


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

SUBDIR =        sys ss sim shell \
		axon buffer concen device hh hines olf out personal segment \
                synapse tools user pore \
                xodus
NXSUBDIR =	sys ss shell sim \
		axon buffer concen device hh hines olf out personal segment \
                synapse tools user pore
MINSUBDIR =	sys ss shell sim

default:
	@make -f $(MF) CC_IN="$(CC)" LD_IN="$(LD)" OS_IN="$(OS)" MACHINE_IN="$(MACHINE)" INSTALL="$(INSTALL)" XVERSION="$(XVERSION)" COPT="$(CFLAGS)" XLIBS="$(XLIBS)" LIBS="$(LIBS)" MF="$(MF)" MACH_DEP_FLAGS_IN="$(MACH_DEP_FLAGS)" SUBDIR="$(SUBDIR)" BASECODE="$(BASECODE)" OBJLIBS="$(OBJLIBS)" XODUS="$(XODUS)" RCSRELEASE="$(RCSRELEASE)" libs genesis

nxdefault:
	@make -f $(MF) CC_IN="$(CC)" LD_IN="$(LD)" OS_IN="$(OS)" MACHINE_IN="$(MACHINE)" INSTALL="$(INSTALL)" XVERSION="$(XVERSION)" COPT="$(CFLAGS)" LIBS="$(LIBS)" MF="$(MF)" MACH_DEP_FLAGS_IN="$(MACH_DEP_FLAGS)" SUBDIR="$(SUBDIR)" NXSUBDIR="$(NXSUBDIR)" MINSUBDIR="$(MINSUBDIR)" BASECODE="$(BASECODE)" OBJLIBS="$(OBJLIBS)"  nxlibs nxgenesis

mindefault:
	@make -f $(MF) CC_IN="$(CC)" LD_IN="$(LD)" OS_IN="$(OS)" MACHINE_IN="$(MACHINE)" INSTALL="$(INSTALL)" XVERSION="$(XVERSION)" COPT="$(CFLAGS)" LIBS="$(LIBS)" MF="$(MF)" MACH_DEP_FLAGS_IN="$(MACH_DEP_FLAGS)"  SUBDIR="$(SUBDIR)" NXSUBDIR="$(NXSUBDIR)" MINSUBDIR="$(MINSUBDIR)" BASECODE="$(BASECODE)" OBJLIBS="$(OBJLIBS)"  minlibs mingenesis

cleandist: clean
	-(rm -rf $(INSTALL)/startup/*)
	-(rm -rf $(INSTALL)/startup/.*simrc)
	-(rm -rf $(INSTALL)/lib/*)
	-(rm -rf $(INSTALL)/include/*)
	-(rm -rf $(INSTALL)/genesis)
	-(rm -rf $(INSTALL)/nxgenesis)
	-(rm -rf $(INSTALL)/mingenesis)
	-(rm -rf $(INSTALL)/.*simrc)
	echo "Done with full clean"
	
clean:
	@make -f $(MF) MF="$(MF)" SUBDIR="$(SUBDIR)" RCSRELEASE="$(RCSRELEASE)" clean

rcsclean:
	@make -f $(MF) MF="$(MF)" SUBDIR="$(SUBDIR)" RCSRELEASE="$(RCSRELEASE)" rcsclean

install:
	@make -f $(MF) MF="$(MF)" INSTALL="$(INSTALL)" SUBDIR="$(SUBDIR)" install

nxinstall:
	@make -f $(MF) MF="$(MF)" INSTALL="$(INSTALL)" NXSUBDIR="$(NXSUBDIR)" nxinstall

mininstall:
	@make -f $(MF) MF="$(MF)" INSTALL="$(INSTALL)" MINSUBDIR="$(MINSUBDIR)" mininstall
