2008-05-18 04:44:47 +02:00
|
|
|
#!/bin/sh
|
2008-06-16 03:18:21 +02:00
|
|
|
|
|
|
|
# Copyright (C) 2008 Jonathan Moore Liles #
|
|
|
|
# #
|
|
|
|
# This program is free software; you can redistribute it and/or modify it #
|
|
|
|
# under the terms of the GNU General Public License as published by the #
|
|
|
|
# Free Software Foundation; either version 2 of the License, or (at your #
|
|
|
|
# option) any later version. #
|
|
|
|
# #
|
|
|
|
# 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; see the file COPYING. If not,write to the Free Software #
|
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
|
2008-05-18 04:44:47 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
. scripts/colors
|
|
|
|
|
2008-06-16 03:18:21 +02:00
|
|
|
#####
|
|
|
|
## support functions for 'configure' scripts.
|
2008-05-18 04:44:47 +02:00
|
|
|
|
|
|
|
fatal ()
|
|
|
|
{
|
|
|
|
echo "$BOLD$RED$*$SGR0" > /dev/stderr
|
|
|
|
exit 255
|
|
|
|
}
|
|
|
|
|
2008-05-25 18:26:53 +02:00
|
|
|
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
|
2008-05-29 20:35:04 +02:00
|
|
|
echo "## options" > .config
|
2008-05-25 18:26:53 +02:00
|
|
|
|
|
|
|
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;
|
2008-05-29 20:35:04 +02:00
|
|
|
' | sed -n '/^[^ =]\+=./p' >> .config
|
2008-05-25 18:26:53 +02:00
|
|
|
UPDATE=yes;
|
|
|
|
fi
|
|
|
|
fi
|
2008-05-18 17:30:06 +02:00
|
|
|
|
2008-05-29 20:35:04 +02:00
|
|
|
if [ $HELP != yes ] && [ $UPDATE != yes ]
|
|
|
|
then
|
|
|
|
if ! ( [ -t 0 ] && [ -t 1 ] )
|
|
|
|
then
|
|
|
|
fatal "not a terminal!"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2008-05-18 04:44:47 +02:00
|
|
|
ask ()
|
|
|
|
{
|
2008-05-25 19:12:51 +02:00
|
|
|
local A D O
|
2008-05-18 04:44:47 +02:00
|
|
|
|
2008-05-25 18:26:53 +02:00
|
|
|
D="`eval echo \\$$2`"
|
|
|
|
D=${D:-$3}
|
2008-05-18 04:44:47 +02:00
|
|
|
|
2008-05-25 18:26:53 +02:00
|
|
|
if [ $HELP = yes ]
|
|
|
|
then
|
2008-05-25 19:12:51 +02:00
|
|
|
if [ "$3" = yes ] || [ "$3" = no ]
|
2008-05-25 18:26:53 +02:00
|
|
|
then
|
2008-05-25 19:12:51 +02:00
|
|
|
O=`echo -n "$2" | sed s/^USE_/--enable-/ | tr '[[:upper:]]' '[[:lower:]]'`
|
2008-05-25 18:26:53 +02:00
|
|
|
else
|
2008-05-25 19:12:51 +02:00
|
|
|
O=`echo -n "--$2" | tr '[[:upper:]]' '[[:lower:]]'`
|
2008-05-25 18:26:53 +02:00
|
|
|
fi
|
|
|
|
|
2008-05-25 19:12:51 +02:00
|
|
|
printf " ${BOLD}${GREEN}%-15s${SGR0}\t%-40s (currently: ${BOLD}%s${SGR0})\n" "$O" "$1" "$D"
|
2008-05-25 18:26:53 +02:00
|
|
|
|
|
|
|
return
|
|
|
|
fi
|
2008-05-18 06:28:36 +02:00
|
|
|
|
2008-05-25 18:26:53 +02:00
|
|
|
echo -n "$BLACK$BOLD::$SGR0 ${1}? [$BOLD${D}$SGR0] "
|
2008-05-18 06:28:36 +02:00
|
|
|
|
2008-05-25 18:26:53 +02:00
|
|
|
if [ $UPDATE = yes ]
|
|
|
|
then
|
|
|
|
A="$D"
|
|
|
|
echo
|
|
|
|
else
|
|
|
|
read A
|
|
|
|
A=${A:-$D}
|
|
|
|
fi
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
append "${2}=${A:-$D}"
|
2010-01-08 06:25:07 +01:00
|
|
|
|
|
|
|
eval "${2}='${A:-$D}'"
|
2008-05-18 04:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ok ()
|
|
|
|
{
|
2012-03-07 02:24:42 +01:00
|
|
|
echo '
'`tput cuf 30`"$BOLD${GREEN}ok${SGR0} ${*:+${BOLD}${BLACK}($*)${SGR0}}"
|
2008-05-18 04:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
failed ()
|
|
|
|
{
|
2012-03-07 02:24:42 +01:00
|
|
|
echo '
'`tput cuf 30`"$BOLD${RED}failed!${SGR0}" > /dev/stderr
|
2008-05-29 20:35:04 +02:00
|
|
|
rm -f .config
|
2008-05-18 04:44:47 +02:00
|
|
|
}
|
|
|
|
|
2012-02-29 06:20:05 +01:00
|
|
|
missing ()
|
|
|
|
{
|
2012-03-07 02:24:42 +01:00
|
|
|
echo '
'`tput cuf 30`"$BOLD${YELLOW}missing!${SGR0}" > /dev/stderr
|
2012-02-29 06:20:05 +01:00
|
|
|
}
|
|
|
|
|
2008-05-18 06:28:36 +02:00
|
|
|
using ()
|
|
|
|
{
|
|
|
|
[ "`eval echo \\$USE_$1`" = yes ]
|
|
|
|
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
2008-05-20 22:29:10 +02:00
|
|
|
upcase ()
|
|
|
|
{
|
|
|
|
echo "$*" | tr '[[:lower:]]' '[[:upper:]]'
|
|
|
|
}
|
|
|
|
|
2008-05-18 04:44:47 +02:00
|
|
|
extract_options ()
|
|
|
|
{
|
2008-05-20 21:34:02 +02:00
|
|
|
local line name value
|
2008-05-18 04:44:47 +02:00
|
|
|
|
2008-05-29 20:35:04 +02:00
|
|
|
if [ -f .config ]
|
2008-05-18 04:44:47 +02:00
|
|
|
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
|
2008-05-20 21:34:02 +02:00
|
|
|
name=${line%=*}
|
|
|
|
value=${line#*=}
|
|
|
|
eval "$name='$value'"
|
2008-05-18 16:50:42 +02:00
|
|
|
fi
|
|
|
|
done
|
2008-05-29 20:35:04 +02:00
|
|
|
} < .config
|
2008-05-18 04:44:47 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
begin ()
|
|
|
|
{
|
|
|
|
echo -n "Checking sanity..."
|
2012-02-29 06:20:05 +01:00
|
|
|
require_command tput tput > /dev/null
|
2012-03-08 03:26:06 +01:00
|
|
|
require_command pkg_config pkg-config > /dev/null
|
2008-05-26 20:29:10 +02:00
|
|
|
require_command sed sed > /dev/null
|
2008-05-18 04:44:47 +02:00
|
|
|
ok
|
|
|
|
}
|
|
|
|
|
2008-05-25 19:12:51 +02:00
|
|
|
warn ()
|
|
|
|
{
|
2012-03-03 01:29:59 +01:00
|
|
|
echo " ${BOLD}${YELLOW}* ${SGR0}${BOLD}$*"
|
2008-05-25 19:12:51 +02:00
|
|
|
}
|
|
|
|
|
2008-05-26 20:44:17 +02:00
|
|
|
info ()
|
|
|
|
{
|
|
|
|
echo "${BOLD}${CYAN}--- ${SGR0}$*"
|
|
|
|
}
|
|
|
|
|
2008-05-18 04:44:47 +02:00
|
|
|
begin_options ()
|
|
|
|
{
|
|
|
|
# get the old values
|
|
|
|
extract_options
|
|
|
|
|
2008-05-25 18:26:53 +02:00
|
|
|
if [ $HELP = yes ]
|
|
|
|
then
|
2008-05-26 20:29:10 +02:00
|
|
|
echo
|
2008-05-26 20:44:17 +02:00
|
|
|
warn "This is a ${BOLD}non-configure${SGR0} script. Run without any arguments and you will be prompted"
|
|
|
|
warn "with configuration choices. Alternatively, you may use the following autoconf style"
|
|
|
|
warn "arguments for non-interactive configuration."
|
2008-05-25 18:26:53 +02:00
|
|
|
echo
|
|
|
|
echo " Available options:"
|
|
|
|
echo
|
|
|
|
else
|
2008-05-29 20:35:04 +02:00
|
|
|
echo > .config
|
2008-05-25 18:26:53 +02:00
|
|
|
append "# This file was automatically generated on `date`. Any changes may be lost!"
|
|
|
|
append "## options"
|
|
|
|
|
|
|
|
if [ $UPDATE = yes ]
|
|
|
|
then
|
2008-05-26 20:44:17 +02:00
|
|
|
info "Updating configuration"
|
2008-05-25 18:26:53 +02:00
|
|
|
else
|
2008-05-26 20:44:17 +02:00
|
|
|
info "Configuration required"
|
2008-05-25 18:26:53 +02:00
|
|
|
fi
|
|
|
|
fi
|
2008-05-18 04:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
begin_tests ()
|
|
|
|
{
|
2008-05-26 20:44:17 +02:00
|
|
|
if [ $HELP = yes ]
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
exit 0;
|
|
|
|
fi
|
2008-05-25 18:26:53 +02:00
|
|
|
|
2008-05-18 16:50:42 +02:00
|
|
|
append "## libs"
|
2008-05-18 04:44:47 +02:00
|
|
|
extract_options
|
|
|
|
}
|
|
|
|
|
|
|
|
append ()
|
|
|
|
{
|
2008-05-29 20:35:04 +02:00
|
|
|
echo "$1" >> .config
|
2008-05-18 04:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
end ()
|
|
|
|
{
|
2008-05-26 20:44:17 +02:00
|
|
|
info "Configuration complete"
|
2008-05-29 20:35:04 +02:00
|
|
|
touch .config
|
2008-05-18 04:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
require_command ()
|
|
|
|
{
|
|
|
|
echo -n "Checking for ${BOLD}$1${SGR0}..."
|
|
|
|
|
2012-03-07 02:24:42 +01:00
|
|
|
local name;
|
|
|
|
|
|
|
|
if [ -x "$2" ]
|
|
|
|
then
|
2012-03-07 05:01:37 +01:00
|
|
|
name="$PWD/$2"
|
2012-03-08 03:22:37 +01:00
|
|
|
ok "$name"
|
2012-03-07 02:24:42 +01:00
|
|
|
elif [ -x "`which "$2"`" ]
|
2008-05-18 04:44:47 +02:00
|
|
|
then
|
2012-03-07 02:24:42 +01:00
|
|
|
name="`which "$2"`"
|
2012-03-08 03:22:37 +01:00
|
|
|
ok "$name"
|
2012-03-07 02:24:42 +01:00
|
|
|
else
|
2008-05-18 04:44:47 +02:00
|
|
|
failed
|
|
|
|
fatal "Command $1 not found."
|
|
|
|
fi
|
2012-03-07 02:24:42 +01:00
|
|
|
|
2012-03-07 05:01:37 +01:00
|
|
|
append "$1=$name"
|
2012-10-30 17:11:13 +01:00
|
|
|
eval "${1}='${name}'"
|
2008-05-18 04:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
require_package ()
|
|
|
|
{
|
2008-05-20 22:29:10 +02:00
|
|
|
local name
|
|
|
|
|
2008-05-18 04:44:47 +02:00
|
|
|
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
|
|
|
|
|
2008-05-20 22:29:10 +02:00
|
|
|
name="`upcase \"$1\"`"
|
2012-02-20 11:50:19 +01:00
|
|
|
append "${name}_LIBS=`pkg-config --libs $3 | sed 's/,\\?--as-needed//g'`"
|
2008-05-20 22:29:10 +02:00
|
|
|
append "${name}_CFLAGS=-DHAVE_${1} `pkg-config --cflags $3`"
|
2008-05-18 04:44:47 +02:00
|
|
|
|
2008-05-31 07:31:03 +02:00
|
|
|
ok `pkg-config --modversion "$3"`
|
2008-05-18 04:44:47 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2012-02-29 06:20:05 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2008-05-18 17:30:06 +02:00
|
|
|
_test_version ()
|
|
|
|
{
|
2010-01-21 01:33:02 +01:00
|
|
|
if [ $# = 6 ]
|
2010-01-21 01:33:02 +01:00
|
|
|
then
|
|
|
|
[ $1 -gt $4 ] && return 0
|
|
|
|
[ $1 -eq $4 ] && [ $2 -gt $5 ] && return 0
|
|
|
|
[ $1 -eq $4 ] && [ $2 -eq $5 ] && [ $3 -gt $6 ] && return 0
|
|
|
|
[ $1 -eq $4 ] && [ $2 -eq $5 ] && [ $3 -eq $6 ] && return 0
|
|
|
|
return 1
|
2010-01-21 01:33:02 +01:00
|
|
|
elif [ $# = 4 ]
|
2010-01-21 01:33:02 +01:00
|
|
|
then
|
|
|
|
[ $1 -gt $3 ] && return 0
|
|
|
|
[ $1 -eq $3 ] && [ $2 -eq $4 ] && return 0
|
2010-01-21 01:33:02 +01:00
|
|
|
return 1
|
2010-01-21 01:33:02 +01:00
|
|
|
fi
|
2008-05-18 17:30:06 +02:00
|
|
|
}
|
|
|
|
|
2008-06-09 00:44:25 +02:00
|
|
|
# return true if #1 is greater than or equal to $2
|
2008-05-18 17:30:06 +02:00
|
|
|
test_version ()
|
|
|
|
{
|
|
|
|
local IFS
|
|
|
|
IFS='.'
|
|
|
|
|
2008-06-09 00:44:25 +02:00
|
|
|
_test_version $1 $2
|
2008-05-18 17:30:06 +02:00
|
|
|
}
|
|
|
|
|
2008-05-18 19:00:27 +02:00
|
|
|
version_of ()
|
|
|
|
{
|
|
|
|
echo `pkg-config --modversion $1`
|
|
|
|
}
|
|
|
|
|
2012-03-04 09:08:07 +01:00
|
|
|
hostname_resolvable ()
|
|
|
|
{
|
|
|
|
ping -c1 `hostname` >/dev/null 2>/dev/null
|
|
|
|
}
|
|
|
|
|
2012-10-30 17:11:13 +01:00
|
|
|
require_NTK ()
|
2008-05-18 04:44:47 +02:00
|
|
|
{
|
2008-05-18 17:30:06 +02:00
|
|
|
local use
|
2012-04-27 19:14:53 +02:00
|
|
|
local appendflags
|
2012-10-30 17:11:13 +01:00
|
|
|
local is_local
|
2008-05-18 17:30:06 +02:00
|
|
|
|
2012-10-30 17:11:13 +01:00
|
|
|
is_local=
|
2012-03-08 03:26:06 +01:00
|
|
|
|
2012-10-30 17:11:13 +01:00
|
|
|
echo -n "Checking for ${BOLD}NTK${SGR0}..."
|
2008-05-18 04:44:47 +02:00
|
|
|
|
2012-10-30 17:11:13 +01:00
|
|
|
if [ -n "`which ntk-config`" ]
|
|
|
|
then
|
|
|
|
echo "found system NTK..."
|
|
|
|
require_command ntk_config ntk-config
|
|
|
|
else
|
|
|
|
echo "no system NTK found... checking for bundled version..."
|
|
|
|
require_command ntk_config lib/ntk/ntk-config
|
|
|
|
is_local=yes
|
|
|
|
fi
|
|
|
|
|
|
|
|
FLTK_VERSION=`${ntk_config} --version`
|
2008-05-18 04:44:47 +02:00
|
|
|
|
2008-06-09 00:44:25 +02:00
|
|
|
if ! test_version $FLTK_VERSION $1
|
2008-05-18 04:44:47 +02:00
|
|
|
then
|
|
|
|
failed
|
|
|
|
fatal "The installed FLTK version ($FLTK_VERSION) is too old."
|
|
|
|
else
|
2008-05-31 07:31:03 +02:00
|
|
|
ok $FLTK_VERSION
|
2008-05-18 04:44:47 +02:00
|
|
|
fi
|
|
|
|
|
2012-10-30 17:11:13 +01:00
|
|
|
if [ "x$is_local" = "xyes" ]
|
|
|
|
then
|
|
|
|
require_command FLUID lib/ntk/fluid/ntk-fluid
|
|
|
|
else
|
|
|
|
require_command FLUID ntk-fluid
|
|
|
|
fi
|
|
|
|
|
2008-05-18 17:30:06 +02:00
|
|
|
use=
|
2012-04-27 19:14:53 +02:00
|
|
|
appendflags=
|
2008-05-18 17:30:06 +02:00
|
|
|
|
|
|
|
while [ $# -gt 1 ]
|
|
|
|
do
|
|
|
|
shift 1
|
2012-04-27 19:14:53 +02:00
|
|
|
|
|
|
|
[ "$1" = 'cairo' ] && appendflags="-DFLTK_HAVE_CAIRO=1 -DUSE_X11=1"
|
|
|
|
|
2008-05-18 17:30:06 +02:00
|
|
|
use="$use --use-$1"
|
|
|
|
done
|
|
|
|
|
2012-10-30 17:11:13 +01:00
|
|
|
append "FLTK_LIBS=`${ntk_config} $use --libs | sed 's/,\\?--as-needed//g'`"
|
|
|
|
append "FLTK_LDFLAGS=`${ntk_config} $use --ldflags | sed 's/,\\?--as-needed//g'`"
|
|
|
|
append "FLTK_CFLAGS=`${ntk_config} $use --cflags` $appendflags"
|
2008-05-18 04:44:47 +02:00
|
|
|
}
|