
SHELL = /bin/sh

#=============================================================================
#
#  This is a template makefile to build a product.
#
#  This file is designed to be invoked by a shell script called sdssmake
#  which selects supported options.
#
#  The following products must be setup when making such a product:
#	dervish		- for dervish libraries and include files.
#	sdsstools	- for sdssmake and filter_warn
#	tex		- for making the postscript documentation
#
#  INSTALL_DIR    --- Root directory into which the product is to be installed.
#                     For example, INSTALL_DIR = $(MYSCH_DIR).
#  SUBDIRECTORIES --- List of subdirectories contained in the root directory
#                     for this product (i.e., this directory).
#
#  For example, for the product "mySch":
#     INSTALL_DIR   = $(MYSCH_DIR)
#     SUBDIRECTORIES= bin doc etc examples include lib src test ups
#
#=============================================================================

INSTALL_DIR	= $(TARGET_INSTALL_DIR)
SUBDIRECTORIES	= bin doc etc examples include lib src test ups

#=============================================================================
#
# You should not have to edit any of the rest of this file, if all you are
# doing is building one class library and one executable, and some supporting
# TCL scripts.
#
#=============================================================================

#===========================================================================
# STANDARD TARGETS
#===========================================================================

default:
	@ echo Please invoke this makefile using sdssmake. >&2
	@ exit 1

all :
	@ echo "Updating libraries and directories"
	@ echo ""
	@ for f in $(SUBDIRECTORIES); do \
		(cd $$f ; echo In $$f; $(MAKE) $(MFLAGS) all ); \
	done

make :
	@echo "Making make files"
	@echo ""
	@ for f in src; do \
		(cd $$f ; echo In $$f; $(MAKE) $(MFLAGS) make ); \
	done

install :
	@ echo ""
	@ echo "You should be sure to have updated before doing this."
	@ if [ "$(INSTALL_DIR)" = "" ]; then \
		echo You have not specified a destination directory >&2; \
		exit 1; \
	fi 
	@ if [ `(cd $(INSTALL_DIR); pwd)` = `pwd` ]; then \
		echo "The destination directory is the same as the current directory." >&2; \
		echo "The install will be aborted." >&2; \
		exit 1; \
	fi
	@ echo ""
	@ echo "You will be installing in \$$INSTALL_DIR = $(INSTALL_DIR)"
	@ echo ""
	@ echo "I'll give you 5 seconds to think about it (control-C to abort) ..."
	@ for pos in          5 4 3 2 1; do \
	   echo "                              " | sed -e 's/ /'$$pos'/'$$pos; \
	   sleep 1; \
	done
	@ rm -rf $(INSTALL_DIR)
	@ mkdir $(INSTALL_DIR)
	@ for f in $(SUBDIRECTORIES); do \
		(cd $$f ; echo In $$f; $(MAKE) $(MFLAGS) install ); \
	done
	/bin/cp Makefile $(INSTALL_DIR)

clean :
	@ echo in .
	rm -f *~ core *.bak *.orig *.old .#* #*#
	@ for f in $(SUBDIRECTORIES); do \
		(cd $$f ; echo In $$f; $(MAKE) $(MFLAGS) clean); \
	done
