changeset 22039:0a528a6dac95

build: use pkg-config in OCTAVE_CHECK_LIB without overriding user options * acinclude.m4 (OCTAVE_CHECK_LIB): Use pkg-config only when configure is not called with --with-LIB or --without-LIB options.
author Mike Miller <mtmiller@octave.org>
date Tue, 05 Jul 2016 11:07:55 -0700
parents a4eb6d3de9f0
children 79e7a6fc524d
files m4/acinclude.m4
diffstat 1 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/m4/acinclude.m4	Tue Jul 05 11:06:22 2016 +0200
+++ b/m4/acinclude.m4	Tue Jul 05 11:07:55 2016 -0700
@@ -649,6 +649,7 @@
       [AS_HELP_STRING([--without-$1], [$7])])],
     with_$1=$withval, with_$1=yes)
 
+  ac_octave_$1_pkg_check=no
   m4_toupper([$1])_LIBS=
   warn_$1="$3"
   case $with_$1 in
@@ -657,6 +658,7 @@
       m4_toupper([$1])_LIBS=
     ;;
     yes | "")
+      ac_octave_$1_pkg_check=yes
       m4_toupper([$1])_LIBS="-l$1"
     ;;
     -* | */* | *.a | *.so | *.so.* | *.o)
@@ -667,11 +669,17 @@
     ;;
   esac
 
-  PKG_CHECK_EXISTS([$1], [
-    m4_toupper([$1])_CPPFLAGS="$($PKG_CONFIG --cflags-only-I $1) $m4_toupper([$1])_CPPFLAGS"
-    m4_toupper([$1])_LDFLAGS="$($PKG_CONFIG --libs-only-L $1) $m4_toupper([$1])_LDFLAGS"
-    m4_toupper([$1])_LIBS="$($PKG_CONFIG --libs-only-l $1) $m4_toupper([$1])_LIBS"
-  ])
+  if test $ac_octave_$1_pkg_check = yes; then
+    PKG_CHECK_EXISTS([$1], [
+      if test -z "$m4_toupper([$1])_CPPFLAGS"; then
+        m4_toupper([$1])_CPPFLAGS="$($PKG_CONFIG --cflags-only-I $1)"
+      fi
+      if test -z "$m4_toupper([$1])_LDFLAGS"; then
+        m4_toupper([$1])_LDFLAGS="$($PKG_CONFIG --libs-only-L $1)"
+      fi
+      m4_toupper([$1])_LIBS="$($PKG_CONFIG --libs-only-l $1)"
+    ])
+  fi
 
   if test -n "$m4_toupper([$1])_LIBS"; then
     ac_octave_save_CPPFLAGS="$CPPFLAGS"