From 85bf898826302442f5daeb83686f434c7c234422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Fri, 11 May 2018 17:45:58 +0200 Subject: [PATCH] Don't invoke pkg-config unnecessarily. Previously, we always invoked AX_PKG_CONFIG_CHECK() for a disabled component (i.e. a component which we provide but which was disabled on the configure command line). This is both excessive (because we only need to run this check for components that will be needed during the build) and insufficient (because we also need to run it for components from other Cryb projects). --- m4/cryb_to.m4 | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/m4/cryb_to.m4 b/m4/cryb_to.m4 index 7410165..e141561 100644 --- a/m4/cryb_to.m4 +++ b/m4/cryb_to.m4 @@ -54,22 +54,23 @@ AC_DEFUN([CRYB_LIB_PROVIDE], [ m4_define([COMP], m4_toupper([$1])) m4_define([comp], m4_tolower([$1])) m4_set_add([cryb_provides], comp) - m4_foreach_w([req], [$2], [m4_set_add([cryb_requires], req)]) + m4_foreach_w([dep], [$2], [m4_set_add([cryb_dependencies], dep)]) AC_ARG_ENABLE([cryb-]comp, AS_HELP_STRING([--enable-cryb-]comp, [build the ]comp[ library]), [enable_cryb_]comp[=$enableval], [enable_cryb_]comp[=$enable_all]) if test [x"$enable_cryb_]comp[" = x"yes"] ; then + for dep in $2 ; do eval "cryb_${dep}_needed=yes" ; done AC_DEFINE([HAVE_CRYB_]COMP, [1], [Define to 1 if you have $1]) AC_SUBST([CRYB_]COMP[_VERSION], [$PACKAGE_VERSION]) AC_SUBST([CRYB_]COMP[_CFLAGS], []) AC_SUBST([CRYB_]COMP[_LIBS], ['\$(top_builddir)/lib/]comp[/libcryb-]comp[.la]') - AM_CONDITIONAL([HAVE_CRYB_]COMP, [true]) - else - AX_PKG_CONFIG_CHECK([cryb-]comp, [$PACKAGE_VERSION]) fi + AM_CONDITIONAL([HAVE_CRYB_]COMP, [ + test [x"$enable_cryb_]comp[" = x"yes"] && \ + test [x"$ax_pc_cv_have_cryb_]comp[" = x"yes"]]) AM_CONDITIONAL([CRYB_]COMP, [test [x"$enable_cryb_]comp[" = x"yes"]]) ]) @@ -80,7 +81,10 @@ dnl dnl Declare a Cryb library that we require. dnl AC_DEFUN([CRYB_LIB_REQUIRE], [ - m4_foreach_w([req], [$1], [m4_set_add([cryb_requires], req)]) + m4_foreach_w([dep], [$1], [ + m4_set_add([cryb_dependencies], dep) + [cryb_]dep[_needed=yes] + ]) ]) dnl @@ -91,10 +95,11 @@ dnl Verify that all dependencies have been satisfied. dnl AC_DEFUN([CRYB_CHECK_DEPENDENCIES], [ AC_MSG_CHECKING([required Cryb elements]) - m4_set_foreach([cryb_requires], [req], [ - if test [x"$enable_cryb_]req[" != x"yes"] && \ - test [x"$ax_pc_cv_have_cryb_]req[" != x"yes"] ; then - AC_MSG_ERROR([missing cryb-]req) + m4_set_foreach([cryb_dependencies], [dep], [ + if test [x"$cryb_]dep[_needed" = x"yes"] && \ + test [x"$enable_cryb_]dep[" != x"yes"] && \ + test [x"$ax_pc_cv_have_cryb_]dep[" = x""] ; then + AX_PKG_CONFIG_REQUIRE([cryb-]dep, [$PACKAGE_VERSION]) fi ]) AC_MSG_RESULT([ok])