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.
This commit is contained in:
Dag-Erling Smørgrav 2018-05-13 00:24:38 +02:00
parent 85bf898826
commit 323197908d
3 changed files with 49 additions and 19 deletions

View file

@ -202,7 +202,9 @@ CRYB_LIB_PROVIDE([oath], [core digest enc mac rand])
CRYB_LIB_PROVIDE([rand], [core]) CRYB_LIB_PROVIDE([rand], [core])
CRYB_LIB_PROVIDE([test], [core]) CRYB_LIB_PROVIDE([test], [core])
CRYB_CHECK_DEPENDENCIES CRYB_LIB_REQUIRE([test])
CRYB_RESOLVE
############################################################################ ############################################################################
# #

View file

@ -44,6 +44,28 @@ AC_DEFUN([CRYB_INIT], [
[enable_all=yes]) [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
dnl CRYB_LIB_PROVIDE(library-name, [dependencies]) dnl CRYB_LIB_PROVIDE(library-name, [dependencies])
dnl ---------------------------------------------- dnl ----------------------------------------------
@ -54,7 +76,7 @@ AC_DEFUN([CRYB_LIB_PROVIDE], [
m4_define([COMP], m4_toupper([$1])) m4_define([COMP], m4_toupper([$1]))
m4_define([comp], m4_tolower([$1])) m4_define([comp], m4_tolower([$1]))
m4_set_add([cryb_provides], comp) 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, AC_ARG_ENABLE([cryb-]comp,
AS_HELP_STRING([--enable-cryb-]comp, AS_HELP_STRING([--enable-cryb-]comp,
[build the ]comp[ library]), [build the ]comp[ library]),
@ -68,10 +90,6 @@ AC_DEFUN([CRYB_LIB_PROVIDE], [
AC_SUBST([CRYB_]COMP[_LIBS], AC_SUBST([CRYB_]COMP[_LIBS],
['\$(top_builddir)/lib/]comp[/libcryb-]comp[.la]') ['\$(top_builddir)/lib/]comp[/libcryb-]comp[.la]')
fi 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 dnl
@ -82,27 +100,37 @@ dnl Declare a Cryb library that we require.
dnl dnl
AC_DEFUN([CRYB_LIB_REQUIRE], [ AC_DEFUN([CRYB_LIB_REQUIRE], [
m4_foreach_w([dep], [$1], [ m4_foreach_w([dep], [$1], [
m4_set_add([cryb_dependencies], dep) m4_set_add([cryb_requires], dep)
[cryb_]dep[_needed=yes] [cryb_]dep[_needed=yes]
]) ])
]) ])
dnl dnl
dnl CRYB_CHECK_DEPENDENCIES dnl CRYB_RESOLVE
dnl ----------------------- dnl ------------
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 dnl
AC_DEFUN([CRYB_CHECK_DEPENDENCIES], [ AC_DEFUN([CRYB_RESOLVE], [
AC_MSG_CHECKING([required Cryb elements]) AC_MSG_CHECKING([required Cryb components])
m4_set_foreach([cryb_dependencies], [dep], [ m4_set_foreach([cryb_requires], [comp], [
if test [x"$cryb_]dep[_needed" = x"yes"] && \ if test [x"$cryb_]comp[_needed" = x"yes"] && \
test [x"$enable_cryb_]dep[" != x"yes"] && \ test [x"$enable_cryb_]comp[" != x"yes"] && \
test [x"$ax_pc_cv_have_cryb_]dep[" = x""] ; then test [x"$ax_pc_cv_have_cryb_]comp[" = x""] ; then
AX_PKG_CONFIG_REQUIRE([cryb-]dep, [$PACKAGE_VERSION]) AX_PKG_CONFIG_REQUIRE([cryb-]comp, [$PACKAGE_VERSION])
fi fi
]) ])
AC_MSG_RESULT([ok]) 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 dnl

View file

@ -3,7 +3,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
EXTRA_DIST = EXTRA_DIST =
noinst_HEADERS = noinst_HEADERS =
if CRYB_TEST if HAVE_CRYB_TEST
# Individual libraries # Individual libraries
libcipher = $(top_builddir)/lib/cipher/libcryb-cipher.la libcipher = $(top_builddir)/lib/cipher/libcryb-cipher.la
@ -248,4 +248,4 @@ endif CRYB_TEST
check_PROGRAMS = $(TESTS) check_PROGRAMS = $(TESTS)
endif CRYB_TEST endif HAVE_CRYB_TEST