#---------------------------------------------------------------------------#
#									    #
#	COPYRIGHT	1994, 1995, 1996     Applied Research Corporation   #
#									    #
#			1997, 1998	     Space Applications Corporation #
#									    #
#			ALL RIGHTS RESERVED				    #
#									    #
#---------------------------------------------------------------------------#
#----------------------------------------------------------------------------
# file:		makefile for stand-alone metadata toolkit
#               (using some of PGS Toolkit source group directories)
#
# environment:	MPPDE, machine-independent, PGS directory structure
# 	
# environment variables dependencies:
#   compilers:  CC F77
#   includes:  PGSINC
#   libraries: PGSLIB
#   compilation flags:
#	CFLAGS		common C flags
#	C_CFH		C source + cfortran.h, FORTRAN callable (old CFHFLAGS)
#  	C_F77_CFH	C source + cfortran.h calls FORTRAN obj
#  	C_F77_LIB	libs needed when compiling C, linking to FORTRAN obj
#	F77FLAGS	common F77 flags     
#	F77_C_CFH	FORTRAN source, calls C_CFH C code (old CFH_F77)
#	F77_C_LIB	libs needed when compiling FORTRAN, linking to C obj
#   other:     PGSBIN PGSSRC
#
#
# author:  Mike Sucher 
# revised by: Abe Taaheri  for stand-alone metadata toolkit
#
# history:
#	13-Apr-1994 MES Initital version
#	18-Apr-1994 MES Pass all PGS env variables, and 
# 			call mkpgslib with $PGSHOME override
#	01-Sep-1994 MES Modified C and FORTRAN libs to use the 
# 			Release 3 library libPGSTK.a
# 	08-Sep-1994 MES Clean up target all - remove $(SUBGROUPS) from
# 			target list for recursive call to 'make'.
# 	10-Feb-1995 MES Fix up targets to deal with the unruly UDUNITS
# 			software package.
# 	09-Nov-1995 MES Fix target makechange to handle sgi32 and sgi64.
#       15-Oct-2004 PN  Added tk_PCSMF_bindFORTRAN, remove tk_PC_bindFORTRAN
#                       & tk_SMF_bindFORTRAN to fix fortran problem on sun5.8
# notes:
# 	1) This file is intended for use in the Multi-Platform PGS Development
#       25-Sep-1998 RSTX change GRP = AUX to GRP = EXTRA
# 	   Environment (MPPDE) .  It depends on the PGS-defined toolkit 
# 	   directory structure, and on environmental variables defined
# 	   by MPPDE startup files.  This is how machine independence
# 	   is maintained.
#
# 	2) This makefile calls all subgroup makefiles to build the object
# 	   files needed for the group library.  Then it calls the utility
# 	   mkpgslib to build the library for this tool group.
#
# 	3) Variable SUBGROUPS must be set for each tool group to be built.
#
#----------------------------------------------------------------------------

#
# Set the name of this tool group
#

GRP= EXTRA

# force make to use the 'sh' shell
SHELL = /bin/sh

# Default target
TARG=all

# name of remove utility
RM= /bin/rm
RMFLAGS= -f 

# define C preprocessor symbols 
DFLAGS  = -D$(HDFSYS)

# path for #include directive
IFLAG   = -I$(PGSINC) -I$(HDFINC) -I$(HDF5INC) -I$(HDFEOS_INC)


# object files from this sub-group needed to build library
LIBOFILES = \
	$(PGSOBJ)/$(GRP)/tk_SMF.o \
	$(PGSOBJ)/$(GRP)/tk_Env.o \
	$(PGSOBJ)/$(GRP)/tk_PC_files.o \
	$(PGSOBJ)/$(GRP)/tk_PCSMF_bindFORTRAN.o

#
# General rules
#

all:	message $(LIBOFILES) lib

lib:
	@$(PGSBIN)/mkpgslib $(GRP)

# dummy target to force make
makeme:

message:
	@echo "    Makefile for group: $(GRP); Target: all"

clean:
	$(RM) $(RMFLAGS) core *.o $(LIBOFILES)

#
# compilation rules
#

$(PGSOBJ)/$(GRP)/tk_SMF.o: tk_SMF.c
	$(CC) -c $(CFHFLAGS) $(DFLAGS) $(IFLAG) $? -o $@

$(PGSOBJ)/$(GRP)/tk_Env.o: tk_Env.c
	$(CC) -c $(CFHFLAGS) $(DFLAGS) $(IFLAG) $? -o $@

$(PGSOBJ)/$(GRP)/tk_PC_files.o: tk_PC_files.c
	$(CC) -c $(CFHFLAGS) $(DFLAGS) $(IFLAG) $? -o $@

$(PGSOBJ)/$(GRP)/tk_PCSMF_bindFORTRAN.o: tk_PCSMF_bindFORTRAN.c
	$(CC) -c $(CFHFLAGS) $(DFLAGS) $(IFLAG) $? -o $@

# compile C to executable
.c.o:
	$(MAKE) $(MFLAGS) $(PGSOBJ)/$(GRP)/$@
