base/dispatch.c: Add (unused) machinery for probing ELF auxilary vector.
[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])
34AM_INIT_AUTOMAKE([foreign parallel-tests])
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])
61 $1([x86_64,*], [amd64], [sysv])])
ff1f7e22
MW
62
63dnl A utility to clear the `seen' flags, used so as to process each CPU or
64dnl ABI once.
65m4_define([catacomb_CLEAR_FLAGS],
66[m4_ifdef([catacomb_seen_cpu/$2],
67 [m4_undefine([catacomb_seen_cpu/$2])])dnl
68m4_ifdef([catacomb_seen_abi/$3],
69 [m4_undefine([catacomb_seen_abi/$3])])])
08e2be29 70
ff1f7e22
MW
71dnl Identify the current host.
72case $host_cpu,$host_os in
08e2be29 73 m4_define([catacomb_CPU_CASE],
ff1f7e22 74 [$1) CPUFAM=$2 ABI=$3 ;;
08e2be29
MW
75])
76 catacomb_CPU_FAMILIES([catacomb_CPU_CASE])
ff1f7e22
MW
77 *) CPUFAM=nil ABI=nil ;;
78esac
79
80dnl Figure out the current CPU.
81catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS])
82case $CPUFAM in
83 m4_define([catacomb_DEFINE_CPU],
84 [m4_ifdef([catacomb_seen_cpu/$2], [],
85 [$2)
86 AC_DEFINE([CPUFAM_]m4_translit([$2], [a-z], [A-Z]), [1],
87 [Define if host CPU family is \`$2\'.])
88 ;;m4_define([catacomb_seen_cpu/$2], [t])])])
89 catacomb_CPU_FAMILIES([catacomb_DEFINE_CPU])
90 nil) ;;
91 *) AC_MSG_ERROR([BUG: unexpected cpufam \`$CPUFAM']) ;;
92esac
93AC_SUBST([CPUFAM])
94
95dnl Figure out the current ABI.
96catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS])
97case $ABI in
98 m4_define([catacomb_DEFINE_ABI],
99 [m4_ifdef([catacomb_seen_abi/$3], [],
100 [$3)
101 AC_DEFINE([ABI_]m4_translit([$3], [a-z], [A-Z]), [1],
102 [Define if host ABI variant is \`$3\'.])
103 ;;m4_define([catacomb_seen_abi/$3], [t])])])
104 catacomb_CPU_FAMILIES([catacomb_DEFINE_ABI])
105 nil) ;;
106 *) AC_MSG_ERROR([BUG: unexpected ABI \`$ABI']) ;;
107esac
108AC_SUBST([ABI])
109
110dnl Establish Automake conditions for things.
111catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS])
112m4_define([catacomb_COND_CPU],
113[m4_define([_CPU], m4_translit([$2], [a-z], [A-Z]))
114m4_define([_ABI], m4_translit([$3], [a-z], [A-Z]))
115AM_CONDITIONAL([CPUABI_]_CPU[_]_ABI, [test x$CPUFAM/$ABI = x$2/$3])
116m4_ifdef([catacomb_seen_cpu/$2], [],
117[AM_CONDITIONAL([CPUFAM_]_CPU, [test x$CPUFAM = x$2])dnl
118m4_define([catacomb_seen_cpu/$2], [t])])
119m4_ifdef([catacomb_seen_abi/$3], [],
120[AM_CONDITIONAL([ABI_]_ABI, [test x$ABI = x$3])dnl
121m4_define([catacomb_seen_abi/$3], [t])])])
122catacomb_CPU_FAMILIES([catacomb_COND_CPU])
123AM_CONDITIONAL([KNOWN_CPUFAM], [test x$CPUFAM != xnil])
124
125dnl Report on what we found.
126case $CPUFAM in
127 nil) AC_MSG_RESULT([not supported]) ;;
128 *) AC_MSG_RESULT([$CPUFAM/$ABI]) ;;
08e2be29 129esac
08e2be29 130
a02a22d4
MW
131dnl Some equipment wanted for checking CPU features at runtime.
132AC_CHECK_HEADERS([asm/hwcap.h])
133AC_CHECK_HEADERS([sys/auxv.h])
134AC_CHECK_HEADERS([linux/auxvec.h])
135AC_CHECK_FUNCS([getauxval])
136
08e2be29 137dnl--------------------------------------------------------------------------
ba6e6b64
MW
138dnl C programming environment.
139
0f00dc4c
MW
140dnl Find out if we're cross-compiling.
141AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
142
ba6e6b64
MW
143dnl Various standard types.
144AC_CHECK_TYPE([pid_t], [int])
145AC_TYPE_UID_T
146AC_CHECK_TYPE([ssize_t], [int])
67ea7285 147AC_CHECK_TYPE([socklen_t], [int])
ba6e6b64
MW
148
149dnl The maths library.
1504e033 150mdw_ORIG_LIBS=$LIBS LIBS=
ba6e6b64
MW
151AC_SEARCH_LIBS([log], [m])
152AC_SEARCH_LIBS([sqrt], [m])
1504e033 153AC_SUBST([MATHLIBS], [$LIBS])
ba6e6b64
MW
154LIBS=$mdw_ORIG_LIBS
155
1c3d4cf5
MW
156dnl Find out whether very long integer types are available.
157AC_CHECK_HEADERS([stdint.h])
158AC_SUBST([have_stdint_h])
159AC_C_LONG_LONG
160
161dnl Find the bit lengths of the obvious integer types. This will be useful
162dnl when deciding on a representation for multiprecision integers.
163type_bits="" type_bits_sep=""
164AC_DEFUN([catacomb_UINT_BITS],
165 [mdw_UINT_BITS([$2], [$1])
166 type_bits="$type_bits$type_bits_sep('$1', $[]$1_bits)"
167 type_bits_sep=", "])
168catacomb_UINT_BITS([uchar], [unsigned char])
169catacomb_UINT_BITS([ushort], [unsigned short])
170catacomb_UINT_BITS([uint], [unsigned int])
171catacomb_UINT_BITS([ulong], [unsigned long])
172if test "$ac_cv_c_long_long" = "yes"; then
173 catacomb_UINT_BITS([ullong], [unsigned long long])
174fi
175if test "$ac_cv_header_stdint_h" = "yes"; then
176 catacomb_UINT_BITS([uintmax], [uintmax_t])
177fi
178AC_SUBST([type_bits])
179
180dnl Determine the limits of common C integer types.
181limits="" limits_sep=""
182AC_DEFUN([catacomb_COMPILE_TIME_CONSTANT],
183 [case "$2" in
184 =*)
185 $1="$2"; $1=${$1#=}
186 ;;
187 *)
188 AC_CACHE_CHECK([compile-time value of $2], [mdw_cv_constant_$3],
189 [mdw_PROBE_CONSTANT([mdw_cv_constant_$3], [$2], [$4])])
190 $1=$mdw_cv_constant_$3
191 ;;
192 esac])
193AC_DEFUN([catacomb_LIMIT],
194[catacomb_COMPILE_TIME_CONSTANT([lo], [$2], [$1_min],
195[#include <limits.h>
196#include <stddef.h>])
197 catacomb_COMPILE_TIME_CONSTANT([hi], [$3], [$1_max],
198[#include <limits.h>
199#include <stddef.h>])
200 limits="$limits$limits_sep('$1', $lo, $hi)" limits_sep=", "])
201catacomb_LIMIT([SCHAR], [SCHAR_MIN], [SCHAR_MAX])
202catacomb_LIMIT([CHAR], [CHAR_MIN], [CHAR_MAX])
203catacomb_LIMIT([UCHAR], [=0], [UCHAR_MAX])
204catacomb_LIMIT([UINT8], [=0], [=0xff])
205catacomb_LIMIT([SHRT], [SHRT_MIN], [SHRT_MAX])
206catacomb_LIMIT([USHRT], [=0], [USHRT_MAX])
207catacomb_LIMIT([UINT16], [=0], [=0xffff])
208catacomb_LIMIT([INT], [INT_MIN], [INT_MAX])
209catacomb_LIMIT([UINT], [=0], [UINT_MAX])
210catacomb_LIMIT([LONG], [LONG_MIN], [LONG_MAX])
211catacomb_LIMIT([ULONG], [=0], [ULONG_MAX])
212catacomb_LIMIT([UINT32], [=0], [=0xffffffff])
213if test "$ac_cv_c_long_long" = "yes"; then
214 catacomb_LIMIT([LLONG], [LLONG_MIN], [LLONG_MAX])
215 catacomb_LIMIT([ULLONG], [=0], [ULLONG_MAX])
216fi
217catacomb_LIMIT([SIZET], [=0], [~(size_t)0])
218AC_SUBST([limits])
219
ba6e6b64
MW
220dnl Functions used for noise-gathering.
221AC_CHECK_FUNCS([setgroups])
222AC_CACHE_CHECK([whether the freewheel noise generator will work],
223 [catacomb_cv_freewheel],
224[AC_TRY_LINK(
225[#include <setjmp.h>
226#include <sys/time.h>],
227[struct itimerval itv = { { 0, 0 }, { 0, 5000 } };
228jmp_buf j;
229setitimer(ITIMER_REAL, &itv, 0);
f6ca8103 230sigsetjmp(j, 1);],
ba6e6b64
MW
231[catacomb_cv_freewheel=yes],
232[catacomb_cv_freewheel=no])])
233case $catacomb_cv_freewheel in
234 yes)
235 AC_DEFINE([USE_FREEWHEEL], [1],
236 [Define if you want to use the freewheel noise generator.])
237 ;;
238esac
239
240dnl Support for the passphrase pixie.
241mdw_ORIG_LIBS=$LIBS
242AC_SEARCH_LIBS([socket], [socket])
243AC_SUBST([PIXIE_LIBS], [$LIBS])
244LIBS=$mdw_ORIG_LIBS
245
246dnl Memory locking support.
247AC_CHECK_FUNCS([mlock])
248
249dnl Necessary support libraries.
23bbea75 250PKG_CHECK_MODULES([mLib], [mLib >= 2.2.1])
ba6e6b64
MW
251AM_CFLAGS="$AM_CFLAGS $mLib_CFLAGS"
252
253dnl--------------------------------------------------------------------------
254dnl Python.
255
256dnl Make sure we have a suitable version.
257AM_PATH_PYTHON([2.5])
258
259dnl--------------------------------------------------------------------------
260dnl Special debugging options.
261
262AC_ARG_ENABLE([mpw],
263 [AS_HELP_STRING([--enable-mpw], [force small-width mp digits])],
264 [case "$enableval" in
265 y*|t*|short)
266 AC_DEFINE([FORCE_MPW_SHORT], [1],
267 [Define to force small-width mp digits.])
268 ;;
269 cussid)
270 AC_DEFINE([FORCE_MPW_CUSSID], [1],
271 [Define to force strange-width mp digits.])
272 ;;
273 esac])
274
275dnl--------------------------------------------------------------------------
276dnl Produce output.
277
278AC_CONFIG_HEADER([config/config.h])
279
280AC_CONFIG_FILES(
0f00dc4c
MW
281 [Makefile]
282 [base/Makefile]
283 [key/Makefile]
284 [math/Makefile]
285 [misc/Makefile]
286 [pub/Makefile]
287 [rand/Makefile]
288 [symm/Makefile]
289 [progs/Makefile])
ba6e6b64
MW
290AC_OUTPUT
291
292dnl----- That's all, folks --------------------------------------------------