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