#-----------------------------------------------------------------------
# Copyright 1996-2016 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#-----------------------------------------------------------------------
#------------------------------------------------------------------------------
#
#  NSSDC/CDF						CDF tests makefile.
#
#  Version 1.5, 20-Feb-96, Hughes STX.
#
#  Modification history:
#
#   V1.0  26-Jan-94, J Love	Original version.
#   V1.0a 23-Feb-94, J Love	Added `CC='.
#   V1.0b  6-Apr-94, J Love	Finished `CC='.
#   V1.1  19-Dec-94, J Love	CDF V2.5.
#   V1.2   5-Jan-95, J Love	Updated dependencies, etc.
#   V1.2a 20-Jan-95, J Love	IRIX 6.x.
#   V1.3  16-Mar-95, J Love	Multi-compiler support, etc.
#   V1.4   3-Apr-95, J Love	POSIX.
#   V1.5  20-Feb-96, J Love	CDF V2.6.
#   V1.6  12-Feb-07, D Berger   Added existing LD_LIBRARY_PATH to temp 
#                               definition.
#   V1.7  22-Feb-16, M Liu      Modified to handle Mac's El Captain's not 
#                               (Mac OS 10.11) handling DYLD_LIBRARY_PATH
#
#------------------------------------------------------------------------------
#
# Notes:
#
# `make' on DECstations complains (prints an error message) if an if-then-else
# construct evaluates to FALSE but there is no `false' part.  To prevent this,
# the `NULL' command is executed as the `false' part.
#
#------------------------------------------------------------------------------

.SILENT:

SHELL=/bin/sh
NULL=true

FORTRAN=yes
FCx=gfortran
CCx=gcc
SHARED=yes
FOPTIONS=
FOPTIONSld=
COPTIONS=-O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE   -DHAVE_UNISTD_H -DHAVE_STDARG_H
COPTIONSld=
SYSLIBS=-lc -lm
SHAREDEXT=dylib
MAKE=make
MAKEFILE=Makefile-classic
SRCDIR=
BLDDIR=

INCLUDEcdf=$(SRCDIR)/../src/include

CC=$(CCx)
CFLAGS=$(COPTIONS) -I$(INCLUDEcdf)
CFLAGSld=$(COPTIONSld)

FC=$(FCx)
FEXTRA=
ifeq ("$(FC)","gfortran")
 FEXTRA=-std=legacy -w
endif
FFLAGS=$(FOPTIONS) $(FEXTRA)
FFLAGSld=$(FOPTIONSld)
MACos=Darwin

LIBCDFa=$(BLDDIR)/../src/lib/libcdf.a
LIBCDFshare=$(BLDDIR)/../src/lib/libcdf.$(SHAREDEXT)

LIBsARCHIVE=$(LIBCDFa) $(SYSLIBS)
#LIBsSHARE=$(LIBCDFshare) $(SYSLIBS)

CDFh=$(INCLUDEcdf)/cdf.h
CDFinc=$(INCLUDEcdf)/cdf.inc

BINsC=$(BLDDIR)/qst2c $(BLDDIR)/qst2ic $(BLDDIR)/qst2cutf8 \
      $(BLDDIR)/qst2icEPOCH16 $(BLDDIR)/qst2cOrig $(BLDDIR)/qst2icTT2000
BINsF=$(BLDDIR)/qst2f $(BLDDIR)/qst2if $(BLDDIR)/qst2futf8 \
      $(BLDDIR)/qst2ifEPOCH16 $(BLDDIR)/qst2fOrig $(BLDDIR)/qst2ifTT2000 \
      $(BLDDIR)/qst2ifTT2000UnixTime
BINsCshare=$(BLDDIR)/qst2VersionS $(BLDDIR)/qst2cS $(BLDDIR)/qst2icS \
           $(BLDDIR)/qst2icEPOCH16S $(BLDDIR)/qst2cOrigS $(BLDDIR)/qst2icTT2000S
BINsFshare=$(BLDDIR)/qst2fS $(BLDDIR)/qst2ifS $(BLDDIR)/qst2ifEPOCH16S \
           $(BLDDIR)/qst2fOrigS $(BLDDIR)/qst2ifTT2000S \
           $(BLDDIR)/qst2ifTT2000UnixTimeS

WHICHOS=$(shell uname)
ifeq ("$(WHICHOS)","Darwin")
  MACVERSION=$(shell uname -r | cut -f1 -d.)
  LIBsSHARE=-Wl,-rpath,@loader_path/../src/lib -L$(BLDDIR)/../src/lib $(SYSLIBS) -lcdf
else
  MACVERSION=0
  LIBsSHARE=-L$(BLDDIR)/../src/lib -lcdf $(SYSLIBS) 
endif

#------------------------------------------------------------------------------
# Compile/link.
#------------------------------------------------------------------------------

all: c.yes cS.$(SHARED) f.$(FORTRAN) fS.$(FORTRAN).$(SHARED)

%.o : %.mod

c.yes: $(BINsC)

cS.yes: $(BINsCshare)
cS.no:

f.yes: $(BINsF)
f.no:

fS.yes.yes: $(BINsFshare)
fS.yes.no:
fS.no.yes:
fS.no.no:

$(BLDDIR)/qst2c: $(BLDDIR)/qst2c.o $(LIBCDFa)
	@echo $(CC) $(CFLAGSld) -o $@ $< $(LIBsARCHIVE)
	      $(CC) $(CFLAGSld) -o $@ $< $(LIBsARCHIVE)

$(BLDDIR)/qst2cOrig: $(BLDDIR)/qst2cOrig.o $(LIBCDFa)
	@echo $(CC) $(CFLAGSld) -o $@ $< $(LIBsARCHIVE)
	      $(CC) $(CFLAGSld) -o $@ $< $(LIBsARCHIVE)

$(BLDDIR)/qst2ic: $(BLDDIR)/qst2ic.o $(LIBCDFa)
	@echo $(CC) $(CFLAGSld) -o $@ $< $(LIBsARCHIVE)
	      $(CC) $(CFLAGSld) -o $@ $< $(LIBsARCHIVE)

$(BLDDIR)/qst2cutf8: $(BLDDIR)/qst2cutf8.o $(LIBCDFa)
	@echo $(CC) $(CFLAGSld) -o $@ $< $(LIBsARCHIVE)
	      $(CC) $(CFLAGSld) -o $@ $< $(LIBsARCHIVE)

$(BLDDIR)/qst2icEPOCH16: $(BLDDIR)/qst2icEPOCH16.o $(LIBCDFa)
	@echo $(CC) $(CFLAGSld) -o $@ $< $(LIBsARCHIVE)
	      $(CC) $(CFLAGSld) -o $@ $< $(LIBsARCHIVE)

$(BLDDIR)/qst2icTT2000: $(BLDDIR)/qst2icTT2000.o $(LIBCDFa)
	@echo $(CC) $(CFLAGSld) -o $@ $< $(LIBsARCHIVE)
	      $(CC) $(CFLAGSld) -o $@ $< $(LIBsARCHIVE)

$(BLDDIR)/qst2VersionS: $(BLDDIR)/qst2Version.o $(LIBCDFshare)
	@echo $(CC) $(CFLAGSld) -o $@ $< $(LIBsSHARE)
	      $(CC) $(CFLAGSld) -o $@ $< $(LIBsSHARE)

$(BLDDIR)/qst2cS: $(BLDDIR)/qst2c.o $(LIBCDFshare)
	@echo $(CC) $(CFLAGSld) -o $@ $< $(LIBsSHARE)
	      $(CC) $(CFLAGSld) -o $@ $< $(LIBsSHARE)

$(BLDDIR)/qst2cOrigS: $(BLDDIR)/qst2cOrig.o $(LIBCDFshare)
	@echo $(CC) $(CFLAGSld) -o $@ $< $(LIBsSHARE)
	      $(CC) $(CFLAGSld) -o $@ $< $(LIBsSHARE)

$(BLDDIR)/qst2icS: $(BLDDIR)/qst2ic.o $(LIBCDFshare)
	@echo $(CC) $(CFLAGSld) -o $@ $< $(LIBsSHARE)
	      $(CC) $(CFLAGSld) -o $@ $< $(LIBsSHARE)

$(BLDDIR)/qst2icEPOCH16S: $(BLDDIR)/qst2icEPOCH16.o $(LIBCDFshare)
	@echo $(CC) $(CFLAGSld) -o $@ $< $(LIBsSHARE)
	      $(CC) $(CFLAGSld) -o $@ $< $(LIBsSHARE)

$(BLDDIR)/qst2icTT2000S: $(BLDDIR)/qst2icTT2000.o $(LIBCDFshare)
	@echo $(CC) $(CFLAGSld) -o $@ $< $(LIBsSHARE)
	      $(CC) $(CFLAGSld) -o $@ $< $(LIBsSHARE)

$(BLDDIR)/qst2f: $(BLDDIR)/qst2f.o $(LIBCDFa)
	@if [ $(MACos) =  `uname` ] ; then \
	   if [ `uname -r | cut -f1 -d.` = 8 ]; then \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE) -lSystemStubs; \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE) -lSystemStubs; \
	   else \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	   fi \
	else \
	  echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	       $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	fi

$(BLDDIR)/qst2if: $(BLDDIR)/qst2if.o $(LIBCDFa)
	@if [ $(MACos) =  `uname` ] ; then \
	   if [ `uname -r | cut -f1 -d.` = 8 ]; then \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE) -lSystemStubs; \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE) -lSystemStubs; \
	   else \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	   fi \
	else \
	  echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	       $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	fi

$(BLDDIR)/qst2futf8: $(BLDDIR)/qst2futf8.o $(LIBCDFa)
	@if [ $(MACos) =  `uname` ] ; then \
	   if [ `uname -r | cut -f1 -d.` = 8 ]; then \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE) -lSystemStubs; \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE) -lSystemStubs; \
	   else \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	   fi \
	else \
	  echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	       $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	fi

$(BLDDIR)/qst2fOrig: $(BLDDIR)/qst2fOrig.o $(LIBCDFa)
	@if [ $(MACos) =  `uname` ] ; then \
	   if [ `uname -r | cut -f1 -d.` = 8 ]; then \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE) -lSystemStubs; \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE) -lSystemStubs; \
	   else \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	   fi \
	else \
	  echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	       $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	fi

$(BLDDIR)/qst2ifEPOCH16: $(BLDDIR)/qst2ifEPOCH16.o $(LIBCDFa)
	@if [ $(MACos) =  `uname` ] ; then \
	   if [ `uname -r | cut -f1 -d.` = 8 ]; then \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE) -lSystemStubs; \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE) -lSystemStubs; \
	   else \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	   fi \
	else \
	  echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	       $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	fi

$(BLDDIR)/qst2ifTT2000: $(BLDDIR)/qst2ifTT2000.o $(LIBCDFa)
	@if [ $(MACos) =  `uname` ] ; then \
	   if [ `uname -r | cut -f1 -d.` = 8 ]; then \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE) -lSystemStubs; \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE) -lSystemStubs; \
	   else \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	   fi \
	else \
	  echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	       $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	fi

$(BLDDIR)/qst2ifTT2000UnixTime: $(BLDDIR)/qst2ifTT2000UnixTime.o $(LIBCDFa)
	@if [ $(MACos) =  `uname` ] ; then \
	   if [ `uname -r | cut -f1 -d.` = 8 ]; then \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE) -lSystemStubs; \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE) -lSystemStubs; \
	   else \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	   fi \
	else \
	  echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	       $(FC) $(FFLAGSld) -o $@ $< $(LIBsARCHIVE); \
	fi

$(BLDDIR)/qst2fS:	$(BLDDIR)/qst2f.o $(LIBCDFshare)
	@if [ $(MACos) =  `uname` ] ; then \
	   if [ `uname -r | cut -f1 -d.` = 8 ]; then \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE) -lSystemStubs; \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE) -lSystemStubs; \
	   else \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	   fi \
	else \
	  echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	       $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	fi

$(BLDDIR)/qst2ifS: $(BLDDIR)/qst2if.o $(LIBCDFshare)
	@if [ $(MACos) =  `uname` ] ; then \
	   if [ `uname -r | cut -f1 -d.` = 8 ]; then \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE) -lSystemStubs; \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE) -lSystemStubs; \
	   else \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	   fi \
	else \
	  echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	       $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	fi

$(BLDDIR)/qst2fOrigS: $(BLDDIR)/qst2fOrig.o $(LIBCDFshare)
	@if [ $(MACos) =  `uname` ] ; then \
	   if [ `uname -r | cut -f1 -d.` = 8 ]; then \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE) -lSystemStubs; \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE) -lSystemStubs; \
	   else \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	   fi \
	else \
	  echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	       $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	fi

$(BLDDIR)/qst2ifEPOCH16S: $(BLDDIR)/qst2ifEPOCH16.o $(LIBCDFshare)
	@if [ $(MACos) =  `uname` ] ; then \
	   if [ `uname -r | cut -f1 -d.` = 8 ]; then \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE) -lSystemStubs; \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE) -lSystemStubs; \
	   else \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	   fi \
	else \
	  echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	       $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	fi

$(BLDDIR)/qst2ifTT2000S: $(BLDDIR)/qst2ifTT2000.o $(LIBCDFshare)
	@if [ $(MACos) =  `uname` ] ; then \
	   if [ `uname -r | cut -f1 -d.` = 8 ]; then \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE) -lSystemStubs; \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE) -lSystemStubs; \
	   else \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	   fi \
	else \
	  echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	       $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	fi

$(BLDDIR)/qst2ifTT2000UnixTimeS: $(BLDDIR)/qst2ifTT2000UnixTime.o $(LIBCDFshare)
	@if [ $(MACos) =  `uname` ] ; then \
	   if [ `uname -r | cut -f1 -d.` = 8 ]; then \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE) -lSystemStubs; \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE) -lSystemStubs; \
	   else \
	     echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	          $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	   fi \
	else \
	  echo $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	       $(FC) $(FFLAGSld) -o $@ $< $(LIBsSHARE); \
	fi

$(BLDDIR)/%.o: %.c
	@echo $(CC) $(CFLAGS) -c $< -o $@
	      $(CC) $(CFLAGS) -c $< -o $@

$(BLDDIR)/%.o: %.f
	@echo $(FC) $(FFLAGS) -c $< -o $@
	      $(FC) $(FFLAGS) -c $< -o $@

$(BLDDIR)/qst2Version.o: qst2Version.c $(CDFh)
$(BLDDIR)/qst2c.o: qst2c.c $(CDFh)
$(BLDDIR)/qst2cOrig.o: qst2cOrig.c $(CDFh)
$(BLDDIR)/qst2cutf8.o: qst2cutf8.c $(CDFh)
$(BLDDIR)/qst2ic.o: qst2ic.c $(CDFh)
$(BLDDIR)/qst2icEPOCH16.o: qst2icEPOCH16.c $(CDFh)
$(BLDDIR)/qst2icTT2000.o: qst2icTT2000.c $(CDFh)
$(BLDDIR)/qst2f.o: qst2f.f $(CDFh) $(CDFinc)
$(BLDDIR)/qst2if.o: qst2if.f $(CDFh) $(CDFinc)
$(BLDDIR)/qst2fOrig.o: qst2fOrig.f $(CDFh) $(CDFinc)
$(BLDDIR)/qst2futf8.o: qst2futf8.f $(CDFh) $(CDFinc)
$(BLDDIR)/qst2ifEPOCH16.o: qst2ifEPOCH16.f $(CDFh) $(CDFinc)
$(BLDDIR)/qst2ifTT2000.o: qst2ifTT2000.f $(CDFh) $(CDFinc)
$(BLDDIR)/qst2ifTT2000UnixTime.o: qst2ifTT2000UnixTime.f $(CDFh) $(CDFinc)

#------------------------------------------------------------------------------
# Tests.
#     Each executable name is preceeded by `./' in case the current directory
# is not in the path.
#------------------------------------------------------------------------------

test:
	@if [ -f TEST.cdf ] ; then \rm TEST.* ; else $(NULL) ; fi
	@echo ""
	@echo "Testing CDF library..."
	@echo ""
	@$(BLDDIR)/qst2c
	@$(BLDDIR)/qst2cOrig
	@$(BLDDIR)/qst2ic
	@if [ -f $(BLDDIR)/qst2cutf8 ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2cutf8 ; else $(NULL) ; fi
	@$(BLDDIR)/qst2icEPOCH16
	@if [ -f $(BLDDIR)/qst2icTT2000 ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2icTT2000 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2f ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2f ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2if ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2if ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2fOrig ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2fOrig ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2futf8 ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2futf8 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2ifEPOCH16 ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2ifEPOCH16 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2ifTT2000 ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2ifTT2000 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2ifTT2000UnixTime ] ; then $(MAKE) BLDDIR=$(BLDDIR) -f $(BLDDIR)/$(MAKEFILE) test.qst2ifTT2000UnixTime ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2VersionS ] ; then \
	  echo ""; echo "Testing shareable CDF library..."; echo "" ; \
	 else $(NULL) ; \
	fi
# If Mac OX 10.11 (version 15) and later... use special handling
	@if [ $(MACVERSION) -lt 15 ] ; then \
	        $(MAKE) MAKE=$(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.normalShare ; \
	else \
	        $(MAKE) MAKE=$(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.Mac15Share ; \
	fi

test.normalShare:
	@if [ -f $(BLDDIR)/qst2VersionS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2VersionS ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2cS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2cS ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2cOrigS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2cOrigS ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2icS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2icS ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2icEPOCH16S ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2icEPOCH16S ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2icTT2000S ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2icTT2000S ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2fS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2fS ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2ifS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2ifS ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2fOrigS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2fOrigS ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2ifEPOCH16S ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2ifEPOCH16S ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2ifTT2000S ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2ifTT2000S ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2ifTT2000UnixTimeS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2ifTT2000UnixTimeS ; else $(NULL) ; fi

test.Mac15Share:
	@if [ -f $(BLDDIR)/qst2VersionS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2VersionS15 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2cS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2cS15 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2cOrigS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2cOrigS15 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2icS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2icS15 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2icEPOCH16S ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2icEPOCH16S15 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2icTT2000S ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2icTT2000S15 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2fS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2fS15 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2ifS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2ifS15 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2fOrigS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2fOrigS15 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2ifEPOCH16S ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2ifEPOCH16S15 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2ifTT2000S ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2ifTT2000S15 ; else $(NULL) ; fi
	@if [ -f $(BLDDIR)/qst2ifTT2000UnixTimeS ] ; then $(MAKE) -f $(BLDDIR)/$(MAKEFILE) BLDDIR=$(BLDDIR) test.qst2ifTT2000UnixTimeS15 ; else $(NULL) ; fi

test.qst2VersionS:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(DYLD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2VersionS

test.qst2cS:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(DYLD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2cS

test.qst2cOrigS:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(DYLD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2cOrigS

test.qst2cutf8:
	$(BLDDIR)/qst2cutf8

test.qst2icS:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(DYLD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2icS

test.qst2icEPOCH16S:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(DYLD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2icEPOCH16S

test.qst2icTT2000:
	@export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2icTT2000

test.qst2icTT2000S:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(DYLD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2icTT2000S

test.qst2f:
	@export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2f

test.qst2fS:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(DYLD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2fS

test.qst2if:
	@export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2if

test.qst2ifS:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(DYLD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2ifS

test.qst2fOrigS:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(DYLD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2fOrigS

test.qst2fOrig:
	@export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2fOrig

test.qst2futf8:
	$(BLDDIR)/qst2futf8

test.qst2ifEPOCH16:
	@export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2ifEPOCH16

test.qst2ifEPOCH16S:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(DYLD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2ifEPOCH16S

test.qst2ifTT2000:
	@export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2ifTT2000

test.qst2ifTT2000S:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(DYLD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2ifTT2000S

test.qst2ifTT2000UnixTime:
	@export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2ifTT2000UnixTime

test.qst2ifTT2000UnixTimeS:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(DYLD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2ifTT2000UnixTimeS

test.qst2VersionS15:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2VersionS

test.qst2cS15:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2cS

test.qst2cOrigS15:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2cOrigS

test.qst2icS15:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2icS

test.qst2icEPOCH16S15:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2icEPOCH16S

test.qst2icTT2000S15:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2icTT2000S

test.qst2fS15:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2fS

test.qst2ifS15:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2ifS

test.qst2fOrigS15:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2fOrigS

test.qst2ifEPOCH16S15:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2ifEPOCH16S

test.qst2ifTT2000S15:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2ifTT2000S

test.qst2ifTT2000UnixTimeS15:
	@export LD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export DYLD_LIBRARY_PATH="$(BLDDIR)/../src/lib:$(LD_LIBRARY_PATH)" ; \
	export PATH="$(BLDDIR)/../src/lib:$(PATH)" ; \
	export CDF_LEAPSECONDSTABLE="$(BLDDIR)/../CDFLeapSeconds.txt" ; \
	$(BLDDIR)/qst2ifTT2000UnixTimeS

#------------------------------------------------------------------------------

#------------------------------------------------------------------------------

clean:
	@-rm -f $(BLDDIR)/*.o
	@-rm -f $(BLDDIR)/*.exe
	@-rm -f $(BLDDIR)/qst2c
	@-rm -f $(BLDDIR)/qst2cOrig
	@-rm -f $(BLDDIR)/qst2cutf8
	@-rm -f $(BLDDIR)/qst2ic
	@-rm -f $(BLDDIR)/qst2iEPOCH16c
	@-rm -f $(BLDDIR)/qst2f
	@-rm -f $(BLDDIR)/qst2if
	@-rm -f $(BLDDIR)/qst2fOrig
	@-rm -f $(BLDDIR)/qst2iEPOCH16f
	@-rm -f $(BLDDIR)/qst2VersionS
	@-rm -f $(BLDDIR)/qst2cS
	@-rm -f $(BLDDIR)/qst2cOrigS
	@-rm -f $(BLDDIR)/qst2icS
	@-rm -f $(BLDDIR)/qst2icEPOCH16
	@-rm -f $(BLDDIR)/qst2icEPOCH16S
	@-rm -f $(BLDDIR)/qst2icTT2000
	@-rm -f $(BLDDIR)/qst2icTT2000S
	@-rm -f $(BLDDIR)/qst2fS
	@-rm -f $(BLDDIR)/qst2ifS
	@-rm -f $(BLDDIR)/qst2fOrigS
	@-rm -f $(BLDDIR)/qst2futf8
	@-rm -f $(BLDDIR)/qst2ifEPOCH16
	@-rm -f $(BLDDIR)/qst2ifEPOCH16S
	@-rm -f $(BLDDIR)/qst2ifTT2000
	@-rm -f $(BLDDIR)/qst2ifTT2000S
	@-rm -f $(BLDDIR)/qst2ifTT2000UnixTime
	@-rm -f $(BLDDIR)/qst2ifTT2000UnixTimeS
	@-rm -f $(BLDDIR)/qstleapsecondsinfo
	@-rm -f $(BLDDIR)/*.trace
	@-rm -f $(BLDDIR)/core
	@-rm -f $(BLDDIR)/*.cdf

purge:
	@-rm -f $(BLDDIR)/*~
	@-rm -f $(BLDDIR)/*#
