scripts: Allow suggested packages.

This commit is contained in:
Jonathan Moore Liles 2012-02-28 21:20:05 -08:00
parent 55c83cf4ec
commit 7590c52c76
1 changed files with 35 additions and 2 deletions

View File

@ -127,15 +127,20 @@ ask ()
ok () ok ()
{ {
echo -e '\r'`tput cuf 30`"$BOLD${GREEN}ok${SGR0} ${*:+${BOLD}${BLACK}($*)${SGR0}}" echo '\r'`tput cuf 30`"$BOLD${GREEN}ok${SGR0} ${*:+${BOLD}${BLACK}($*)${SGR0}}"
} }
failed () failed ()
{ {
echo "$BOLD${RED}failed!${SGR0}" > /dev/stderr echo '\r'`tput cuf 30`"$BOLD${RED}failed!${SGR0}" > /dev/stderr
rm -f .config rm -f .config
} }
missing ()
{
echo '\r'`tput cuf 30`"$BOLD${YELLOW}missing!${SGR0}" > /dev/stderr
}
using () using ()
{ {
[ "`eval echo \\$USE_$1`" = yes ] [ "`eval echo \\$USE_$1`" = yes ]
@ -178,6 +183,7 @@ extract_options ()
begin () begin ()
{ {
echo -n "Checking sanity..." echo -n "Checking sanity..."
require_command tput tput > /dev/null
require_command pkg-config pkg-config > /dev/null require_command pkg-config pkg-config > /dev/null
require_command sed sed > /dev/null require_command sed sed > /dev/null
ok ok
@ -280,6 +286,33 @@ require_package ()
return 0 return 0
} }
suggest_package ()
{
local name
echo -n "Checking for $BOLD$1$SGR0..."
if ! pkg-config --exists $3
then
missing
warn "Suggested package $1 doesn't appear to be installed. Some functionality may be missing from your build."
warn "Continuing without $1...\n"
return 1;
elif ! pkg-config --atleast-version $2 $3
then
missing
warn "The installed version of suggested package $1 (`pkg-config --mod-version $3`) is too old."
warn "Continuing without $1..."
return 1;
fi
name="`upcase \"$1\"`"
append "${name}_LIBS=`pkg-config --libs $3 | sed 's/,\\?--as-needed//g'`"
append "${name}_CFLAGS=-DHAVE_${1} `pkg-config --cflags $3`"
ok `pkg-config --modversion "$3"`
return 0
}
_test_version () _test_version ()
{ {
if [ $# = 6 ] if [ $# = 6 ]