###############################################################################
# This is Makefile for building make_acisbg, lc_clean and badpixfilter
# for CIAO-3.4 or later, under Solaris or Linux. The configuration is not
# automated so edit the appropriate parts below.
# 
# `lc_clean' and `badpixfilter' use the FITSIO library that comes with FTOOLS
# (or with the CIAO OTS package) and do not need any CIAO stuff.
# `make_acisbg' also needs PIXLIB that comes with CIAO. The current CIAO
# binary distribution should include the necessary libraries (or compile
# ot from source). CIAO is at http://asc.harvard.edu/ciao/.
# 
# Before running 'make', run your CIAO setup script, then check that the env.
# variable ASCDS_INSTALL is set and points to the CIAO root directory.
#
# Maxim Markevitch <maxim % head.cfa.harvard.edu>, 6 Jan 2001
# 9.2.01: renamed pixlib_int.o -> ini_pixlib.o
# 25.10.3: updated libs for ciao-3.
# 13.5.4: removed ./bool.h, ./pixlib.h and -I.; replaced with -I $ciaoinc
# 30.1.7: updated libs for ciao-3.4 (E. Mandel fixed code to use new
#         pixlib interface; also removed need for -DNOREADPAR)
###############################################################################

###################################
## CIAO-related stuff (needed only for make_acisbg):

ciaoinc = $(ASCDS_INSTALL)/include
# (pixlib.h and bool.h are there)

# ciao-3.4:
CIAOLIBS =  -L$(ASCDS_INSTALL)/lib \
            -lpix -lmatrix -lcxccaldb -lerr \
            -lASCGen++ -lascgen -lascdm \
            -lregion -lvarmmrl -lslglue -ldl -lcxccfitsio
###################################

###############################################################################
## System-dependent compiler options, uncomment the right set:

# ## Solaris:
# ##
# fitsio =/data/alexey3/lheasoft/lheasoft/sparc-sun-solaris2.8/lib/
# fitsinc=/iraf/irafext/ftools/src/cfitsio/
# #
# FC = f77
# FFLAGS = -e -fast
# CC = gcc
# CFLAGS = -O -g -I ${fitsinc} -I ${ciaoinc}
# SYSLIB1 = -lM77 -lF77 -lsunmath -Bdynamic -lelf
# SYSLIB2 = -lsocket -lnsl
# SYSLIB3 = -lm

## Linux (compiler optimization options are for a Pentium processor):
##
# these are for lc_clean and badpixfilter; make_acisbg uses ciao's cfitsio
fitsio =/data/maxim1/soft/lib
fitsinc=/data/maxim1/soft/cfitsio-2.500

FC = g77
FFLAGS = -O -fno-backslash -ffixed-line-length-132 -fno-second-underscore -fno-f2c -fno-automatic -mcpu=pentiumpro -malign-double
CC = gcc
CFLAGS = -O -g -I ${fitsinc} -I ${ciaoinc}
SYSLIB1 =
SYSLIB2 =
SYSLIB3 = -lm

## (in CFLAGS, -I ${ciaoinc} is for pixlib calls in make_acisbg)
###############################################################################

LIBFITS = -L${fitsio} -lcfitsio 

OBJ1 = pixlib_interface.o ini_pixlib.o get_param.o rmblanks.o theta_phi.o \
	urand.o if_goodttime.o newunit.o
OBJ2 = get_param.o if_goodttime.o newunit.o get_numbered_param.o \
	ssort.o istrchr.o

all:	lc_clean badpixfilter make_acisbg

make_acisbg: make_acisbg.o $(OBJ1)
	${LINK.f} -o make_acisbg  make_acisbg.o $(OBJ1) \
	$(CIAOLIBS) $(SYSLIB1) $(SYSLIB2) $(SYSLIB3)

lc_clean: lc_clean.o $(OBJ2)
	${LINK.f} -o lc_clean lc_clean.o $(OBJ2) \
	$(LIBFITS)  $(SYSLIB2)

badpixfilter: badpixfilter.o
	$(LINK.c) -o badpixfilter badpixfilter.o \
	$(LIBFITS)  $(SYSLIB2) $(SYSLIB3)

clean:  
	rm -f *.o
