#
#LINUX LIBRARIES
libs = -L. -lshape -lutil -L ~/lib -lpgplot -lcfitsio -L/usr/X11R6/lib -lX11 -O

# mm is maximum shapelet order that will be used
# mmpix is maximum size of a fits image that can be analyzed (mmpix x mmpix)
# mmpoly is maximum polynomial order to be used for spatial variation of PSF
#
# Make sure the following derived parameters are consistent with these choices
# msh = (mm+1) * (mm+2) /2 +2
# mmpoly2=(mmpoly+1)*(mmpoly+2)/2
#
flg1 = -Dmm=16 -Dmsh=155 -Dmmpix=9000 -Dmmcat=1000000 -Dmmpoly=6 -Dmmpoly2=28
flg2 = -ffixed-line-length-0 -O -Wall

.F.o: 
	f77 $(flg1) $(flg2) -c  -O $*.F


libshape.a: code.o convolve.o fitshear.o operators.o plotshape.o \
            setpsfmat.o setroundshear.o setroundshearshift.o
	ar crs libshape.a code.o convolve.o fitshear.o operators.o plotshape.o\
            setpsfmat.o setroundshear.o setroundshearshift.o
libutil.a: fits.o mrq.o workhorse.o fitpoly.o readpars.o
	ar crs libutil.a fits.o mrq.o workhorse.o fitpoly.o readpars.o

psfcat2sherr: psfcat2sherr.o  libshape.a libutil.a
	f77 psfcat2sherr.o $(libs) -o psfcat2sherr
fitpsfmap2: fitpsfmap2.o  libshape.a libutil.a
	f77 fitpsfmap2.o $(libs) -o fitpsfmap2
cat2sherr: cat2sherr.o libshape.a libutil.a
	f77 cat2sherr.o $(libs) -o cat2sherr
sortbybeta: sortbybeta.o libutil.a
	f77 sortbybeta.o $(libs) -o sortbybeta
sh2gerrshift012: sh2gerrshift012.o libshape.a libutil.a
	f77 sh2gerrshift012.o $(libs) -o sh2gerrshift012
chpmean: chpmean.o libutil.a
	f77 chpmean.o $(libs) -o chpmean

all: psfcat2sherr fitpsfmap2 cat2sherr sortbybeta sh2gerrshift012 chpmean

clean:
	\rm *.o *.a psfcat2sherr fitpsfmap2 cat2sherr sortbybeta sh2gerrshift012 chpmean


