#-----------------------------------------------------------------------------
# GNU makefile definitions for building WCSLIB 4.17
#
# 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.4.17 or libwcs.4.17.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.4.17.
#
#   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/people/Mark.Calabretta
# $Id: makedefs.in,v 1.1 2014/02/12 21:11:41 irby Exp $
#-----------------------------------------------------------------------------
# Version.
  LIBVER    := @LIBVER@
  WCSLIBPKG := wcslib-@PACKAGE_VERSION@

# System architecture.
  ARCH     := @ARCH@

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

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

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

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

# Static object library.
  WCSLIB   := libwcs-$(LIBVER).a
  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@


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

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

# Common targets.
.PHONY : all build printenv show

all : show build

# 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 '  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)'
	-@ echo '  CFLAGS      := $(CFLAGS)'
	-@ echo '  FC          := $(FC)'
	-@ echo '  FFLAGS      := $(FFLAGS)'
	-@ echo '  WCSLIB      := $(WCSLIB)'
	-@ 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 ''

# Code development overrides, for use in the code subdirectories.
-include ../flavours
