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