### ====================================================================
### Makefile for double-precision C version of ELEFUNT package.  This
### code can be compiled with either C or C++ compilers.
###
### Makefile for Unix benchmark programs in C, FORTRAN, and Pascal
### Invoke as
###
###	make NAME=-xxx CC=yy [XCFLAGS=...] [XDEFINES=...] [XINCLUDES=...] target
###
### where xxx will be a unique suffix added to the output files to allow
### accumulation of results from multiple runs with different compiler
### options or from different machines.
###
### The defaults for XCFLAGS is an empty string, so as to obtain the
### standard compiler options.
###
### Current target list:
###	all		make talldp output
###	check		make individual test output
###	clean		remove unneeded intermediate files
###	clobber		same as distclean
###	distclean	remove everything that make can rebuild
###	header		internal target
###	install		dummy target
###	lint		run lint on source code
###	maintainer-clean do NOT use this target (for maintainer only)
###	mostlyclean	same as clean
###	summary		summarize all bit loss reports
###	TALLDP		run all double-precision tests
###	TALOG		run alog tests
###	TASIN		run asin tests
###	TATAN		run atan tests
###	TEXP		run exp tests
###	TMACHA		run machar tests
###	TPOWER		run power tests
###	TSIN		run sin tests
###	TSINH		run sinh tests
###	TSQRT		run sqrt tests
###	TTAN		run tan tests
###	TTANH		run tanh tests
###	talldp$(X)	make executable to run all double-precision tests
###	talog$(X)	make executable to test alog
###	tasin$(X)	make executable to test asin
###	tatan$(X)	make executable to test atan
###	texp$(X)	make executable to test exp
###	tmacha$(X)	make executable to test machar
###	tpower$(X)	make executable to test power
###	tsin$(X)	make executable to test sin
###	tsinh$(X)	make executable to test sinh
###	tsqrt$(X)	make executable to test sqrt
###	ttan$(X)	make executable to test tan
###	ttanh$(X)	make executable to test tanh
###	uninstall	dummy target
###
### [27-May-2002] -- Update with GNU standard targets, and delete old
###		     Fortran and Pascal references, since their code
###		     exists in separate directories
### [23-Feb-1988] -- Update with NAME option, prefix identifying text to all
###		   output files, add time prefix to commands.
### [10-Jan-1987] -- Original version.
### ====================================================================

CFLAGS		= $(DEFINES) $(INCLUDES) $(OPT) $(XCFLAGS)

DEFINES		= $(XDEFINES)

### This is how stderr is redirected to stdout in standard sh
ERROUT		= 2>&1

INCLUDES	= $(XINCLUDES)

### Here is how we find the host name.
HOSTNAME	= `hostname`

LDFLAGS		= $(XLDFLAGS)

LIBS		= $(XLIBS) -lm

LINTFLAGS	= -abchnpx $(DEFINES)

### MFLAGS are the combined flags to be passed to inferior makes
MFLAGS		= -i "NAME=$(NAME)" "CC=$(CC)" "CFLAGS=$(CFLAGS)" $(XMFLAGS)

OPT		= -g $(XOPT)

RM		= /bin/rm -f

SHELL		= /bin/sh

### XCFLAGS is for additional options to built-in CFLAGS value
XCFLAGS		=

XDEFINES	=

XINCLUDES	=

XLDFLAGS	=

XLIBS		=

### XMFLAGS are additional options to pass to inferior makes
XMFLAGS		=

XOPT		=

### File extensions:

LST		= lst

### Output file name appendage
NAME		= xxx

O		= o

OUT		= $(LST)-$(NAME)

X		=

### File and test lists:

CFILES          = ipow.c machar.c ran.c randl.c store.c talldp.c talog.c \
		  tasin.c tatan.c texp.c tmacha.c tpower.c tsin.c tsinh.c \
		  tsqrt.c ttan.c ttanh.c

COMMONOBJS	= ../common/initseed.$(O) ../common/maxtest.$(O)

OBJS            = $(COMMONOBJS) ipow.$(O) machar.$(O) ran.$(O) randl.$(O) \
		  store.$(O)

TALLDPOBJS      = talog.$(O) tasin.$(O) tatan.$(O) texp.$(O) tmacha.$(O) \
		  tpower.$(O) tsin.$(O) tsinh.$(O) tsqrt.$(O) ttan.$(O) \
		  ttanh.$(O)

TESTS           = TMACHA TALOG TASIN TATAN TEXP TPOWER TSIN TSINH TSQRT TTAN \
		  TTANH

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

.SUFFIXES:

.SUFFIXES:	.o .i .c

.c.i:
	$(CC) $(CFLAGS) -E $< > $*.i

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

all:	TALLDP

check:
	for f in $(TESTS) ; \
	do \
		$(MAKE) $$f ; \
	done

clean:
	-$(RM) $(COMMONOBJS)
	-$(RM) *.i
	-$(RM) *.nm
	-$(RM) *.$(O)
	-$(RM) a.out core ./*~ ./#*
	-$(RM) lint.lst
	-$(RM) talldp$(X)
	-$(RM) talog$(X)
	-$(RM) tasin$(X)
	-$(RM) tatan$(X)
	-$(RM) texp$(X)
	-$(RM) tmacha$(X)
	-$(RM) tpower$(X)
	-$(RM) tsin$(X)
	-$(RM) tsinh$(X)
	-$(RM) tsqrt$(X)
	-$(RM) ttan$(X)
	-$(RM) ttanh$(X)

clobber:	distclean

distclean:	mostlyclean
	-$(RM) t*.$(LST) t*.$(LST)-xxx t*.$(OUT)

install:
	@echo There is nothing to install for this package.

lint:	$(CFILES)
	lint $(LINTFLAGS) $(CFILES) >>lint.lst $(ERROUT)

maintainer-clean:	distclean
	@echo "This command is intended for maintainers to use;"
	@echo "it deletes files that may require special tools to rebuild."

mostlyclean:	clean
	-$(RM) *.s

TALLDP:	talldp$(X)
	$(MAKE) $(MFLAGS) TITLE="./talldp$(X) >>talldp.$(OUT) $(ERROUT)"\
		OUTFILE=talldp.$(OUT) header
	./talldp$(X) >>talldp.$(OUT) $(ERROUT)

TALOG:	talog$(X)
	$(MAKE) $(MFLAGS) TITLE="./talog$(X) >>talog.$(OUT) $(ERROUT)"\
		OUTFILE=talog.$(OUT) header
	./talog$(X) >>talog.$(OUT) $(ERROUT)

TASIN:	tasin$(X)
	$(MAKE) $(MFLAGS) TITLE="./tasin$(X) >>tasin.$(OUT) $(ERROUT)"\
		OUTFILE=tasin.$(OUT) header
	./tasin$(X) >>tasin.$(OUT) $(ERROUT)

TATAN:	tatan$(X)
	$(MAKE) $(MFLAGS) TITLE="./tatan$(X) >>tatan.$(OUT) $(ERROUT)"\
		OUTFILE=tatan.$(OUT) header
	./tatan$(X) >>tatan.$(OUT) $(ERROUT)

TEXP:	texp$(X)
	$(MAKE) $(MFLAGS) TITLE="./texp$(X) >>texp.$(OUT) $(ERROUT)"\
		OUTFILE=texp.$(OUT) header
	./texp$(X) >>texp.$(OUT) $(ERROUT)

TMACHA:	tmacha$(X)
	$(MAKE) $(MFLAGS) TITLE="./tmacha$(X) >>tmacha.$(OUT) $(ERROUT)"\
		OUTFILE=tmacha.$(OUT) header
	./tmacha$(X) >>tmacha.$(OUT) $(ERROUT)

TPOWER:	tpower$(X)
	$(MAKE) $(MFLAGS) TITLE="./tpower$(X) >>tpower.$(OUT) $(ERROUT)"\
		OUTFILE=tpower.$(OUT) header
	./tpower$(X) >>tpower.$(OUT) $(ERROUT)

TSIN:	tsin$(X)
	$(MAKE) $(MFLAGS) TITLE="./tsin$(X) >>tsin.$(OUT) $(ERROUT)"\
		OUTFILE=tsin.$(OUT) header
	./tsin$(X) >>tsin.$(OUT) $(ERROUT)

TSINH:	tsinh$(X)
	$(MAKE) $(MFLAGS) TITLE="./tsinh$(X) >>tsinh.$(OUT) $(ERROUT)"\
		OUTFILE=tsinh.$(OUT) header
	./tsinh$(X) >>tsinh.$(OUT) $(ERROUT)

TSQRT:	tsqrt$(X)
	$(MAKE) $(MFLAGS) TITLE="./tsqrt$(X) >>tsqrt.$(OUT) $(ERROUT)"\
		OUTFILE=tsqrt.$(OUT) header
	./tsqrt$(X) >>tsqrt.$(OUT) $(ERROUT)

TTAN:	ttan$(X)
	$(MAKE) $(MFLAGS) TITLE="./ttan$(X) >>ttan.$(OUT) $(ERROUT)"\
		OUTFILE=ttan.$(OUT) header
	./ttan$(X) >>ttan.$(OUT) $(ERROUT)

TTANH:	ttanh$(X)
	$(MAKE) $(MFLAGS) TITLE="./ttanh$(X) >>ttanh.$(OUT) $(ERROUT)"\
		OUTFILE=ttanh.$(OUT) header
	./ttanh$(X) >>ttanh.$(OUT) $(ERROUT)

tmacha$(X):	../common/mmacha.$(O) tmacha.$(O) $(OBJS)
	$(CC) $(CFLAGS) -o $@ ../common/mmacha.$(O) tmacha.$(O) $(OBJS) $(LDFLAGS) $(LIBS)

talldp$(X):	talldp.$(O) $(TALLDPOBJS) $(OBJS)
	$(CC) $(CFLAGS) -o $@ talldp.$(O) $(TALLDPOBJS) $(OBJS) $(LDFLAGS) $(LIBS)

talog$(X):	../common/malog.$(O) talog.$(O) $(OBJS)
	$(CC) $(CFLAGS) -o $@ ../common/malog.$(O) talog.$(O) $(OBJS) $(LDFLAGS) $(LIBS)

tasin$(X):	../common/masin.$(O) tasin.$(O) $(OBJS)
	$(CC) $(CFLAGS) -o $@ ../common/masin.$(O) tasin.$(O) $(OBJS) $(LDFLAGS) $(LIBS)

tatan$(X):	../common/matan.$(O) tatan.$(O) $(OBJS)
	$(CC) $(CFLAGS) -o $@ ../common/matan.$(O) tatan.$(O) $(OBJS) $(LDFLAGS) $(LIBS)

texp$(X):	../common/mexp.$(O) texp.$(O) $(OBJS)
	$(CC) $(CFLAGS) -o $@ ../common/mexp.$(O) texp.$(O) $(OBJS) $(LDFLAGS) $(LIBS)

tpower$(X):	../common/mpower.$(O) tpower.$(O) $(OBJS)
	$(CC) $(CFLAGS) -o $@ ../common/mpower.$(O) tpower.$(O) $(OBJS) $(LDFLAGS) $(LIBS)

tsin$(X):	../common/msin.$(O) tsin.$(O) $(OBJS)
	$(CC) $(CFLAGS) -o $@ ../common/msin.$(O) tsin.$(O) $(OBJS) $(LDFLAGS) $(LIBS)

tsinh$(X):	../common/msinh.$(O) tsinh.$(O) $(OBJS)
	$(CC) $(CFLAGS) -o $@ ../common/msinh.$(O) tsinh.$(O) $(OBJS) $(LDFLAGS) $(LIBS)

tsqrt$(X):	../common/msqrt.$(O) tsqrt.$(O) $(OBJS)
	$(CC) $(CFLAGS) -o $@ ../common/msqrt.$(O) tsqrt.$(O) $(OBJS) $(LDFLAGS) $(LIBS)

ttan$(X):	../common/mtan.$(O) ttan.$(O) $(OBJS)
	$(CC) $(CFLAGS) -o $@ ../common/mtan.$(O) ttan.$(O) $(OBJS) $(LDFLAGS) $(LIBS)

ttanh$(X):	../common/mtanh.$(O) ttanh.$(O) $(OBJS)
	$(CC) $(CFLAGS) -o $@ ../common/mtanh.$(O) ttanh.$(O) $(OBJS) $(LDFLAGS) $(LIBS)

### Internal make target for constructing uniform output file headers
header:
	(	echo "Host        = $(HOSTNAME)" ; \
		echo "Command     = $(TITLE)" ; \
		echo "uname -a    = `uname -a`" ; \
		echo "Make flags  = $(MFLAGS)" ; \
		echo "Date        = `date`" ; \
		echo "----------------------------------------" ; \
		echo " ") >$(OUTFILE)

### This target just shows a quick summary of the tests with their
### name and accuracy loss.  Detailed examination of the output is
### required for a proper evaluation of the results.
summary:
	egrep "^1|ESTIMATED LOSS" *.$(OUT)

uninstall:

### Object file dependencies:
ELEFUNT_H	= elefunt.h ../common/elefunt.h
ipow.o:		ipow.c $(ELEFUNT_H)
machar.o:	machar.c $(ELEFUNT_H)
ran.o:		ran.c $(ELEFUNT_H)
randl.o:	randl.c $(ELEFUNT_H)
store.o:	store.c $(ELEFUNT_H)
talldp.o:	talldp.c $(ELEFUNT_H)
talog.o:	talog.c $(ELEFUNT_H)
tasin.o:	tasin.c $(ELEFUNT_H)
tatan.o:	tatan.c $(ELEFUNT_H)
texp.o:		texp.c $(ELEFUNT_H)
tmacha.o:	tmacha.c $(ELEFUNT_H)
tpower.o:	tpower.c $(ELEFUNT_H)
tsin.o:		tsin.c $(ELEFUNT_H)
tsinh.o:	tsinh.c $(ELEFUNT_H)
tsqrt.o:	tsqrt.c $(ELEFUNT_H)
ttan.o:		ttan.c $(ELEFUNT_H)
ttanh.o:	ttanh.c $(ELEFUNT_H)
