#-----------------------------------------------------------------------------
# GNU makefile definitions for building WCSLIB 8.6
#
# makedefs is generated from makedefs.in by configure.  It contains variable
# definitions and some general-purpose rules for building WCSLIB.
#
# Targets defined here
# --------------------
#   printenv:  Print the environment as seen within makefile rules.
#   show:      Print the values of all makefile variables used.
#
# Notes:
#   1) If you need to make changes then it may be preferable to modify
#      makedefs.in (not makedefs).  The makefile will detect this and
#      automatically re-run config.status to regenerate makedefs.
#
#   2) There are three choices for trigd functions - cosd(), sind(), tand(),
#      acosd(), asind(), atand(), and atan2d(), made by setting WCSTRIG:
#
#      1: Use the wrapper functions supplied with WCSLIB (default):
#         WCSTRIG := WRAPPER
#
#      2: Use native trigd functions supplied in a mathematics library such
#         as libsunmath (you will also need to add the library to the LIBS
#         variable below):
#         WCSTRIG := NATIVE
#
#      3: Use C preprocessor macro implementations of the trigd functions
#         (this method is typically 20% faster but may lead to rounding
#         errors near the poles):
#         WCSTRIG := MACRO
#
#   3) Variables for creating the shared (dynamic) library are currently
#      only set by 'configure' if the GNU C compiler is used.  However,
#      you can set these variables by hand, preferably in makedefs.in.
#
#      Shared libraries require position-independent code (PIC) which imposes
#      a performance overhead.  Consequently the static libraries are
#      compiled separately without this option.
#
#      The shared library will be installed with version number, e.g. as
#      libwcs.so.8.6 or libwcs.8.6.dylib with or without the symlink
#      required to make it visible to the linker (controlled by the SHRLN
#      variable).  On Macs it is deliberately not created because its very
#      existence precludes static linking with the cctools linker.  You can
#      still link dynamically by using -lwcs.8.6.
#
#   4) PGPLOT is Tim Pearson's Fortran graphics library with separate C
#      interface available from astro.caltech.edu.  It is only required by
#      one utility, wcsgrid, and the test programs that plot test grids
#      (tprj2, tcel1, tcel2, tspc, ttab2, ttab3, twcsmix, and tpih2).  You can
#      skip these by setting PGPLOTLIB to blank.
#
#      It is difficult for configure to deduce what auxiliary graphics
#      libraries may be needed for PGPLOT since it depends on which of many
#      possible graphics drivers were selected when PGPLOT was installed.
#      Therefore it is quite likely that you will need to add additional
#      libraries to PGPLOTLIB.
#
#   5) CFITSIO is Bill Pence's FITS I/O library written in C with Fortran
#      wrappers, available from http://heasarc.gsfc.nasa.gov/fitsio.
#
#      CFITSIO is required by three utilities, HPXcvt, wcsgrid, and wcsware,
#      and also by the test programs twcstab and twcshdr.  wcsware and the
#      test programs use fits_read_wcstab() which is implemented by
#      getwcstab.c.  However, this implementation is included in CFITSIO post
#      3.004beta, so getwcstab.c is required here only for older releases
#      (controlled by variable GETWCSTAB).  getwcstab.o itself is not inserted
#      into the WCSLIB object library.
#
#      If available, CFITSIO is also optionally used for test programs
#      tfitshdr, tbth1, tpih1 and tpih2 by setting preprocessor macro
#      -DDO_CFITSIO.
#
# Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
# http://www.atnf.csiro.au/computing/software/wcs
# $Id: makedefs.in,v 8.6 2026/03/29 13:53:57 mcalabre Exp $
#-----------------------------------------------------------------------------
# Version.
  LIBVER    := @LIBVER@
  WCSLIBPKG := wcslib-@PACKAGE_VERSION@

# Additional options for GNU make added by configure.
  MAKEFLAGS += @MAKEFLAGS@

# System architecture.
  ARCH     := @ARCH@

# Flex and options.
  FLEX     := @FLEX@
  FLFLAGS  := @FLFLAGS@

# C preprocessor and options.
  CPP      := @CPP@
  CPPFLAGS := @CPPFLAGS@
  WCSTRIG  := WRAPPER

# C compiler and options.
  CC       := @CC@
  CFLAGS   := @CFLAGS@

# Fortran compiler and options.
  FC       := @F77@
  FFLAGS   := @FFLAGS@

# Use the Fortran 2003 BIND(C) wrappers?  (Recommended for LTO.)
  BINDC    := @BINDC@

# Static object library.
  WCSLIB   := libwcs-$(LIBVER).a
  ARFLAGS  := @ARFLAGS@
  RANLIB   := @RANLIB@

# Shared (dynamic) library (see note 3 above).
  SHRLIB   := @SHRLIB@
  SONAME   := @SONAME@
  SHRFLAGS := @SHRFLAGS@
  SHRLD    := @SHRLD@
  SHRLN    := @SHRLN@

# What subdirectories to build.
  SUBDIRS  := @SUBDIRS@
  TSTDIRS  := @TSTDIRS@

# Top of the 'make install' hierarchy: pgsbox -> Fortran -> C.
  INSTDIR  := @INSTDIR@

# Installation utilities and locations.
  LN_S     := @LN_S@
  INSTALL  := @INSTALL@

  # Needed for the definitions provided by autoconf.
  prefix          := @prefix@
  exec_prefix     := @exec_prefix@
  datarootdir     := @datarootdir@
  PACKAGE_TARNAME := @PACKAGE_TARNAME@
  docdir          := @docdir@

  LIBDIR   := $(DESTDIR)@libdir@
  BINDIR   := $(DESTDIR)@bindir@
  INCDIR   := $(DESTDIR)@includedir@/wcslib-$(LIBVER)
  INCLINK  := $(DESTDIR)@includedir@/wcslib
  DOCDIR   := $(DESTDIR)@docdir@
  DOCLINK  := $(dir $(DESTDIR)@docdir@)wcslib
  HTMLDIR  := $(DESTDIR)@htmldir@
  PDFDIR   := $(DESTDIR)@pdfdir@
  MANDIR   := $(DESTDIR)@mandir@

# For putting timestamps in the build log.
  TIMER    := date +"%a %Y/%m/%d %X %z, executing on $$HOST"


# The remaining options are for building utilities and test programs.
# -------------------------------------------------------------------
# Linker options (use CC for linking).
  LD       = $(CC)
  LDFLAGS := @LDFLAGS@

# PGPLOT (see note 4 above).
  PGPLOTINC := @PGPLOTINC@
  PGPLOTLIB := @PGPLOTLIB@

# CFITSIO (see note 5 above).
  CFITSIOINC := @CFITSIOINC@
  CFITSIOLIB := @CFITSIOLIB@
  GETWCSTAB  := @GETWCSTAB@

# Libraries required by the above Fortran compiler.
  FLIBS := @FLIBS@

# Libraries required by WCSLIB itself.
  LIBS := @LIBS@

# Default observer coordinates for sundazel.  May be set as environment
# variables, either generally or in $HOME/.sundazelrc, which is read by
# configure.
  OBSLNG := @OBSLNG@
  OBSLAT := @OBSLAT@
  OBSTZ  := @OBSTZ@

#-----------------------------------------------------------------------------
# You shouldn't need to change anything below here.
#-----------------------------------------------------------------------------

SHELL := /bin/sh
VPATH := ..

# Common targets.
.PHONY : all build FORCE printenv show

all : show
	-@ echo ''
	 @ $(MAKE) build

FORCE :

# Print the environment as seen by makefile rules.
printenv :
	-@ printenv | sort

# Print variable definitions.
show :: wcsconfig.h
	-@ echo ''
	-@ uname -a
	-@ echo ''
	-@ $(MAKE) --version | head -1
	-@ echo '  SUBDIR      := $(SUBDIR)'
	-@ echo '  MAKEFLAGS   := $(MAKEFLAGS)'
	-@ echo ''
	-@ echo 'For building and installing $(WCSLIBPKG)...'
	-@ echo '  ARCH        := $(ARCH)'
	-@ echo '  FLEX        := $(FLEX)'
	-@ echo '  FLFLAGS     := $(FLFLAGS)'
	-@ echo '  CPP         := $(CPP)'
	-@ echo '  CPPFLAGS    := $(CPPFLAGS)'
	-@ echo '  WCSTRIG     := $(WCSTRIG)'
	-@ echo '  CC          := $(CC)'
	-@ if [ "@GCC_VERSION@" ] ; then \
	     echo '                 GCC version is @GCC_VERSION@' ; \
	   fi
	-@ echo '  CFLAGS      := $(CFLAGS)'
	-@ echo '  FC          := $(FC)'
	-@ echo '  FFLAGS      := $(FFLAGS)'
	-@ echo '  BINDC       := $(BINDC)'
	-@ echo '  WCSLIB      := $(WCSLIB)'
	-@ echo '  ARFLAGS     := $(ARFLAGS)'
	-@ echo '  RANLIB      := $(RANLIB)'
	-@ echo '  SHRLIB      := $(SHRLIB)'
	-@ echo '  SONAME      := $(SONAME)'
	-@ echo '  SHRFLAGS    := $(SHRFLAGS)'
	-@ echo '  SHRLD       := $(SHRLD)'
	-@ echo '  SHRLN       := $(SHRLN)'
	-@ echo '  LN_S        := $(LN_S)'
	-@ echo '  INSTALL     := $(INSTALL)'
	-@ echo '  LIBDIR      := $(LIBDIR)'
	-@ echo '  BINDIR      := $(BINDIR)'
	-@ echo '  INCDIR      := $(INCDIR)'
	-@ echo '  INCLINK     := $(INCLINK)'
	-@ echo '  DOCDIR      := $(DOCDIR)'
	-@ echo '  DOCLINK     := $(DOCLINK)'
	-@ echo '  HTMLDIR     := $(HTMLDIR)'
	-@ echo '  PDFDIR      := $(PDFDIR)'
	-@ echo '  MANDIR      := $(MANDIR)'
	-@ echo '  TIMER       := $(TIMER)'
	-@ echo ''
	-@ echo 'Important wcsconfig.h defines...'
	-@ echo "  `grep HAVE_SINCOS $<`"
	-@ echo "  `grep WCSLIB_INT64 $<`"
	-@ echo ''
	-@ echo 'To build utilities and test programs...'
	-@ echo '  LD          := $(LD)'
	-@ echo '  LDFLAGS     := $(LDFLAGS)'
	-@ echo '  PGPLOTINC   := $(PGPLOTINC)'
	-@ echo '  PGPLOTLIB   := $(PGPLOTLIB)'
	-@ echo '  CFITSIOINC  := $(CFITSIOINC)'
	-@ echo '  CFITSIOLIB  := $(CFITSIOLIB)'
	-@ echo '  GETWCSTAB   := $(GETWCSTAB)'
	-@ echo '  FLIBS       := $(FLIBS)'
	-@ echo '  LIBS        := $(LIBS)'
	-@ echo ''
	-@ echo 'Default observer coordinates for sundazel...'
	-@ echo '  OBSLNG      := $(OBSLNG)'
	-@ echo '  OBSLAT      := $(OBSLAT)'
	-@ echo '  OBSTZ       := $(OBSTZ)'
	-@ echo ''
	-@ echo 'For code development...'
	-@ echo '  FLAVOUR     := $(FLAVOUR)'
	-@ echo '  MODE        := $(MODE)'
	-@ echo '  VALGRIND    := $(VALGRIND)'
	-@ echo '  EXTRA_CLEAN := $(EXTRA_CLEAN)'
	-@ echo ''

# For code development.
FLAVOUR     := @FLAVOUR@
MODE        := @MODE@
VALGRIND    := @VALGRIND@
EXTRA_CLEAN := @EXTRA_CLEAN@

# Check MODE.
ifeq "$(MODE)" "interactive"
  # Important not to have output batched when running the test programs.
  MAKEFLAGS := $(filter-out -Otarget,$(MAKEFLAGS)) -Onone
endif

ifneq "$(FLAVOUR)" "default"
  TIMER := $(TIMER) ; echo "    with $(FLAVOUR) FLAVOUR."
endif
