Skip to contentSkip to conversation

pkg-config related fixes for cross compilation

PATCH Superseded Paolo Bonzini 1 participant 5 messages Jan 13, 2010

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover pkg-config related fixes for cross compilation

This is v2 of the series to simplify cross-compiling, by using a cross pkg-config tool whenever possible.

I'm now using pkg-config also in the native compilation case whenever possible. I also found and fixed a typo in the static SDL case.

Paolo Bonzini (4):
use cross-prefix for pkgconfig
fixes to the static compilation case for sdl
use pkg-config for sdl whenever available
use pkg-config for libcurl whenever available

 configure |   50 +++++++++++++++++++++++++++++++++++--------------
 1 files changed, 36 insertions(+), 14 deletions(-)
#1 lore raw

PATCH v2 1/4 use cross-prefix for pkgconfig

Since pkgconfig can give different output for different targets, it should be tried with the cross-compilation prefix first.

---
 configure |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
configure +14 -5
index 5c056f5..f3584db 100755
@@ -965,6 +965,15 @@ EOF
 fi
 
 ##########################################
+# pkgconfig probe
+
+pkgconfig="${cross_prefix}pkg-config"
+if ! test -x "$(which $pkgconfig 2>/dev/null)"; then
+  # likely not cross compiling, or hope for the best
+  pkgconfig=pkg-config
+fi
+
+##########################################
 # Sparse probe
 if test "$sparse" != "no" ; then
   if test -x "$(which cgcc 2>/dev/null)"; then
@@ -1047,8 +1056,8 @@ if test "$vnc_tls" != "no" ; then
 #include <gnutls/gnutls.h>
 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`
+  vnc_tls_cflags=`$pkgconfig --cflags gnutls 2> /dev/null`
+  vnc_tls_libs=`$pkgconfig --libs gnutls 2> /dev/null`
   if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
     vnc_tls=yes
     libs_softmmu="$vnc_tls_libs $libs_softmmu"
@@ -1320,7 +1329,7 @@ if test "$check_utests" != "no" ; then
 #include <check.h>
 int main(void) { suite_create("qemu test"); return 0; }
 EOF
-  check_libs=`pkg-config --libs check`
+  check_libs=`$pkgconfig --libs check`
   if compile_prog "" $check_libs ; then
     check_utests=yes
     libs_tools="$check_libs $libs_tools"
@@ -1339,8 +1348,8 @@ if test "$bluez" != "no" ; then
 #include <bluetooth/bluetooth.h>
 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`
+  bluez_cflags=`$pkgconfig --cflags bluez 2> /dev/null`
+  bluez_libs=`$pkgconfig --libs bluez 2> /dev/null`
   if compile_prog "$bluez_cflags" "$bluez_libs" ; then
     bluez=yes
     libs_softmmu="$bluez_libs $libs_softmmu"
Signature · 1 line
1.6.5.2
#2 lore raw

PATCH v2 2/4 fixes to the static compilation case for sdl

In reply to Paolo Bonzini

After the next commit, pkg-config could be used for the shared library configuration case and sdl-config for static libraries. So I prepare the test here by doing two changes:

at the same time I remove useless backslashes from the invocation of grep;

1) fixing a typo ($sd_cflags). The typo has been there since commit 1ac88f2 (remove sdl_static. Just do the right thing if static is yes, 2009-07-27).

2) fixing an erroneous "test ... | grep > /dev/null" idiom that would never succeed since grep's output would be empty;

3) checking the status code after executing sdl-config --static --libs; this is needed for the next patch only.

---
1 and 2 above show that the aalib-config case is not very much used. In addition to this, on my system aalib-config does not support --static-libs at all. So I was very much tempted to nuke the aalib-config handling completely.

 configure |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
configure +3 -3
index f3584db..b8641b8 100755
@@ -1009,12 +1009,12 @@ EOF
       fi
     fi
 
-    # static link with sdl ?
+    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
     if test "$sdl" = "yes" -a "$static" = "yes" ; then
       sdl_libs=`sdl-config --static-libs 2>/dev/null`
-      if test `sdl-config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` ; then
+      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
          sdl_libs="$sdl_libs `aalib-config --static-libs >2 /dev/null`"
-         sdl_cflags="$sd_cflags `aalib-config --cflags >2 /dev/null`"
+         sdl_cflags="$sdl_cflags `aalib-config --cflags >2 /dev/null`"
       fi
       if compile_prog "$sdl_cflags" "$sdl_libs" ; then
 	:
Signature · 1 line
1.6.5.2
#3 lore raw

PATCH v2 3/4 use pkg-config for sdl whenever available

In reply to Paolo Bonzini

Together with the first patch this enables using the prefixed pkg-config, thus picking up the correct flags for SDL.

---
 configure |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
configure +10 -4
index b8641b8..2553724 100755
@@ -989,18 +989,24 @@ fi
 ##########################################
 # SDL probe
 
-sdl_too_old=no
+if $pkgconfig sdl --modversion >/dev/null 2>&1; then
+  sdlconfig="$pkgconfig sdl"
+  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
+else
+  sdlconfig='sdl-config'
+  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
+fi
 
+sdl_too_old=no
 if test "$sdl" != "no" ; then
   cat > $TMPC << EOF
 #include <SDL.h>
 #undef main /* We don't want SDL to override our main() */
 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
 EOF
-  sdl_cflags=`sdl-config --cflags 2> /dev/null`
-  sdl_libs=`sdl-config --libs 2> /dev/null`
+  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
+  sdl_libs=`$sdlconfig --libs 2> /dev/null`
   if compile_prog "$sdl_cflags" "$sdl_libs" ; then
-    _sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
     if test "$_sdlversion" -lt 121 ; then
       sdl_too_old=yes
     else
Signature · 1 line
1.6.5.2
#4 lore raw

PATCH v2 4/4 use pkg-config for libcurl whenever available

In reply to Paolo Bonzini
---
 configure |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
configure +8 -2
index 2553724..b3d4640 100755
@@ -1309,13 +1309,19 @@ fi
 ##########################################
 # curl probe
 
+if $pkgconfig libcurl --modversion >/dev/null 2>&1; then
+  curlconfig='$pkgconfig libcurl'
+else
+  curlconfig=curl-config
+fi
+
 if test "$curl" != "no" ; then
   cat > $TMPC << EOF
 #include <curl/curl.h>
 int main(void) { return curl_easy_init(); }
 EOF
-  curl_cflags=`curl-config --cflags 2>/dev/null`
-  curl_libs=`curl-config --libs 2>/dev/null`
+  curl_cflags=`$curlconfig --cflags 2>/dev/null`
+  curl_libs=`$curlconfig --libs 2>/dev/null`
   if compile_prog "$curl_cflags" "$curl_libs" ; then
     curl=yes
     libs_tools="$curl_libs $libs_tools"
Signature · 1 line
1.6.5.2