#!/bin/sh
# configure 1.2 (96/05/21)
# This script prepends a suitable perl binary path to the yacht script.
# This path can differ from system to system.
#
# Richard Beton April 1996
# (C) Roke Manor Research Limited

#{{{  Copyright and disclaimer
cat<<END
yacht - Yet Another Code Harness Tool
=====================================

Richard Beton
(C) Roke Manor Research Limited 1995.

    All the files in this distribution (except those explicitly given
    other Copyrights) are Copyright 1995 Roke Manor Research Limited
    and are not to be re-distributed without explicit written permission.

    This release is for personal or research use only and not to be sold
    in any form.

    This software is provided by Roke Manor Research Limited ''as is''
    and any express or implied warranties, including, but not limited to,
    the implied warranties of merchantability and fitness for a
    particular purpose are disclaimed.  In no event shall the
    regents or contributors be liable for any direct, indirect,
    incidental, special, exemplary, or consequential damages
    (including, but not limited to, procurement of substitute
    goods or services; loss of use, data, or profits; or business
    interruption) however caused and on any theory of liability,
    whether in contract, strict liability, or tort (including
    negligence or otherwise) arising in any way out of the use of
    this software, even if advised of the possibility of such
    damage.

END
#}}}  

programs="yacht liblist"

#{{{  Is perl on PATH?

PERL=`type perl | cut -d' ' -f3`

#}}}  
#{{{  Is perl in /usr/bin or /usr/local/bin?

if [ ! "$PERL" ]
then
    if [ -x /usr/bin/perl ]
        then PERL=/usr/bin/perl
    elif [ -x /usr/local/bin/perl ]
        then PERL=/usr/local/bin/perl
    fi
fi

#}}}  
#{{{  Ask user for perl directory.

if [ ! "$PERL" ]
then
    /usr/ucb/echo "Yacht is a Perl script and requires Perl to be installed on your system."
    /usr/ucb/echo "Enter the full pathname where Perl is installed:"
    /usr/ucb/echo -n "[$PERL] "
    read answer

    if [ "$answer" != "" ]
    then
        if [ -x $answer ]
        then PERL=$answer
        else echo $answer is not a valid executable. Configuration failed.
             exit 1
        fi
    fi
fi

#}}}  

if [ "$PERL" != "" ]
then
    echo Using $PERL.
    for prog in $programs
    do
        echo "  $prog.pl --> $prog"
        echo "#!$PERL"    > $prog
        tail +2 $prog.pl >> $prog
        chmod a+x $prog
    done
else
    echo Configuration failed.
    exit 1
fi
