2008-05-18 04:44:47 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (C) 2008 Jonathan Moore Liles
|
|
|
|
# This file is licensed under version 2 of the GPL.
|
|
|
|
|
|
|
|
. scripts/colors
|
|
|
|
|
|
|
|
# support functions for 'configure' scripts.
|
|
|
|
|
|
|
|
fatal ()
|
|
|
|
{
|
|
|
|
echo "$BOLD$RED$*$SGR0" > /dev/stderr
|
|
|
|
exit 255
|
|
|
|
}
|
|
|
|
|
|
|
|
ask ()
|
|
|
|
{
|
2008-05-18 06:28:36 +02:00
|
|
|
local A D
|
2008-05-18 04:44:47 +02:00
|
|
|
|
2008-05-18 06:28:36 +02:00
|
|
|
D="`eval echo \\$$2`"
|
|
|
|
D=${D:-$3}
|
2008-05-18 04:44:47 +02:00
|
|
|
|
2008-05-18 06:28:36 +02:00
|
|
|
echo -n "$BLACK$BOLD::$SGR0 $1 [$BOLD${D}$SGR0] "
|
|
|
|
read A
|
|
|
|
A=${A:-$D}
|
|
|
|
|
|
|
|
if [ "$3" = yes ] || [ "$3" = no ]
|
|
|
|
then
|
|
|
|
case "$A" in
|
|
|
|
no | n | N) A=no ;;
|
|
|
|
yes | y | Y) A=yes ;;
|
|
|
|
* ) fatal "Invalid response. Must be 'yes' or 'no'" ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2008-05-18 16:50:42 +02:00
|
|
|
append "${2}=${A:-$D}"
|
2008-05-18 04:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ok ()
|
|
|
|
{
|
2008-05-18 05:06:03 +02:00
|
|
|
echo "$BOLD${GREEN}ok${SGR0}"
|
2008-05-18 04:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
failed ()
|
|
|
|
{
|
|
|
|
echo "$BOLD${RED}failed!${SGR0}" > /dev/stderr
|
|
|
|
rm -f make.conf
|
|
|
|
}
|
|
|
|
|
2008-05-18 06:28:36 +02:00
|
|
|
using ()
|
|
|
|
{
|
|
|
|
[ "`eval echo \\$USE_$1`" = yes ]
|
|
|
|
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
2008-05-18 04:44:47 +02:00
|
|
|
extract_options ()
|
|
|
|
{
|
2008-05-18 16:50:42 +02:00
|
|
|
local line;
|
2008-05-18 04:44:47 +02:00
|
|
|
|
|
|
|
if [ -f make.conf ]
|
|
|
|
then
|
2008-05-18 16:50:42 +02:00
|
|
|
{
|
|
|
|
while read line
|
|
|
|
do
|
|
|
|
[ "$line" = "## options" ] && break
|
|
|
|
done
|
|
|
|
|
|
|
|
while read line
|
|
|
|
do
|
|
|
|
if [ "$line" = "## libs" ]
|
|
|
|
then
|
|
|
|
break
|
|
|
|
else
|
|
|
|
eval "$line"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
} < make.conf
|
2008-05-18 04:44:47 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
begin ()
|
|
|
|
{
|
|
|
|
echo -n "Checking sanity..."
|
|
|
|
require_command pkg-config pkg-config > /dev/null
|
|
|
|
ok
|
|
|
|
}
|
|
|
|
|
|
|
|
begin_options ()
|
|
|
|
{
|
|
|
|
# get the old values
|
|
|
|
extract_options
|
|
|
|
|
2008-05-18 16:50:42 +02:00
|
|
|
echo > make.conf
|
|
|
|
append "# This file was automatically generated on `date`. Any changes may be lost!"
|
|
|
|
append "## options"
|
2008-05-18 04:44:47 +02:00
|
|
|
|
|
|
|
echo "--- Configuration required ---"
|
|
|
|
}
|
|
|
|
|
|
|
|
begin_tests ()
|
|
|
|
{
|
2008-05-18 16:50:42 +02:00
|
|
|
append "## libs"
|
2008-05-18 04:44:47 +02:00
|
|
|
extract_options
|
|
|
|
}
|
|
|
|
|
|
|
|
append ()
|
|
|
|
{
|
|
|
|
echo "$1" >> make.conf
|
|
|
|
}
|
|
|
|
|
|
|
|
end ()
|
|
|
|
{
|
|
|
|
echo "--- Configuration complete ---"
|
2008-05-18 16:50:42 +02:00
|
|
|
touch make.conf
|
2008-05-18 04:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
require_command ()
|
|
|
|
{
|
|
|
|
echo -n "Checking for ${BOLD}$1${SGR0}..."
|
|
|
|
|
|
|
|
if ! [ -x "`which $2`" ]
|
|
|
|
then
|
|
|
|
failed
|
|
|
|
fatal "Command $1 not found."
|
|
|
|
else
|
|
|
|
ok
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
require_package ()
|
|
|
|
{
|
|
|
|
echo -n "Checking for $BOLD$1$SGR0..."
|
|
|
|
if ! pkg-config --exists $3
|
|
|
|
then
|
|
|
|
failed
|
|
|
|
fatal "Required package $1 doesn't appear to be installed."
|
|
|
|
elif ! pkg-config --atleast-version $2 $3
|
|
|
|
then
|
|
|
|
failed
|
|
|
|
fatal "The installed version of $1 (`pkg-config --mod-version $3`) is too old."
|
|
|
|
fi
|
|
|
|
|
|
|
|
append "${1}_LIBS=`pkg-config --libs $3`"
|
|
|
|
append "${1}_CFLAGS=-DHAVE_${1} `pkg-config --cflags $3`"
|
|
|
|
|
|
|
|
ok
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
require_FLTK ()
|
|
|
|
{
|
|
|
|
echo -n "Checking for ${BOLD}FLTK${SGR0}..."
|
|
|
|
|
|
|
|
FLTK_VERSION=`fltk-config --version`
|
|
|
|
|
|
|
|
FLTK_VERSION_MAJOR=`echo $FLTK_VERSION | cut -d'.' -f1`
|
|
|
|
FLTK_VERSION_MINOR=`echo $FLTK_VERSION | cut -d'.' -f2`
|
2008-05-18 06:28:36 +02:00
|
|
|
FLTK_VERSION_MICRO=`echo $FLTK_VERSION | cut -d'.' -f3`
|
2008-05-18 04:44:47 +02:00
|
|
|
|
2008-05-18 06:28:36 +02:00
|
|
|
if ! ( [ $FLTK_VERSION_MAJOR -ge $1 ] && [ $FLTK_VERSION_MINOR -ge $2 ] && [ $FLTK_VERSION_MICRO -ge $3 ] )
|
2008-05-18 04:44:47 +02:00
|
|
|
then
|
|
|
|
failed
|
|
|
|
fatal "The installed FLTK version ($FLTK_VERSION) is too old."
|
|
|
|
else
|
|
|
|
ok
|
|
|
|
fi
|
|
|
|
|
|
|
|
append "FLTK_LIBS=`fltk-config --use-images --ldflags`"
|
|
|
|
append "FLTK_CFLAGS=`fltk-config --cflags`"
|
|
|
|
}
|