Skip to contentSkip to conversation

./configure: request pkg-config to provide private libs when static linking

PATCH Superseded Sergei Trofimovich 3 participants 9 messages Jan 23, 2012 – Jan 29, 2012

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ./configure: request pkg-config to provide private libs when static linking

From: Sergei Trofimovich <[email protected]>

---
 configure |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
configure +1 -0
index 467e87b..f3dcfba 100755
@@ -553,6 +553,7 @@ for opt do
   --static)
     static="yes"
     LDFLAGS="-static $LDFLAGS"
+    pkg_config="${pkg_config} --static"
   ;;
   --mandir=*) mandir="$optarg"
   ;;
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 2/2 ./configure: add link check for nss-smartcard

From: Sergei Trofimovich <[email protected]>

Current './configure --static && make' fails for me:

    LINK  qemu-nbd
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lssl3
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lsmime3
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lnssutil3
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lnss3
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lplds4
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lplc4
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lnspr4

My system does not provide static libraries for nss, so fix autoconfiguration by link checking.

---
 configure |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
configure +9 -4
index f3dcfba..9ef8422 100755
@@ -2520,11 +2520,16 @@ if test "$smartcard" != "no" ; then
     smartcard_cflags=""
     # TODO - what's the minimal nss version we support?
     if test "$smartcard_nss" != "no"; then
-        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 ; then
+      cat > $TMPC << EOF
+#include <pk11pub.h>
+int main(void) { PK11_FreeSlot(0); return 0; }
+EOF
+        smartcard_cflags="-I\$(SRC_PATH)/libcacard"
+        libcacard_libs=$($pkg_config --libs nss 2>/dev/null)
+        libcacard_cflags=$($pkg_config --cflags nss 2>/dev/null)
+        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \
+          compile_prog "$smartcard_cflags $libcacard_cflags" "$libcacard_libs"; then
             smartcard_nss="yes"
-            smartcard_cflags="-I\$(SRC_PATH)/libcacard"
-            libcacard_libs=$($pkg_config --libs nss 2>/dev/null)
-            libcacard_cflags=$($pkg_config --cflags nss 2>/dev/null)
             QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags"
             LIBS="$libcacard_libs $LIBS"
         else
Signature · 1 line
1.7.3.4
#2 lore raw

Re: [Qemu-devel] [PATCH 2/2] ./configure: add link check for nss-smartcard

Quoted 2 lines · Sergei Trofimovich

From: Sergei Trofimovich <[email protected]>

Looks good to me.

Quoted 48 lines

Current './configure --static && make' fails for me:

    LINK  qemu-nbd
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lssl3
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lsmime3
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lnssutil3
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lnss3
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lplds4
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lplc4
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lnspr4

My system does not provide static libraries for nss, so fix autoconfiguration by link checking.

---
 configure |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
configure +9 -4
index f3dcfba..9ef8422 100755
@@ -2520,11 +2520,16 @@ if test "$smartcard" != "no" ; then
     smartcard_cflags=""
     # TODO - what's the minimal nss version we support?
     if test "$smartcard_nss" != "no"; then
-        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 ; then
+      cat > $TMPC << EOF
+#include <pk11pub.h>
+int main(void) { PK11_FreeSlot(0); return 0; }
+EOF
+        smartcard_cflags="-I\$(SRC_PATH)/libcacard"
+        libcacard_libs=$($pkg_config --libs nss 2>/dev/null)
+        libcacard_cflags=$($pkg_config --cflags nss 2>/dev/null)
+        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \
+          compile_prog "$smartcard_cflags $libcacard_cflags" "$libcacard_libs"; then
             smartcard_nss="yes"
-            smartcard_cflags="-I\$(SRC_PATH)/libcacard"
-            libcacard_libs=$($pkg_config --libs nss 2>/dev/null)
-            libcacard_cflags=$($pkg_config --cflags nss 2>/dev/null)
             QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags"
             LIBS="$libcacard_libs $LIBS"
         else
Signature · 1 line
1.7.3.4
#3 lore raw

Re: [Qemu-devel] [PATCH 2/2] ./configure: add link check for nss-smartcard

In reply to Sergei Trofimovich
Quoted 13 lines · On Mon, 23 Jan 2012 10:41:38 +0300 Sergei Trofimovich <[email protected]> wrote:

From: Sergei Trofimovich <[email protected]>

Current './configure --static && make' fails for me:

    LINK  qemu-nbd
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lssl3
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lsmime3
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lnssutil3
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lnss3
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lplds4
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lplc4
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lnspr4
Quoted 7 lines

My system does not provide static libraries for nss, so fix autoconfiguration by link checking.

---
 configure |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

ping

Signature · 1 line
  Sergei
#4 lore raw
In reply to Sergei Trofimovich
Quoted 13 lines · Sergei Trofimovich

From: Sergei Trofimovich <[email protected]>

---
 configure |    1 +

 1 files changed, 1 insertions(+), 0 deletions(-)
configure +0 -0
index 467e87b..f3dcfba 100755
@@ -553,6 +553,7 @@ for opt do
   --static)
Quoted 6 lines

    static="yes"
    LDFLAGS="-static $LDFLAGS"
+    pkg_config="${pkg_config} --static"
  ;;
  --mandir=*) mandir="$optarg"
  ;;

I guess this works, but it seems a bit fragile, for example if ! has $pkg_config; then
...
will work, but
if ! has "$pkg_config"; then
...

won't.

-- PMM

#5 lore raw

PATCH v2 1/2 ./configure: request pkg-config to provide private libs when static linking

From: Sergei Trofimovich <[email protected]>

Added wrapper around pkg-config to allow:
- safe options injection via ${QEMU_PKG_CONFIG_FLAGS}
- spaces in path to pkg-config

---
 configure |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
configure +8 -3
index 467e87b..97d51a7 100755
@@ -234,7 +234,11 @@ ld="${LD-${cross_prefix}ld}"
 libtool="${LIBTOOL-${cross_prefix}libtool}"
 strip="${STRIP-${cross_prefix}strip}"
 windres="${WINDRES-${cross_prefix}windres}"
-pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}"
+pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
+query_pkg_config() {
+    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
+}
+pkg_config=query_pkg_config # TODO: sed 's/$pkg_config/pkg_config/g'
 sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
 
 # default flags for all hosts
@@ -553,6 +557,7 @@ for opt do
   --static)
     static="yes"
     LDFLAGS="-static $LDFLAGS"
+    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
   ;;
   --mandir=*) mandir="$optarg"
   ;;
@@ -1445,8 +1450,8 @@ fi
 ##########################################
 # pkg-config probe
 
-if ! has $pkg_config; then
-  echo "Error: pkg-config binary '$pkg_config' not found"
+if ! has "$pkg_config_exe"; then
+  echo "Error: pkg-config binary '$pkg_config_exe' not found"
   exit 1
 fi
 
Signature · 1 line
1.7.8.3
#6 lore raw
Quoted 11 lines · Sergei Trofimovich
(quoted diff) +0 -0
@@ -234,7 +234,11 @@ ld="${LD-${cross_prefix}ld}"

 libtool="${LIBTOOL-${cross_prefix}libtool}"
 strip="${STRIP-${cross_prefix}strip}"
 windres="${WINDRES-${cross_prefix}windres}"

configure +5 -1
-pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}"
+pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
+query_pkg_config() {
+    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
+}
+pkg_config=query_pkg_config # TODO: sed 's/$pkg_config/pkg_config/g'

 sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"

Either it's worth making the change suggested in the TODO, in which case we should have another patch in the series which does it (and drop the TODO comment here), or it's not worth making the change, in which case we should just drop the TODO comment.

If we do make the substitution, I think it should be s/$pkg_config/query_pkg_config/ because having a local shell function which silently shadows the well-known pkg_config binary would be pretty confusing.

I'm happy for us not to make the substitution, I think.

-- PMM

#7 lore raw

PATCH v3 1/2 ./configure: request pkg-config to provide private libs when static linking

From: Sergei Trofimovich <[email protected]>

Added wrapper around pkg-config to allow:
- safe options injection via ${QEMU_PKG_CONFIG_FLAGS}
- spaces in path to pkg-config

---
 configure |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
configure +8 -3
index 467e87b..c90e519 100755
@@ -234,7 +234,11 @@ ld="${LD-${cross_prefix}ld}"
 libtool="${LIBTOOL-${cross_prefix}libtool}"
 strip="${STRIP-${cross_prefix}strip}"
 windres="${WINDRES-${cross_prefix}windres}"
-pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}"
+pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
+query_pkg_config() {
+    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
+}
+pkg_config=query_pkg_config
 sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
 
 # default flags for all hosts
@@ -553,6 +557,7 @@ for opt do
   --static)
     static="yes"
     LDFLAGS="-static $LDFLAGS"
+    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
   ;;
   --mandir=*) mandir="$optarg"
   ;;
@@ -1445,8 +1450,8 @@ fi
 ##########################################
 # pkg-config probe
 
-if ! has $pkg_config; then
-  echo "Error: pkg-config binary '$pkg_config' not found"
+if ! has "$pkg_config_exe"; then
+  echo "Error: pkg-config binary '$pkg_config_exe' not found"
   exit 1
 fi
 
Signature · 1 line
1.7.8.3