#---------------------------------------------------------------------------#
#									    #
#	COPYRIGHT	1994, 1995, 1996     Applied Research Corporation   #
#									    #
#			1997, 1998	     Space Applications Corporation #
#									    #
#			ALL RIGHTS RESERVED				    #
#									    #
#---------------------------------------------------------------------------#
# file:		makefile for PGS Toolkit source directory
#
# 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
# 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 Revisions for Release 3:
# 			- Renamed target 'message' to 'success'
# 			- Revised target 'all'.
# 			- Reformatted target '_groups'.
# 	02-Sep-1994 MES Added target 'cleano'
# 			Added target 'pgstk'
# 			Revised target 'all' to call 'pgstk' and 'cleano'
# 	13-Sep-1994 MES Revised target 'cleano' to use rm -f instead of rm.
# 	30-Dec-1994 MES Added the tool group: GCT
#       20-Feb-1998 AT Rmoved tools that are not required for stand alone 
#       25-Sep-1998 RSTX  change AUX to EXTRA
#                      Metadata tools
# notes:
# 	1) This file is dependent on the PGS-defined toolkit directory 
# 	   structure, and on environment variables defined by PGS 
# 	   environment startup files.  This is how machine independence
# 	   is maintained.
#----------------------------------------------------------------------------

# Define sh shell
SHELL=/bin/sh

# Default target
TARG=all

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

#
# PGS Toolkit Groups
#

#PGS_GROUPS=  EXTRA CBP CSC CUC IO MEM MET PC SMF TD XML
PGS_GROUPS=  EXTRA CBP CSC CUC IO MEM MET TD XML

#
#
# General rules
#

all:	announce $(PGS_GROUPS)

announce:
	@echo "MTD Toolkit top level makefile..."

utilities:
	@$(MAKE) $(MFLAGS) CSC TD TARG=utilities

ephtobin:
	@$(MAKE) $(MFLAGS) CBP TARG=ephtobin

# dummy target to force make
makeme:

# Target to make EXTRA (Auxiliary) tools
EXTRA: makeme
	@echo ""; cd $@; echo Making \`$(TARG)\' in ./$@; \
              $(MAKE) $(MFLAGS) GRP=$@ $(TARG)

# Target to make CBP tools
CBP: makeme
	@echo ""; cd $@; echo Making \`$(TARG)\' in ./$@; \
              $(MAKE) $(MFLAGS) GRP=$@ $(TARG)

# Target to make CSC tools
CSC: makeme
	@echo ""; cd $@; echo Making \`$(TARG)\' in ./$@; \
              $(MAKE) $(MFLAGS) GRP=$@ $(TARG)

# Target to make CUC tools
CUC: makeme
	@echo ""; cd $@; echo Making \`$(TARG)\' in ./$@; \
              $(MAKE) $(MFLAGS) GRP=$@ $(TARG)

# Target to make IO tools
IO: makeme
	@echo ""; cd $@; echo Making \`$(TARG)\' in ./$@; \
              $(MAKE) $(MFLAGS) GRP=$@ $(TARG)

# Target to make MEM tools
MEM: makeme
	@echo ""; cd $@; echo Making \`$(TARG)\' in ./$@; \
              $(MAKE) $(MFLAGS) GRP=$@ $(TARG)

# Target to make MET tools
MET: makeme
	@echo ""; cd $@; echo Making \`$(TARG)\' in ./$@; \
              $(MAKE) $(MFLAGS) GRP=$@ $(TARG)

# Target to make PC tools
#PC: makeme
#	@echo ""; cd $@; echo Making \`$(TARG)\' in ./$@; \
#              $(MAKE) $(MFLAGS) GRP=$@ $(TARG)

# Target to make SMF tools
#SMF: makeme
#	@echo ""; cd $@; echo Making \`$(TARG)\' in ./$@; \
#              $(MAKE) $(MFLAGS) GRP=$@ $(TARG)

# Target to make TD tools
TD: makeme
	@echo ""; cd $@; echo Making \`$(TARG)\' in ./$@; \
              $(MAKE) $(MFLAGS) GRP=$@ $(TARG)

# Target to make XML tools
XML: makeme
	@echo ""; cd $@; echo Making \`$(TARG)\' in ./$@; \
              $(MAKE) $(MFLAGS) GRP=$@ $(TARG)

# Run "make clean" in each of the tool directories
clean:
	@$(MAKE) $(MFLAGS) TARG=$@ $(PGS_GROUPS)
	$(RM) $(RMFLAGS) core *.log *.o

# Search for and remove all .o files from source and object directories
cleano:
	@echo "Removing all object files in TOOLKIT source directories..." ; \
	find $(PGSSRC) -name \*.o -print -exec rm -f {} \; 
	@echo "Removing all object files in TOOLKIT object directories..." ; \
	find $(PGSOBJ) -name \*.o -print -exec rm -f {} \;
