dir=${dir:-../../src}
# Get the canonical directory name
case "$dir" in 
	/*)   
		;; 
	*)	
		dir=`cd "$dir" && pwd || echo "$dir"`
		;;
esac
echo "Directory under test is $dir"
sccs_dir=${dir}/../bsd


# Make a variable for each CSSC command.  These are the commands we run 
# in order to set up each test.  Because they are variables, we can set
# them (and $dir) to test any set of binaries we want.
get=${get:-${dir}/get}
admin=${admin:- ${dir}/admin}
cdc=${cdc:-${dir}/cdc}
prs=${prs:-${dir}/prs}
prt=${prt:-${dir}/prt}
delta=${delta:-${dir}/delta}
sact=${sact:-${dir}/sact}
sccsprog=${sccsprog:-${sccs_dir}/sccs}
sccsdiff=${sccsdiff:-${dir}/sccsdiff}
unget=${unget:-${dir}/unget}
what=${what:-${dir}/what}
val=${val:-${dir}/val}
rmdel=${rmdel:-${dir}/rmdel}


DIFF=${DIFF:-diff}

for f in ${get} ${admin} ${csc} ${prs} ${prt} \
	${delta} ${sact} ${sccsdiff} ${unget} ${what} ${rmdel}
do
	case $f in 
		/*)
			test -x "$f" || echo "WARNING: cannot execute $f" >&2
			;;
		*)
			;;
	esac
done

# Find the sccs driver program.   Note that we use ${sccsprog} here;
# ${sccsprog} was set, above.

# We need to run the candidate 
# to find out if it accepts the --prefix option.

if test x"${sccs}" = x
then
    if test x"${sccsprog}" = x
    then
        if test -f "${dir}/sccs"
        then
        sccsprog="${dir}/sccs"
        elif test -f "${dir}/bsd/sccs"
        then
        sccsprog="${dir}/bsd/sccs"
        else
        case "${dir}" in 
            /*)    sccsprog="${dir}/bsd/sccs"
                    ;;
            ../..) sccsprog="${dir}/bsd/sccs"
                    ;;
            *) sccsprog="sccs"
                    ;;
        esac
        fi
    fi

    # Find out if it takes the --prefix option.  If so,
    # use it.
    if ${sccsprog} --cssc >/dev/null 2>&1
    then
        sccsargs="--prefix=${dir}/"
    else
        sccsargs=""
    fi

    sccs="${sccsprog} ${sccsargs}"
fi

# Allow the user to disable Valgrind via the 
# environment, so that we can still execute
# "make dist" quickly when that's useful.
if test -n "$CSSC_DISABLE_VALGRIND"; then
   unset VALGRIND
fi

# Set up some valgrind-enabled commands so that we can use these
# in a targeted way.   If we use valgrind for every invocation,
# the regression tests will run very slowly.
vg_get="${VALGRIND} ${get}"
vg_admin="${VALGRIND} ${admin}"
vg_cdc="${VALGRIND} ${cdc}"
vg_prs="${VALGRIND} ${prs}"
vg_prt="${VALGRIND} ${prt}"
vg_delta="${VALGRIND} ${delta}"
vg_sact="${VALGRIND} ${sact}"
vg_sccsdiff="${VALGRIND} ${sccsdiff}"
vg_unget="${VALGRIND} ${unget}"
vg_what="${VALGRIND} ${what}"
vg_val="${VALGRIND} ${val}"
vg_rmdel="${VALGRIND} ${rmdel}"
vg_sccs="${VALGRIND} ${sccs}"
