configure: Provide and use convenience error reporting function

Provide a convenience function for reporting an error and exiting,
and update various places in the configure script to use it.
This allows us to be a little more consistent about how format
our error messages and makes the calling code shorter.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1365419487-19867-2-git-send-email-peter.maydell@linaro.org
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Peter Maydell 2013-04-08 12:11:26 +01:00 committed by Anthony Liguori
parent 1e885b2527
commit 76ad07a493

193
configure vendored
View File

@ -27,6 +27,17 @@ printf " '%s'" "$0" "$@" >> config.log
echo >> config.log echo >> config.log
echo "#" >> config.log echo "#" >> config.log
error_exit() {
echo
echo "ERROR: $1"
while test -n "$2"; do
echo " $2"
shift
done
echo
exit 1
}
do_cc() { do_cc() {
# Run the compiler, capturing its output to the log. # Run the compiler, capturing its output to the log.
echo $cc "$@" >> config.log echo $cc "$@" >> config.log
@ -46,11 +57,10 @@ do_cc() {
esac esac
echo $cc -Werror "$@" >> config.log echo $cc -Werror "$@" >> config.log
$cc -Werror "$@" >> config.log 2>&1 && return $? $cc -Werror "$@" >> config.log 2>&1 && return $?
echo "ERROR: configure test passed without -Werror but failed with -Werror." error_exit "configure test passed without -Werror but failed with -Werror." \
echo "This is probably a bug in the configure script. The failing command" "This is probably a bug in the configure script. The failing command" \
echo "will be at the bottom of config.log." "will be at the bottom of config.log." \
echo "You can run configure with --disable-werror to bypass this check." "You can run configure with --disable-werror to bypass this check."
exit 1
} }
compile_object() { compile_object() {
@ -494,11 +504,10 @@ SunOS)
LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS" LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
LIBS="-lsunmath $LIBS" LIBS="-lsunmath $LIBS"
else else
echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
echo "libsunmath from the Sun Studio compilers tools, due to a lack of" "libsunmath from the Sun Studio compilers tools, due to a lack of" \
echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
echo "Studio 11 can be downloaded from www.sun.com." "Studio 11 can be downloaded from www.sun.com."
exit 1
fi fi
fi fi
fi fi
@ -1185,8 +1194,7 @@ if test "$ARCH" = "unknown"; then
echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)" echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
ARCH=tci ARCH=tci
else else
echo "Unsupported CPU = $cpu, try --enable-tcg-interpreter" error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
exit 1
fi fi
fi fi
@ -1198,8 +1206,7 @@ EOF
if compile_object ; then if compile_object ; then
: C compiler works ok : C compiler works ok
else else
echo "ERROR: \"$cc\" either does not exist or does not work" error_exit "\"$cc\" either does not exist or does not work"
exit 1
fi fi
# Consult white-list to determine whether to enable werror # Consult white-list to determine whether to enable werror
@ -1254,8 +1261,7 @@ fi
if test "$static" = "yes" ; then if test "$static" = "yes" ; then
if test "$pie" = "yes" ; then if test "$pie" = "yes" ; then
echo "static and pie are mutually incompatible" error_exit "static and pie are mutually incompatible"
exit 1
else else
pie="no" pie="no"
fi fi
@ -1294,8 +1300,7 @@ EOF
fi fi
else else
if test "$pie" = "yes"; then if test "$pie" = "yes"; then
echo "PIE not available due to missing toolchain support" error_exit "PIE not available due to missing toolchain support"
exit 1
else else
echo "Disabling PIE due to missing toolchain support" echo "Disabling PIE due to missing toolchain support"
pie="no" pie="no"
@ -1310,40 +1315,36 @@ if test "$solaris" = "yes" ; then
if has $install; then if has $install; then
: :
else else
echo "Solaris install program not found. Use --install=/usr/ucb/install or" error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
echo "install fileutils from www.blastwave.org using pkg-get -i fileutils" "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
echo "to get ginstall which is used by default (which lives in /opt/csw/bin)" "to get ginstall which is used by default (which lives in /opt/csw/bin)"
exit 1
fi fi
if test "`path_of $install`" = "/usr/sbin/install" ; then if test "`path_of $install`" = "/usr/sbin/install" ; then
echo "Error: Solaris /usr/sbin/install is not an appropriate install program." error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
echo "try ginstall from the GNU fileutils available from www.blastwave.org" "try ginstall from the GNU fileutils available from www.blastwave.org" \
echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install" "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
exit 1
fi fi
if has ar; then if has ar; then
: :
else else
echo "Error: No path includes ar"
if test -f /usr/ccs/bin/ar ; then if test -f /usr/ccs/bin/ar ; then
echo "Add /usr/ccs/bin to your path and rerun configure" error_exit "No path includes ar" \
"Add /usr/ccs/bin to your path and rerun configure"
fi fi
exit 1 error_exit "No path includes ar"
fi fi
fi fi
if ! has $python; then if ! has $python; then
echo "Python not found. Use --python=/path/to/python" error_exit "Python not found. Use --python=/path/to/python"
exit 1
fi fi
# Note that if the Python conditional here evaluates True we will exit # Note that if the Python conditional here evaluates True we will exit
# with status 1 which is a shell 'false' value. # with status 1 which is a shell 'false' value.
if ! "$python" -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then if ! "$python" -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
echo "Cannot use '$python', Python 2.4 or later is required." error_exit "Cannot use '$python', Python 2.4 or later is required." \
echo "Note that Python 3 or later is not yet supported." "Note that Python 3 or later is not yet supported." \
echo "Use --python=/path/to/python to specify a supported Python." "Use --python=/path/to/python to specify a supported Python."
exit 1
fi fi
if test -z "${target_list+xxx}" ; then if test -z "${target_list+xxx}" ; then
@ -1362,11 +1363,8 @@ esac
feature_not_found() { feature_not_found() {
feature=$1 feature=$1
echo "ERROR" error_exit "User requested feature $feature" \
echo "ERROR: User requested feature $feature" "configure was not able to find it"
echo "ERROR: configure was not able to find it"
echo "ERROR"
exit 1;
} }
if test -z "$cross_prefix" ; then if test -z "$cross_prefix" ; then
@ -1408,8 +1406,7 @@ fi
# pkg-config probe # pkg-config probe
if ! has "$pkg_config_exe"; then if ! has "$pkg_config_exe"; then
echo "Error: pkg-config binary '$pkg_config_exe' not found" error_exit "pkg-config binary '$pkg_config_exe' not found"
exit 1
fi fi
########################################## ##########################################
@ -1448,11 +1445,8 @@ EOF
if compile_prog "" "-lz" ; then if compile_prog "" "-lz" ; then
: :
else else
echo error_exit "zlib check failed" \
echo "Error: zlib check failed" "Make sure to have the zlib libs and headers installed."
echo "Make sure to have the zlib libs and headers installed."
echo
exit 1
fi fi
fi fi
@ -1629,14 +1623,12 @@ if test "$xen_pci_passthrough" != "no"; then
xen_pci_passthrough=yes xen_pci_passthrough=yes
else else
if test "$xen_pci_passthrough" = "yes"; then if test "$xen_pci_passthrough" = "yes"; then
echo "ERROR"
echo "ERROR: User requested feature Xen PCI Passthrough"
echo "ERROR: but this feature require /sys from Linux"
if test "$xen_ctrl_version" -lt 340; then if test "$xen_ctrl_version" -lt 340; then
echo "ERROR: This feature does not work with Xen 3.3" error_exit "User requested feature Xen PCI Passthrough" \
"This feature does not work with Xen 3.3"
fi fi
echo "ERROR" error_exit "User requested feature Xen PCI Passthrough" \
exit 1; " but this feature requires /sys from Linux"
fi fi
xen_pci_passthrough=no xen_pci_passthrough=no
fi fi
@ -2010,11 +2002,8 @@ EOF
if compile_prog "$cfl" "$lib" ; then if compile_prog "$cfl" "$lib" ; then
: :
else else
echo error_exit "$drv check failed" \
echo "Error: $drv check failed" "Make sure to have the $drv libs and headers installed."
echo "Make sure to have the $drv libs and headers installed."
echo
exit 1
fi fi
} }
@ -2029,11 +2018,8 @@ for drv in $audio_drv_list; do
fmod) fmod)
if test -z $fmod_lib || test -z $fmod_inc; then if test -z $fmod_lib || test -z $fmod_inc; then
echo error_exit "You must specify path to FMOD library and headers" \
echo "Error: You must specify path to FMOD library and headers" "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
echo
exit 1
fi fi
audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc" audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
libs_softmmu="$fmod_lib $libs_softmmu" libs_softmmu="$fmod_lib $libs_softmmu"
@ -2076,11 +2062,8 @@ for drv in $audio_drv_list; do
*) *)
echo "$audio_possible_drivers" | grep -q "\<$drv\>" || { echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
echo error_exit "Unknown driver '$drv' selected" \
echo "Error: Unknown driver '$drv' selected" "Possible drivers are: $audio_possible_drivers"
echo "Possible drivers are: $audio_possible_drivers"
echo
exit 1
} }
;; ;;
esac esac
@ -2209,8 +2192,7 @@ then
LIBS="$glib_libs $LIBS" LIBS="$glib_libs $LIBS"
libs_qga="$glib_libs $libs_qga" libs_qga="$glib_libs $libs_qga"
else else
echo "glib-$glib_req_ver required to compile QEMU" error_exit "glib-$glib_req_ver required to compile QEMU"
exit 1
fi fi
########################################## ##########################################
@ -2227,11 +2209,10 @@ if test "$pixman" = ""; then
fi fi
if test "$pixman" = "none"; then if test "$pixman" = "none"; then
if test "$want_tools" != "no" -o "$softmmu" != "no"; then if test "$want_tools" != "no" -o "$softmmu" != "no"; then
echo "ERROR: pixman disabled but system emulation or tools build" error_exit "pixman disabled but system emulation or tools build" \
echo " enabled. You can turn off pixman only if you also" "enabled. You can turn off pixman only if you also" \
echo " disable all system emulation targets and the tools" "disable all system emulation targets and the tools" \
echo " build with '--disable-tools --disable-system'." "build with '--disable-tools --disable-system'."
exit 1
fi fi
pixman_cflags= pixman_cflags=
pixman_libs= pixman_libs=
@ -2240,12 +2221,11 @@ elif test "$pixman" = "system"; then
pixman_libs=`$pkg_config --libs pixman-1 2>/dev/null` pixman_libs=`$pkg_config --libs pixman-1 2>/dev/null`
else else
if test ! -d ${source_path}/pixman/pixman; then if test ! -d ${source_path}/pixman/pixman; then
echo "ERROR: pixman not present. Your options:" error_exit "pixman not present. Your options:" \
echo " (1) Preferred: Install the pixman devel package (any recent" " (1) Preferred: Install the pixman devel package (any recent" \
echo " distro should have packages as Xorg needs pixman too)." " distro should have packages as Xorg needs pixman too)." \
echo " (2) Fetch the pixman submodule, using:" " (2) Fetch the pixman submodule, using:" \
echo " git submodule update --init pixman" " git submodule update --init pixman"
exit 1
fi fi
mkdir -p pixman/pixman mkdir -p pixman/pixman
pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman" pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
@ -2304,11 +2284,8 @@ else
fi fi
if test "$mingw32" != yes -a "$pthread" = no; then if test "$mingw32" != yes -a "$pthread" = no; then
echo error_exit "pthread check failed" \
echo "Error: pthread check failed" "Make sure to have the pthread libs and headers installed."
echo "Make sure to have the pthread libs and headers installed."
echo
exit 1
fi fi
########################################## ##########################################
@ -2363,8 +2340,7 @@ fi
if test "$virtio_blk_data_plane" = "yes" -a \ if test "$virtio_blk_data_plane" = "yes" -a \
"$linux_aio" != "yes" ; then "$linux_aio" != "yes" ; then
echo "Error: virtio-blk-data-plane requires Linux AIO, please try --enable-linux-aio" error_exit "virtio-blk-data-plane requires Linux AIO, please try --enable-linux-aio"
exit 1
elif test -z "$virtio_blk_data_plane" ; then elif test -z "$virtio_blk_data_plane" ; then
virtio_blk_data_plane=$linux_aio virtio_blk_data_plane=$linux_aio
fi fi
@ -2861,10 +2837,7 @@ elif compile_prog "" "-lm" ; then
LIBS="-lm $LIBS" LIBS="-lm $LIBS"
libs_qga="-lm $libs_qga" libs_qga="-lm $libs_qga"
else else
echo error_exit "libm check failed"
echo "Error: libm check failed"
echo
exit 1
fi fi
########################################## ##########################################
@ -3040,11 +3013,8 @@ fi
$python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend > /dev/null 2> /dev/null $python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend > /dev/null 2> /dev/null
if test "$?" -ne 0 ; then if test "$?" -ne 0 ; then
echo error_exit "invalid trace backend" \
echo "Error: invalid trace backend" "Please choose a supported trace backend."
echo "Please choose a supported trace backend."
echo
exit 1
fi fi
########################################## ##########################################
@ -3059,10 +3029,7 @@ EOF
LIBS="-lust -lurcu-bp $LIBS" LIBS="-lust -lurcu-bp $LIBS"
libs_qga="-lust -lurcu-bp $libs_qga" libs_qga="-lust -lurcu-bp $libs_qga"
else else
echo error_exit "Trace backend 'ust' missing libust header files"
echo "Error: Trace backend 'ust' missing libust header files"
echo
exit 1
fi fi
fi fi
@ -3070,10 +3037,7 @@ fi
# For 'dtrace' backend, test if 'dtrace' command is present # For 'dtrace' backend, test if 'dtrace' command is present
if test "$trace_backend" = "dtrace"; then if test "$trace_backend" = "dtrace"; then
if ! has 'dtrace' ; then if ! has 'dtrace' ; then
echo error_exit "dtrace command is not found in PATH $PATH"
echo "Error: dtrace command is not found in PATH $PATH"
echo
exit 1
fi fi
trace_backend_stap="no" trace_backend_stap="no"
if has 'stap' ; then if has 'stap' ; then
@ -3131,10 +3095,7 @@ elif test "$coroutine" = "windows" ; then
elif test "$coroutine" = "sigaltstack" ; then elif test "$coroutine" = "sigaltstack" ; then
coroutine_backend=sigaltstack coroutine_backend=sigaltstack
else else
echo error_exit "unknown coroutine backend $coroutine"
echo "Error: unknown coroutine backend $coroutine"
echo
exit 1
fi fi
########################################## ##########################################
@ -3319,8 +3280,7 @@ if test "$softmmu" = yes ; then
tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)" tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
else else
if test "$virtfs" = yes; then if test "$virtfs" = yes; then
echo "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel" error_exit "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
exit 1
fi fi
virtfs=no virtfs=no
fi fi
@ -3967,22 +3927,20 @@ case "$target" in
;; ;;
${target_arch2}-linux-user) ${target_arch2}-linux-user)
if test "$linux" != "yes" ; then if test "$linux" != "yes" ; then
echo "ERROR: Target '$target' is only available on a Linux host" error_exit "Target '$target' is only available on a Linux host"
exit 1
fi fi
target_user_only="yes" target_user_only="yes"
target_linux_user="yes" target_linux_user="yes"
;; ;;
${target_arch2}-bsd-user) ${target_arch2}-bsd-user)
if test "$bsd" != "yes" ; then if test "$bsd" != "yes" ; then
echo "ERROR: Target '$target' is only available on a BSD host" error_exit "Target '$target' is only available on a BSD host"
exit 1
fi fi
target_user_only="yes" target_user_only="yes"
target_bsd_user="yes" target_bsd_user="yes"
;; ;;
*) *)
echo "ERROR: Target '$target' not recognised" error_exit "Target '$target' not recognised"
exit 1 exit 1
;; ;;
esac esac
@ -4113,8 +4071,7 @@ case "$target_arch2" in
TARGET_ARCH=xtensa TARGET_ARCH=xtensa
;; ;;
*) *)
echo "Unsupported target CPU" error_exit "Unsupported target CPU"
exit 1
;; ;;
esac esac
# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH