# KMB 2005 Sep 13

VERSION=1.2
GCC=gcc -O3 -Wall

all: autocorrelation lsqpoly test-covariance makedat covariance ar4

test:
	make all
	@echo testing lsqpoly...
	time ./makedat 100000 | ./lsqpoly 2
	@echo testing covariance...
	time ./test-covariance 100000 | ./covariance
	@echo correct covariance matrix is...
	@echo " 1.0"
	@echo "-0.2   2.0"
	@echo " 0.1   0.5   5.0"
	@echo testing autocorrelation...
	time ./ar4 1000000 | ./autocorrelation 50 | tee > ac-test.out
	@echo "if graph from GNU plotutils is installed, you will now see a plot of the exact autocorrelation (dotted line) and the computed autocorrelation (circles)"
	graph -TX -C -m0 -S 4 ac-test.out -m8 -S 0 ar4-acf.dat

ar4: ar4.c rng-kmb.c
	${GCC} ar4.c -o ar4 -lm

lsqpoly: lsqpoly.o 274.o
	${GCC} lsqpoly.o 274.o -o lsqpoly -lm

lsqpoly.o: lsqpoly.c
	${GCC} -c lsqpoly.c

274.o: 274.c
	${GCC} -c 274.c

test-covariance: test-covariance.c rng-kmb.c
	${GCC} test-covariance.c -o test-covariance -lm

covariance: covariance.c
	${GCC} covariance.c -o covariance -lm

autocorrelation: autocorrelation.c
	${GCC} autocorrelation.c -o autocorrelation -lm

makedat: makedat.c rng-kmb.c
	${GCC} makedat.c -o makedat -lm

install: lsqpoly covariance autocorrelation
	cp lsqpoly covariance autocorrelation /usr/local/bin

tar:
	(cd ..; tar zcvf pipemath-${VERSION}.tgz pipemath-${VERSION}/README pipemath-${VERSION}/Makefile pipemath-${VERSION}/f2cdefs.h pipemath-${VERSION}/*c pipemath-${VERSION}/ar4-acf.dat)

bu:
	make tar
	mcopy -o ../pipemath-${VERSION}.tgz a:

clean:
	rm -f *o lsqpoly covariance autocorrelation test-covariance makedat
