progs/pixie.c: Fix format security bugs.
[u/mdw/catacomb] / configure.ac
1 dnl -*-autoconf-*-
2 dnl
3 dnl Configuration script for Catacomb
4 dnl
5 dnl (c) 2013 Straylight/Edgeware
6 dnl
7
8 dnl----- Licensing notice ---------------------------------------------------
9 dnl
10 dnl This file is part of Catacomb.
11 dnl
12 dnl Catacomb is free software; you can redistribute it and/or modify
13 dnl it under the terms of the GNU Library General Public License as
14 dnl published by the Free Software Foundation; either version 2 of the
15 dnl License, or (at your option) any later version.
16 dnl
17 dnl Catacomb is distributed in the hope that it will be useful,
18 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
19 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 dnl GNU Library General Public License for more details.
21 dnl
22 dnl You should have received a copy of the GNU Library General Public
23 dnl License along with Catacomb; if not, write to the Free
24 dnl Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 dnl MA 02111-1307, USA.
26
27 dnl--------------------------------------------------------------------------
28 dnl Initialization.
29
30 mdw_AUTO_VERSION
31 AC_INIT([catacomb], AUTO_VERSION, [mdw@distorted.org.uk])
32 AC_CONFIG_SRCDIR([catacomb.pc.in])
33 AC_CONFIG_AUX_DIR([config])
34 AM_INIT_AUTOMAKE([foreign parallel-tests])
35 mdw_SILENT_RULES
36
37 AC_PROG_CC
38 AX_CFLAGS_WARN_ALL
39 AM_PROG_LIBTOOL
40 mdw_LIBTOOL_VERSION_INFO
41
42 AC_PROG_YACC
43
44 AC_SUBST(AM_CFLAGS)
45
46 dnl--------------------------------------------------------------------------
47 dnl C programming environment.
48
49 dnl Find out if we're cross-compiling.
50 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
51
52 dnl Various standard types.
53 AC_CHECK_TYPE([pid_t], [int])
54 AC_TYPE_UID_T
55 AC_CHECK_TYPE([ssize_t], [int])
56
57 dnl The maths library.
58 mdw_ORIG_LIBS=$LIBS
59 AC_SEARCH_LIBS([log], [m])
60 AC_SEARCH_LIBS([sqrt], [m])
61 AC_SUBST([CATACOMB_LIBS], [$LIBS])
62 LIBS=$mdw_ORIG_LIBS
63
64 dnl Find out whether very long integer types are available.
65 AC_CHECK_HEADERS([stdint.h])
66 AC_SUBST([have_stdint_h])
67 AC_C_LONG_LONG
68
69 dnl Find the bit lengths of the obvious integer types. This will be useful
70 dnl when deciding on a representation for multiprecision integers.
71 type_bits="" type_bits_sep=""
72 AC_DEFUN([catacomb_UINT_BITS],
73 [mdw_UINT_BITS([$2], [$1])
74 type_bits="$type_bits$type_bits_sep('$1', $[]$1_bits)"
75 type_bits_sep=", "])
76 catacomb_UINT_BITS([uchar], [unsigned char])
77 catacomb_UINT_BITS([ushort], [unsigned short])
78 catacomb_UINT_BITS([uint], [unsigned int])
79 catacomb_UINT_BITS([ulong], [unsigned long])
80 if test "$ac_cv_c_long_long" = "yes"; then
81 catacomb_UINT_BITS([ullong], [unsigned long long])
82 fi
83 if test "$ac_cv_header_stdint_h" = "yes"; then
84 catacomb_UINT_BITS([uintmax], [uintmax_t])
85 fi
86 AC_SUBST([type_bits])
87
88 dnl Determine the limits of common C integer types.
89 limits="" limits_sep=""
90 AC_DEFUN([catacomb_COMPILE_TIME_CONSTANT],
91 [case "$2" in
92 =*)
93 $1="$2"; $1=${$1#=}
94 ;;
95 *)
96 AC_CACHE_CHECK([compile-time value of $2], [mdw_cv_constant_$3],
97 [mdw_PROBE_CONSTANT([mdw_cv_constant_$3], [$2], [$4])])
98 $1=$mdw_cv_constant_$3
99 ;;
100 esac])
101 AC_DEFUN([catacomb_LIMIT],
102 [catacomb_COMPILE_TIME_CONSTANT([lo], [$2], [$1_min],
103 [#include <limits.h>
104 #include <stddef.h>])
105 catacomb_COMPILE_TIME_CONSTANT([hi], [$3], [$1_max],
106 [#include <limits.h>
107 #include <stddef.h>])
108 limits="$limits$limits_sep('$1', $lo, $hi)" limits_sep=", "])
109 catacomb_LIMIT([SCHAR], [SCHAR_MIN], [SCHAR_MAX])
110 catacomb_LIMIT([CHAR], [CHAR_MIN], [CHAR_MAX])
111 catacomb_LIMIT([UCHAR], [=0], [UCHAR_MAX])
112 catacomb_LIMIT([UINT8], [=0], [=0xff])
113 catacomb_LIMIT([SHRT], [SHRT_MIN], [SHRT_MAX])
114 catacomb_LIMIT([USHRT], [=0], [USHRT_MAX])
115 catacomb_LIMIT([UINT16], [=0], [=0xffff])
116 catacomb_LIMIT([INT], [INT_MIN], [INT_MAX])
117 catacomb_LIMIT([UINT], [=0], [UINT_MAX])
118 catacomb_LIMIT([LONG], [LONG_MIN], [LONG_MAX])
119 catacomb_LIMIT([ULONG], [=0], [ULONG_MAX])
120 catacomb_LIMIT([UINT32], [=0], [=0xffffffff])
121 if test "$ac_cv_c_long_long" = "yes"; then
122 catacomb_LIMIT([LLONG], [LLONG_MIN], [LLONG_MAX])
123 catacomb_LIMIT([ULLONG], [=0], [ULLONG_MAX])
124 fi
125 catacomb_LIMIT([SIZET], [=0], [~(size_t)0])
126 AC_SUBST([limits])
127
128 dnl Functions used for noise-gathering.
129 AC_CHECK_FUNCS([setgroups])
130 AC_CACHE_CHECK([whether the freewheel noise generator will work],
131 [catacomb_cv_freewheel],
132 [AC_TRY_LINK(
133 [#include <setjmp.h>
134 #include <sys/time.h>],
135 [struct itimerval itv = { { 0, 0 }, { 0, 5000 } };
136 jmp_buf j;
137 setitimer(ITIMER_REAL, &itv, 0);
138 sigsetjump(j, 1);],
139 [catacomb_cv_freewheel=yes],
140 [catacomb_cv_freewheel=no])])
141 case $catacomb_cv_freewheel in
142 yes)
143 AC_DEFINE([USE_FREEWHEEL], [1],
144 [Define if you want to use the freewheel noise generator.])
145 ;;
146 esac
147
148 dnl Support for the passphrase pixie.
149 mdw_ORIG_LIBS=$LIBS
150 AC_SEARCH_LIBS([socket], [socket])
151 AC_SUBST([PIXIE_LIBS], [$LIBS])
152 LIBS=$mdw_ORIG_LIBS
153
154 dnl Memory locking support.
155 AC_CHECK_FUNCS([mlock])
156
157 dnl Necessary support libraries.
158 PKG_CHECK_MODULES([mLib], [mLib >= 2.2.1])
159 AM_CFLAGS="$AM_CFLAGS $mLib_CFLAGS"
160
161 dnl--------------------------------------------------------------------------
162 dnl Python.
163
164 dnl Make sure we have a suitable version.
165 AM_PATH_PYTHON([2.5])
166
167 dnl--------------------------------------------------------------------------
168 dnl Special debugging options.
169
170 AC_ARG_ENABLE([mpw],
171 [AS_HELP_STRING([--enable-mpw], [force small-width mp digits])],
172 [case "$enableval" in
173 y*|t*|short)
174 AC_DEFINE([FORCE_MPW_SHORT], [1],
175 [Define to force small-width mp digits.])
176 ;;
177 cussid)
178 AC_DEFINE([FORCE_MPW_CUSSID], [1],
179 [Define to force strange-width mp digits.])
180 ;;
181 esac])
182
183 dnl--------------------------------------------------------------------------
184 dnl Produce output.
185
186 AC_CONFIG_HEADER([config/config.h])
187
188 AC_CONFIG_FILES(
189 [Makefile]
190 [base/Makefile]
191 [key/Makefile]
192 [math/Makefile]
193 [misc/Makefile]
194 [pub/Makefile]
195 [rand/Makefile]
196 [symm/Makefile]
197 [progs/Makefile])
198 AC_OUTPUT
199
200 dnl----- That's all, folks --------------------------------------------------