Add and use has() and path_of() funcs
Add has() and path_of() funcs and use them across configure; has() will test whether a command or builtin is available; path_of() will search the PATH for executables and return the full pathname if found. Signed-off-by: Loïc Minier <lool@dooz.org Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
a0dfd8a415
commit
0dba619507
52
configure
vendored
52
configure
vendored
@ -27,6 +27,42 @@ compile_prog() {
|
|||||||
$cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
|
$cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check whether a command is available to this shell (may be either an
|
||||||
|
# executable or a builtin)
|
||||||
|
has() {
|
||||||
|
type "$1" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# search for an executable in PATH
|
||||||
|
path_of() {
|
||||||
|
local_command="$1"
|
||||||
|
local_ifs="$IFS"
|
||||||
|
local_dir=""
|
||||||
|
|
||||||
|
# pathname has a dir component?
|
||||||
|
if [ "${local_command#*/}" != "$local_command" ]; then
|
||||||
|
if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
|
||||||
|
echo "$local_command"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -z "$local_command" ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
IFS=:
|
||||||
|
for local_dir in $PATH; do
|
||||||
|
if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
|
||||||
|
echo "$local_dir/$local_command"
|
||||||
|
IFS="${local_ifs:-$(printf ' \t\n')}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# not found
|
||||||
|
IFS="${local_ifs:-$(printf ' \t\n')}"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# default parameters
|
# default parameters
|
||||||
cpu=""
|
cpu=""
|
||||||
prefix=""
|
prefix=""
|
||||||
@ -767,7 +803,7 @@ fi
|
|||||||
# Solaris specific configure tool chain decisions
|
# Solaris specific configure tool chain decisions
|
||||||
#
|
#
|
||||||
if test "$solaris" = "yes" ; then
|
if test "$solaris" = "yes" ; then
|
||||||
solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
|
solinst=`path_of $install`
|
||||||
if test -z "$solinst" ; then
|
if test -z "$solinst" ; then
|
||||||
echo "Solaris install program not found. Use --install=/usr/ucb/install or"
|
echo "Solaris install program not found. Use --install=/usr/ucb/install or"
|
||||||
echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
|
echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
|
||||||
@ -780,7 +816,7 @@ if test "$solaris" = "yes" ; then
|
|||||||
echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
|
echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
|
sol_ar=`path_of ar`
|
||||||
if test -z "$sol_ar" ; then
|
if test -z "$sol_ar" ; then
|
||||||
echo "Error: No path includes ar"
|
echo "Error: No path includes ar"
|
||||||
if test -f /usr/ccs/bin/ar ; then
|
if test -f /usr/ccs/bin/ar ; then
|
||||||
@ -973,7 +1009,7 @@ fi
|
|||||||
# pkgconfig probe
|
# pkgconfig probe
|
||||||
|
|
||||||
pkgconfig="${cross_prefix}pkg-config"
|
pkgconfig="${cross_prefix}pkg-config"
|
||||||
if ! test -x "$(which $pkgconfig 2>/dev/null)"; then
|
if ! has $pkgconfig; then
|
||||||
# likely not cross compiling, or hope for the best
|
# likely not cross compiling, or hope for the best
|
||||||
pkgconfig=pkg-config
|
pkgconfig=pkg-config
|
||||||
fi
|
fi
|
||||||
@ -981,7 +1017,7 @@ fi
|
|||||||
##########################################
|
##########################################
|
||||||
# Sparse probe
|
# Sparse probe
|
||||||
if test "$sparse" != "no" ; then
|
if test "$sparse" != "no" ; then
|
||||||
if test -x "$(which cgcc 2>/dev/null)"; then
|
if has cgcc; then
|
||||||
sparse=yes
|
sparse=yes
|
||||||
else
|
else
|
||||||
if test "$sparse" = "yes" ; then
|
if test "$sparse" = "yes" ; then
|
||||||
@ -997,7 +1033,7 @@ fi
|
|||||||
if $pkgconfig sdl --modversion >/dev/null 2>&1; then
|
if $pkgconfig sdl --modversion >/dev/null 2>&1; then
|
||||||
sdlconfig="$pkgconfig sdl"
|
sdlconfig="$pkgconfig sdl"
|
||||||
_sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
|
_sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
|
||||||
elif which sdl-config >/dev/null 2>&1; then
|
elif has sdl-config; then
|
||||||
sdlconfig='sdl-config'
|
sdlconfig='sdl-config'
|
||||||
_sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
|
_sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
|
||||||
else
|
else
|
||||||
@ -1428,8 +1464,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if test "$kvm" = "yes" ; then
|
if test "$kvm" = "yes" ; then
|
||||||
if [ -x "`which awk 2>/dev/null`" ] && \
|
if has awk && has grep; then
|
||||||
[ -x "`which grep 2>/dev/null`" ]; then
|
|
||||||
kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
|
kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
|
||||||
| grep "error: " \
|
| grep "error: " \
|
||||||
| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
|
| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
|
||||||
@ -1698,8 +1733,7 @@ fi
|
|||||||
|
|
||||||
# Check if tools are available to build documentation.
|
# Check if tools are available to build documentation.
|
||||||
if test "$docs" != "no" ; then
|
if test "$docs" != "no" ; then
|
||||||
if test -x "`which texi2html 2>/dev/null`" -a \
|
if has texi2html && has pod2man; then
|
||||||
-x "`which pod2man 2>/dev/null`" ; then
|
|
||||||
docs=yes
|
docs=yes
|
||||||
else
|
else
|
||||||
if test "$docs" = "yes" ; then
|
if test "$docs" = "yes" ; then
|
||||||
|
Loading…
Reference in New Issue
Block a user