forked from besser82/libxcrypt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
335 lines (306 loc) · 10.5 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# Process this file with autoconf to produce a configure script.
m4_include([m4/zw_automodern.m4])
AC_INIT([xcrypt],
[4.1.3],
[https://github.com/besser82/libxcrypt/issues],
[libxcrypt],
[https://github.com/besser82/libxcrypt])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([m4])
AC_CONFIG_SRCDIR([crypt.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
Makefile
libxcrypt.pc
])
AM_INIT_AUTOMAKE
AH_TOP(
[#ifndef _CRYPT_CONFIG_H
#define _CRYPT_CONFIG_H 1])
AH_BOTTOM(
[#endif /* config.h */])
# Checks for programs.
AC_CANONICAL_HOST
AC_PROG_CC
# Dependencies
PKG_PROG_PKG_CONFIG
PKG_INSTALLDIR
# C99 language and library features are used unconditionally.
# Don't even try to build with an older compiler.
case "$ac_prog_cc_stdc" in
c89 | no) AC_MSG_ERROR([a C99- or C11-compliant compiler is required]) ;;
esac
AC_PROG_CPP
AC_PROG_AWK
AC_PROG_MAKE_SET
AC_PROG_LN_S
AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE
zw_SIMPLE_ENABLE_WARNINGS
LT_INIT
# Check for system's endianness
AC_C_BIGENDIAN(
AC_DEFINE([IS_BIGENDIAN], 1,
[Define to 1 if system's architecture is big-endian.]),
AC_DEFINE([IS_BIGENDIAN], 0,
[Define to 0 if system's architecture is little-endian.])
)
# One of the test scripts needs to use -dD.
AC_CACHE_CHECK([whether the preprocessor ($CPP) supports -dD],
[ac_cv_prog_cc_dD],
[printf '#include <errno.h>' |
$CPP -dD -xc - > conftest.i 2>&AS_MESSAGE_LOG_FD
if test $? -ne 0; then
ac_cv_prog_cc_dD=no
elif grep -q '#define EDOM' conftest.i; then
ac_cv_prog_cc_dD=yes
else
ac_cv_prog_cc_dD=no
fi
rm -f conftest.i
])
AM_CONDITIONAL([HAVE_CPP_dD], [test $ac_cv_prog_cc_dD = yes])
# Checks for libraries.
# Checks for header files.
AC_CHECK_HEADERS_ONCE(
[fcntl.h stdbool.h sys/cdefs.h sys/random.h sys/syscall.h])
# stdint.h and inttypes.h were checked for by AC_INCLUDES_DEFAULT,
# invoked implicitly by the above.
if test $ac_cv_header_stdbool_h != yes ||
test $ac_cv_header_stdint_h != yes ||
test $ac_cv_header_inttypes_h != yes; then
AC_MSG_ERROR([a C99- or C11-compliant runtime library is required])
fi
# Checks for the specific things that we need from sys/cdefs.h, which
# might or might not be there (there's no standard for this header).
AS_IF([test $ac_cv_header_sys_cdefs_h = yes],
[AC_CACHE_CHECK([whether sys/cdefs.h defines __BEGIN_DECLS and __END_DECLS],
[ac_cv_header_sys_cdefs_begin_end_decls], [
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <sys/cdefs.h>
__BEGIN_DECLS
extern int foo(void);
__END_DECLS
]])],
[ac_cv_header_sys_cdefs_begin_end_decls=yes],
[ac_cv_header_sys_cdefs_begin_end_decls=no])
])
AC_CACHE_CHECK([whether sys/cdefs.h defines __nonnull],
[ac_cv_header_sys_cdefs_nonnull], [
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <sys/cdefs.h>
extern char *foo(char *, char *) __nonnull ((1, 2));
]])],
[ac_cv_header_sys_cdefs_nonnull=yes],
[ac_cv_header_sys_cdefs_nonnull=no])
])
AC_CACHE_CHECK([whether sys/cdefs.h defines __THROW],
[ac_cv_header_sys_cdefs_THROW], [
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <sys/cdefs.h>
extern void foo(void) __THROW;
]])],
[ac_cv_header_sys_cdefs_THROW=yes],
[ac_cv_header_sys_cdefs_THROW=no])
])],
dnl AS_IF else
[ac_cv_header_sys_cdefs_begin_end_decls=no
ac_cv_header_sys_cdefs_nonnull=no
ac_cv_header_sys_cdefs_THROW=no])
if test $ac_cv_header_sys_cdefs_begin_end_decls = yes; then
AC_DEFINE([HAVE_SYS_CDEFS_BEGIN_END_DECLS], 1,
[Define if <sys/cdefs.h> defines __BEGIN_DECLS and __END_DECLS.])
fi
if test $ac_cv_header_sys_cdefs_nonnull = yes; then
AC_DEFINE([HAVE_SYS_CDEFS_NONNULL], 1,
[Define if <sys/cdefs.h> defines __nonnull.])
fi
if test $ac_cv_header_sys_cdefs_THROW = yes; then
AC_DEFINE([HAVE_SYS_CDEFS_THROW], 1,
[Define if <sys/cdefs.h> defines __THROW.])
fi
# Checks for typedefs, structures, and compiler characteristics.
zw_C_ALIGNAS
zw_C_ALIGNOF
zw_C_MAX_ALIGN_T
zw_C_STATIC_ASSERT
zw_PROG_LD_WRAP
# Checks for library functions.
AC_CHECK_FUNCS_ONCE([
arc4random_buf
explicit_bzero
explicit_memset
getentropy
getrandom
memset_s
open64
syscall
])
# Disable valgrind tools for checking multithreaded
# programs, as we don't use them in checks.
AX_VALGRIND_DFLT([drd], [off])
AX_VALGRIND_DFLT([helgrind], [off])
# Valgrind's sgcheck is b0rk3n upstream.
AX_VALGRIND_DFLT([sgcheck], [off])
# Add a target to run testsuite with valgrind.
AX_VALGRIND_CHECK()
# Configure options.
AC_ARG_ENABLE([failure-tokens],
AS_HELP_STRING(
[--disable-failure-tokens],
[Make crypt and crypt_r return NULL on failure, instead of a
special "failure token" string that isn't the hash of any
passphrase. This matches the behavior of several other
crypt implementations, but will break programs that assume these
functions never return NULL. crypt_rn and crypt_ra are not affected
by this option, and will always return NULL on failure.]
),
[case "$enableval" in
yes) enable_failure_tokens=1;;
no) enable_failure_tokens=0;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-failure-tokens]);;
esac],
[enable_failure_tokens=1])
AC_DEFINE_UNQUOTED([ENABLE_FAILURE_TOKENS], [$enable_failure_tokens],
[Define to 1 if crypt and crypt_r should return a "failure token" on
failure, or 0 if they should return NULL.])
AC_ARG_ENABLE([obsolete-api],
AS_HELP_STRING(
[--enable-obsolete-api[=ARG]],
[When set to "yes", include all compatibility interfaces.
When set to "alt", include interfaces for compatibility with ALT.
When set to "glibc", include interfaces for compatibility with glibc.
When set to "owl", include interfaces for compatibility with Owl.
When set to "suse", include interfaces for compatibility with SUSE.
When set to "no", do not include any compatibility definitions at all,
and change the soname of the installed library to libcrypt.so.2.
This setting only affects existing binaries; new programs cannot
be linked against the obsolete APIs (bigcrypt, fcrypt, encrypt, setkey)
in any case. [default=yes]]
),
[case "${enableval}" in
alt|glibc|owl)
enable_obsolete_api=1
enable_compat_suse=0
COMPAT_ABI=${enableval} ;;
yes|suse)
enable_obsolete_api=1
enable_compat_suse=1
COMPAT_ABI=${enableval} ;;
no)
enable_obsolete_api=0
enable_compat_suse=0
COMPAT_ABI=${enableval} ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-obsolete-api]) ;;
esac],
[enable_obsolete_api=1
enable_compat_suse=1
COMPAT_ABI=yes]
)
AC_SUBST(COMPAT_ABI)
AC_ARG_ENABLE([hashes],
AS_HELP_STRING(
[--enable-hashes=HASHES],
[Select hash algorithms to support. Acceptable values are
'all' or a comma-separated list of names from the file
'hashes.lst' and/or the keywords 'strong', 'freebsd',
'glibc', 'netbsd', 'openbsd', 'osx', and 'solaris',
which select groups of hashes as described in that file.
The default is 'all'.
Note: if binary compatibility with any historic libcrypt is
desired (i.e. any --enable-obsolete-api setting other than
'no'), the 'des' hash must be enabled.]),
[hashes_selected=$enableval],
[hashes_selected=all]
)
# This code must run after AC_PROG_AWK.
hashes_enabled=$(
$AWK -f ${srcdir}/sel-hashes.awk -v SELECTED_HASHES="$hashes_selected" \
${srcdir}/hashes.lst
)
if test x"$hashes_enabled" = x || test x"$hashes_enabled" = x,; then
AC_MSG_ERROR([bad value '${hashes_selected}' for --enable-hashes])
fi
AC_SUBST([hashes_enabled])
# If the traditional DES hash is disabled, then the obsolete APIs are
# implicitly disabled.
case "$hashes_enabled" in
*,des,*) ;;
*)
if test x"$COMPAT_ABI" != xno; then
AC_MSG_WARN(
[--enable-hashes=${hashes_selected} forces --enable-obsolete-api=no])
fi
enable_obsolete_api=0
enable_compat_suse=0
COMPAT_ABI=no
;;
esac
# The obsolete APIs are unconditionally excluded from the static library,
# so if we are not building the shared library, we are effectively not
# building obsolete APIs, and we shouldn't try to test them.
if test x$enable_shared != xyes; then enable_obsolete_api=0; fi
# Determine whether there's even a GNU libc on this system that we
# need to be binary backward compatible with.
SYMVER_FLOOR=none
if test $enable_obsolete_api = 1; then
AC_MSG_CHECKING([minimum symbol version to use for compatibility symbols])
case $host_os in
*linux*)
while read pattern version cond; do
if test -z "$pattern" || test "x$pattern" = 'x#'; then
continue
fi
if expr "$host_cpu" : "$pattern" > /dev/null; then
if test -z "$cond"; then
cond_matched=yes
else
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
#include <limits.h>
#if $cond
#error yes
#endif
]])],
[cond_matched=no], [cond_matched=yes])
fi
if test $cond_matched = yes; then
SYMVER_FLOOR="$version"
break
fi
fi
done < ${srcdir}/libcrypt.minver
;;
*gnu*)
# glibc exists for GNU Hurd, but it is unclear to me whether
# it has a stable ABI yet. For now, we are assuming not.
;;
*)
# Other host OSes do not use glibc, so there is no reason to
# attempt to be binary compatible with it.
;;
esac
AC_MSG_RESULT([$SYMVER_FLOOR])
fi
if test x"$SYMVER_FLOOR" = xnone; then
SYMVER_FLOOR=XCRYPT_2.0
SYMVER_MIN=XCRYPT_2.0
enable_obsolete_api=0
else
SYMVER_MIN=GLIBC_2.0
fi
AC_SUBST([SYMVER_FLOOR])
AC_SUBST([SYMVER_MIN])
AC_DEFINE_UNQUOTED([SYMVER_FLOOR], [$SYMVER_FLOOR],
[Define as the lowest compatibility symbol version that is actually
included in libcrypt.so.])
AC_DEFINE_UNQUOTED([ENABLE_OBSOLETE_API], [$enable_obsolete_api],
[Define as 1 if the obsolete APIs (fcrypt, encrypt, setkey)
should be included, 0 otherwise.])
AM_CONDITIONAL([ENABLE_OBSOLETE_API], [test $enable_obsolete_api = 1])
AM_CONDITIONAL([ENABLE_COMPAT_SUSE], [test $enable_compat_suse = 1])
# The Makefile needs to know which versions of the library we are building.
AM_CONDITIONAL([ENABLE_STATIC], [test $enable_static = yes])
AM_CONDITIONAL([ENABLE_SHARED], [test $enable_shared = yes])
# The Makefile needs to know if we are cross-compiling.
AM_CONDITIONAL([CROSS_COMPILING], [test $cross_compiling = yes])
AC_OUTPUT