# RCS: $Id: Makefile,v 3.4 1998/09/24 14:00:48 arots Exp arots $
# Make sure the paths for the cfitsio library and its include files,
# as well as the install target, are set correctly, below.
#
# For proper installation, the environment variable ASC_DATA needs
# to be set.
# If your installation uses $LHEA_DATA, rather than $ASC_DATA, set
# the parameter below appropriately, and make a change in bary.h.
# If this is a private user installation, we recommend using
# $TIMING_DIR instead.
#
# For pre-Chandra missions, set the default JPLEPH, $DEFEPHEM, to JPLEPH.200.
# 
# "make" is equivalent to:
#	make lib	- make libbary.a
#	make install	- make and install all executables
#	make clean	- clean out extraneous files
#
# The important targets are:
#	make lib	- make libbary.a
#	make baryFase	- make baryFase executable
#	make axBary	- make axBary executable
#	make all	- make all executables
#	make clean	- clean out extraneous files to start over
# These targets are rather special-purpose
#	make faseBin	- make faseBin executable
#	make fBsub	- make fBsub executable
#	make fBadd	- make fBadd executable
#	make fBfsum	- make fBfsum executable
#	make fBssum	- make fBssum executable
#	make bineph2fits	- make bineph2fits executable

#------------------------------------------------------------------------
# Set the following parameters to the right values for your installation

# TARGET=		/usr/local/bin
TARGET=		./bin
INCLUDES=	-I. -I/d1/xebec1/jpl/c/cfitsio
LIBDIRS=	-L. -L/d1/xebec1/jpl/c/cfitsio
ASC_DATA=	./asc_data
# For $LHEA_DATA installation:
# ASC_DATA=	${LHEA_DATA}
# For $TIMING_DIR installation:
# ASC_DATA=	${TIMING_DIR}

#------------------------------------------------------------------------
# You should not have to change anything below this line, but you may
# want to check the following entries
# (-static does not work well with cfitsio 2.0 and up)

ANSI=		
# DEFINES=	-static
DEFINES=	
CC=		gcc

CFLAGS=		${INCLUDES} ${LIBDIRS} ${ANSI} ${DEFINES}

SHAR=		shar
CTAR=		tar cvf
XTAR=		tar xvf
CP=		cp
MKDIR=		mkdir
AR=		ar -r
RANLIB=		ranlib
RM=		rm -f
RCSCLEAN=	rcsclean
CI=		ci
CO=		co -l
LN=		ln -s
DEFEPHEM=	JPLEPH.405
# For pre-AXAF missions:
# DEFEPHEM=	JPLEPH.200

#------------------------------------------------------------------------
# No more changes below this line

OMAINFILES=	baryFase.o \
		axBarym.o \
		faseBin.o \
		fBsub.o \
		fBadd.o \
		fBfsum.o \
		fBssum.o \
		bineph2fits.o

OLIBFILES=	bary.o \
		clock.o \
		scorbit.o \
		xCC.o \
		ctatv.o \
		axBary.o \
		phaseHist.o \
		dpleph.o

OFILES=		${OMAINFILES} ${OLIBFILES}

HFILES=		bary.h

CFILES=		bary.c \
		clock.c \
		scorbit.c \
		xCC.c \
		ctatv.c \
		phaseHist.c \
		faseBin.c \
		fBsub.c \
		fBadd.c \
		fBfsum.c \
		fBssum.c \
		baryFase.c \
		axBary.c \
		axBarym.c \
		dpleph.c \
		bineph2fits.c

EXECFILES=	baryFase \
		axBary \
		faseBin \
		fBsub \
		fBadd \
		fBfsum \
		fBssum \
		bineph2fits

MANFILES=

XXFILES=	00README \
		fBREADME \
		Makefile

EPHFILES=	JPLEPH.200 \
		JPLEPH.405 \
		tai-utc.dat \
		psrtime.dat \
		psrbin.dat \
		tdc.dat

OBJS=		${OFILES}
SRCFILES=	${HFILES} ${CFILES} ${MANFILES} \
		${XXFILES}
BLIB=		libbary.a
SCRIPTFILES=	
LOCLIBS=	-lbary
FIOLIBS=	-lcfitsio
SYSLIBS=	-lm -lsocket -lnsl
LIBS=		${LOCLIBS} ${FIOLIBS} ${SYSLIBS}

default: lib install clean

lib:	${OLIBFILES}
	${AR} ${BLIB} ${OLIBFILES}
	${RANLIB} ${BLIB}

all: ${EXECFILES}

baryFase: baryFase.o ${BLIB}
		${CC} ${CFLAGS} -o baryFase baryFase.o ${LIBS}
axBary: axBarym.o ${BLIB}
		${CC} ${CFLAGS} -o axBary axBarym.o ${LIBS}
faseBin: faseBin.o ${BLIB}
		${CC} ${CFLAGS} -o faseBin faseBin.o ${LIBS}
fBsub: fBsub.o ${BLIB}
		${CC} ${CFLAGS} -o fBsub fBsub.o ${LIBS}
fBsub2: fBsub2.o ${BLIB}
		${CC} ${CFLAGS} -o fBsub2 fBsub2.o ${LIBS}
fBadd: fBadd.o ${BLIB}
		${CC} ${CFLAGS} -o fBadd fBadd.o ${LIBS}
fBfsum: fBfsum.o ${BLIB}
		${CC} ${CFLAGS} -o fBfsum fBfsum.o ${LIBS}
fBssum: fBssum.o ${BLIB}
		${CC} ${CFLAGS} -o fBssum fBssum.o ${LIBS}
bineph2fits: bineph2fits.o ${BLIB}
		${CC} ${CFLAGS} -o bineph2fits bineph2fits.o ${LIBS}


install: ${EXECFILES} ${SCRIPTFILES}
	${CP} ${EXECFILES} ${SCRIPTFILES} ${TARGET}
	${CP} ${EPHFILES} ${ASC_DATA}
	${RM} ${ASC_DATA}/JPLEPH
	${LN} ${DEFEPHEM} ${ASC_DATA}/JPLEPH

clean:
	${RM} *.o core *~ ${EXECFILES} *.a *.tar *.tar.gz
	${RCSCLEAN} ${SRCFILES} ${SCRIPTFILES}

tar: ${SRCFILES} ${SCRIPTFILES}
	${RM} bary.tar*
	${CTAR} bary.tar ${SRCFILES} ${SCRIPTFILES} ${EPHFILES}

rcsci: 
	${CI} ${SRCFILES} ${SCRIPTFILES}

rcsco: 
	${CO} ${SRCFILES} ${SCRIPTFILES}

