# makefile 1.4 8/25/92

# HOST should be the name of your machine
HOST = Sun-SS1

# CC should be the name of your favorite C compiler
CC = cc

# set your compiler flag(s) here
CFLAG1 = -O4
CFLAG2 = -Bstatic
CFLAG3 =
CFLAG4 =

# where to install?
LIBDIR = ./local/lib
INCDIR = ./local/include
BINDIR = ./local/bin
MAN1DIR = ./man/local/man1
MAN3DIR = ./man/local/man3

# you shouldn't have to change anything below this line
CFLAGS = ${CFLAG1} ${CFLAG2} ${CFLAG3} ${CFLAG4}

# where the results of the test script will be written
RESULTFILE = results.${HOST}.${CC}${CFLAG1}${CFLAG2}${CFLAG3}${CFLAG4}

# a standard resultfile
RESULTSTD = results.Sun-SS1.cc-O4-Bstatic.orig

INCS =  mrandom.h bentley.h pcrand.h xsq.h

SRCS = mrtest.c mrandom.c bentley.c pcrand.c xsq.c

OBJS = mrandom.o bentley.o pcrand.o xsq.o

all	:
	make test
	make install

install	: mrtest mrtestv mrandom.a
	install -c mrandom.a ${LIBDIR}
	install -c ${INCS} ${INCDIR}
	install -c mrtest mrtestv ${BINDIR}
	install -c mrandom.3 ${MAN3DIR}
	install -c mrtest.1 ${MAN1DIR}

mrandom.a: ${OBJS}
	ar r mrandom.a ${OBJS}
	ranlib mrandom.a
	chmod a+rwx mrandom.a

mrtestv	: mrandom.a mrtest.c
	${CC} ${CFLAGS} -DVECTOR mrtest.c -o mrtestv mrandom.a -lm

mrtestv.s: ${OBJS} mrtest.c
	${CC} ${CFLAGS} -S -DVECTOR mrtest.c \
	  -o mrtestv.s mrandom.o bentley.o pcrand.o xsq.o -lm

mrtestg	: ${OBJS} mrtest.c
	${CC} ${CFLAGS} -g mrtest.c \
	  -o mrtestg mrandom.o bentley.o pcrand.o xsq.o -lm

mrtest	: ${OBJS} mrtest.c
	${CC} ${CFLAGS} mrtest.c \
	  -o mrtest mrandom.o bentley.o pcrand.o xsq.o -lm

test:
	# force recompilation, just in case CFLAGS or CC have changed.
	/bin/rm -f ${OBJS} mrandom.a
	# The following command should take a few minutes...
	csh < script > ${RESULTFILE}
	#
	# Since mrtest's output should be machine- and compiler independent,
	# the following diff should show only differences in timing and
	# in compiler invocation lines.  If you see anything else, please
	# contact the author, cthombor@mars.d.umn.edu.
	# 
	-diff ${RESULTFILE} ${RESULTSTD}
	#
	# End of test.

clean	:
	rm -f *.o *.s
	rm -f mrtest mrtestv mrtestg mrtestv.s mrandom.a
	rm -f Soda/*.dvi Soda/article.{ps,log}
	rm -f ${RESULTFILE} RNGstatefile
