From 40c0b23126ff36d7074b9e21d45523a985bbcef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Wed, 24 Jun 2015 09:26:45 +0000 Subject: [PATCH] even more support for weird and sloppy packages --- ax_init_standard_project.m4 | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/ax_init_standard_project.m4 b/ax_init_standard_project.m4 index 8de0217..1b48313 100644 --- a/ax_init_standard_project.m4 +++ b/ax_init_standard_project.m4 @@ -372,9 +372,9 @@ EOF # fails if not found AC_DEFUN([AX_PKG_REQUIRE], [ PKG_PROG_PKG_CONFIG - $1_found=0 + $1_found=no PKG_CHECK_MODULES([$1], [$2], [ - $1_found=1 + $1_found=$2 PKG_REQUIREMENTS+=" $2" ], [ if test -n "$4"; then @@ -382,7 +382,7 @@ AC_DEFUN([AX_PKG_REQUIRE], [ for pkg in $4; do PKG_CHECK_MODULES([$1], [$pkg], [ PKG_REQUIREMENTS+=" $pkg" - $1_found=1 + $1_found=$pkg break; ], [ AC_MSG_WARN([Recommended package $pkg for feature $1 not installed]) @@ -394,30 +394,48 @@ AC_DEFUN([AX_PKG_REQUIRE], [ AC_SUBST(AM_CXXFLAGS) AC_SUBST(PKG_REQUIREMENTS) if test -n "$3"; then - $1_found=0 + tmp_package=${$1_found} + $1_found=no old_CPPFLAGS=${CPPFLAGS} CPPFLAGS=" ${$1_CFLAGS} ${CPPFLAGS}" AC_CHECK_HEADER([$3], [ - $1_found=1 + $1_found=yes ], [ for x in ${$1_CFLAGS}; do AC_MSG_NOTICE([search for $3 in ${x[#]-I}]) for f in $(find ${x[#]-I} -name "$3"); do if test -f "$f"; then - $1_found=1 + $1_found=yes $1_CFLAGS+=" -I${f%/*}" AC_MSG_NOTICE([added path ${f%/*}]) break; fi done - if test ${$1_found} -eq 1; then + if test "${$1_found}" != "no"; then break; fi done + if test "${$1_found}" = "no"; then + tmp_includedir=$(pkg-config --variable=includedir $tmp_package) + for x in ${tmp_includedir}; do + AC_MSG_NOTICE([search for $3 in $x]) + for f in $(find ${x} -name "$3"); do + if test -f "$f"; then + $1_found=yes + $1_CFLAGS+=" -I${f%/*}" + AC_MSG_NOTICE([added path ${f%/*}]) + break; + fi + done + if test "${$1_found}" != "no"; then + break; + fi + done + fi ]) CPPFLAGS=${old_CPPFLAGS} fi - if test ${$1_found} -eq 0; then + if test "${$1_found}" = "no"; then if test -n "$3"; then if test -n "$4"; then AC_MSG_ERROR([Feature $1 not found, need header $3 in modules $2 or $4])