Currently, to check for cURL, configure uses either pkg-config (the default),
or curl-config (as a fallback).

But curl-config and pkg-config do not have the same set of options:
  - to check for shared libs, both use the option: --libs
  - to check for static libs:
    - pkg-config uses: --static --libs
    - curl-config uses: --static-libs

To add to the complexity, pkg-config is called through the querry_pkg_config
wrapper, that already passes --static when static linking is required, but
there is no such wrapper for curl-config, so we miss the occasion to pass
--static-libs

To fix this:
  - introduce a new variable QEMU_XXX_CONFIG_LIBS_FLAGS that mirrors the
    behavior of QEMU_PKG_CONFIG_FLAGS; this variable can be used by all
    xxx-config scripts (eg. curl-config, but later sdl-config too).
    Default it to '--libs', which is for shared linking;
  - properly use either --libs for pkg-config (--static is already taken
    care of in the wrapper), or $QEMU_XXX_CONFIG_LIBS_FLAGS for curl-config.

Signed-off-by: "Yann E. MORIN" <yann.morin.1...@free.fr>
Reviewed-by: Stefan Hajnoczi <stefa...@gmail.com>
---
 configure |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index d97fd81..67c9238 100755
--- a/configure
+++ b/configure
@@ -126,7 +126,7 @@ audio_win_int=""
 cc_i386=i386-pc-linux-gnu-gcc
 libs_qga=""
 debug_info="yes"
-
+QEMU_XXX_CONFIG_LIBS_FLAGS="--libs"
 target_list=""
 
 # Default value for a variable defining feature "foo".
@@ -626,6 +626,7 @@ for opt do
     static="yes"
     LDFLAGS="-static $LDFLAGS"
     QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
+    QEMU_XXX_CONFIG_LIBS_FLAGS="--static-libs"
   ;;
   --mandir=*) mandir="$optarg"
   ;;
@@ -2077,8 +2078,10 @@ fi
 
 if $pkg_config libcurl --modversion >/dev/null 2>&1; then
   curlconfig="$pkg_config libcurl"
+  curlconfiglibs="--libs"
 else
   curlconfig=curl-config
+  curlconfiglibs="$QEMU_XXX_CONFIG_LIBS_FLAGS"
 fi
 
 if test "$curl" != "no" ; then
@@ -2087,7 +2090,7 @@ if test "$curl" != "no" ; then
 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
 EOF
   curl_cflags=`$curlconfig --cflags 2>/dev/null`
-  curl_libs=`$curlconfig --libs 2>/dev/null`
+  curl_libs=`$curlconfig $curlconfiglibs 2>/dev/null`
   if compile_prog "$curl_cflags" "$curl_libs" ; then
     curl=yes
     libs_tools="$curl_libs $libs_tools"
-- 
1.7.2.5


Reply via email to