3 # Copyright (C) 2008 Jonathan Moore Liles #
5 # This program is free software; you can redistribute it and/or modify it #
6 # under the terms of the GNU General Public License as published by the #
7 # Free Software Foundation; either version 2 of the License, or (at your #
8 # option) any later version. #
10 # This program is distributed in the hope that it will be useful, but WITHOUT #
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
15 # You should have received a copy of the GNU General Public License along #
16 # with This program; see the file COPYING. If not,write to the Free Software #
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
23 ## support functions for 'configure' scripts.
27 echo "$BOLD$RED$*$SGR0" > /dev
/stderr
55 # fatal "This is not an autoconf script. Run it without any options and you will be prompted."
61 echo "## options" > .config
64 s/--\(enable\|disable\)-\([^ =]\+\)/--\1-\U\2/g;
65 s/--enable-\([^ =]\+\)=\(.*\)/USE_\1=\2/g;
66 s/--enable-\([^ =]\+\)/USE_\1=yes/g;
67 s/--disable-\([^ =]\+\)/USE_\1=no/g;
69 ' |
sed -n '/^[^ =]\+=./p' >> .config
74 if [ $HELP != yes ] && [ $UPDATE != yes ]
76 if ! ( [ -t 0 ] && [ -t 1 ] )
78 fatal
"not a terminal!"
91 if [ "$3" = yes ] ||
[ "$3" = no
]
93 O
=`echo -n "$2" | sed s/^USE_/--enable-/ | tr '[[:upper:]]' '[[:lower:]]'`
95 O
=`echo -n "--$2" | tr '[[:upper:]]' '[[:lower:]]'`
98 printf " ${BOLD}${GREEN}%-15s${SGR0}\t%-40s (currently: ${BOLD}%s${SGR0})\n" "$O" "$1" "$D"
103 echo -n "$BLACK$BOLD::$SGR0 ${1}? [$BOLD${D}$SGR0] "
114 if [ "$3" = yes ] ||
[ "$3" = no
]
118 yes | y | Y
) A
=yes ;;
119 * ) fatal
"Invalid response. Must be 'yes' or 'no'" ;;
123 append
"${2}=${A:-$D}"
125 eval "${2}='${A:-$D}'"
130 echo '
'`tput cuf 30`"$BOLD${GREEN}ok${SGR0} ${*:+${BOLD}${BLACK}($*)${SGR0}}"
135 echo '
'`tput cuf 30`"$BOLD${RED}failed!${SGR0}" > /dev
/stderr
141 echo '
'`tput cuf 30`"$BOLD${YELLOW}missing!${SGR0}" > /dev
/stderr
146 [ "`eval echo \\$USE_$1`" = yes ]
153 echo "$*" |
tr '[[:lower:]]' '[[:upper:]]'
158 local line name value
165 [ "$line" = "## options" ] && break
170 if [ "$line" = "## libs" ]
176 eval "$name='$value'"
185 echo -n "Checking sanity..."
186 require_command
tput tput > /dev
/null
187 require_command pkg_config pkg-config
> /dev
/null
188 require_command
sed sed > /dev
/null
194 echo " ${BOLD}${YELLOW}* ${SGR0}${BOLD}$*"
199 echo "${BOLD}${CYAN}--- ${SGR0}$*"
210 warn
"This is a ${BOLD}non-configure${SGR0} script. Run without any arguments and you will be prompted"
211 warn
"with configuration choices. Alternatively, you may use the following autoconf style"
212 warn
"arguments for non-interactive configuration."
214 echo " Available options:"
218 append
"# This file was automatically generated on `date`. Any changes may be lost!"
223 info
"Updating configuration"
225 info
"Configuration required"
249 info
"Configuration complete"
255 echo -n "Checking for ${BOLD}$1${SGR0}..."
263 elif [ -x "`which "$2"`" ]
269 fatal
"Command $1 not found."
279 echo -n "Checking for $BOLD$1$SGR0..."
280 if ! pkg-config
--exists $3
283 fatal
"Required package $1 doesn't appear to be installed."
284 elif ! pkg-config
--atleast-version $2 $3
287 fatal
"The installed version of $1 (`pkg-config --mod-version $3`) is too old."
290 name
="`upcase \"$1\"`"
291 append
"${name}_LIBS=`pkg-config --libs $3 | sed 's/,\\?--as-needed//g'`"
292 append
"${name}_CFLAGS=-DHAVE_${1} `pkg-config --cflags $3`"
294 ok
`pkg-config --modversion "$3"`
302 echo -n "Checking for $BOLD$1$SGR0..."
303 if ! pkg-config
--exists $3
306 warn
"Suggested package $1 doesn't appear to be installed. Some functionality may be missing from your build."
307 warn
"Continuing without $1...\n"
309 elif ! pkg-config
--atleast-version $2 $3
312 warn
"The installed version of suggested package $1 (`pkg-config --mod-version $3`) is too old."
313 warn
"Continuing without $1..."
317 name
="`upcase \"$1\"`"
318 append
"${name}_LIBS=`pkg-config --libs $3 | sed 's/,\\?--as-needed//g'`"
319 append
"${name}_CFLAGS=-DHAVE_${1} `pkg-config --cflags $3`"
321 ok
`pkg-config --modversion "$3"`
329 [ $1 -gt $4 ] && return 0
330 [ $1 -eq $4 ] && [ $2 -gt $5 ] && return 0
331 [ $1 -eq $4 ] && [ $2 -eq $5 ] && [ $3 -gt $6 ] && return 0
332 [ $1 -eq $4 ] && [ $2 -eq $5 ] && [ $3 -eq $6 ] && return 0
336 [ $1 -gt $3 ] && return 0
337 [ $1 -eq $3 ] && [ $2 -eq $4 ] && return 0
342 # return true if #1 is greater than or equal to $2
353 echo `pkg-config --modversion $1`
356 hostname_resolvable
()
358 ping -c1 `hostname` >/dev
/null
2>/dev
/null
366 require_command ntk_config lib
/ntk
/ntk-config
368 echo -n "Checking for ${BOLD}FLTK${SGR0}..."
370 FLTK_VERSION
=`lib/ntk/ntk-config --version`
372 if ! test_version
$FLTK_VERSION $1
375 fatal
"The installed FLTK version ($FLTK_VERSION) is too old."
387 [ "$1" = 'cairo' ] && appendflags
="-DFLTK_HAVE_CAIRO=1 -DUSE_X11=1"
392 append
"FLTK_LIBS=`lib/ntk/ntk-config $use --libs | sed 's/,\\?--as-needed//g'`"
393 append
"FLTK_LDFLAGS=`lib/ntk/ntk-config $use --ldflags | sed 's/,\\?--as-needed//g'`"
394 append
"FLTK_CFLAGS=`lib/ntk/ntk-config $use --cflags` $appendflags"