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_MSG_CHECKING([CPU family and ABI])
54 dnl The table of CPU families and ABIs which we might support. Support is
55 dnl not uniform: each dispatched function might or might not have an
56 dnl implementation for any particular CPU/ABI combination.
57 AC_DEFUN([catacomb_CPU_FAMILIES],
58 [$1([i[[3-6]]86,*], [x86], [sysv])])
60 dnl A utility to clear the `seen' flags, used so as to process each CPU or
62 m4_define([catacomb_CLEAR_FLAGS],
63 [m4_ifdef([catacomb_seen_cpu/$2],
64 [m4_undefine([catacomb_seen_cpu/$2])])dnl
65 m4_ifdef([catacomb_seen_abi/$3],
66 [m4_undefine([catacomb_seen_abi/$3])])])
68 dnl Identify the current host.
69 case $host_cpu,$host_os in
70 m4_define([catacomb_CPU_CASE],
71 [$1) CPUFAM=$2 ABI=$3 ;;
73 catacomb_CPU_FAMILIES([catacomb_CPU_CASE])
74 *) CPUFAM=nil ABI=nil ;;
77 dnl Figure out the current CPU.
78 catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS])
80 m4_define([catacomb_DEFINE_CPU],
81 [m4_ifdef([catacomb_seen_cpu/$2], [],
83 AC_DEFINE([CPUFAM_]m4_translit([$2], [a-z], [A-Z]), [1],
84 [Define if host CPU family is \`$2\'.])
85 ;;m4_define([catacomb_seen_cpu/$2], [t])])])
86 catacomb_CPU_FAMILIES([catacomb_DEFINE_CPU])
88 *) AC_MSG_ERROR([BUG: unexpected cpufam \`$CPUFAM']) ;;
92 dnl Figure out the current ABI.
93 catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS])
95 m4_define([catacomb_DEFINE_ABI],
96 [m4_ifdef([catacomb_seen_abi/$3], [],
98 AC_DEFINE([ABI_]m4_translit([$3], [a-z], [A-Z]), [1],
99 [Define if host ABI variant is \`$3\'.])
100 ;;m4_define([catacomb_seen_abi/$3], [t])])])
101 catacomb_CPU_FAMILIES([catacomb_DEFINE_ABI])
103 *) AC_MSG_ERROR([BUG: unexpected ABI \`$ABI']) ;;
107 dnl Establish Automake conditions for things.
108 catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS])
109 m4_define([catacomb_COND_CPU],
110 [m4_define([_CPU], m4_translit([$2], [a-z], [A-Z]))
111 m4_define([_ABI], m4_translit([$3], [a-z], [A-Z]))
112 AM_CONDITIONAL([CPUABI_]_CPU[_]_ABI, [test x$CPUFAM/$ABI = x$2/$3])
113 m4_ifdef([catacomb_seen_cpu/$2], [],
114 [AM_CONDITIONAL([CPUFAM_]_CPU, [test x$CPUFAM = x$2])dnl
115 m4_define([catacomb_seen_cpu/$2], [t])])
116 m4_ifdef([catacomb_seen_abi/$3], [],
117 [AM_CONDITIONAL([ABI_]_ABI, [test x$ABI = x$3])dnl
118 m4_define([catacomb_seen_abi/$3], [t])])])
119 catacomb_CPU_FAMILIES([catacomb_COND_CPU])
120 AM_CONDITIONAL([KNOWN_CPUFAM], [test x$CPUFAM != xnil])
122 dnl Report on what we found.
124 nil) AC_MSG_RESULT([not supported]) ;;
125 *) AC_MSG_RESULT([$CPUFAM/$ABI]) ;;
128 dnl--------------------------------------------------------------------------
129 dnl C programming environment.
131 dnl Find out if we're cross-compiling.
132 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
134 dnl Various standard types.
135 AC_CHECK_TYPE([pid_t], [int])
137 AC_CHECK_TYPE([ssize_t], [int])
138 AC_CHECK_TYPE([socklen_t], [int])
140 dnl The maths library.
141 mdw_ORIG_LIBS=$LIBS LIBS=
142 AC_SEARCH_LIBS([log], [m])
143 AC_SEARCH_LIBS([sqrt], [m])
144 AC_SUBST([MATHLIBS], [$LIBS])
147 dnl Find out whether very long integer types are available.
148 AC_CHECK_HEADERS([stdint.h])
149 AC_SUBST([have_stdint_h])
152 dnl Find the bit lengths of the obvious integer types. This will be useful
153 dnl when deciding on a representation for multiprecision integers.
154 type_bits="" type_bits_sep=""
155 AC_DEFUN([catacomb_UINT_BITS],
156 [mdw_UINT_BITS([$2], [$1])
157 type_bits="$type_bits$type_bits_sep('$1', $[]$1_bits)"
159 catacomb_UINT_BITS([uchar], [unsigned char])
160 catacomb_UINT_BITS([ushort], [unsigned short])
161 catacomb_UINT_BITS([uint], [unsigned int])
162 catacomb_UINT_BITS([ulong], [unsigned long])
163 if test "$ac_cv_c_long_long" = "yes"; then
164 catacomb_UINT_BITS([ullong], [unsigned long long])
166 if test "$ac_cv_header_stdint_h" = "yes"; then
167 catacomb_UINT_BITS([uintmax], [uintmax_t])
169 AC_SUBST([type_bits])
171 dnl Determine the limits of common C integer types.
172 limits="" limits_sep=""
173 AC_DEFUN([catacomb_COMPILE_TIME_CONSTANT],
179 AC_CACHE_CHECK([compile-time value of $2], [mdw_cv_constant_$3],
180 [mdw_PROBE_CONSTANT([mdw_cv_constant_$3], [$2], [$4])])
181 $1=$mdw_cv_constant_$3
184 AC_DEFUN([catacomb_LIMIT],
185 [catacomb_COMPILE_TIME_CONSTANT([lo], [$2], [$1_min],
187 #include <stddef.h>])
188 catacomb_COMPILE_TIME_CONSTANT([hi], [$3], [$1_max],
190 #include <stddef.h>])
191 limits="$limits$limits_sep('$1', $lo, $hi)" limits_sep=", "])
192 catacomb_LIMIT([SCHAR], [SCHAR_MIN], [SCHAR_MAX])
193 catacomb_LIMIT([CHAR], [CHAR_MIN], [CHAR_MAX])
194 catacomb_LIMIT([UCHAR], [=0], [UCHAR_MAX])
195 catacomb_LIMIT([UINT8], [=0], [=0xff])
196 catacomb_LIMIT([SHRT], [SHRT_MIN], [SHRT_MAX])
197 catacomb_LIMIT([USHRT], [=0], [USHRT_MAX])
198 catacomb_LIMIT([UINT16], [=0], [=0xffff])
199 catacomb_LIMIT([INT], [INT_MIN], [INT_MAX])
200 catacomb_LIMIT([UINT], [=0], [UINT_MAX])
201 catacomb_LIMIT([LONG], [LONG_MIN], [LONG_MAX])
202 catacomb_LIMIT([ULONG], [=0], [ULONG_MAX])
203 catacomb_LIMIT([UINT32], [=0], [=0xffffffff])
204 if test "$ac_cv_c_long_long" = "yes"; then
205 catacomb_LIMIT([LLONG], [LLONG_MIN], [LLONG_MAX])
206 catacomb_LIMIT([ULLONG], [=0], [ULLONG_MAX])
208 catacomb_LIMIT([SIZET], [=0], [~(size_t)0])
211 dnl Functions used for noise-gathering.
212 AC_CHECK_FUNCS([setgroups])
213 AC_CACHE_CHECK([whether the freewheel noise generator will work],
214 [catacomb_cv_freewheel],
217 #include <sys/time.h>],
218 [struct itimerval itv = { { 0, 0 }, { 0, 5000 } };
220 setitimer(ITIMER_REAL, &itv, 0);
222 [catacomb_cv_freewheel=yes],
223 [catacomb_cv_freewheel=no])])
224 case $catacomb_cv_freewheel in
226 AC_DEFINE([USE_FREEWHEEL], [1],
227 [Define if you want to use the freewheel noise generator.])
231 dnl Support for the passphrase pixie.
233 AC_SEARCH_LIBS([socket], [socket])
234 AC_SUBST([PIXIE_LIBS], [$LIBS])
237 dnl Memory locking support.
238 AC_CHECK_FUNCS([mlock])
240 dnl Necessary support libraries.
241 PKG_CHECK_MODULES([mLib], [mLib >= 2.2.1])
242 AM_CFLAGS="$AM_CFLAGS $mLib_CFLAGS"
244 dnl--------------------------------------------------------------------------
247 dnl Make sure we have a suitable version.
248 AM_PATH_PYTHON([2.5])
250 dnl--------------------------------------------------------------------------
251 dnl Special debugging options.
254 [AS_HELP_STRING([--enable-mpw], [force small-width mp digits])],
255 [case "$enableval" in
257 AC_DEFINE([FORCE_MPW_SHORT], [1],
258 [Define to force small-width mp digits.])
261 AC_DEFINE([FORCE_MPW_CUSSID], [1],
262 [Define to force strange-width mp digits.])
266 dnl--------------------------------------------------------------------------
269 AC_CONFIG_HEADER([config/config.h])
283 dnl----- That's all, folks --------------------------------------------------