base/dispatch.c: Indent some preprocessor definitions properly.
[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
52AC_DEFUN([catacomb_CPU_FAMILIES],
53 [$1([i[[3-6]]86], [X86])])
54
55case $host_cpu in
56 m4_define([catacomb_CPU_CASE],
57 [$1)
58 AC_DEFINE([CPUFAM_$2], [1], [Define if host CPU family is $2.])
59 cpufam=$2
60 ;;
61])
62 catacomb_CPU_FAMILIES([catacomb_CPU_CASE])
63 *) cpufam=nil ;;
64esac
65m4_define([catacomb_CPU_DEFS],
66 [AM_CONDITIONAL([CPUFAM_$2], [test x$cpufam = x$2])])
67catacomb_CPU_FAMILIES([catacomb_CPU_DEFS])
68
69dnl--------------------------------------------------------------------------
ba6e6b64
MW
70dnl C programming environment.
71
0f00dc4c
MW
72dnl Find out if we're cross-compiling.
73AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
74
ba6e6b64
MW
75dnl Various standard types.
76AC_CHECK_TYPE([pid_t], [int])
77AC_TYPE_UID_T
78AC_CHECK_TYPE([ssize_t], [int])
67ea7285 79AC_CHECK_TYPE([socklen_t], [int])
ba6e6b64
MW
80
81dnl The maths library.
1504e033 82mdw_ORIG_LIBS=$LIBS LIBS=
ba6e6b64
MW
83AC_SEARCH_LIBS([log], [m])
84AC_SEARCH_LIBS([sqrt], [m])
1504e033 85AC_SUBST([MATHLIBS], [$LIBS])
ba6e6b64
MW
86LIBS=$mdw_ORIG_LIBS
87
1c3d4cf5
MW
88dnl Find out whether very long integer types are available.
89AC_CHECK_HEADERS([stdint.h])
90AC_SUBST([have_stdint_h])
91AC_C_LONG_LONG
92
93dnl Find the bit lengths of the obvious integer types. This will be useful
94dnl when deciding on a representation for multiprecision integers.
95type_bits="" type_bits_sep=""
96AC_DEFUN([catacomb_UINT_BITS],
97 [mdw_UINT_BITS([$2], [$1])
98 type_bits="$type_bits$type_bits_sep('$1', $[]$1_bits)"
99 type_bits_sep=", "])
100catacomb_UINT_BITS([uchar], [unsigned char])
101catacomb_UINT_BITS([ushort], [unsigned short])
102catacomb_UINT_BITS([uint], [unsigned int])
103catacomb_UINT_BITS([ulong], [unsigned long])
104if test "$ac_cv_c_long_long" = "yes"; then
105 catacomb_UINT_BITS([ullong], [unsigned long long])
106fi
107if test "$ac_cv_header_stdint_h" = "yes"; then
108 catacomb_UINT_BITS([uintmax], [uintmax_t])
109fi
110AC_SUBST([type_bits])
111
112dnl Determine the limits of common C integer types.
113limits="" limits_sep=""
114AC_DEFUN([catacomb_COMPILE_TIME_CONSTANT],
115 [case "$2" in
116 =*)
117 $1="$2"; $1=${$1#=}
118 ;;
119 *)
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
123 ;;
124 esac])
125AC_DEFUN([catacomb_LIMIT],
126[catacomb_COMPILE_TIME_CONSTANT([lo], [$2], [$1_min],
127[#include <limits.h>
128#include <stddef.h>])
129 catacomb_COMPILE_TIME_CONSTANT([hi], [$3], [$1_max],
130[#include <limits.h>
131#include <stddef.h>])
132 limits="$limits$limits_sep('$1', $lo, $hi)" limits_sep=", "])
133catacomb_LIMIT([SCHAR], [SCHAR_MIN], [SCHAR_MAX])
134catacomb_LIMIT([CHAR], [CHAR_MIN], [CHAR_MAX])
135catacomb_LIMIT([UCHAR], [=0], [UCHAR_MAX])
136catacomb_LIMIT([UINT8], [=0], [=0xff])
137catacomb_LIMIT([SHRT], [SHRT_MIN], [SHRT_MAX])
138catacomb_LIMIT([USHRT], [=0], [USHRT_MAX])
139catacomb_LIMIT([UINT16], [=0], [=0xffff])
140catacomb_LIMIT([INT], [INT_MIN], [INT_MAX])
141catacomb_LIMIT([UINT], [=0], [UINT_MAX])
142catacomb_LIMIT([LONG], [LONG_MIN], [LONG_MAX])
143catacomb_LIMIT([ULONG], [=0], [ULONG_MAX])
144catacomb_LIMIT([UINT32], [=0], [=0xffffffff])
145if test "$ac_cv_c_long_long" = "yes"; then
146 catacomb_LIMIT([LLONG], [LLONG_MIN], [LLONG_MAX])
147 catacomb_LIMIT([ULLONG], [=0], [ULLONG_MAX])
148fi
149catacomb_LIMIT([SIZET], [=0], [~(size_t)0])
150AC_SUBST([limits])
151
ba6e6b64
MW
152dnl Functions used for noise-gathering.
153AC_CHECK_FUNCS([setgroups])
154AC_CACHE_CHECK([whether the freewheel noise generator will work],
155 [catacomb_cv_freewheel],
156[AC_TRY_LINK(
157[#include <setjmp.h>
158#include <sys/time.h>],
159[struct itimerval itv = { { 0, 0 }, { 0, 5000 } };
160jmp_buf j;
161setitimer(ITIMER_REAL, &itv, 0);
f6ca8103 162sigsetjmp(j, 1);],
ba6e6b64
MW
163[catacomb_cv_freewheel=yes],
164[catacomb_cv_freewheel=no])])
165case $catacomb_cv_freewheel in
166 yes)
167 AC_DEFINE([USE_FREEWHEEL], [1],
168 [Define if you want to use the freewheel noise generator.])
169 ;;
170esac
171
172dnl Support for the passphrase pixie.
173mdw_ORIG_LIBS=$LIBS
174AC_SEARCH_LIBS([socket], [socket])
175AC_SUBST([PIXIE_LIBS], [$LIBS])
176LIBS=$mdw_ORIG_LIBS
177
178dnl Memory locking support.
179AC_CHECK_FUNCS([mlock])
180
181dnl Necessary support libraries.
23bbea75 182PKG_CHECK_MODULES([mLib], [mLib >= 2.2.1])
ba6e6b64
MW
183AM_CFLAGS="$AM_CFLAGS $mLib_CFLAGS"
184
185dnl--------------------------------------------------------------------------
186dnl Python.
187
188dnl Make sure we have a suitable version.
189AM_PATH_PYTHON([2.5])
190
191dnl--------------------------------------------------------------------------
192dnl Special debugging options.
193
194AC_ARG_ENABLE([mpw],
195 [AS_HELP_STRING([--enable-mpw], [force small-width mp digits])],
196 [case "$enableval" in
197 y*|t*|short)
198 AC_DEFINE([FORCE_MPW_SHORT], [1],
199 [Define to force small-width mp digits.])
200 ;;
201 cussid)
202 AC_DEFINE([FORCE_MPW_CUSSID], [1],
203 [Define to force strange-width mp digits.])
204 ;;
205 esac])
206
207dnl--------------------------------------------------------------------------
208dnl Produce output.
209
210AC_CONFIG_HEADER([config/config.h])
211
212AC_CONFIG_FILES(
0f00dc4c
MW
213 [Makefile]
214 [base/Makefile]
215 [key/Makefile]
216 [math/Makefile]
217 [misc/Makefile]
218 [pub/Makefile]
219 [rand/Makefile]
220 [symm/Makefile]
221 [progs/Makefile])
ba6e6b64
MW
222AC_OUTPUT
223
224dnl----- That's all, folks --------------------------------------------------