# Unix make file for long double precision function library
# Be sure to check the size of a pointer, LARGEMEM, in lcalc.h;
# the size of long double, XPD, in mconf.h; and the type of
# computer and endianness of the numbers in mconf.h.
#CC= gcc
#CC = /a/gnu/linux/xgcc -B/a/gnu/linux/ -I/a/gnu/linux/include
#CFLAGS= -O0 -fno-builtin
CFLAGS= -O2 -Wall -Wuninitialized
LIBS= 
OBJS= acoshl.o asinhl.o asinl.o atanhl.o atanl.o bdtrl.o btdtrl.o cbrtl.o \
chdtrl.o coshl.o ellpel.o ellpkl.o elliel.o ellikl.o ellpjl.o \
exp10l.o exp2l.o expl.o fdtrl.o gammal.o gdtrl.o igamil.o igaml.o \
incbetl.o incbil.o isnanl.o j0l.o j1l.o jnl.o ldrand.o log10l.o log2l.o \
logl.o nbdtrl.o ndtril.o ndtrl.o pdtrl.o powl.o powil.o sinhl.o sinl.o \
sqrtl.o stdtrl.o tanhl.o tanl.o unityl.o ynl.o \
floorl.o polevll.o unityl.o mtherr.o
# cmplxl.o clogl.o

all: mtstl lparanoi lcalc fltestl nantst testvect libml.a

mtstl: libml.a mtstl.o $(OBJS)
	$(CC) $(CFLAGS) -o mtstl mtstl.o libml.a $(LIBS)
#	aout2exe mtstl

lparanoi: libml.a lparanoi.o setprec.o ieee.o econst.o $(OBJS)
	$(CC) $(CFLAGS) -o lparanoi lparanoi.o setprec.o ieee.o econst.o libml.a $(LIBS)
#	aout2exe lparanoi

lcalc: libml.a lcalc.o ieee.o econst.o $(OBJS)
	$(CC) $(CFLAGS) -o lcalc lcalc.o ieee.o econst.o libml.a $(LIBS)

lcalc.o: lcalc.c lcalc.h ehead.h

ieee.o: ieee.c ehead.h

# Use $(OBJS) in ar command for libml.a if possible; else *.o
libml.a: $(OBJS) mconf.h
	ar -rv libml.a *.o
	ranlib libml.a

# Use assembly language sqrt and floor if available.
# sqrtl.c does not give strictly rounded results.
# The floor.c routines are slow.
#floorl.o: floorl.387
#	as -o floorl.o floorl.387
#sqrtl.o: sqrtl.387
#	as -o sqrtl.o sqrtl.387
#setprec.o: setprec.387
#	as -o setprec.o setprec.387

# ELF versions for linux
#floorl.o: floorlelf.387
#	as -o floorl.o floorlelf.387
sqrtl.o: sqrtlelf.387
	as -o sqrtl.o sqrtlelf.387
setprec.o: setprelf.387
	as -o setprec.o setprelf.387

# 68K routines
# For Sun 3
#floorl.o: floorl.sun
#	as -o floorl.o floorl.sun
#setprec.o: setprec.688
#	as -o setprec.o setprec.688
#sqrtl.o: sqrtl.sun
#	as -o sqrtl.o sqrtl.sun

# For Motorola 68k sysv
# Thanks to Philippe De Muyter <phdm@info.ucl.ac.be>
#floorl.o: floorl.mot
#	as -o floorl.o floorl.mot
#setprec.o: setprec.mot
#	as -o setprec.o setprec.mot
#sqrtl.o: sqrtl.mot
#	as -o sqrtl.o sqrtl.mot

fltestl: fltestl.c libml.a
	$(CC) $(CFLAGS) -o fltestl fltestl.c libml.a

flrtstl: flrtstl.c libml.a
	$(CC) $(CFLAGS) -o flrtstl flrtstl.c libml.a

nantst: nantst.c libml.a
	$(CC) $(CFLAGS) -o nantst nantst.c libml.a

testvect: testvect.o libml.a
	$(CC) $(CFLAGS) -o testvect testvect.o libml.a

testvect.o: testvect.c
	$(CC) -g -c -o testvect.o testvect.c

clean:
	rm -f *.o
	rm -f mtstl
	rm -f lcalc
	rm -f fltestl
	rm -f flrtstl
	rm -f nanst
	rm -f lparanoi
	rm -f testvect
	rm -f libml.a

# Run test programs
check: mtstl fltestl testvect libml.a
	-mtstl
	-fltestl
	-testvect
