3 dnl Configuration script for Catacomb
5 dnl (c) 2013 Straylight/Edgeware
8 dnl----- Licensing notice ---------------------------------------------------
10 dnl This file is part of Catacomb.
12 dnl Catacomb is free software; you can redistribute it and/or modify
13 dnl it under the terms of the GNU Library General Public License as
14 dnl published by the Free Software Foundation; either version 2 of the
15 dnl License, or (at your option) any later version.
17 dnl Catacomb is distributed in the hope that it will be useful,
18 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
19 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 dnl GNU Library General Public License for more details.
22 dnl You should have received a copy of the GNU Library General Public
23 dnl License along with Catacomb; if not, write to the Free
24 dnl Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 dnl MA 02111-1307, USA.
27 dnl--------------------------------------------------------------------------
31 AC_INIT([catacomb], AUTO_VERSION, [mdw@distorted.org.uk])
32 AC_CONFIG_SRCDIR([catacomb.pc.in])
33 AC_CONFIG_AUX_DIR([config])
34 AM_INIT_AUTOMAKE([foreign parallel-tests])
41 mdw_LIBTOOL_VERSION_INFO
49 dnl--------------------------------------------------------------------------
50 dnl Host-specific configuration.
52 AC_DEFUN([catacomb_CPU_FAMILIES],
53 [$1([i[[3-6]]86], [X86])])
56 m4_define([catacomb_CPU_CASE],
58 AC_DEFINE([CPUFAM_$2], [1], [Define if host CPU family is $2.])
62 catacomb_CPU_FAMILIES([catacomb_CPU_CASE])
65 m4_define([catacomb_CPU_DEFS],
66 [AM_CONDITIONAL([CPUFAM_$2], [test x$cpufam = x$2])])
67 catacomb_CPU_FAMILIES([catacomb_CPU_DEFS])
69 dnl--------------------------------------------------------------------------
70 dnl C programming environment.
72 dnl Find out if we're cross-compiling.
73 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
75 dnl Various standard types.
76 AC_CHECK_TYPE([pid_t], [int])
78 AC_CHECK_TYPE([ssize_t], [int])
79 AC_CHECK_TYPE([socklen_t], [int])
81 dnl The maths library.
82 mdw_ORIG_LIBS=$LIBS LIBS=
83 AC_SEARCH_LIBS([log], [m])
84 AC_SEARCH_LIBS([sqrt], [m])
85 AC_SUBST([MATHLIBS], [$LIBS])
88 dnl Find out whether very long integer types are available.
89 AC_CHECK_HEADERS([stdint.h])
90 AC_SUBST([have_stdint_h])
93 dnl Find the bit lengths of the obvious integer types. This will be useful
94 dnl when deciding on a representation for multiprecision integers.
95 type_bits="" type_bits_sep=""
96 AC_DEFUN([catacomb_UINT_BITS],
97 [mdw_UINT_BITS([$2], [$1])
98 type_bits="$type_bits$type_bits_sep('$1', $[]$1_bits)"
100 catacomb_UINT_BITS([uchar], [unsigned char])
101 catacomb_UINT_BITS([ushort], [unsigned short])
102 catacomb_UINT_BITS([uint], [unsigned int])
103 catacomb_UINT_BITS([ulong], [unsigned long])
104 if test "$ac_cv_c_long_long" = "yes"; then
105 catacomb_UINT_BITS([ullong], [unsigned long long])
107 if test "$ac_cv_header_stdint_h" = "yes"; then
108 catacomb_UINT_BITS([uintmax], [uintmax_t])
110 AC_SUBST([type_bits])
112 dnl Determine the limits of common C integer types.
113 limits="" limits_sep=""
114 AC_DEFUN([catacomb_COMPILE_TIME_CONSTANT],
120 AC_CACHE_CHECK([compile-time value of $2], [mdw_cv_constant_$3],
121 [mdw_PROBE_CONSTANT([mdw_cv_constant_$3], [$2], [$4])])
122 $1=$mdw_cv_constant_$3
125 AC_DEFUN([catacomb_LIMIT],
126 [catacomb_COMPILE_TIME_CONSTANT([lo], [$2], [$1_min],
128 #include <stddef.h>])
129 catacomb_COMPILE_TIME_CONSTANT([hi], [$3], [$1_max],
131 #include <stddef.h>])
132 limits="$limits$limits_sep('$1', $lo, $hi)" limits_sep=", "])
133 catacomb_LIMIT([SCHAR], [SCHAR_MIN], [SCHAR_MAX])
134 catacomb_LIMIT([CHAR], [CHAR_MIN], [CHAR_MAX])
135 catacomb_LIMIT([UCHAR], [=0], [UCHAR_MAX])
136 catacomb_LIMIT([UINT8], [=0], [=0xff])
137 catacomb_LIMIT([SHRT], [SHRT_MIN], [SHRT_MAX])
138 catacomb_LIMIT([USHRT], [=0], [USHRT_MAX])
139 catacomb_LIMIT([UINT16], [=0], [=0xffff])
140 catacomb_LIMIT([INT], [INT_MIN], [INT_MAX])
141 catacomb_LIMIT([UINT], [=0], [UINT_MAX])
142 catacomb_LIMIT([LONG], [LONG_MIN], [LONG_MAX])
143 catacomb_LIMIT([ULONG], [=0], [ULONG_MAX])
144 catacomb_LIMIT([UINT32], [=0], [=0xffffffff])
145 if test "$ac_cv_c_long_long" = "yes"; then
146 catacomb_LIMIT([LLONG], [LLONG_MIN], [LLONG_MAX])
147 catacomb_LIMIT([ULLONG], [=0], [ULLONG_MAX])
149 catacomb_LIMIT([SIZET], [=0], [~(size_t)0])
152 dnl Functions used for noise-gathering.
153 AC_CHECK_FUNCS([setgroups])
154 AC_CACHE_CHECK([whether the freewheel noise generator will work],
155 [catacomb_cv_freewheel],
158 #include <sys/time.h>],
159 [struct itimerval itv = { { 0, 0 }, { 0, 5000 } };
161 setitimer(ITIMER_REAL, &itv, 0);
163 [catacomb_cv_freewheel=yes],
164 [catacomb_cv_freewheel=no])])
165 case $catacomb_cv_freewheel in
167 AC_DEFINE([USE_FREEWHEEL], [1],
168 [Define if you want to use the freewheel noise generator.])
172 dnl Support for the passphrase pixie.
174 AC_SEARCH_LIBS([socket], [socket])
175 AC_SUBST([PIXIE_LIBS], [$LIBS])
178 dnl Memory locking support.
179 AC_CHECK_FUNCS([mlock])
181 dnl Necessary support libraries.
182 PKG_CHECK_MODULES([mLib], [mLib >= 2.2.1])
183 AM_CFLAGS="$AM_CFLAGS $mLib_CFLAGS"
185 dnl--------------------------------------------------------------------------
188 dnl Make sure we have a suitable version.
189 AM_PATH_PYTHON([2.5])
191 dnl--------------------------------------------------------------------------
192 dnl Special debugging options.
195 [AS_HELP_STRING([--enable-mpw], [force small-width mp digits])],
196 [case "$enableval" in
198 AC_DEFINE([FORCE_MPW_SHORT], [1],
199 [Define to force small-width mp digits.])
202 AC_DEFINE([FORCE_MPW_CUSSID], [1],
203 [Define to force strange-width mp digits.])
207 dnl--------------------------------------------------------------------------
210 AC_CONFIG_HEADER([config/config.h])
224 dnl----- That's all, folks --------------------------------------------------