configure: add some autoconf emulation.

This commit is contained in:
Jonathan Moore Liles 2008-05-25 11:26:53 -05:00
parent 0d40ca5b6b
commit 1c599fd7f6
2 changed files with 112 additions and 24 deletions

6
configure vendored
View File

@ -9,9 +9,9 @@ begin
begin_options
ask "Install prefix?" prefix /usr/local
ask "Require LASH?" USE_LASH yes
ask "Build for debugging?" USE_DEBUG no
ask "Install prefix" prefix /usr/local
ask "Require LASH" USE_LASH yes
ask "Build for debugging" USE_DEBUG no
begin_tests

View File

@ -14,7 +14,48 @@ fatal ()
exit 255
}
[ $# -gt 0 ] && fatal "This is not an autoconf script. Run it without any options and you will be prompted."
UPDATE=no
HELP=no
split ()
{
while [ $# -gt 0 ]
do
echo $1
shift 1
done
}
if [ $# -gt 0 ]
then
case "$1" in
--update)
UPDATE=yes
shift 1
;;
--help)
HELP=yes
shift 1
;;
*)
# fatal "This is not an autoconf script. Run it without any options and you will be prompted."
;;
esac
if [ $# -gt 0 ]
then
echo "## options" > make.conf
split "$@" | sed '
s/--\(enable\|disable\)-\([^ =]\+\)/--\1-\U\2/g;
s/--enable-\([^ =]\+\)=\(.*\)/USE_\1=\2/g;
s/--enable-\([^ =]\+\)/USE_\1=yes/g;
s/--disable-\([^ =]\+\)/USE_\1=no/g;
s/--\([^ =]\+\)/\1/g;
' | sed -n '/^[^ =]\+=./p' >> make.conf
UPDATE=yes;
fi
fi
ask ()
{
@ -23,9 +64,37 @@ ask ()
D="`eval echo \\$$2`"
D=${D:-$3}
echo -n "$BLACK$BOLD::$SGR0 $1 [$BOLD${D}$SGR0] "
if [ $HELP = yes ]
then
echo -en "\t"
if [ "$D" = yes ] || [ "$D" = no ]
then
if [ "$D" = yes ]
then
echo -n "$2" | sed s/^USE_/--enable-/ | tr '[[:upper:]]' '[[:lower:]]'
else
echo -n "$2" | sed s/^USE_/--disable-/ | tr '[[:upper:]]' '[[:lower:]]'
fi
else
echo -n "--$2" | tr '[[:upper:]]' '[[:lower:]]'
fi
echo -e "\t$1"
return
fi
echo -n "$BLACK$BOLD::$SGR0 ${1}? [$BOLD${D}$SGR0] "
if [ $UPDATE = yes ]
then
A="$D"
echo
else
read A
A=${A:-$D}
fi
if [ "$3" = yes ] || [ "$3" = no ]
then
@ -101,15 +170,34 @@ begin_options ()
# get the old values
extract_options
if [ $HELP = yes ]
then
echo "****"
echo "This is not an autoconf script! Run without any arguments and you will be prompted."
echo "Alternatively, you may use the following autoconf style arguments for"
echo "non-interactive configuration."
echo "****"
echo
echo " Available options:"
echo
else
echo > make.conf
append "# This file was automatically generated on `date`. Any changes may be lost!"
append "## options"
if [ $UPDATE = yes ]
then
echo "--- Updating configuration ---"
else
echo "--- Configuration required ---"
fi
fi
}
begin_tests ()
{
[ $HELP = yes ] && exit 0
append "## libs"
extract_options
}