#!/bin/sh


: script used to extract .SH files with variable substitutions

mkdir -p UU
cd UU
cat >extract <<'EOS'
PERL_CONFIG_SH=true
echo "Doing variable substitutions on .SH files..."
if test -f MANIFEST; then
        set x `awk '{print $1}' < MANIFEST | grep '\.SH$'`
else
        echo "(Looking for .SH files under the source directory.)"
        set x `(cd "$src"; find . -name "*.SH" -print)`
fi
shift
case $# in
0) set x `(cd "$src"; echo *.SH)`; shift;;
esac
if test ! -f "$src/$1"; then
        shift
fi
mkdir_p='
name=$1;
create="";
while test $name; do
        if test ! -d "$name"; then
                create="$name $create";
                name=`echo $name | sed -e "s|^[^/]*$||"`;
                name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
        else
                name="";
        fi;
done;
for file in $create; do
        mkdir $file;
done
'
for file in $*; do
        case "$src" in
        ".")
                case "$file" in
                */*)
                        dir=`expr X$file : 'X\(.*\)/'`
                        file=`expr X$file : 'X.*/\(.*\)'`
                        (cd "$dir" && . ./$file)
                        ;;
                *)
                        . ./$file
                        ;;
                esac
                ;;
        *)
                case "$file" in
                */*)
                        dir=`expr X$file : 'X\(.*\)/'`
                        file=`expr X$file : 'X.*/\(.*\)'`
                        (set x $dir; shift; eval $mkdir_p)
                        sh <"$src/$dir/$file"
			;;
                *)
                        sh <"$src/$file"
                        ;;
                esac
                ;;
        esac
done
if test -f "$src/config_h.SH"; then
        if test ! -f config.h; then
        : oops, they left it out of MANIFEST, probably, so do it anyway.
        . "$src/config_h.SH"
        fi
fi
EOS

cd ..

# For now
make=make

echo "Run a copy of the end of Configure"

: if this fails, just run all the .SH files by hand
. ./config.sh

echo " "

pwd=`pwd`
. ./UU/extract
cd "$pwd"


echo "Run $make depend unconditionally"
$make depend && echo "Now you must run '$make'."

if $test -f Policy.sh; then
    $cat <<EOM

If you compile $package on a different machine or from a different object
directory, copy the Policy.sh file from this object directory to the
new one before you run Configure -- this will help you with most of
the policy defaults.

EOM
fi
if $test -f config.msg; then
    echo "Hmm.  I also noted the following information while running:"
    echo " "
    $cat config.msg >&4
    $rm -f config.msg
fi
$rm -f kit*isdone ark*isdone
$rm -rf UU

: End of Configure

