CC = gcc
//CFLAGS = -Wall
CFLAGS = -O2
//VERBOSE = 
VERBOSE = -DVERBOSE
//PGDIR = /usr/local/pgplot/
PGDIR =
CPGLIBS = ${PGDIR} -lcpgplot -lpgplot -L/usr/X11R6/lib -lX11 
//CPGLIBS = ${PGDIR} -lcpgplot -lpgplot -lpng -L/usr/X11R6/lib -lX11 
//FITSDIR = -I/usr/local/include/
FITSDIR = 
FITSLIBS = ${FITSDIR} -lcfitsio
//PROF = -pg
PROF =


OBJS = file.o xym.o triangle.o verbose.o treematch.o verification.o gauss.o \
	wcs.o thdrad.o tmat.o matched.o opm_param.o

GOBJS = graphics.o

OOBJS = original_data.o

PROGS = opm opm_match \
	local_coordinate_degree local_coordinate_RADec get_default_param \
	read_matched_coef calc_magdel calc_wcs_header

GPROGS = plot_dxdy plot_magdel plot_map

OPROGS = opm_original

.SUFFIXES: .c .o

all: ${OBJS} ${PROGS}

.c.o: $*.c
	${CC} -c $*.c ${CFLAGS}

plot: ${OBJS} ${GOBJS} ${GPROGS}

original: ${OBJS} ${OOBJS} ${OPROGS}

cfitsio: put_wcs_header

clean:
	/bin/rm -f ${OBJS} ${GOBJS} ${OOBJS} ${PROGS} ${GPROGS} ${OPROGS} put_wcs_header *~

opm: ${OBJS} boolean.h opm.c
	${CC} ${CFLAGS} opm.c ${OBJS} ${VERBOSE} ${PROF} -lm -o opm

opm_match: ${OBJS} boolean.h opm_match.c
	${CC} ${CFLAGS} opm_match.c ${OBJS} ${VERBOSE} ${PROF} -lm -o opm_match

local_coordinate_degree: local_coordinate_degree.c ${OBJS}
	${CC} ${CFLAGS} local_coordinate_degree.c ${OBJS} ${VERBOSE} -lm -o local_coordinate_degree

local_coordinate_RADec: local_coordinate_RADec.c ${OBJS}
	${CC} ${CFLAGS} local_coordinate_RADec.c ${OBJS} ${VERBOSE} -lm -o local_coordinate_RADec

get_default_param: get_default_param.c ${OBJS}
	${CC} ${CFLAGS} get_default_param.c ${OBJS} -lm -o get_default_param

read_matched_coef: read_matched_coef.c ${OBJS}
	${CC} ${CFLAGS} read_matched_coef.c ${OBJS} -lm -o read_matched_coef

calc_magdel: calc_magdel.c ${OBJS}
	${CC} ${CFLAGS} calc_magdel.c ${OBJS} -lm -o calc_magdel

calc_wcs_header: calc_wcs_header.c ${OBJS}
	${CC} ${CFLAGS} calc_wcs_header.c ${OBJS} -lm -o calc_wcs_header

graphics.o: graphics.c graphics.h
	${CC} ${CFLAGS} -c graphics.c ${PGDIR}

plot_dxdy: plot_dxdy.c ${OBJS} ${GOBJS}
	${CC} ${CFLAGS} -c plot_dxdy.c ${PGDIR}
	${FC} plot_dxdy.o ${OBJS} ${GOBJS} ${CPGLIBS} -lm -o plot_dxdy
	/bin/rm -f plot_dxdy.o

plot_magdel: plot_magdel.c ${OBJS} ${GOBJS}
	${CC} ${CFLAGS} -c plot_magdel.c ${PGDIR}
	${FC} plot_magdel.o ${OBJS} ${GOBJS} ${CPGLIBS} -lm -o plot_magdel
	/bin/rm -f plot_magdel.o

plot_map: plot_map.c ${OBJS} ${GOBJS}
	${CC} ${CFLAGS} -c plot_map.c ${PGDIR}
	${FC} plot_map.o ${OBJS} ${GOBJS} ${CPGLIBS} -lm -o plot_map
	/bin/rm -f plot_magdel.o

opm_original: opm_original.c ${OBJS} ${OOBJS}
	${CC} ${CFLAGS} opm_original.c ${OBJS} ${OOBJS} ${VERBOSE} -lm -o opm_original
	
put_wcs_header: put_wcs_header.c ${OBJS}
	${CC} ${CFLAGS} put_wcs_header.c ${OBJS} ${FITSLIBS} -lm -o put_wcs_header
