
# To rebuild tool(s) without first removing all object files (e.g., to
# continue after fixing a syntax error), invoke as "make <target> CLEAN="
#
CLEAN=clean

G960BASE=${G960ROOT}/${HOST}

gnu:	${TOOLS} ${GLIBS}

intel:	${ILIBS}

all:	gnu intel

clean:
	-@cwd=`pwd`; \
	for T in ${TOOLS} ${LIBPATHS} ; do \
		echo "=============== $$T ==============="; \
		cd src/$$T/${HOST}; make clean; cd $$cwd; \
	done

# Do before building a release.  On all 'common' source directories:
#   o check for locked files
#   o set VERSION file to specified version number
#   o make clean
#   o check out most current copy of all RCS'd files
#   o distribute most current makefile to host-specific directories
#
# Invoke with VERSION=<release version number>.
prerelease:
	@case ${VERSION}y in \
	y) \
	   echo "Specify 'VERSION=' on make invocation";\
	   exit 1 ;; \
	esac
	-@cwd=`pwd`;						\
	for T in ${TOOLS} ${LIBPATHS} ; do			\
		echo "=============== $$T ===============";	\
		cd src/$$T/common;				\
		LOCKED=`rlog -R -L RCS/*` ;			\
		if test x"$$LOCKED" != x ; then			\
			echo "WARNING: RCS files are checked-out:"; \
			for l in $$LOCKED; do			\
				echo "	"$$l ;			\
			done					\
		fi ;						\
		echo '${VERSION}' >VERSION ;			\
		make clean;					\
		co RCS/* ;					\
		cd $$cwd ;					\
	done
	mkmake ${TOOLS} ${LIBPATHS}


# Build a single tool or library.  "Subroutine" target, not to be invoked
# directly.  "Arguments" passed in:
#	DIR	Name of src subdirectory
#	HOST	Name of host
#	CLEAN	"clean" to clean before build;  "" to build without cleaning
#	TARGET	"install" for tools;  "install_gnu" or "install_intel" for libs
#
# Note that two environment variables are set in the invocation of the lower-
# level makefile (G960BASE and PATH) so the GNU tools (hopefully already built)
# can be used in building the libraries.  G960BASE is also passed as a make
# macro so the lower-level makefile can know where to install the tools or
# libraries it builds.
# 
tool:
	@case ${HOST}y in \
	y) \
	   echo "Specify 'HOST=' on make invocation";\
	   exit 1 ;; \
	esac
	@echo "=============== ${DIR}: ${TARGET} ==============="
	cd src/${DIR}/${HOST} && \
	G960BASE=${G960BASE} PATH="${G960BASE}/bin:$$PATH" \
			make ${CLEAN} ${TARGET} G960BASE=${G960BASE}

