#
# Run this script one time from a requirements directory to install the generic
# requirements Makefile and its subsidiary csh scripts.  As a convenience, the
# script also installs the simple requirments testing files in ../testing/
# requirements.
#

#
# Set the PROJECT_SUPPORT_DIR envir var if not already set.
#
if (`printenv PROJECT_SUPPORT_DIR` == "") then
    setenv PROJECT_SUPPORT_DIR ~/work/support
endif

#
# Set the source dirs for the files to be copied.
#
set srd = $PROJECT_SUPPORT_DIR/configuration/requirements
set strd = $PROJECT_SUPPORT_DIR/configuration/testing/requirements

#
# Ensure that we are in a requirements directory.  If so, proceed with the
# copying.  The copying can be forced from a non-requirements dir if -f is
# given as the first command-line arg.
#
set d = `pwd`
set d = $d:t
set f = $1
shift
echo "$f"
if (($d != "requirements") && ("$f" != '-f')) then
    echo "This script must be run from a projects requirements directory."
else
    cp $srd/Makefile \
       $srd/.check-gif-dates.csh \
       $srd/.make-ps-links.csh \
       $srd/.update-gifs.csh \
       .
endif

#
# Ensure there's a ../testing/requirements dir and if not, make one.  Then copy
# over the simple testing files.
#
if (! -e ../testing) then
    mkdir ../testing
    mkdir ../testing/requirements
else
    if (! -e ../testing/requirements) then
        mkdir ../testing/requirements
    endif
endif

cp $strd/.make-{test,good}.csh ../testing/requirements
