#!/bin/sh

# file: $USFS/util/make/make_all_dirs.sh
#
# this function actually does the work of building a single directory
# its arguments are:
#
#    make_all_dirs.sh <directory> make_options...
#
# for example,
#
#    make_all_dirs.sh $PWD install
#
# this will run make in the directory $PWD using make's install target.
#

# important definitions
#
ISIP_MAKEFILE="GNUmakefile";

# define a function to build a subdirectory
#
build_dir () {

    # descend into that directory
    #
    cd $DIR;

    # only make the directory if a valid makefile exists
    #
    if (test -f "$ISIP_MAKEFILE") then

	# echo the directory
	#
	echo " ... building $DIR ...";

	# build the directory
	#
	$ISIP_MAKE $MAKE_OPTS;
    fi
}

# grab the directory
#
DIR="$1";

# grab the make options
#
shift;
MAKE_OPTS="$*";

# execute a make for the argument
# 
build_dir;

# exit gracefully
# 
exit 0;
