From 323197908de796e9face5454eee06b5f898da732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Sun, 13 May 2018 00:24:38 +0200 Subject: [PATCH] Continue to refine our build system. Most importantly, differentiate between library and non-library components. The former can be provided and required, and if provided but disabled, can be replaced by pre-installed versions. The latter can only be provided and cannot be the target of a dependency relationship. --- configure.ac | 4 +++- m4/cryb_to.m4 | 60 +++++++++++++++++++++++++++++++++++++-------------- t/Makefile.am | 4 ++-- 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/configure.ac b/configure.ac index 4c709f7..a41799a 100644 --- a/configure.ac +++ b/configure.ac @@ -202,7 +202,9 @@ CRYB_LIB_PROVIDE([oath], [core digest enc mac rand]) CRYB_LIB_PROVIDE([rand], [core]) CRYB_LIB_PROVIDE([test], [core]) -CRYB_CHECK_DEPENDENCIES +CRYB_LIB_REQUIRE([test]) + +CRYB_RESOLVE ############################################################################ # diff --git a/m4/cryb_to.m4 b/m4/cryb_to.m4 index e141561..1b6eb84 100644 --- a/m4/cryb_to.m4 +++ b/m4/cryb_to.m4 @@ -44,6 +44,28 @@ AC_DEFUN([CRYB_INIT], [ [enable_all=yes]) ]) +dnl +dnl CRYB_PROVIDE(component-name, [dependencies]) +dnl -------------------------------------------- +dnl +dnl Declare a non-library component that we provide, and its library +dnl dependencies. +dnl +AC_DEFUN([CRYB_PROVIDE], [ + m4_define([COMP], m4_toupper([$1])) + m4_define([comp], m4_tolower([$1])) + m4_set_add([cryb_provides], comp) + m4_foreach_w([dep], [$2], [m4_set_add([cryb_requires], dep)]) + AC_ARG_ENABLE([cryb-]comp, + AS_HELP_STRING([--enable-cryb-]comp, + [build the ]comp[ component]), + [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 + fi +]) + dnl dnl CRYB_LIB_PROVIDE(library-name, [dependencies]) dnl ---------------------------------------------- @@ -54,7 +76,7 @@ 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([dep], [$2], [m4_set_add([cryb_dependencies], dep)]) + m4_foreach_w([dep], [$2], [m4_set_add([cryb_requires], dep)]) AC_ARG_ENABLE([cryb-]comp, AS_HELP_STRING([--enable-cryb-]comp, [build the ]comp[ library]), @@ -68,10 +90,6 @@ AC_DEFUN([CRYB_LIB_PROVIDE], [ AC_SUBST([CRYB_]COMP[_LIBS], ['\$(top_builddir)/lib/]comp[/libcryb-]comp[.la]') 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"]]) ]) dnl @@ -82,27 +100,37 @@ dnl Declare a Cryb library that we require. dnl AC_DEFUN([CRYB_LIB_REQUIRE], [ m4_foreach_w([dep], [$1], [ - m4_set_add([cryb_dependencies], dep) + m4_set_add([cryb_requires], dep) [cryb_]dep[_needed=yes] ]) ]) dnl -dnl CRYB_CHECK_DEPENDENCIES -dnl ----------------------- +dnl CRYB_RESOLVE +dnl ------------ dnl -dnl Verify that all dependencies have been satisfied. +dnl Verify that all dependencies have been satisfied and set automake +dnl conditionals to reflect enabled and available components. dnl -AC_DEFUN([CRYB_CHECK_DEPENDENCIES], [ - AC_MSG_CHECKING([required Cryb elements]) - 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]) +AC_DEFUN([CRYB_RESOLVE], [ + AC_MSG_CHECKING([required Cryb components]) + m4_set_foreach([cryb_requires], [comp], [ + if test [x"$cryb_]comp[_needed" = x"yes"] && \ + test [x"$enable_cryb_]comp[" != x"yes"] && \ + test [x"$ax_pc_cv_have_cryb_]comp[" = x""] ; then + AX_PKG_CONFIG_REQUIRE([cryb-]comp, [$PACKAGE_VERSION]) fi ]) AC_MSG_RESULT([ok]) + AC_MSG_CHECKING([provided Cryb components]) + m4_set_foreach([cryb_provides], [comp], [ + m4_define([COMP], m4_toupper(comp)) + 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"]]) + ]) + AC_MSG_RESULT([ok]) ]) dnl diff --git a/t/Makefile.am b/t/Makefile.am index 67c084b..0a990b5 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -3,7 +3,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include EXTRA_DIST = noinst_HEADERS = -if CRYB_TEST +if HAVE_CRYB_TEST # Individual libraries libcipher = $(top_builddir)/lib/cipher/libcryb-cipher.la @@ -248,4 +248,4 @@ endif CRYB_TEST check_PROGRAMS = $(TESTS) -endif CRYB_TEST +endif HAVE_CRYB_TEST