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