#!/bin/sh
#
# This file is part of SnarfNews
# Copyright (C) 1991,1992,1993,1994,1995,1996 Alec Muffett
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

PATH="$PATH:/usr/local/bin:/usr/sbin:/sbin:/usr/bin:/bin:/usr/ccs/bin:/usr/ucb:/usr/etc:/usr/lib:/etc"
export PATH

echo "Configure: cleaning up..."
sleep 1
make

for path in `echo $PATH | tr : ' '`
do
    if [ -x $path/perl5 ]
    then
	perl=$path/perl5
	break
    fi

    if [ -x $path/perl ]
    then
	perl=$path/perl
	break
    fi
done

echo ""
echo "Configure: where is your perl5 binary? [$perl]"
read ans

case "$ans" in
    "")
	;;
    /*)
	perl=$ans
	;;
    *)
	echo "error: must be a full pathname"
	exit 1
	;;
esac

echo ""
echo "Configure: using $perl..."

if [ ! -x $perl ]
then
    echo "error: $perl is not an executable."
    exit 1
fi

if $perl -e 'exit 0 if ($] < 5) ; exit 1'
then
    echo "error: $perl is not perl5, perhaps an earlier revision?"
    exit 1
fi

if $perl -e "exit 1 if (-B \"$perl\"); exit 0"
then
    echo "error: $perl is not a binary."
    exit 1
fi

for file in `find lib ! -type l -type f -print`
do
    $perl -pi~ -e "s:^#!\s*/\S+/perl([\d\.]+)?\b:#!$perl:go" $file
done

echo "Configure: done."

echo ""
echo "Configure: now edit the 'snarf' script to suit your taste"

exit 0

