dnl -*-autoconf-*- dnl dnl Configuration script for Catacomb dnl dnl (c) 2013 Straylight/Edgeware dnl dnl----- Licensing notice --------------------------------------------------- dnl dnl This file is part of Catacomb. dnl dnl Catacomb is free software; you can redistribute it and/or modify dnl it under the terms of the GNU Library General Public License as dnl published by the Free Software Foundation; either version 2 of the dnl License, or (at your option) any later version. dnl dnl Catacomb is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU Library General Public License for more details. dnl dnl You should have received a copy of the GNU Library General Public dnl License along with Catacomb; if not, write to the Free dnl Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, dnl MA 02111-1307, USA. dnl-------------------------------------------------------------------------- dnl Initialization. mdw_AUTO_VERSION AC_INIT([catacomb], AUTO_VERSION, [mdw@distorted.org.uk]) AC_CONFIG_SRCDIR([catacomb.pc.in]) AC_CONFIG_AUX_DIR([config]) AM_INIT_AUTOMAKE([foreign parallel-tests color-tests subdir-objects]) AC_CANONICAL_HOST mdw_SILENT_RULES AC_PROG_CC AX_CFLAGS_WARN_ALL AM_PROG_LIBTOOL mdw_LIBTOOL_VERSION_INFO AM_PROG_AS AC_PROG_YACC AC_SUBST(AM_CFLAGS) dnl-------------------------------------------------------------------------- dnl Host-specific configuration. AC_MSG_CHECKING([CPU family and ABI]) dnl The table of CPU families and ABIs which we might support. Support is dnl not uniform: each dispatched function might or might not have an dnl implementation for any particular CPU/ABI combination. AC_DEFUN([catacomb_CPU_FAMILIES], [$1([i[[3-6]]86,cygwin], [x86], [win]) $1([i[[3-6]]86,*], [x86], [sysv]) $1([x86_64,cygwin], [amd64], [win]) $1([x86_64,*], [amd64], [sysv]) $1([arm,*-gnueabi | arm,*-gnueabihf | dnl armv*,*-gnueabi | armv*,*-gnueabihf], [armel], [gnueabi])]) dnl A utility to clear the `seen' flags, used so as to process each CPU or dnl ABI once. m4_define([catacomb_CLEAR_FLAGS], [m4_ifdef([catacomb_seen_cpu/$2], [m4_undefine([catacomb_seen_cpu/$2])])dnl m4_ifdef([catacomb_seen_abi/$3], [m4_undefine([catacomb_seen_abi/$3])])]) dnl Identify the current host. case $host_cpu,$host_os in m4_define([catacomb_CPU_CASE], [$1) CPUFAM=$2 ABI=$3 ;; ]) catacomb_CPU_FAMILIES([catacomb_CPU_CASE]) *) CPUFAM=nil ABI=nil ;; esac dnl Figure out the current CPU. catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS]) case $CPUFAM in m4_define([catacomb_DEFINE_CPU], [m4_ifdef([catacomb_seen_cpu/$2], [], [$2) AC_DEFINE([CPUFAM_]m4_translit([$2], [a-z], [A-Z]), [1], [Define if host CPU family is \`$2\'.]) ;;m4_define([catacomb_seen_cpu/$2], [t])])]) catacomb_CPU_FAMILIES([catacomb_DEFINE_CPU]) nil) ;; *) AC_MSG_ERROR([BUG: unexpected cpufam \`$CPUFAM']) ;; esac AC_SUBST([CPUFAM]) dnl Figure out the current ABI. catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS]) case $ABI in m4_define([catacomb_DEFINE_ABI], [m4_ifdef([catacomb_seen_abi/$3], [], [$3) AC_DEFINE([ABI_]m4_translit([$3], [a-z], [A-Z]), [1], [Define if host ABI variant is \`$3\'.]) ;;m4_define([catacomb_seen_abi/$3], [t])])]) catacomb_CPU_FAMILIES([catacomb_DEFINE_ABI]) nil) ;; *) AC_MSG_ERROR([BUG: unexpected ABI \`$ABI']) ;; esac AC_SUBST([ABI]) dnl Establish Automake conditions for things. catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS]) m4_define([catacomb_COND_CPU], [m4_define([_CPU], m4_translit([$2], [a-z], [A-Z])) m4_define([_ABI], m4_translit([$3], [a-z], [A-Z])) AM_CONDITIONAL([CPUABI_]_CPU[_]_ABI, [test x$CPUFAM/$ABI = x$2/$3]) m4_ifdef([catacomb_seen_cpu/$2], [], [AM_CONDITIONAL([CPUFAM_]_CPU, [test x$CPUFAM = x$2])dnl m4_define([catacomb_seen_cpu/$2], [t])]) m4_ifdef([catacomb_seen_abi/$3], [], [AM_CONDITIONAL([ABI_]_ABI, [test x$ABI = x$3])dnl m4_define([catacomb_seen_abi/$3], [t])])]) catacomb_CPU_FAMILIES([catacomb_COND_CPU]) AM_CONDITIONAL([KNOWN_CPUFAM], [test x$CPUFAM != xnil]) dnl Report on what we found. case $CPUFAM in nil) AC_MSG_RESULT([not supported]) ;; *) AC_MSG_RESULT([$CPUFAM/$ABI]) ;; esac dnl-------------------------------------------------------------------------- dnl C programming environment. AC_LANG([C]) CATACOMB_LIBS= dnl Find out if we're cross-compiling. AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes]) dnl Various standard types. AC_CHECK_TYPE([pid_t], [int]) AC_TYPE_UID_T AC_CHECK_TYPE([ssize_t], [int]) AC_CHECK_TYPE([socklen_t], [int]) dnl The maths library. mdw_ORIG_LIBS=$LIBS LIBS= AC_SEARCH_LIBS([log], [m]) AC_SEARCH_LIBS([sqrt], [m]) AC_SUBST([MATHLIBS], [$LIBS]) LIBS=$mdw_ORIG_LIBS dnl Find out whether very long integer types are available. AC_CHECK_HEADERS([stdint.h]) AC_SUBST([have_stdint_h]) AC_C_LONG_LONG dnl Some equipment wanted for checking CPU features at runtime. AC_CHECK_HEADERS([asm/hwcap.h]) AC_CHECK_HEADERS([sys/auxv.h]) AC_CHECK_HEADERS([linux/auxvec.h]) AC_CHECK_FUNCS([getauxval]) dnl Find the bit lengths of the obvious integer types. This will be useful dnl when deciding on a representation for multiprecision integers. type_bits="" type_bits_sep="" AC_DEFUN([catacomb_UINT_BITS], [mdw_UINT_BITS([$2], [$1]) type_bits="$type_bits$type_bits_sep('$1', $[]$1_bits)" type_bits_sep=", "]) catacomb_UINT_BITS([uchar], [unsigned char]) catacomb_UINT_BITS([ushort], [unsigned short]) catacomb_UINT_BITS([uint], [unsigned int]) catacomb_UINT_BITS([ulong], [unsigned long]) if test "$ac_cv_c_long_long" = "yes"; then catacomb_UINT_BITS([ullong], [unsigned long long]) fi if test "$ac_cv_header_stdint_h" = "yes"; then catacomb_UINT_BITS([uintmax], [uintmax_t]) fi AC_SUBST([type_bits]) dnl Determine the limits of common C integer types. limits="" limits_sep="" AC_DEFUN([catacomb_COMPILE_TIME_CONSTANT], [case "$2" in =*) $1="$2"; $1=${$1#=} ;; *) AC_CACHE_CHECK([compile-time value of $2], [mdw_cv_constant_$3], [mdw_PROBE_CONSTANT([mdw_cv_constant_$3], [$2], [$4])]) $1=$mdw_cv_constant_$3 ;; esac]) AC_DEFUN([catacomb_LIMIT], [catacomb_COMPILE_TIME_CONSTANT([lo], [$2], [$1_min], [#include #include ]) catacomb_COMPILE_TIME_CONSTANT([hi], [$3], [$1_max], [#include #include ]) limits="$limits$limits_sep('$1', $lo, $hi)" limits_sep=", "]) catacomb_LIMIT([SCHAR], [SCHAR_MIN], [SCHAR_MAX]) catacomb_LIMIT([CHAR], [CHAR_MIN], [CHAR_MAX]) catacomb_LIMIT([UCHAR], [=0], [UCHAR_MAX]) catacomb_LIMIT([UINT8], [=0], [=0xff]) catacomb_LIMIT([SHRT], [SHRT_MIN], [SHRT_MAX]) catacomb_LIMIT([USHRT], [=0], [USHRT_MAX]) catacomb_LIMIT([UINT16], [=0], [=0xffff]) catacomb_LIMIT([INT], [INT_MIN], [INT_MAX]) catacomb_LIMIT([UINT], [=0], [UINT_MAX]) catacomb_LIMIT([LONG], [LONG_MIN], [LONG_MAX]) catacomb_LIMIT([ULONG], [=0], [ULONG_MAX]) catacomb_LIMIT([UINT32], [=0], [=0xffffffff]) if test "$ac_cv_c_long_long" = "yes"; then catacomb_LIMIT([LLONG], [LLONG_MIN], [LLONG_MAX]) catacomb_LIMIT([ULLONG], [=0], [ULLONG_MAX]) fi catacomb_LIMIT([SIZET], [=0], [~(size_t)0]) AC_SUBST([limits]) dnl Functions used for noise-gathering. AC_CHECK_FUNCS([setgroups]) AC_CHECK_HEADERS([linux/random.h]) mdw_ORIG_LIBS=$LIBS LIBS=$CATACOMB_LIBS AC_SEARCH_LIBS([clock_gettime], [rt]) CATACOMB_LIBS=$LIBS LIBS=$mdw_ORIG_LIBS if test "$ac_cv_search_clock_gettime" != no; then AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define if you have the \`clock_gettime' function.]) fi AC_CHECK_FUNCS([getentropy]) AC_CACHE_CHECK([whether the freewheel noise generator will work], [catacomb_cv_freewheel], [AC_TRY_LINK( [#include #include ], [struct itimerval itv = { { 0, 0 }, { 0, 5000 } }; jmp_buf j; setitimer(ITIMER_REAL, &itv, 0); sigsetjmp(j, 1);], [catacomb_cv_freewheel=yes], [catacomb_cv_freewheel=no])]) case $catacomb_cv_freewheel in yes) AC_DEFINE([USE_FREEWHEEL], [1], [Define if you want to use the freewheel noise generator.]) ;; esac dnl Support for the passphrase pixie. mdw_ORIG_LIBS=$LIBS AC_SEARCH_LIBS([socket], [socket]) AC_SUBST([PIXIE_LIBS], [$LIBS]) LIBS=$mdw_ORIG_LIBS dnl Memory locking support. AC_CHECK_FUNCS([mlock]) dnl Set the master libraries we need. AC_SUBST([CATACOMB_LIBS]) dnl Necessary support libraries. PKG_CHECK_MODULES([mLib], [mLib >= 2.2.2.1]) AM_CFLAGS="$AM_CFLAGS $mLib_CFLAGS" dnl-------------------------------------------------------------------------- dnl Python. dnl Make sure we have a suitable version. AM_PATH_PYTHON([2.5]) dnl-------------------------------------------------------------------------- dnl Special debugging options. AC_ARG_ENABLE([mpw], [AS_HELP_STRING([--enable-mpw], [force small-width mp digits])], [case "$enableval" in y*|t*|short) AC_DEFINE([FORCE_MPW_SHORT], [1], [Define to force small-width mp digits.]) ;; cussid) AC_DEFINE([FORCE_MPW_CUSSID], [1], [Define to force strange-width mp digits.]) ;; esac]) dnl-------------------------------------------------------------------------- dnl Produce output. AC_CONFIG_HEADER([config/config.h]) AC_CONFIG_FILES( [Makefile] [base/Makefile] [key/Makefile] [math/Makefile] [misc/Makefile] [pub/Makefile] [rand/Makefile] [symm/Makefile] [progs/Makefile]) AC_OUTPUT dnl----- That's all, folks --------------------------------------------------