qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Turner <digit@google.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] Fix cygwin build and simplify feature detection in 'configure' script
Date: Wed, 10 Jun 2009 22:52:17 +0200	[thread overview]
Message-ID: <60cad3f0906101352o55dbb029i96989f52503e22a1@mail.gmail.com> (raw)
In-Reply-To: <60cad3f0906100453y7a27dc2fhb1ea7d4c6f69e861@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 12416 bytes --]

As a related note, is anyone seriously using/developing the mainline QEMU
sources on/for Windows?

If so, what is the recommended environment to do so? I'm currently using
cygwin to generate
mingw-linked binaries (which dont require cygwin.dll at runtime), but I can
think of other ways
to generate these:

- using MSYS + mingw
- using mingw and the Windows command line
- using Linux and the linux-mingw32 toolchain

Finally, what is the best way to send patches to this list?. I notice that
many patches are also sent
directly to various developers, and that they tend to get
reviewed/accepted/rejected a tad more rapidly.

Is it ok to send patches as attachments ? or should they be sent with
git-send-email instead?

By the way, I'd be happy to regularly check the Windows mainline build if
that can help.

I'm also preparing a series of patches that fix several Windows-specific
issues (most of them related
to this horrible thing they called Winsock...).

Thanks for your time.

- David

On Wed, Jun 10, 2009 at 1:53 PM, David Turner <digit@google.com> wrote:

> 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.
>
> Signed-off-by: digit <digit@google.com>
> ---
>  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
>
>
>
>

[-- Attachment #2: Type: text/html, Size: 17571 bytes --]

  reply	other threads:[~2009-06-10 20:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-10 11:53 [Qemu-devel] [PATCH] Fix cygwin build and simplify feature detection in 'configure' script David Turner
2009-06-10 20:52 ` David Turner [this message]
2009-06-10 21:40   ` [Qemu-devel] " malc
2009-06-10 22:09     ` David Turner
2009-06-10 22:17       ` Filip Navara
2009-06-10 22:29         ` David Turner
2009-06-10 23:32           ` David Turner
2009-06-11  0:53             ` David Turner
2009-06-10 22:19       ` malc
2009-06-12  2:26         ` Jamie Lokier
2009-06-12  9:55           ` Daniel P. Berrange
2009-06-12 10:36             ` Mark Cave-Ayland
2009-06-10 21:46   ` Consul
  -- strict thread matches above, loose matches on Subject: below --
2009-06-10 22:02 Teemu Nätkinniemi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60cad3f0906101352o55dbb029i96989f52503e22a1@mail.gmail.com \
    --to=digit@google.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).