base/dispatch.c: Missing parens on call to `get_hwcaps'.
[catacomb] / configure.ac
CommitLineData
ba6e6b64
MW
1dnl -*-autoconf-*-
2dnl
3dnl Configuration script for Catacomb
4dnl
5dnl (c) 2013 Straylight/Edgeware
6dnl
7
8dnl----- Licensing notice ---------------------------------------------------
9dnl
10dnl This file is part of Catacomb.
11dnl
12dnl Catacomb is free software; you can redistribute it and/or modify
13dnl it under the terms of the GNU Library General Public License as
14dnl published by the Free Software Foundation; either version 2 of the
15dnl License, or (at your option) any later version.
16dnl
17dnl Catacomb is distributed in the hope that it will be useful,
18dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
19dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20dnl GNU Library General Public License for more details.
21dnl
22dnl You should have received a copy of the GNU Library General Public
23dnl License along with Catacomb; if not, write to the Free
24dnl Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25dnl MA 02111-1307, USA.
26
27dnl--------------------------------------------------------------------------
28dnl Initialization.
29
30mdw_AUTO_VERSION
31AC_INIT([catacomb], AUTO_VERSION, [mdw@distorted.org.uk])
32AC_CONFIG_SRCDIR([catacomb.pc.in])
33AC_CONFIG_AUX_DIR([config])
1c8e76bd 34AM_INIT_AUTOMAKE([foreign parallel-tests color-tests subdir-objects])
08e2be29 35AC_CANONICAL_HOST
ba6e6b64
MW
36mdw_SILENT_RULES
37
38AC_PROG_CC
39AX_CFLAGS_WARN_ALL
40AM_PROG_LIBTOOL
41mdw_LIBTOOL_VERSION_INFO
42
6adca914
MW
43AM_PROG_AS
44
ba6e6b64
MW
45AC_PROG_YACC
46
47AC_SUBST(AM_CFLAGS)
48
49dnl--------------------------------------------------------------------------
08e2be29
MW
50dnl Host-specific configuration.
51
ff1f7e22
MW
52AC_MSG_CHECKING([CPU family and ABI])
53
54dnl The table of CPU families and ABIs which we might support. Support is
55dnl not uniform: each dispatched function might or might not have an
56dnl implementation for any particular CPU/ABI combination.
08e2be29 57AC_DEFUN([catacomb_CPU_FAMILIES],
0f23f75f
MW
58 [$1([i[[3-6]]86,cygwin], [x86], [win])
59 $1([i[[3-6]]86,*], [x86], [sysv])
60 $1([x86_64,cygwin], [amd64], [win])
61bd904b
MW
61 $1([x86_64,*], [amd64], [sysv])
62 $1([armv*,*-gnueabi | armv*,*-gnueabihf], [armel], [gnueabi])])
ff1f7e22
MW
63
64dnl A utility to clear the `seen' flags, used so as to process each CPU or
65dnl ABI once.
66m4_define([catacomb_CLEAR_FLAGS],
67[m4_ifdef([catacomb_seen_cpu/$2],
68 [m4_undefine([catacomb_seen_cpu/$2])])dnl
69m4_ifdef([catacomb_seen_abi/$3],
70 [m4_undefine([catacomb_seen_abi/$3])])])
08e2be29 71
ff1f7e22
MW
72dnl Identify the current host.
73case $host_cpu,$host_os in
08e2be29 74 m4_define([catacomb_CPU_CASE],
ff1f7e22 75 [$1) CPUFAM=$2 ABI=$3 ;;
08e2be29
MW
76])
77 catacomb_CPU_FAMILIES([catacomb_CPU_CASE])
ff1f7e22
MW
78 *) CPUFAM=nil ABI=nil ;;
79esac
80
81dnl Figure out the current CPU.
82catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS])
83case $CPUFAM in
84 m4_define([catacomb_DEFINE_CPU],
85 [m4_ifdef([catacomb_seen_cpu/$2], [],
86 [$2)
87 AC_DEFINE([CPUFAM_]m4_translit([$2], [a-z], [A-Z]), [1],
88 [Define if host CPU family is \`$2\'.])
89 ;;m4_define([catacomb_seen_cpu/$2], [t])])])
90 catacomb_CPU_FAMILIES([catacomb_DEFINE_CPU])
91 nil) ;;
92 *) AC_MSG_ERROR([BUG: unexpected cpufam \`$CPUFAM']) ;;
93esac
94AC_SUBST([CPUFAM])
95
96dnl Figure out the current ABI.
97catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS])
98case $ABI in
99 m4_define([catacomb_DEFINE_ABI],
100 [m4_ifdef([catacomb_seen_abi/$3], [],
101 [$3)
102 AC_DEFINE([ABI_]m4_translit([$3], [a-z], [A-Z]), [1],
103 [Define if host ABI variant is \`$3\'.])
104 ;;m4_define([catacomb_seen_abi/$3], [t])])])
105 catacomb_CPU_FAMILIES([catacomb_DEFINE_ABI])
106 nil) ;;
107 *) AC_MSG_ERROR([BUG: unexpected ABI \`$ABI']) ;;
108esac
109AC_SUBST([ABI])
110
111dnl Establish Automake conditions for things.
112catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS])
113m4_define([catacomb_COND_CPU],
114[m4_define([_CPU], m4_translit([$2], [a-z], [A-Z]))
115m4_define([_ABI], m4_translit([$3], [a-z], [A-Z]))
116AM_CONDITIONAL([CPUABI_]_CPU[_]_ABI, [test x$CPUFAM/$ABI = x$2/$3])
117m4_ifdef([catacomb_seen_cpu/$2], [],
118[AM_CONDITIONAL([CPUFAM_]_CPU, [test x$CPUFAM = x$2])dnl
119m4_define([catacomb_seen_cpu/$2], [t])])
120m4_ifdef([catacomb_seen_abi/$3], [],
121[AM_CONDITIONAL([ABI_]_ABI, [test x$ABI = x$3])dnl
122m4_define([catacomb_seen_abi/$3], [t])])])
123catacomb_CPU_FAMILIES([catacomb_COND_CPU])
124AM_CONDITIONAL([KNOWN_CPUFAM], [test x$CPUFAM != xnil])
125
126dnl Report on what we found.
127case $CPUFAM in
128 nil) AC_MSG_RESULT([not supported]) ;;
129 *) AC_MSG_RESULT([$CPUFAM/$ABI]) ;;
08e2be29 130esac
08e2be29 131
a02a22d4
MW
132dnl Some equipment wanted for checking CPU features at runtime.
133AC_CHECK_HEADERS([asm/hwcap.h])
134AC_CHECK_HEADERS([sys/auxv.h])
135AC_CHECK_HEADERS([linux/auxvec.h])
136AC_CHECK_FUNCS([getauxval])
137
08e2be29 138dnl--------------------------------------------------------------------------
ba6e6b64
MW
139dnl C programming environment.
140
0f00dc4c
MW
141dnl Find out if we're cross-compiling.
142AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
143
ba6e6b64
MW
144dnl Various standard types.
145AC_CHECK_TYPE([pid_t], [int])
146AC_TYPE_UID_T
147AC_CHECK_TYPE([ssize_t], [int])
67ea7285 148AC_CHECK_TYPE([socklen_t], [int])
ba6e6b64
MW
149
150dnl The maths library.
1504e033 151mdw_ORIG_LIBS=$LIBS LIBS=
ba6e6b64
MW
152AC_SEARCH_LIBS([log], [m])
153AC_SEARCH_LIBS([sqrt], [m])
1504e033 154AC_SUBST([MATHLIBS], [$LIBS])
ba6e6b64
MW
155LIBS=$mdw_ORIG_LIBS
156
1c3d4cf5
MW
157dnl Find out whether very long integer types are available.
158AC_CHECK_HEADERS([stdint.h])
159AC_SUBST([have_stdint_h])
160AC_C_LONG_LONG
161
162dnl Find the bit lengths of the obvious integer types. This will be useful
163dnl when deciding on a representation for multiprecision integers.
164type_bits="" type_bits_sep=""
165AC_DEFUN([catacomb_UINT_BITS],
166 [mdw_UINT_BITS([$2], [$1])
167 type_bits="$type_bits$type_bits_sep('$1', $[]$1_bits)"
168 type_bits_sep=", "])
169catacomb_UINT_BITS([uchar], [unsigned char])
170catacomb_UINT_BITS([ushort], [unsigned short])
171catacomb_UINT_BITS([uint], [unsigned int])
172catacomb_UINT_BITS([ulong], [unsigned long])
173if test "$ac_cv_c_long_long" = "yes"; then
174 catacomb_UINT_BITS([ullong], [unsigned long long])
175fi
176if test "$ac_cv_header_stdint_h" = "yes"; then
177 catacomb_UINT_BITS([uintmax], [uintmax_t])
178fi
179AC_SUBST([type_bits])
180
181dnl Determine the limits of common C integer types.
182limits="" limits_sep=""
183AC_DEFUN([catacomb_COMPILE_TIME_CONSTANT],
184 [case "$2" in
185 =*)
186 $1="$2"; $1=${$1#=}
187 ;;
188 *)
189 AC_CACHE_CHECK([compile-time value of $2], [mdw_cv_constant_$3],
190 [mdw_PROBE_CONSTANT([mdw_cv_constant_$3], [$2], [$4])])
191 $1=$mdw_cv_constant_$3
192 ;;
193 esac])
194AC_DEFUN([catacomb_LIMIT],
195[catacomb_COMPILE_TIME_CONSTANT([lo], [$2], [$1_min],
196[#include <limits.h>
197#include <stddef.h>])
198 catacomb_COMPILE_TIME_CONSTANT([hi], [$3], [$1_max],
199[#include <limits.h>
200#include <stddef.h>])
201 limits="$limits$limits_sep('$1', $lo, $hi)" limits_sep=", "])
202catacomb_LIMIT([SCHAR], [SCHAR_MIN], [SCHAR_MAX])
203catacomb_LIMIT([CHAR], [CHAR_MIN], [CHAR_MAX])
204catacomb_LIMIT([UCHAR], [=0], [UCHAR_MAX])
205catacomb_LIMIT([UINT8], [=0], [=0xff])
206catacomb_LIMIT([SHRT], [SHRT_MIN], [SHRT_MAX])
207catacomb_LIMIT([USHRT], [=0], [USHRT_MAX])
208catacomb_LIMIT([UINT16], [=0], [=0xffff])
209catacomb_LIMIT([INT], [INT_MIN], [INT_MAX])
210catacomb_LIMIT([UINT], [=0], [UINT_MAX])
211catacomb_LIMIT([LONG], [LONG_MIN], [LONG_MAX])
212catacomb_LIMIT([ULONG], [=0], [ULONG_MAX])
213catacomb_LIMIT([UINT32], [=0], [=0xffffffff])
214if test "$ac_cv_c_long_long" = "yes"; then
215 catacomb_LIMIT([LLONG], [LLONG_MIN], [LLONG_MAX])
216 catacomb_LIMIT([ULLONG], [=0], [ULLONG_MAX])
217fi
218catacomb_LIMIT([SIZET], [=0], [~(size_t)0])
219AC_SUBST([limits])
220
ba6e6b64
MW
221dnl Functions used for noise-gathering.
222AC_CHECK_FUNCS([setgroups])
223AC_CACHE_CHECK([whether the freewheel noise generator will work],
224 [catacomb_cv_freewheel],
225[AC_TRY_LINK(
226[#include <setjmp.h>
227#include <sys/time.h>],
228[struct itimerval itv = { { 0, 0 }, { 0, 5000 } };
229jmp_buf j;
230setitimer(ITIMER_REAL, &itv, 0);
f6ca8103 231sigsetjmp(j, 1);],
ba6e6b64
MW
232[catacomb_cv_freewheel=yes],
233[catacomb_cv_freewheel=no])])
234case $catacomb_cv_freewheel in
235 yes)
236 AC_DEFINE([USE_FREEWHEEL], [1],
237 [Define if you want to use the freewheel noise generator.])
238 ;;
239esac
240
241dnl Support for the passphrase pixie.
242mdw_ORIG_LIBS=$LIBS
243AC_SEARCH_LIBS([socket], [socket])
244AC_SUBST([PIXIE_LIBS], [$LIBS])
245LIBS=$mdw_ORIG_LIBS
246
247dnl Memory locking support.
248AC_CHECK_FUNCS([mlock])
249
250dnl Necessary support libraries.
a1acefec 251PKG_CHECK_MODULES([mLib], [mLib >= 2.2.2.1])
ba6e6b64
MW
252AM_CFLAGS="$AM_CFLAGS $mLib_CFLAGS"
253
254dnl--------------------------------------------------------------------------
255dnl Python.
256
257dnl Make sure we have a suitable version.
258AM_PATH_PYTHON([2.5])
259
260dnl--------------------------------------------------------------------------
261dnl Special debugging options.
262
263AC_ARG_ENABLE([mpw],
264 [AS_HELP_STRING([--enable-mpw], [force small-width mp digits])],
265 [case "$enableval" in
266 y*|t*|short)
267 AC_DEFINE([FORCE_MPW_SHORT], [1],
268 [Define to force small-width mp digits.])
269 ;;
270 cussid)
271 AC_DEFINE([FORCE_MPW_CUSSID], [1],
272 [Define to force strange-width mp digits.])
273 ;;
274 esac])
275
276dnl--------------------------------------------------------------------------
277dnl Produce output.
278
279AC_CONFIG_HEADER([config/config.h])
280
281AC_CONFIG_FILES(
0f00dc4c
MW
282 [Makefile]
283 [base/Makefile]
284 [key/Makefile]
285 [math/Makefile]
286 [misc/Makefile]
287 [pub/Makefile]
288 [rand/Makefile]
289 [symm/Makefile]
290 [progs/Makefile])
ba6e6b64
MW
291AC_OUTPUT
292
293dnl----- That's all, folks --------------------------------------------------