From: Jan Kiszka <jan.kis...@siemens.com>

Not all (didn't find any) mingw32 cross-toolchains ship a binutils-devel
package, thus lack libiberty.a. According to 08f3896a, -liberty is only
needed for getopt when building for 64 bit. Test for the availability
of a getopt implementation and only pull in libiberty when linking
without it failed.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>
---
 configure |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 6911c3b..42effb9 100755
--- a/configure
+++ b/configure
@@ -481,7 +481,16 @@ if test "$mingw32" = "yes" ; then
   QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
   # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
   QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
-  LIBS="-lwinmm -lws2_32 -liberty -liphlpapi $LIBS"
+  # check need for -liberty (getopt on w64)
+  cat > $TMPC << EOF
+#include <unistd.h>
+int main(void) { return getopt(0, NULL, NULL); }
+EOF
+  if compile_prog "" "" ; then
+    LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
+  else
+    LIBS="-lwinmm -lws2_32 -liberty -liphlpapi $LIBS"
+  fi
   prefix="c:/Program Files/Qemu"
   mandir="\${prefix}"
   datadir="\${prefix}"
-- 
1.7.3.4

Reply via email to