default: addstar
help:
	@echo "make options: addstar (default)"

include ../../Makefile.System
HOME 	=	$(ROOT)/src/addstar
BIN	=	$(HOME)/bin
LIB	=	$(HOME)/lib
SRC	=	$(HOME)/src
MAN	=	$(HOME)/doc
INC	= 	$(HOME)/include
include ../../Makefile.Common

# programs may add their own internal requirements here
FULL_CFLAGS   = $(BASE_CFLAGS) -Wall -Werror
FULL_CPPFLAGS = $(BASE_CPPFLAGS)
FULL_LDFLAGS  = -lkapa -ldvo -lFITS -lohana $(BASE_LDFLAGS)

addstar     : $(BIN)/addstar.$(ARCH)
addstard    : $(BIN)/addstard.$(ARCH)
addstart    : $(BIN)/addstart.$(ARCH)
addstarc    : $(BIN)/addstarc.$(ARCH)
mkacc-2mass : $(BIN)/mkacc-2mass.$(ARCH)
sedstar     : $(BIN)/sedstar.$(ARCH)
load2mass   : $(BIN)/load2mass.$(ARCH)
gztest      : $(BIN)/gztest.$(ARCH)

all: addstar addstarc addstard addstart sedstar load2mass skycells

ADDSTAR = \
$(SRC)/ConfigInit.$(ARCH).o \
$(SRC)/SetSignals.$(ARCH).o \
$(SRC)/Shutdown.$(ARCH).o \
$(SRC)/SkyListForStars.$(ARCH).o \
$(SRC)/SkyRegionUtils.$(ARCH).o \
$(SRC)/SkyTableFromTychoIndex.$(ARCH).o \
$(SRC)/addstar.$(ARCH).o \
$(SRC)/airmass.$(ARCH).o \
$(SRC)/args.$(ARCH).o \
$(SRC)/build_links.$(ARCH).o \
$(SRC)/calibrate.$(ARCH).o \
$(SRC)/dump.$(ARCH).o \
$(SRC)/edge_check.$(ARCH).o \
$(SRC)/fakeimage.$(ARCH).o \
$(SRC)/find_matches.$(ARCH).o \
$(SRC)/find_matches_closest.$(ARCH).o \
$(SRC)/find_matches_refstars.$(ARCH).o \
$(SRC)/find_subset.$(ARCH).o \
$(SRC)/get2mass.$(ARCH).o \
$(SRC)/get2mass_as.$(ARCH).o \
$(SRC)/get2mass_as_raw.$(ARCH).o \
$(SRC)/get2mass_dr2.$(ARCH).o \
$(SRC)/get2mass_ops.$(ARCH).o \
$(SRC)/getgsc.$(ARCH).o \
$(SRC)/gettycho.$(ARCH).o \
$(SRC)/getusno.$(ARCH).o \
$(SRC)/getusnob.$(ARCH).o \
$(SRC)/greference.$(ARCH).o \
$(SRC)/grefstars.$(ARCH).o \
$(SRC)/LoadStars.$(ARCH).o \
$(SRC)/LoadHeaders.$(ARCH).o \
$(SRC)/MatchHeaders.$(ARCH).o \
$(SRC)/LoadData.$(ARCH).o \
$(SRC)/LoadDataSDSS.$(ARCH).o \
$(SRC)/LoadDataPMM.$(ARCH).o \
$(SRC)/in_image.$(ARCH).o \
$(SRC)/load_subpix.$(ARCH).o \
$(SRC)/opening_angle.$(ARCH).o \
$(SRC)/parse_time.$(ARCH).o \
$(SRC)/replace_match.$(ARCH).o \
$(SRC)/resort_catalog.$(ARCH).o \
$(SRC)/ReadStarsFITS.$(ARCH).o \
$(SRC)/ReadStarsTEXT.$(ARCH).o \
$(SRC)/ReadStarsSDSS.$(ARCH).o \
$(SRC)/FilterStars.$(ARCH).o \
$(SRC)/ImageOptions.$(ARCH).o \
$(SRC)/GetFileMode.$(ARCH).o \
$(SRC)/ReadImageHeader.$(ARCH).o \
$(SRC)/UpdateImageIDs.$(ARCH).o \
$(SRC)/update_coords.$(ARCH).o

ADDSTARD = \
$(SRC)/CheckPassword.$(ARCH).o \
$(SRC)/ConfigInit.$(ARCH).o \
$(SRC)/NewImage.$(ARCH).o \
$(SRC)/NewRefcat.$(ARCH).o \
$(SRC)/NewReflist.$(ARCH).o \
$(SRC)/SetSignals.$(ARCH).o \
$(SRC)/Shutdown.$(ARCH).o \
$(SRC)/SkyListForStars.$(ARCH).o \
$(SRC)/SkyRegionUtils.$(ARCH).o \
$(SRC)/SkyTableFromTychoIndex.$(ARCH).o \
$(SRC)/SocketOps.$(ARCH).o \
$(SRC)/UpdateDatabase_Image.$(ARCH).o \
$(SRC)/UpdateDatabase_Refcat.$(ARCH).o \
$(SRC)/UpdateDatabase_Reflist.$(ARCH).o \
$(SRC)/addstard.$(ARCH).o \
$(SRC)/airmass.$(ARCH).o \
$(SRC)/args_server.$(ARCH).o \
$(SRC)/build_links.$(ARCH).o \
$(SRC)/calibrate.$(ARCH).o \
$(SRC)/edge_check.$(ARCH).o \
$(SRC)/find_matches.$(ARCH).o \
$(SRC)/find_matches_closest.$(ARCH).o \
$(SRC)/find_matches_refstars.$(ARCH).o \
$(SRC)/find_subset.$(ARCH).o \
$(SRC)/get2mass.$(ARCH).o \
$(SRC)/get2mass_as.$(ARCH).o \
$(SRC)/get2mass_as_raw.$(ARCH).o \
$(SRC)/get2mass_dr2.$(ARCH).o \
$(SRC)/get2mass_ops.$(ARCH).o \
$(SRC)/getgsc.$(ARCH).o \
$(SRC)/gettycho.$(ARCH).o \
$(SRC)/getusno.$(ARCH).o \
$(SRC)/getusnob.$(ARCH).o \
$(SRC)/ImageOptions.$(ARCH).o \
$(SRC)/greference.$(ARCH).o \
$(SRC)/in_image.$(ARCH).o \
$(SRC)/load_subpix.$(ARCH).o \
$(SRC)/opening_angle.$(ARCH).o \
$(SRC)/replace_match.$(ARCH).o \
$(SRC)/update_coords.$(ARCH).o

ADDSTART = \
$(SRC)/addstart.$(ARCH).o \
$(SRC)/ImageOptions.$(ARCH).o \
$(SRC)/DatasetOps.$(ARCH).o \
$(SRC)/SocketOps.$(ARCH).o \
$(SRC)/ConfigInit.$(ARCH).o \
$(SRC)/args_server.$(ARCH).o \
$(SRC)/CheckPassword.$(ARCH).o \
$(SRC)/UpdateDatabase_Image.$(ARCH).o \
$(SRC)/UpdateDatabase_Reflist.$(ARCH).o \
$(SRC)/UpdateDatabase_Refcat.$(ARCH).o \
$(SRC)/airmass.$(ARCH).o \
$(SRC)/build_links.$(ARCH).o \
$(SRC)/calibrate.$(ARCH).o \
$(SRC)/find_matches.$(ARCH).o \
$(SRC)/find_matches_closest.$(ARCH).o \
$(SRC)/find_matches_refstars.$(ARCH).o \
$(SRC)/find_subset.$(ARCH).o \
$(SRC)/get2mass.$(ARCH).o \
$(SRC)/get2mass_as.$(ARCH).o \
$(SRC)/get2mass_as_raw.$(ARCH).o \
$(SRC)/get2mass_dr2.$(ARCH).o \
$(SRC)/get2mass_ops.$(ARCH).o \
$(SRC)/getgsc.$(ARCH).o \
$(SRC)/getusno.$(ARCH).o \
$(SRC)/getusnob.$(ARCH).o \
$(SRC)/gettycho.$(ARCH).o \
$(SRC)/greference.$(ARCH).o \
$(SRC)/in_image.$(ARCH).o \
$(SRC)/load_subpix.$(ARCH).o \
$(SRC)/replace_match.$(ARCH).o \
$(SRC)/SetSignals.$(ARCH).o \
$(SRC)/SkyRegionUtils.$(ARCH).o \
$(SRC)/SkyListForStars.$(ARCH).o \
$(SRC)/update_coords.$(ARCH).o \
$(SRC)/Shutdown.$(ARCH).o \
$(SRC)/edge_check.$(ARCH).o \
$(SRC)/opening_angle.$(ARCH).o \
$(SRC)/SkyTableFromTychoIndex.$(ARCH).o \
$(SRC)/ListenClients_Thread.$(ARCH).o \
$(SRC)/NewImage_Thread.$(ARCH).o \
$(SRC)/NewReflist_Thread.$(ARCH).o \
$(SRC)/NewRefcat_Thread.$(ARCH).o 

ADDSTARC = \
$(SRC)/addstarc.$(ARCH).o \
$(SRC)/airmass.$(ARCH).o \
$(SRC)/SocketOps.$(ARCH).o \
$(SRC)/ConfigInit.$(ARCH).o \
$(SRC)/LoadStars.$(ARCH).o \
$(SRC)/LoadHeaders.$(ARCH).o \
$(SRC)/MatchHeaders.$(ARCH).o \
$(SRC)/LoadData.$(ARCH).o \
$(SRC)/LoadDataSDSS.$(ARCH).o \
$(SRC)/LoadDataPMM.$(ARCH).o \
$(SRC)/grefstars.$(ARCH).o \
$(SRC)/load_subpix.$(ARCH).o \
$(SRC)/parse_time.$(ARCH).o \
$(SRC)/ReadStarsFITS.$(ARCH).o \
$(SRC)/GetFileMode.$(ARCH).o \
$(SRC)/ReadImageHeader.$(ARCH).o \
$(SRC)/ReadStarsTEXT.$(ARCH).o \
$(SRC)/ReadStarsSDSS.$(ARCH).o \
$(SRC)/UpdateImageIDs.$(ARCH).o \
$(SRC)/FilterStars.$(ARCH).o \
$(SRC)/Shutdown.$(ARCH).o \
$(SRC)/SetSignals.$(ARCH).o \
$(SRC)/args_client.$(ARCH).o

### this program may need to be repaired (EAM 2006.08)
MKACC-2MASS = \
$(SRC)/mkacc-2mass.$(ARCH).o \
$(SRC)/ConfigInit.$(ARCH).o \
$(SRC)/SetSignals.$(ARCH).o \
$(SRC)/get2mass_as.$(ARCH).o

LOAD-2MASS = \
$(SRC)/load2mass.$(ARCH).o \
$(SRC)/load2mass_as_rawdata.$(ARCH).o \
$(SRC)/load2mass_catalog.$(ARCH).o \
$(SRC)/get2mass_ops.$(ARCH).o \
$(SRC)/get2mass_full.$(ARCH).o \
$(SRC)/find_matches_refstars.$(ARCH).o \
$(SRC)/args_load2mass.$(ARCH).o \
$(SRC)/replace_match.$(ARCH).o \
$(SRC)/update_coords.$(ARCH).o \
$(SRC)/ConfigInit.$(ARCH).o \
$(SRC)/Shutdown.$(ARCH).o \
$(SRC)/SetSignals.$(ARCH).o

SEDSTAR = \
$(SRC)/sedstar.$(ARCH).o \
$(SRC)/SEDtableLoad.$(ARCH).o \
$(SRC)/SEDfit.$(ARCH).o \
$(SRC)/SEDops.$(ARCH).o \
$(SRC)/args_sedstar.$(ARCH).o \
$(SRC)/ConfigInit.$(ARCH).o \
$(SRC)/Shutdown.$(ARCH).o \
$(SRC)/SetSignals.$(ARCH).o

SKYCELLS = \
$(SRC)/skycells.$(ARCH).o \
$(SRC)/args_skycells.$(ARCH).o \
$(SRC)/ConfigInit_skycells.$(ARCH).o \
$(SRC)/Shutdown.$(ARCH).o \
$(SRC)/SetSignals.$(ARCH).o \
$(SRC)/sky_tessalation.$(ARCH).o

$(ADDSTARC) : $(INC)/addstar.h
$(ADDSTARD) : $(INC)/addstar.h
$(ADDSTART) : $(INC)/addstar.h
$(ADDSTAR)  : $(INC)/addstar.h
$(SKYCELLS) : $(INC)/addstar.h
$(LOAD-2MASS) : $(INC)/addstar.h $(INC)/2mass.h

$(BIN)/addstar.$(ARCH) : $(ADDSTAR)
$(BIN)/addstard.$(ARCH) : $(ADDSTARD)
$(BIN)/addstart.$(ARCH) : $(ADDSTART)
$(BIN)/addstarc.$(ARCH) : $(ADDSTARC)
$(BIN)/mkacc-2mass.$(ARCH) : $(MKACC-2MASS)
$(BIN)/sedstar.$(ARCH)   : $(SEDSTAR)
$(BIN)/load2mass.$(ARCH) : $(LOAD-2MASS)
$(BIN)/skycells.$(ARCH) : $(SKYCELLS)

INSTALL = addstar addstarc addstard addstart sedstar load2mass skycells

# dependancy rules for binary code #########################
$(INSTALL): % : $(BIN)/%.$(ARCH)

%.clean :
	rm -f $(BIN)/$*.$(ARCH)

%.install:
	make $(DESTBIN)/$*

install:
	for i in $(INSTALL); do make $$i.install || exit; done
