[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] Fix cygwin build and simplify feature detection in
From: |
David Turner |
Subject: |
[Qemu-devel] [PATCH] Fix cygwin build and simplify feature detection in 'configure' script |
Date: |
Wed, 10 Jun 2009 13:53:09 +0200 |
Feature detection didn't work properly under cygwin because the OS_CFLAGS=-mno-cygwin
flags was not passed to the feature checks (which only used $ARCH_CFLAGS). The end
result being that features were detected against the mostly-Posix Cygwin headers,
while compilation happened against the Mingw headers which lack many headers like
<sys/uio.h>, <fnmatch.h> and others.
Also, an OS_LDFLAGS=-mno-cygwin was missing, resulting in a link-time error
Finally, three helper functions are introduced to simplify feature detection within
the configure script: check_compile, check_link and check_link_with_log. Feature
detection code was modified to use them instead of directly calling $cc with a really
long list of arguments.
---
configure | 98 +++++++++++++++++++++++++++++++++++--------------------------
1 files changed, 56 insertions(+), 42 deletions(-)
diff --git a/configure b/configure
index 89e7f53..e0191f0 100755
--- a/configure
+++ b/configure
@@ -73,7 +73,21 @@ cat > $TMPC <<EOF
#endif
int main(void) { return 0; }
EOF
- $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
+ $cc $ARCH_CFLAGS -c -o $TMPO $TMPC ${OS_CFLAGS} > /dev/null 2> /dev/null
+}
+
+check_compile() {
+ $cc $ARCH_CFLAGS $OS_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
+}
+
+check_link() {
+ $cc $ARCH_CFLAGS $OS_CFLAGS -o $TMPE $TMPC $* > /dev/null 2> /dev/null
+}
+
+check_link_with_log() {
+ TMPLOG=$1
+ shift
+ $cc $ARCH_CFLAGS $OS_CFLAGS -o $TMPE $TMPC $* > $TMPLOG 2>&1
}
if check_define __i386__ ; then
@@ -216,6 +230,7 @@ case $targetos in
CYGWIN*)
mingw32="yes"
OS_CFLAGS="-mno-cygwin"
+OS_LDFLAGS="-mno-cygwin"
if [ "$cpu" = "i386" ] ; then
kqemu="yes"
fi
@@ -763,7 +778,7 @@ int main(int argc, char ** argv){
}
EOF
-if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
+if check_link; then
$TMPE && bigendian="yes"
else
echo big/little test failed
@@ -809,7 +824,7 @@ void foo()
}
EOF
-if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
+if check_compile; then
:
else
nptl="no"
@@ -822,7 +837,7 @@ cat > $TMPC << EOF
#include <zlib.h>
int main(void) { zlibVersion(); return 0; }
EOF
-if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lz > /dev/null 2> /dev/null ; then
+if check_link -lz; then
:
else
echo
@@ -841,7 +856,7 @@ cat > $TMPC <<EOF
#include <xs.h>
int main(void) { xs_daemon_open; xc_interface_open; }
EOF
- if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC -lxenstore -lxenctrl 2> /dev/null > /dev/null ; then
+ if check_link -lxenstore -lxenctrl; then
:
else
xen="no"
@@ -855,6 +870,8 @@ sdl_too_old=no
if test "$sdl" = "yes" ; then
sdl_config="sdl-config"
+ sdl_cflags=`$sdl_config --cflags 2> /dev/null`
+ sdl_ldflags=`$sdl_config --libs 2> /dev/null`
sdl=no
sdl_static=no
@@ -863,7 +880,7 @@ cat > $TMPC << EOF
#undef main /* We don't want SDL to override our main() */
int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
EOF
- if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` > $TMPSDLLOG 2>&1 ; then
+ if check_link_with_log $TMPSDLLOG $sdl_cflags $sdl_ldflags; then
_sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
if test "$_sdlversion" -lt 121 ; then
sdl_too_old=yes
@@ -882,7 +899,7 @@ EOF
sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
fi
- if $cc -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs > /dev/null 2> /dev/null; then
+ if check_link `$sdl_config --cflags 2> /dev/null` $sdl_static_libs; then
sdl_static=yes
fi
fi # static link
@@ -905,8 +922,8 @@ cat > $TMPC <<EOF
#endif
int main(void) { return 0; }
EOF
- if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` > /dev/null 2>&1 ; then
- sdl_x11="yes"
+ if check_link $sdl_cflags $sdl_ldflags; then
+ sdl_x11="yes"
fi
fi
@@ -919,11 +936,10 @@ int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
EOF
vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
- if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $vnc_tls_cflags $TMPC \
- $vnc_tls_libs > /dev/null 2> /dev/null ; then
- :
+ if check_link $vnc_tls_cflags $vnc_tls_libs; then
+ :
else
- vnc_tls="no"
+ vnc_tls="no"
fi
fi
@@ -938,11 +954,10 @@ EOF
# Assuming Cyrus-SASL installed in /usr prefix
vnc_sasl_cflags=""
vnc_sasl_libs="-lsasl2"
- if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $vnc_sasl_cflags $TMPC \
- $vnc_sasl_libs 2> /dev/null > /dev/null ; then
- :
+ if check_link $vnc_sasl_cflags $vnc_sasl_libs; then
+ :
else
- vnc_sasl="no"
+ vnc_sasl="no"
fi
fi
@@ -957,7 +972,7 @@ int main(void)
return 0;
}
EOF
-if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
+if check_link; then
fnmatch="yes"
fi
@@ -973,7 +988,7 @@ int main(void)
return 0;
}
EOF
- if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lvdeplug > /dev/null 2> /dev/null ; then
+ if check_link -lvdeplug; then
:
else
vde="no"
@@ -994,7 +1009,7 @@ audio_drv_probe()
#include <$hdr>
int main(void) { $exp }
EOF
- if $cc $ARCH_CFLAGS $cfl -o $TMPE $TMPC $lib > /dev/null 2> /dev/null ; then
+ if check_link $cfl $lib; then
:
else
echo
@@ -1058,8 +1073,8 @@ cat > $TMPC << EOF
#include <brlapi.h>
int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
EOF
- if $cc ${ARCH_CFLAGS} -o $TMPE ${OS_CFLAGS} $TMPC -lbrlapi > /dev/null 2> /dev/null ; then
- brlapi=yes
+ if check_link -lbrlapi; then
+ brlapi=yes
fi # brlapi compile test
fi # -z $brlapi
@@ -1075,7 +1090,7 @@ if test "$curses" = "yes" ; then
#endif
int main(void) { resize_term(0, 0); return curses_version(); }
EOF
- if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lcurses > /dev/null 2> /dev/null ; then
+ if check_link -lcurses; then
curses=yes
fi
fi # test "$curses"
@@ -1089,8 +1104,9 @@ if test "$curl" = "yes" ; then
#include <curl/curl.h>
int main(void) { return curl_easy_init(); }
EOF
+ curl_cflags=`curl-cflags --cflags 2>/dev/null`
curl_libs=`curl-config --libs 2>/dev/null`
- if $cc $ARCH_CFLAGS $curl_libs -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
+ if check_link $curl_cflags $curl_libs; then
curl=yes
fi
fi # test "$curl"
@@ -1107,8 +1123,7 @@ int main(void) { return bt_error(0); }
EOF
bluez_cflags=`pkg-config --cflags bluez 2> /dev/null`
bluez_libs=`pkg-config --libs bluez 2> /dev/null`
- if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $bluez_cflags $TMPC \
- $bluez_libs > /dev/null 2> /dev/null ; then
+ if check_link $bluez_cflags $bluez_libs; then
:
else
bluez="no"
@@ -1139,24 +1154,23 @@ EOF
if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
-a -d "$kerneldir/arch/x86/include" ; then
kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
- elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
- kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
+ elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
+ kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
elif test -d "$kerneldir/arch/$cpu/include" ; then
kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
fi
else
kvm_cflags=""
fi
- if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC \
- > /dev/null 2>/dev/null ; then
+ if check_link $kvm_cflags; then
:
else
kvm="no";
if [ -x "`which awk 2>/dev/null`" ] && \
[ -x "`which grep 2>/dev/null`" ]; then
kvmerr=`LANG=C $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC 2>&1 \
- | grep "error: " \
- | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
+ | grep "error: " \
+ | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
if test "$kvmerr" != "" ; then
kvm="no - (${kvmerr})\n\
NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
@@ -1178,7 +1192,7 @@ cat > $TMPC << EOF
int main(void) { pthread_create(0,0,0,0); return 0; }
EOF
for pthread_lib in $PTHREADLIBS_LIST; do
- if $cc $ARCH_CFLAGS -o $TMPE $TMPC $pthread_lib 2> /dev/null > /dev/null ; then
+ if check_link $pthread_lib; then
pthread=yes
PTHREADLIBS="$pthread_lib"
break
@@ -1200,7 +1214,7 @@ cat > $TMPC <<EOF
int main(void) { struct iovec iov; return 0; }
EOF
iovec=no
-if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
+if check_link; then
iovec=yes
fi
@@ -1213,7 +1227,7 @@ cat > $TMPC <<EOF
int main(void) { preadv; }
EOF
preadv=no
-if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
+if check_link; then
preadv=yes
fi
@@ -1224,7 +1238,7 @@ if test "$fdt" = "yes" ; then
cat > $TMPC << EOF
int main(void) { return 0; }
EOF
- if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lfdt 2> /dev/null > /dev/null ; then
+ if check_link -lfdt; then
fdt=yes
fi
fi
@@ -1249,7 +1263,7 @@ main(void)
return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
}
EOF
- if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null > /dev/null ; then
+ if check_link; then
atfile=yes
fi
fi
@@ -1271,7 +1285,7 @@ main(void)
return inotify_init();
}
EOF
- if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null > /dev/null ; then
+ if check_link; then
inotify=yes
fi
fi
@@ -1291,9 +1305,9 @@ int main(void) { clockid_t id; return clock_gettime(id, NULL); }
EOF
rt=no
-if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
+if check_link; then
:
-elif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lrt > /dev/null 2> /dev/null ; then
+elif check_link -lrt; then
rt=yes
fi
@@ -1529,7 +1543,7 @@ else
#include <byteswap.h>
int main(void) { return bswap_32(0); }
EOF
- if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
+ if check_link; then
echo "#define HAVE_BYTESWAP_H 1" >> $config_h
fi
cat > $TMPC << EOF
@@ -1538,7 +1552,7 @@ EOF
#include <machine/bswap.h>
int main(void) { return bswap32(0); }
EOF
- if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
+ if check_link; then
echo "#define HAVE_MACHINE_BSWAP_H 1" >> $config_h
fi
fi
--
1.6.1.2
- [Qemu-devel] [PATCH] Fix cygwin build and simplify feature detection in 'configure' script,
David Turner <=
- [Qemu-devel] Re: [PATCH] Fix cygwin build and simplify feature detection in 'configure' script, David Turner, 2009/06/10
- Re: [Qemu-devel] Re: [PATCH] Fix cygwin build and simplify feature detection in 'configure' script, malc, 2009/06/10
- Re: [Qemu-devel] Re: [PATCH] Fix cygwin build and simplify feature detection in 'configure' script, David Turner, 2009/06/10
- Re: [Qemu-devel] Re: [PATCH] Fix cygwin build and simplify feature detection in 'configure' script, Filip Navara, 2009/06/10
- Re: [Qemu-devel] Re: [PATCH] Fix cygwin build and simplify feature detection in 'configure' script, David Turner, 2009/06/10
- Re: [Qemu-devel] Re: [PATCH] Fix cygwin build and simplify feature detection in 'configure' script, David Turner, 2009/06/10
- Re: [Qemu-devel] Re: [PATCH] Fix cygwin build and simplify feature detection in 'configure' script, David Turner, 2009/06/10
- Re: [Qemu-devel] Re: [PATCH] Fix cygwin build and simplify feature detection in 'configure' script, malc, 2009/06/10
- Re: [Qemu-devel] Re: [PATCH] Fix cygwin build and simplify feature detection in 'configure' script, Jamie Lokier, 2009/06/11
- Re: [Qemu-devel] Re: [PATCH] Fix cygwin build and simplify feature detection in 'configure' script, Daniel P. Berrange, 2009/06/12