# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE

ANUTILS_DIR := $(BASEDIR)/util
ANUTILS_LIB_FILE := $(ANUTILS_DIR)/libanutils.a

ANUTILS_INC :=
ANUTILS_LIB := 
ANUTILS_SLIB := $(ANUTILS_LIB_FILE)
ANUTILS_CFLAGS :=

$(ANUTILS_LIB_FILE):
	$(MAKE) -C $(ANUTILS_DIR) libanutils.a

# Astrometry.net utils ("anutils") depends on:
#  anbase
#  qfits
#  gsl
#  wcslib (optional)

include $(COMMON)/makefile.gsl
include $(COMMON)/makefile.wcslib

ANUTILS_INC += $(ANBASE_INC)
ANUTILS_CFLAGS += $(ANBASE_CFLAGS)
ANUTILS_LIB += $(ANBASE_LIB)
ANUTILS_SLIB += $(ANBASE_SLIB)

ifndef NO_QFITS
include $(COMMON)/makefile.qfits
else
include $(COMMON)/makefile.anbase
endif

ifdef WCSLIB_EXISTS
  ifdef NOWCSLIB
  else
    ANUTILS_CFLAGS += -DWCSLIB_EXISTS
  endif
endif

# WCSTOOLS_EXISTS := 1
ifdef WCSTOOLS_EXISTS
  ANUTILS_CFLAGS += -DWCSTOOLS_EXISTS
  WCSTOOLS_LIB ?= libwcs.a
endif

WCS_LIB := $(WCSTOOLS_LIB) $(WCSLIB_LIB)
WCS_SLIB := $(WCSLIB_SLIB)

ifndef NO_QFITS
ANUTILS_INC += $(QFITS_INC)
ANUTILS_LIB += $(QFITS_LIB)
ANUTILS_SLIB += $(QFITS_SLIB)
endif

ANUTILS_INC += $(GSL_INC) $(WCSLIB_INC)
ANUTILS_SLIB += $(ANUTILS_LIB) $(GSL_SLIB) $(WCS_SLIB)
ANUTILS_LIB += $(GSL_LIB) $(WCS_LIB) -lm

