[libvirt] [PATCH 1/2] build: properly handle ./configure --with-libpcap

Without this fix, ./configure --with-libpcap will cause --with-libpcap=yes to be implicitly passed down, which cause yes/bin/pcap-config to be searched for rather than /usr/bin/pcap-config. Also output pcap: no when pcap is not found or disabled. --- configure.ac | 30 ++++++++++++++++-------------- 1 files changed, 16 insertions(+), 14 deletions(-) diff --git a/configure.ac b/configure.ac index d8be160..b5c995f 100644 --- a/configure.ac +++ b/configure.ac @@ -1194,20 +1194,22 @@ LIBPCAP_FOUND="no" AC_ARG_WITH([libpcap], AC_HELP_STRING([--with-libpcap=@<:@PFX@:>@], [libpcap location])) if test "$with_qemu" = "yes"; then - if test "x$with_libpcap" != "xno" ; then - if test "x$with_libpcap" != "x" ; then - LIBPCAP_CONFIG=$with_libpcap/bin/$LIBPCAP_CONFIG - fi - AC_MSG_CHECKING(libpcap $LIBPCAP_CONFIG >= $LIBPCAP_REQUIRED ) - if ! $LIBPCAP_CONFIG --libs > /dev/null 2>&1 ; then - AC_MSG_RESULT(no) - else - LIBPCAP_LIBS="`$LIBPCAP_CONFIG --libs`" - LIBPCAP_CFLAGS="`$LIBPCAP_CONFIG --cflags`" - LIBPCAP_FOUND="yes" - AC_MSG_RESULT(yes) - fi + AS_CASE(["x$with_libpcap"], + [xno], [LIBPCAP_CONFIG=""], + [x|xyes], [LIBPCAP_CONFIG="pcap-config"], + [LIBPCAP_CONFIG="$with_libpcap/bin/pcap-config"] + ) + AS_IF([test "x$LIBPCAP_CONFIG" != "x"], [ + AC_MSG_CHECKING(libpcap $LIBPCAP_CONFIG >= $LIBPCAP_REQUIRED ) + if ! $LIBPCAP_CONFIG --libs > /dev/null 2>&1 ; then + AC_MSG_RESULT(no) + else + LIBPCAP_LIBS="`$LIBPCAP_CONFIG --libs`" + LIBPCAP_CFLAGS="`$LIBPCAP_CONFIG --cflags`" + LIBPCAP_FOUND="yes" + AC_MSG_RESULT(yes) fi + ]) fi if test "x$LIBPCAP_FOUND" = "xyes"; then @@ -2406,7 +2408,7 @@ AC_MSG_NOTICE([ xmlrpc: $XMLRPC_CFLAGS $XMLRPC_LIBS]) else AC_MSG_NOTICE([ xmlrpc: no]) fi -if test "$with_qemu" = "yes" ; then +if test "$with_qemu" = "yes" -a "$LIBPCAP_FOUND" != "no"; then AC_MSG_NOTICE([ pcap: $LIBPCAP_CFLAGS $LIBPCAP_LIBS]) else AC_MSG_NOTICE([ pcap: no]) -- 1.7.3.3

--- configure.ac | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index b5c995f..eb1425a 100644 --- a/configure.ac +++ b/configure.ac @@ -73,7 +73,7 @@ VERSION_SCRIPT_FLAGS=-Wl,--version-script= LIBVIRT_COMPILE_WARNINGS([maximum]) AC_MSG_CHECKING([for CPUID instruction]) -AC_COMPILE_IFELSE(AC_LANG_PROGRAM( +AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[ #include <stdint.h> ]], @@ -83,7 +83,7 @@ AC_COMPILE_IFELSE(AC_LANG_PROGRAM( "cpuid" : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) : "a" (eax)); - ]]), + ]])], [have_cpuid=yes], [have_cpuid=no]) if test "x$have_cpuid" = xyes; then -- 1.7.3.3

On 12/13/2010 06:44 AM, Diego Elio Pettenò wrote:
--- configure.ac | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac index b5c995f..eb1425a 100644 --- a/configure.ac +++ b/configure.ac @@ -73,7 +73,7 @@ VERSION_SCRIPT_FLAGS=-Wl,--version-script= LIBVIRT_COMPILE_WARNINGS([maximum])
AC_MSG_CHECKING([for CPUID instruction]) -AC_COMPILE_IFELSE(AC_LANG_PROGRAM( +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
ACK, and pushed. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 12/13/2010 06:44 AM, Diego Elio Pettenò wrote:
Without this fix, ./configure --with-libpcap will cause --with-libpcap=yes to be implicitly passed down, which cause yes/bin/pcap-config to be searched for rather than /usr/bin/pcap-config.
Also output pcap: no when pcap is not found or disabled. --- configure.ac | 30 ++++++++++++++++-------------- 1 files changed, 16 insertions(+), 14 deletions(-)
You forgot to run 'make syntax-check', which flagged a problem here:
@@ -2406,7 +2408,7 @@ AC_MSG_NOTICE([ xmlrpc: $XMLRPC_CFLAGS $XMLRPC_LIBS]) else AC_MSG_NOTICE([ xmlrpc: no]) fi -if test "$with_qemu" = "yes" ; then +if test "$with_qemu" = "yes" -a "$LIBPCAP_FOUND" != "no"; then
This must be test abc && test xyz, not test abc -a xyz, to avoid portability problems. ACK with that nit fixed, so I pushed it. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 12/13/2010 06:44 AM, Diego Elio Pettenò wrote:
Without this fix, ./configure --with-libpcap will cause --with-libpcap=yes to be implicitly passed down, which cause yes/bin/pcap-config to be searched for rather than /usr/bin/pcap-config.
+ AS_CASE(["x$with_libpcap"], + [xno], [LIBPCAP_CONFIG=""], + [x|xyes], [LIBPCAP_CONFIG="pcap-config"], + [LIBPCAP_CONFIG="$with_libpcap/bin/pcap-config"] + )
Oops; AS_CASE is not supported in autoconf 2.59, which means this breaks builds on RHEL 5. If you don't beat me to it, I'll submit a patch that breaks this into a raw shell case statement (AS_CASE is really only needed when you invoke other autoconf macros inside the case statement, but this usage does not suffer from any problems where AS_CASE is required). -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

* configure.ac (libpcap): Avoid AS_CASE. --- This fixes the autoconf build problem. But now I'm running into a build problem with automake 1.9.6 not generating $(localedir), which leads to configmake.h missing out on LOCALEDIR. configure.ac | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 64e76dc..51e4271 100644 --- a/configure.ac +++ b/configure.ac @@ -1194,11 +1194,11 @@ LIBPCAP_FOUND="no" AC_ARG_WITH([libpcap], AC_HELP_STRING([--with-libpcap=@<:@PFX@:>@], [libpcap location])) if test "$with_qemu" = "yes"; then - AS_CASE(["x$with_libpcap"], - [xno], [LIBPCAP_CONFIG=""], - [x|xyes], [LIBPCAP_CONFIG="pcap-config"], - [LIBPCAP_CONFIG="$with_libpcap/bin/pcap-config"] - ) + case $with_libpcap in + no) LIBPCAP_CONFIG= ;; + ''|yes) LIBPCAP_CONFIG="pcap-config" ;; + *) LIBPCAP_CONFIG="$with_libpcap/bin/pcap-config" ;; + esac AS_IF([test "x$LIBPCAP_CONFIG" != "x"], [ AC_MSG_CHECKING(libpcap $LIBPCAP_CONFIG >= $LIBPCAP_REQUIRED ) if ! $LIBPCAP_CONFIG --libs > /dev/null 2>&1 ; then -- 1.7.3.3

On 12/14/2010 01:57 PM, Eric Blake wrote:
* configure.ac (libpcap): Avoid AS_CASE. ---
This fixes the autoconf build problem. But now I'm running into a build problem with automake 1.9.6 not generating $(localedir), which leads to configmake.h missing out on LOCALEDIR.
I have tested that the LOCALEDIR situation would be solved by squashing in a .gnulib update, once this gnulib patch is reviewed and accepted upstream: http://thread.gmane.org/gmane.comp.sysutils.automake.general/12378/focus=242... -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Diego Elio Pettenò
-
Eric Blake