#-----------------------------------------------------------------------------
#   GNU makefile definitions for building WCSLIB 4.3.
#
#   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_all:  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-indepent 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.3 or libwcs.4.3.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.
#         Instead, you could link dynamically by using -lwcs.4.3.
#
#      4) PGPLOT is Tim Pearson's Fortran graphics library with separate C
#         interface available from astro.caltech.edu.  It is only required by
#         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 to compile test programs twcstab and twcshdr.
#         These 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
#   http://www.atnf.csiro.au/~mcalabre/index.html
#   $Id: makedefs.in,v 4.3 2007/12/27 05:57:06 cal103 Exp $
#-----------------------------------------------------------------------------
# Version.
  V := @PACKAGE_VERSION@
  WCSLIBV  := wcslib-$V

# 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.
  LIBWCS   := libwcs-$V.a
  RANLIB   := @RANLIB@

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

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

  prefix   := @prefix@
  exec_prefix := @exec_prefix@

  LIBDIR   := @libdir@
  BINDIR   := @bindir@
  INCDIR   := @includedir@/$(WCSLIBV)
  INCLINK  := @includedir@/wcslib

# 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

# Common targets.
.PHONY : all build printenv show_all

all : show_all build

printenv :
	-@ printenv | sort

show_all ::
	-@ echo ''
	-@ uname -a
	-@ echo ''
	-@ $(MAKE) --version | head -1
	-@ echo '  MAKEFLAGS   := $(MAKEFLAGS)'
	-@ echo ''
	-@ echo 'For building and installing $(WCSLIBV)...'
	-@ 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 '  LIBWCS      := $(LIBWCS)'
	-@ echo '  RANLIB      := $(RANLIB)'
	-@ echo '  SHRLIB      := $(SHRLIB)'
	-@ 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 '  TIMER       := $(TIMER)'
	-@ 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
