mirror of
https://github.com/cryb-to/cryb-to.git
synced 2024-11-27 16:15:49 +00:00
Create autoconf macros to automate component selection.
These macros are designed to work in concert with the AX_PKG_CONFIG macros. It is now possible to disable any component, even if another depends on it, provided that it is already installed. For enabled components, we define the same variables as AX_PKG_CONFIG would, so Makefiles don't need to know if a component they rely on is being built as part of this packge or if it was already installed.
This commit is contained in:
parent
e603e0bc2e
commit
dc8984d0a0
4 changed files with 132 additions and 136 deletions
|
@ -12,5 +12,6 @@ EXTRA_DIST = \
|
|||
autogen.sh \
|
||||
m4/ax_gcc_builtin.m4 \
|
||||
m4/ax_pkg_config.m4 \
|
||||
m4/cryb_to.m4 \
|
||||
tools/coverage.sh.in \
|
||||
tools/setprops.sh
|
||||
|
|
150
configure.ac
150
configure.ac
|
@ -186,136 +186,21 @@ unset XFLAGS
|
|||
# Components
|
||||
#
|
||||
|
||||
# Everything
|
||||
AC_ARG_ENABLE([all],
|
||||
AS_HELP_STRING([--disable-all],
|
||||
[disable all libraries and tools]),
|
||||
[enable_all=$enableval],
|
||||
[enable_all=yes])
|
||||
CRYB_INIT
|
||||
|
||||
# Ciphers
|
||||
elements="$elements cipher"
|
||||
requires="$requires cipher:core"
|
||||
AC_ARG_ENABLE([cryb-cipher],
|
||||
AS_HELP_STRING([--enable-cryb-cipher],
|
||||
[build the cipher library]),
|
||||
[enable_cryb_cipher=$enableval],
|
||||
[enable_cryb_cipher=$enable_all])
|
||||
AM_CONDITIONAL([CRYB_CIPHER], [test x"$enable_cryb_cipher" = x"yes"])
|
||||
CRYB_LIB_PROVIDE([cipher], [core])
|
||||
CRYB_LIB_PROVIDE([core], [])
|
||||
CRYB_LIB_PROVIDE([cpe], [core])
|
||||
CRYB_LIB_PROVIDE([digest], [core])
|
||||
CRYB_LIB_PROVIDE([enc], [core])
|
||||
CRYB_LIB_PROVIDE([hash], [core])
|
||||
CRYB_LIB_PROVIDE([mac], [core digest])
|
||||
CRYB_LIB_PROVIDE([mpi], [core])
|
||||
CRYB_LIB_PROVIDE([oath], [core digest enc mac rand])
|
||||
CRYB_LIB_PROVIDE([rand], [core])
|
||||
CRYB_LIB_PROVIDE([test], [core])
|
||||
|
||||
# Core
|
||||
elements="$elements core"
|
||||
AC_ARG_ENABLE([cryb-core],
|
||||
AS_HELP_STRING([--enable-cryb-core],
|
||||
[build the core library]),
|
||||
[enable_cryb_core=$enableval],
|
||||
[enable_cryb_core=$enable_all])
|
||||
AM_CONDITIONAL([CRYB_CORE], [test x"$enable_cryb_core" = x"yes"])
|
||||
|
||||
# CPE
|
||||
elements="$elements cpe"
|
||||
requires="$requires cpe:core"
|
||||
AC_ARG_ENABLE([cryb-cpe],
|
||||
AS_HELP_STRING([--enable-cryb-cpe],
|
||||
[build the CPE library]),
|
||||
[enable_cryb_cpe=$enableval],
|
||||
[enable_cryb_cpe=$enable_all])
|
||||
AM_CONDITIONAL([CRYB_CPE], [test x"$enable_cryb_cpe" = x"yes"])
|
||||
|
||||
# Message digests
|
||||
elements="$elements digest"
|
||||
requires="$requires digests:core"
|
||||
AC_ARG_ENABLE([cryb-digest],
|
||||
AS_HELP_STRING([--enable-cryb-digest],
|
||||
[build the message digest library]),
|
||||
[enable_cryb_digest=$enableval],
|
||||
[enable_cryb_digest=$enable_all])
|
||||
AM_CONDITIONAL([CRYB_DIGEST], [test x"$enable_cryb_digest" = x"yes"])
|
||||
|
||||
# Encodings
|
||||
elements="$elements enc"
|
||||
requires="$requires enc:core"
|
||||
AC_ARG_ENABLE([cryb-enc],
|
||||
AS_HELP_STRING([--enable-cryb-enc],
|
||||
[build the encoding library]),
|
||||
[enable_cryb_enc=$enableval],
|
||||
[enable_cryb_enc=$enable_all])
|
||||
AM_CONDITIONAL([CRYB_ENC], [test x"$enable_cryb_enc" = x"yes"])
|
||||
|
||||
# Non-cryptographic hashes
|
||||
elements="$elements hash"
|
||||
requires="$requires hash:core"
|
||||
AC_ARG_ENABLE([cryb-hash],
|
||||
AS_HELP_STRING([--enable-cryb-hash],
|
||||
[build the non-cryptographic hash library]),
|
||||
[enable_cryb_hash=$enableval],
|
||||
[enable_cryb_hash=$enable_all])
|
||||
AM_CONDITIONAL([CRYB_HASH], [test x"$enable_cryb_hash" = x"yes"])
|
||||
|
||||
# Message authentication codes
|
||||
elements="$elements mac"
|
||||
requires="$requires mac:core mac:digest"
|
||||
AC_ARG_ENABLE([cryb-mac],
|
||||
AS_HELP_STRING([--enable-cryb-mac],
|
||||
[build the message authentication code library]),
|
||||
[enable_cryb_mac=$enableval],
|
||||
[enable_cryb_mac=$enable_all])
|
||||
AM_CONDITIONAL([CRYB_MAC], [test x"$enable_cryb_digest" = x"yes"])
|
||||
|
||||
# Multiple-precision integers
|
||||
elements="$elements mpi"
|
||||
requires="$requires mpi:core"
|
||||
AC_ARG_ENABLE([cryb-mpi],
|
||||
AS_HELP_STRING([--enable-cryb-mpi],
|
||||
[build the multiple-precision math library]),
|
||||
[enable_cryb_mpi=$enableval],
|
||||
[enable_cryb_mpi=$enable_all])
|
||||
AM_CONDITIONAL([CRYB_MPI], [test x"$enable_cryb_mpi" = x"yes"])
|
||||
|
||||
# OATH
|
||||
elements="$elements oath"
|
||||
requires="$requires oath:core oath:digest oath:enc oath:mac oath:rand"
|
||||
AC_ARG_ENABLE([cryb-oath],
|
||||
AS_HELP_STRING([--enable-cryb-oath],
|
||||
[build the OATH library]),
|
||||
[enable_cryb_oath=$enableval],
|
||||
[enable_cryb_oath=$enable_all])
|
||||
AM_CONDITIONAL([CRYB_OATH], [test x"$enable_cryb_oath" = x"yes"])
|
||||
|
||||
# Pseudo-randomness
|
||||
elements="$elements rand"
|
||||
requires="$requires rand:core"
|
||||
AC_ARG_ENABLE([cryb-rand],
|
||||
AS_HELP_STRING([--enable-cryb-rand],
|
||||
[build the pseudo-randomness library]),
|
||||
[enable_cryb_rand=$enableval],
|
||||
[enable_cryb_rand=$enable_all])
|
||||
AM_CONDITIONAL([CRYB_RAND], [test x"$enable_cryb_rand" = x"yes"])
|
||||
|
||||
# Test framework
|
||||
elements="$elements test"
|
||||
requires="$requires test:core"
|
||||
AC_ARG_ENABLE([cryb-test],
|
||||
AS_HELP_STRING([--enable-cryb-test],
|
||||
[build the test framework]),
|
||||
[enable_cryb_test=$enableval],
|
||||
[enable_cryb_test=$enable_all])
|
||||
AM_CONDITIONAL([CRYB_TEST], [test x"$enable_cryb_test" = x"yes"])
|
||||
|
||||
# Check dependencies
|
||||
AC_MSG_CHECKING([dependencies])
|
||||
for req in $requires ; do
|
||||
lhs=${req%:*}
|
||||
lhs_ena=`eval echo \\\$enable_cryb_$lhs`
|
||||
if test x"$lhs_ena" = x"yes" ; then
|
||||
rhs=${req#*:}
|
||||
rhs_ena=`eval echo \\\$enable_cryb_$rhs`
|
||||
if test x"$rhs_ena" != x"yes" ; then
|
||||
AC_MSG_ERROR([cryb-$lhs requires cryb-$rhs])
|
||||
fi
|
||||
fi
|
||||
done
|
||||
AC_MSG_RESULT([ok])
|
||||
CRYB_CHECK_DEPENDENCIES
|
||||
|
||||
############################################################################
|
||||
#
|
||||
|
@ -356,11 +241,4 @@ AC_CONFIG_FILES([
|
|||
AC_CONFIG_FILES([tools/coverage.sh], [chmod +x tools/coverage.sh])
|
||||
AC_OUTPUT
|
||||
|
||||
echo
|
||||
echo The following Cryb components will be built:
|
||||
echo
|
||||
for elem in $elements ; do
|
||||
enable=`eval echo \\\$enable_cryb_$elem`
|
||||
printf "%16s: %s\n" $elem ${enable:-no}
|
||||
done
|
||||
echo
|
||||
CRYB_SUMMARY
|
||||
|
|
1
m4/.gitignore
vendored
1
m4/.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
/*.m4
|
||||
!/ax_gcc_builtin.m4
|
||||
!/ax_pkg_config.m4
|
||||
!/cryb_to.m4
|
||||
|
|
116
m4/cryb_to.m4
Normal file
116
m4/cryb_to.m4
Normal file
|
@ -0,0 +1,116 @@
|
|||
dnl -*- autoconf -*-
|
||||
dnl
|
||||
dnl Copyright (c) 2018 The University of Oslo
|
||||
dnl All rights reserved.
|
||||
dnl
|
||||
dnl Redistribution and use in source and binary forms, with or without
|
||||
dnl modification, are permitted provided that the following conditions
|
||||
dnl are met:
|
||||
dnl 1. Redistributions of source code must retain the above copyright
|
||||
dnl notice, this list of conditions and the following disclaimer.
|
||||
dnl 2. Redistributions in binary form must reproduce the above copyright
|
||||
dnl notice, this list of conditions and the following disclaimer in the
|
||||
dnl documentation and/or other materials provided with the distribution.
|
||||
dnl 3. The name of the author may not be used to endorse or promote
|
||||
dnl products derived from this software without specific prior written
|
||||
dnl permission.
|
||||
dnl
|
||||
dnl THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
dnl ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
dnl ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
dnl OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
dnl SUCH DAMAGE.
|
||||
dnl
|
||||
|
||||
m4_define([CRYB_MACROS_VERSION], [0.20180506])
|
||||
|
||||
dnl
|
||||
dnl CRYB_INIT
|
||||
dnl ---------
|
||||
dnl
|
||||
dnl Initialize.
|
||||
dnl
|
||||
AC_DEFUN([CRYB_INIT], [
|
||||
AC_ARG_ENABLE([all],
|
||||
AS_HELP_STRING([--disable-all],
|
||||
[disable all components]),
|
||||
[enable_all=$enableval],
|
||||
[enable_all=yes])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl CRYB_LIB_PROVIDE(library-name, [dependencies])
|
||||
dnl ----------------------------------------------
|
||||
dnl
|
||||
dnl Declare a Cryb library that we provide, and its dependencies.
|
||||
dnl
|
||||
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)])
|
||||
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
|
||||
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([CRYB_]COMP, [test [x"$enable_cryb_]comp[" = x"yes"]])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl CRYB_LIB_REQUIRE(library-name)
|
||||
dnl ------------------------------
|
||||
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)])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl CRYB_CHECK_DEPENDENCIES
|
||||
dnl -----------------------
|
||||
dnl
|
||||
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)
|
||||
fi
|
||||
])
|
||||
AC_MSG_RESULT([ok])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl CRYB_SUMMARY
|
||||
dnl ------------
|
||||
dnl
|
||||
dnl Print a summary of enabled components.
|
||||
dnl
|
||||
AC_DEFUN([CRYB_SUMMARY], [
|
||||
AS_ECHO([])
|
||||
AS_ECHO(["The following Cryb components will be built:"])
|
||||
AS_ECHO([])
|
||||
m4_set_foreach([cryb_provides], [comp], [
|
||||
[printf "%16s: %s\n" ]comp[ ${enable_cryb_]comp[:-no}]
|
||||
])
|
||||
])
|
Loading…
Reference in a new issue