# Generate an "INSTALL_DIR" makefile macro.
# If INSTALL_DIR is already defined and non-null, use it.
# Otherwise use "$1", or failing that, $HOME.
# Makefile segment is printed to stdout, and equivalent environment variable
# is set.

[ -z "$INSTALL_DIR" ] && INSTALL_DIR="${1:-$HOME}"

echo "Setting installation parent directory to $INSTALL_DIR" 1>&2

cat << EOT

# Where are we to be installed?
# (specify the top-level directory, not the "bin", "lib" or "man" subdirectory)
#
INSTALL_DIR=$INSTALL_DIR

EOT

export INSTALL_DIR
