build: Use macOS' compatibility macros to enable all features.
[libgcrypt.git] / configure.ac
1 # Configure.ac script for Libgcrypt
2 # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006,
3 #               2007, 2008, 2009, 2011 Free Software Foundation, Inc.
4 # Copyright (C) 2012, 2013, 2014, 2015, 2016  g10 Code GmbH
5 #
6 # This file is part of Libgcrypt.
7 #
8 # Libgcrypt is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU Lesser General Public License as
10 # published by the Free Software Foundation; either version 2.1 of
11 # the License, or (at your option) any later version.
12 #
13 # Libgcrypt is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU Lesser General Public License for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
20
21 # (Process this file with autoconf to produce a configure script.)
22 AC_REVISION($Revision$)
23 AC_PREREQ(2.60)
24 min_automake_version="1.14"
25
26 # To build a release you need to create a tag with the version number
27 # (git tag -s libgcrypt-n.m.k) and run "./autogen.sh --force".  Please
28 # bump the version number immediately after the release and do another
29 # commit and push so that the git magic is able to work.  See below
30 # for the LT versions.
31 m4_define(mym4_version_major, [1])
32 m4_define(mym4_version_minor, [8])
33 m4_define(mym4_version_micro, [0])
34
35 # Below is m4 magic to extract and compute the revision number, the
36 # decimalized short revision number, a beta version string, and a flag
37 # indicating a development version (mym4_isgit). Note that the m4
38 # processing is done by autoconf and not during the configure run.
39 m4_define(mym4_version,
40           [mym4_version_major.mym4_version_minor.mym4_version_micro])
41 m4_define([mym4_revision],
42           m4_esyscmd([git rev-parse --short HEAD | tr -d '\n\r']))
43 m4_define([mym4_revision_dec],
44           m4_esyscmd_s([echo $((0x$(echo ]mym4_revision[|head -c 4)))]))
45 m4_define([mym4_betastring],
46           m4_esyscmd_s([git describe --match 'libgcrypt-[0-9].*[0-9]' --long|\
47                         awk -F- '$3!=0{print"-beta"$3}']))
48 m4_define([mym4_isgit],m4_if(mym4_betastring,[],[no],[yes]))
49 m4_define([mym4_full_version],[mym4_version[]mym4_betastring])
50
51 AC_INIT([libgcrypt],[mym4_full_version],[http://bugs.gnupg.org])
52
53 # LT Version numbers, remember to change them just *before* a release.
54 #   (Interfaces removed:    CURRENT++, AGE=0, REVISION=0)
55 #   (Interfaces added:      CURRENT++, AGE++, REVISION=0)
56 #   (No interfaces changed:                   REVISION++)
57 LIBGCRYPT_LT_CURRENT=21
58 LIBGCRYPT_LT_AGE=1
59 LIBGCRYPT_LT_REVISION=3
60
61
62 # If the API is changed in an incompatible way: increment the next counter.
63 #
64 # 1.6: ABI and API change but the change is to most users irrelevant
65 #      and thus the API version number has not been incremented.
66 LIBGCRYPT_CONFIG_API_VERSION=1
67
68 # If you change the required gpg-error version, please remove
69 # unnecessary error code defines in src/gcrypt-int.h.
70 NEED_GPG_ERROR_VERSION=1.25
71
72 PACKAGE=$PACKAGE_NAME
73 VERSION=$PACKAGE_VERSION
74
75 AC_CONFIG_AUX_DIR([build-aux])
76 AC_CONFIG_SRCDIR([src/libgcrypt.vers])
77 AM_INIT_AUTOMAKE([serial-tests dist-bzip2])
78 AC_CONFIG_HEADER(config.h)
79 AC_CONFIG_MACRO_DIR([m4])
80 AC_CONFIG_LIBOBJ_DIR([compat])
81 AC_CANONICAL_HOST
82 AM_MAINTAINER_MODE
83 AM_SILENT_RULES
84
85 AC_ARG_VAR(SYSROOT,[locate config scripts also below that directory])
86
87 AH_TOP([
88 #ifndef _GCRYPT_CONFIG_H_INCLUDED
89 #define _GCRYPT_CONFIG_H_INCLUDED
90
91 /* Enable gpg-error's strerror macro for W32CE.  */
92 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
93 ])
94
95 AH_BOTTOM([
96 #define _GCRYPT_IN_LIBGCRYPT 1
97
98 /* If the configure check for endianness has been disabled, get it from
99    OS macros.  This is intended for making fat binary builds on OS X.  */
100 #ifdef DISABLED_ENDIAN_CHECK
101 # if defined(__BIG_ENDIAN__)
102 #  define WORDS_BIGENDIAN 1
103 # elif defined(__LITTLE_ENDIAN__)
104 #  undef WORDS_BIGENDIAN
105 # else
106 #  error "No endianness found"
107 # endif
108 #endif /*DISABLED_ENDIAN_CHECK*/
109
110 /* We basically use the original Camellia source.  Make sure the symbols
111    properly prefixed.  */
112 #define CAMELLIA_EXT_SYM_PREFIX _gcry_
113
114 #endif /*_GCRYPT_CONFIG_H_INCLUDED*/
115 ])
116
117 AH_VERBATIM([_REENTRANT],
118 [/* To allow the use of Libgcrypt in multithreaded programs we have to use
119     special features from the library. */
120 #ifndef _REENTRANT
121 # define _REENTRANT 1
122 #endif
123 ])
124
125
126 AC_SUBST(LIBGCRYPT_LT_CURRENT)
127 AC_SUBST(LIBGCRYPT_LT_AGE)
128 AC_SUBST(LIBGCRYPT_LT_REVISION)
129 AC_SUBST(PACKAGE)
130 AC_SUBST(VERSION)
131 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
132 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
133 VERSION_NUMBER=m4_esyscmd(printf "0x%02x%02x%02x" mym4_version_major \
134                           mym4_version_minor mym4_version_micro)
135 AC_SUBST(VERSION_NUMBER)
136
137
138 ######################
139 ##  Basic checks.  ### (we need some results later on (e.g. $GCC)
140 ######################
141
142 AC_PROG_MAKE_SET
143 missing_dir=`cd $ac_aux_dir && pwd`
144 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
145 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
146 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
147 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
148 # AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
149 AC_PROG_CC
150 AC_PROG_CPP
151 AM_PROG_CC_C_O
152 AM_PROG_AS
153 AC_ISC_POSIX
154 AC_PROG_INSTALL
155 AC_PROG_AWK
156
157 AC_GNU_SOURCE
158
159 # We need to compile and run a program on the build machine.  A
160 # comment in libgpg-error says that the AC_PROG_CC_FOR_BUILD macro in
161 # the AC archive is broken for autoconf 2.57.  Given that there is no
162 # newer version of that macro, we assume that it is also broken for
163 # autoconf 2.61 and thus we use a simple but usually sufficient
164 # approach.
165 AC_MSG_CHECKING(for cc for build)
166 if test "$cross_compiling" = "yes"; then
167   CC_FOR_BUILD="${CC_FOR_BUILD-cc}"
168 else
169   CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
170 fi
171 AC_MSG_RESULT($CC_FOR_BUILD)
172 AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
173
174
175 LT_PREREQ([2.2.6])
176 LT_INIT([win32-dll disable-static])
177 LT_LANG([Windows Resource])
178
179
180 ##########################
181 ## General definitions. ##
182 ##########################
183
184 # Used by libgcrypt-config
185 LIBGCRYPT_CONFIG_LIBS="-lgcrypt"
186 LIBGCRYPT_CONFIG_CFLAGS=""
187 LIBGCRYPT_CONFIG_HOST="$host"
188
189 # Definitions for symmetric ciphers.
190 available_ciphers="arcfour blowfish cast5 des aes twofish serpent rfc2268 seed"
191 available_ciphers="$available_ciphers camellia idea salsa20 gost28147 chacha20"
192 enabled_ciphers=""
193
194 # Definitions for public-key ciphers.
195 available_pubkey_ciphers="dsa elgamal rsa ecc"
196 enabled_pubkey_ciphers=""
197
198 # Definitions for message digests.
199 available_digests="crc gostr3411-94 md2 md4 md5 rmd160 sha1 sha256 sha512"
200 available_digests="$available_digests sha3 tiger whirlpool stribog blake2"
201 enabled_digests=""
202
203 # Definitions for kdfs (optional ones)
204 available_kdfs="s2k pkdf2 scrypt"
205 enabled_kdfs=""
206
207 # Definitions for random modules.
208 available_random_modules="linux egd unix"
209 auto_random_modules="$available_random_modules"
210
211 # Supported thread backends.
212 LIBGCRYPT_THREAD_MODULES=""
213
214 # Other definitions.
215 print_egd_notice=no
216 have_w32_system=no
217 have_w32ce_system=no
218 have_pthread=no
219
220
221 # Setup some stuff depending on host.
222 case "${host}" in
223     *-*-mingw32*)
224       ac_cv_have_dev_random=no
225       have_w32_system=yes
226       case "${host}" in
227         *-mingw32ce*)
228             have_w32ce_system=yes
229             available_random_modules="w32ce"
230             ;;
231         *)
232             available_random_modules="w32"
233             ;;
234       esac
235       AC_DEFINE(USE_ONLY_8DOT3,1,
236                 [set this to limit filenames to the 8.3 format])
237       AC_DEFINE(HAVE_DRIVE_LETTERS,1,
238                 [defined if we must run on a stupid file system])
239       AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
240                 [defined if we run on some of the PCDOS like systems
241                  (DOS, Windoze. OS/2) with special properties like
242                   no file modes])
243       ;;
244
245     i?86-emx-os2 | i?86-*-os2*emx)
246         # OS/2 with the EMX environment
247         ac_cv_have_dev_random=no
248         AC_DEFINE(HAVE_DRIVE_LETTERS)
249         AC_DEFINE(HAVE_DOSISH_SYSTEM)
250         ;;
251
252     i?86-*-msdosdjgpp*)
253         # DOS with the DJGPP environment
254         ac_cv_have_dev_random=no
255         AC_DEFINE(HAVE_DRIVE_LETTERS)
256         AC_DEFINE(HAVE_DOSISH_SYSTEM)
257         ;;
258
259     *-*-hpux*)
260         if test -z "$GCC" ; then
261             CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
262         fi
263         ;;
264     *-dec-osf4*)
265         if test -z "$GCC" ; then
266             # Suppress all warnings
267             # to get rid of the unsigned/signed char mismatch warnings.
268             CFLAGS="$CFLAGS -w"
269         fi
270         ;;
271     m68k-atari-mint)
272         ;;
273     *-apple-darwin*)
274         AC_DEFINE(_DARWIN_C_SOURCE, 900000L,
275                   Expose all libc features (__DARWIN_C_FULL).)
276         ;;
277     *)
278       ;;
279 esac
280
281 if test "$have_w32_system" = yes; then
282    AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
283    if test "$have_w32ce_system" = yes; then
284      AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE])
285    fi
286 fi
287 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
288 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
289
290
291
292 # A printable OS Name is sometimes useful.
293 case "${host}" in
294     *-*-mingw32ce*)
295         PRINTABLE_OS_NAME="W32CE"
296         ;;
297
298     *-*-mingw32*)
299         PRINTABLE_OS_NAME="W32"
300         ;;
301
302     i?86-emx-os2 | i?86-*-os2*emx )
303         PRINTABLE_OS_NAME="OS/2"
304         ;;
305
306     i?86-*-msdosdjgpp*)
307         PRINTABLE_OS_NAME="MSDOS/DJGPP"
308         ;;
309
310     *-linux*)
311         PRINTABLE_OS_NAME="GNU/Linux"
312         ;;
313
314     *)
315         PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
316         ;;
317 esac
318
319 #
320 # Figure out the name of the random device
321 #
322 case "${host}" in
323     *-openbsd*)
324         NAME_OF_DEV_RANDOM="/dev/srandom"
325         NAME_OF_DEV_URANDOM="/dev/urandom"
326         ;;
327
328     *)
329         NAME_OF_DEV_RANDOM="/dev/random"
330         NAME_OF_DEV_URANDOM="/dev/urandom"
331         ;;
332 esac
333
334
335 AC_ARG_ENABLE(endian-check,
336               AC_HELP_STRING([--disable-endian-check],
337               [disable the endian check and trust the OS provided macros]),
338               endiancheck=$enableval,endiancheck=yes)
339 if test x"$endiancheck" = xyes ; then
340   AC_C_BIGENDIAN
341 else
342   AC_DEFINE(DISABLED_ENDIAN_CHECK,1,[configure did not test for endianess])
343 fi
344
345 AC_CHECK_SIZEOF(unsigned short, 2)
346 AC_CHECK_SIZEOF(unsigned int, 4)
347 AC_CHECK_SIZEOF(unsigned long, 4)
348 AC_CHECK_SIZEOF(unsigned long long, 0)
349 AC_CHECK_SIZEOF(void *, 0)
350
351 AC_TYPE_UINTPTR_T
352
353 if test "$ac_cv_sizeof_unsigned_short" = "0" \
354    || test "$ac_cv_sizeof_unsigned_int" = "0" \
355    || test "$ac_cv_sizeof_unsigned_long" = "0"; then
356     AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
357 fi
358
359 # Ensure that we have UINT64_C before we bother to check for uint64_t
360 AC_CACHE_CHECK([for UINT64_C],[gnupg_cv_uint64_c_works],
361    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <inttypes.h>]],
362        [[uint64_t foo=UINT64_C(42);]])],
363      gnupg_cv_uint64_c_works=yes,gnupg_cv_uint64_c_works=no))
364 if test "$gnupg_cv_uint64_c_works" = "yes" ; then
365    AC_CHECK_SIZEOF(uint64_t)
366 fi
367
368 # Do we have any 64-bit data types?
369 if test "$ac_cv_sizeof_unsigned_int" != "8" \
370    && test "$ac_cv_sizeof_unsigned_long" != "8" \
371    && test "$ac_cv_sizeof_unsigned_long_long" != "8" \
372    && test "$ac_cv_sizeof_uint64_t" != "8"; then
373     AC_MSG_ERROR([[
374 ***
375 *** No 64-bit integer type available.
376 *** It is not possible to build Libgcrypt on this platform.
377 ***]])
378 fi
379
380
381 # If not specified otherwise, all available algorithms will be
382 # included.
383 default_ciphers="$available_ciphers"
384 default_pubkey_ciphers="$available_pubkey_ciphers"
385 default_digests="$available_digests"
386 default_kdfs="$available_kdfs"
387 # Blacklist MD2 by default
388 default_digests=`echo $default_digests | sed -e 's/md2//g'`
389
390 # Substitutions to set generated files in a Emacs buffer to read-only.
391 AC_SUBST(emacs_local_vars_begin, ['Local Variables:'])
392 AC_SUBST(emacs_local_vars_read_only, ['buffer-read-only: t'])
393 AC_SUBST(emacs_local_vars_end, ['End:'])
394
395 ############################
396 ## Command line switches. ##
397 ############################
398
399 # Implementation of the --enable-ciphers switch.
400 AC_ARG_ENABLE(ciphers,
401               AC_HELP_STRING([--enable-ciphers=ciphers],
402                              [select the symmetric ciphers to include]),
403               [enabled_ciphers=`echo $enableval | tr ',:' '  ' | tr '[A-Z]' '[a-z]'`],
404               [enabled_ciphers=""])
405 if test "x$enabled_ciphers" = "x" \
406    -o "$enabled_ciphers" = "yes"  \
407    -o "$enabled_ciphers" = "no"; then
408    enabled_ciphers=$default_ciphers
409 fi
410 AC_MSG_CHECKING([which symmetric ciphers to include])
411 for cipher in $enabled_ciphers; do
412     LIST_MEMBER($cipher, $available_ciphers)
413     if test "$found" = "0"; then
414        AC_MSG_ERROR([unsupported cipher "$cipher" specified])
415     fi
416 done
417 AC_MSG_RESULT([$enabled_ciphers])
418
419 # Implementation of the --enable-pubkey-ciphers switch.
420 AC_ARG_ENABLE(pubkey-ciphers,
421               AC_HELP_STRING([--enable-pubkey-ciphers=ciphers],
422                              [select the public-key ciphers to include]),
423               [enabled_pubkey_ciphers=`echo $enableval | tr ',:' '  ' | tr '[A-Z]' '[a-z]'`],
424               [enabled_pubkey_ciphers=""])
425 if test "x$enabled_pubkey_ciphers" = "x" \
426    -o "$enabled_pubkey_ciphers" = "yes"  \
427    -o "$enabled_pubkey_ciphers" = "no"; then
428    enabled_pubkey_ciphers=$default_pubkey_ciphers
429 fi
430 AC_MSG_CHECKING([which public-key ciphers to include])
431 for cipher in $enabled_pubkey_ciphers; do
432     LIST_MEMBER($cipher, $available_pubkey_ciphers)
433     if test "$found" = "0"; then
434        AC_MSG_ERROR([unsupported public-key cipher specified])
435     fi
436 done
437 AC_MSG_RESULT([$enabled_pubkey_ciphers])
438
439 # Implementation of the --enable-digests switch.
440 AC_ARG_ENABLE(digests,
441               AC_HELP_STRING([--enable-digests=digests],
442                              [select the message digests to include]),
443               [enabled_digests=`echo $enableval | tr ',:' '  ' | tr '[A-Z]' '[a-z]'`],
444               [enabled_digests=""])
445 if test "x$enabled_digests" = "x" \
446    -o "$enabled_digests" = "yes"  \
447    -o "$enabled_digests" = "no"; then
448    enabled_digests=$default_digests
449 fi
450 AC_MSG_CHECKING([which message digests to include])
451 for digest in $enabled_digests; do
452     LIST_MEMBER($digest, $available_digests)
453     if test "$found" = "0"; then
454        AC_MSG_ERROR([unsupported message digest specified])
455     fi
456 done
457 AC_MSG_RESULT([$enabled_digests])
458
459 # Implementation of the --enable-kdfs switch.
460 AC_ARG_ENABLE(kdfs,
461       AC_HELP_STRING([--enable-kfds=kdfs],
462                      [select the KDFs to include]),
463       [enabled_kdfs=`echo $enableval | tr ',:' '  ' | tr '[A-Z]' '[a-z]'`],
464       [enabled_kdfs=""])
465 if test "x$enabled_kdfs" = "x" \
466    -o "$enabled_kdfs" = "yes"  \
467    -o "$enabled_kdfs" = "no"; then
468    enabled_kdfs=$default_kdfs
469 fi
470 AC_MSG_CHECKING([which key derivation functions to include])
471 for kdf in $enabled_kdfs; do
472     LIST_MEMBER($kdf, $available_kdfs)
473     if test "$found" = "0"; then
474        AC_MSG_ERROR([unsupported key derivation function specified])
475     fi
476 done
477 AC_MSG_RESULT([$enabled_kdfs])
478
479 # Implementation of the --enable-random switch.
480 AC_ARG_ENABLE(random,
481               AC_HELP_STRING([--enable-random=name],
482                              [select which random number generator to use]),
483               [random=`echo $enableval | tr '[A-Z]' '[a-z]'`],
484               [])
485 if test "x$random" = "x" -o "$random" = "yes" -o "$random" = "no"; then
486     random=default
487 fi
488 AC_MSG_CHECKING([which random module to use])
489 if test "$random" != "default" -a "$random" != "auto"; then
490     LIST_MEMBER($random, $available_random_modules)
491     if test "$found" = "0"; then
492        AC_MSG_ERROR([unsupported random module specified])
493     fi
494 fi
495 AC_MSG_RESULT($random)
496
497 # Implementation of the --disable-dev-random switch.
498 AC_MSG_CHECKING([whether use of /dev/random is requested])
499 AC_ARG_ENABLE(dev-random,
500 [  --disable-dev-random    disable the use of dev random],
501     try_dev_random=$enableval, try_dev_random=yes)
502 AC_MSG_RESULT($try_dev_random)
503
504 # Implementation of the --with-egd-socket switch.
505 AC_ARG_WITH(egd-socket,
506     [  --with-egd-socket=NAME  Use NAME for the EGD socket)],
507             egd_socket_name="$withval", egd_socket_name="" )
508 AC_DEFINE_UNQUOTED(EGD_SOCKET_NAME, "$egd_socket_name",
509                    [Define if you don't want the default EGD socket name.
510                     For details see cipher/rndegd.c])
511
512 # Implementation of the --enable-random-daemon
513 AC_MSG_CHECKING([whether the experimental random daemon is requested])
514 AC_ARG_ENABLE([random-daemon],
515               AC_HELP_STRING([--enable-random-daemon],
516                              [Build and support the experimental gcryptrnd]),
517               [use_random_daemon=$enableval],
518               [use_random_daemon=no])
519 AC_MSG_RESULT($use_random_daemon)
520 if test x$use_random_daemon = xyes ; then
521     AC_DEFINE(USE_RANDOM_DAEMON,1,
522               [Define to support the experimental random daemon])
523 fi
524 AM_CONDITIONAL(USE_RANDOM_DAEMON, test x$use_random_daemon = xyes)
525
526
527 # Implementation of --disable-asm.
528 AC_MSG_CHECKING([whether MPI assembler modules are requested])
529 AC_ARG_ENABLE([asm],
530               AC_HELP_STRING([--disable-asm],
531                              [Disable MPI assembler modules]),
532               [try_asm_modules=$enableval],
533               [try_asm_modules=yes])
534 AC_MSG_RESULT($try_asm_modules)
535
536 # Implementation of the --enable-m-guard switch.
537 AC_MSG_CHECKING([whether memory guard is requested])
538 AC_ARG_ENABLE(m-guard,
539               AC_HELP_STRING([--enable-m-guard],
540                              [Enable memory guard facility]),
541               [use_m_guard=$enableval], [use_m_guard=no])
542 AC_MSG_RESULT($use_m_guard)
543 if test "$use_m_guard" = yes ; then
544     AC_DEFINE(M_GUARD,1,[Define to use the (obsolete) malloc guarding feature])
545 fi
546
547 # Implementation of the --enable-large-data-tests switch.
548 AC_MSG_CHECKING([whether to run large data tests])
549 AC_ARG_ENABLE(large-data-tests,
550               AC_HELP_STRING([--enable-large-data-tests],
551                  [Enable the real long ruinning large data tests]),
552               large_data_tests=$enableval,large_data_tests=no)
553 AC_MSG_RESULT($large_data_tests)
554 AC_SUBST(RUN_LARGE_DATA_TESTS, $large_data_tests)
555
556
557 # Implementation of the --with-capabilities switch.
558 # Check whether we want to use Linux capabilities
559 AC_MSG_CHECKING([whether use of capabilities is requested])
560 AC_ARG_WITH(capabilities,
561             AC_HELP_STRING([--with-capabilities],
562                            [Use linux capabilities [default=no]]),
563             [use_capabilities="$withval"],[use_capabilities=no])
564 AC_MSG_RESULT($use_capabilities)
565
566 # Implementation of the --enable-hmac-binary-check.
567 AC_MSG_CHECKING([whether a HMAC binary check is requested])
568 AC_ARG_ENABLE(hmac-binary-check,
569               AC_HELP_STRING([--enable-hmac-binary-check],
570                              [Enable library integrity check]),
571               [use_hmac_binary_check=$enableval],
572               [use_hmac_binary_check=no])
573 AC_MSG_RESULT($use_hmac_binary_check)
574 if test "$use_hmac_binary_check" = yes ; then
575     AC_DEFINE(ENABLE_HMAC_BINARY_CHECK,1,
576               [Define to support an HMAC based integrity check])
577 fi
578
579
580 # Implementation of the --disable-padlock-support switch.
581 AC_MSG_CHECKING([whether padlock support is requested])
582 AC_ARG_ENABLE(padlock-support,
583               AC_HELP_STRING([--disable-padlock-support],
584                  [Disable support for the PadLock Engine of VIA processors]),
585               padlocksupport=$enableval,padlocksupport=yes)
586 AC_MSG_RESULT($padlocksupport)
587
588 # Implementation of the --disable-aesni-support switch.
589 AC_MSG_CHECKING([whether AESNI support is requested])
590 AC_ARG_ENABLE(aesni-support,
591               AC_HELP_STRING([--disable-aesni-support],
592                  [Disable support for the Intel AES-NI instructions]),
593               aesnisupport=$enableval,aesnisupport=yes)
594 AC_MSG_RESULT($aesnisupport)
595
596 # Implementation of the --disable-pclmul-support switch.
597 AC_MSG_CHECKING([whether PCLMUL support is requested])
598 AC_ARG_ENABLE(pclmul-support,
599               AC_HELP_STRING([--disable-pclmul-support],
600                  [Disable support for the Intel PCLMUL instructions]),
601               pclmulsupport=$enableval,pclmulsupport=yes)
602 AC_MSG_RESULT($pclmulsupport)
603
604 # Implementation of the --disable-sse41-support switch.
605 AC_MSG_CHECKING([whether SSE4.1 support is requested])
606 AC_ARG_ENABLE(sse41-support,
607               AC_HELP_STRING([--disable-sse41-support],
608                  [Disable support for the Intel SSE4.1 instructions]),
609               sse41support=$enableval,sse41support=yes)
610 AC_MSG_RESULT($sse41support)
611
612 # Implementation of the --disable-drng-support switch.
613 AC_MSG_CHECKING([whether DRNG support is requested])
614 AC_ARG_ENABLE(drng-support,
615               AC_HELP_STRING([--disable-drng-support],
616                  [Disable support for the Intel DRNG (RDRAND instruction)]),
617               drngsupport=$enableval,drngsupport=yes)
618 AC_MSG_RESULT($drngsupport)
619
620 # Implementation of the --disable-avx-support switch.
621 AC_MSG_CHECKING([whether AVX support is requested])
622 AC_ARG_ENABLE(avx-support,
623               AC_HELP_STRING([--disable-avx-support],
624                  [Disable support for the Intel AVX instructions]),
625               avxsupport=$enableval,avxsupport=yes)
626 AC_MSG_RESULT($avxsupport)
627
628 # Implementation of the --disable-avx2-support switch.
629 AC_MSG_CHECKING([whether AVX2 support is requested])
630 AC_ARG_ENABLE(avx2-support,
631               AC_HELP_STRING([--disable-avx2-support],
632                  [Disable support for the Intel AVX2 instructions]),
633               avx2support=$enableval,avx2support=yes)
634 AC_MSG_RESULT($avx2support)
635
636 # Implementation of the --disable-neon-support switch.
637 AC_MSG_CHECKING([whether NEON support is requested])
638 AC_ARG_ENABLE(neon-support,
639               AC_HELP_STRING([--disable-neon-support],
640                  [Disable support for the ARM NEON instructions]),
641               neonsupport=$enableval,neonsupport=yes)
642 AC_MSG_RESULT($neonsupport)
643
644 # Implementation of the --disable-arm-crypto-support switch.
645 AC_MSG_CHECKING([whether ARMv8 Crypto Extension support is requested])
646 AC_ARG_ENABLE(arm-crypto-support,
647               AC_HELP_STRING([--disable-arm-crypto-support],
648                  [Disable support for the ARMv8 Crypto Extension instructions]),
649               armcryptosupport=$enableval,armcryptosupport=yes)
650 AC_MSG_RESULT($armcryptosupport)
651
652 # Implementation of the --disable-O-flag-munging switch.
653 AC_MSG_CHECKING([whether a -O flag munging is requested])
654 AC_ARG_ENABLE([O-flag-munging],
655               AC_HELP_STRING([--disable-O-flag-munging],
656                  [Disable modification of the cc -O flag]),
657               [enable_o_flag_munging=$enableval],
658               [enable_o_flag_munging=yes])
659 AC_MSG_RESULT($enable_o_flag_munging)
660 AM_CONDITIONAL(ENABLE_O_FLAG_MUNGING, test "$enable_o_flag_munging" = "yes")
661
662 # Implementation of the --disable-amd64-as-feature-detection switch.
663 AC_MSG_CHECKING([whether to enable AMD64 as(1) feature detection])
664 AC_ARG_ENABLE(amd64-as-feature-detection,
665               AC_HELP_STRING([--disable-amd64-as-feature-detection],
666                  [Disable the auto-detection of AMD64 as(1) features]),
667               amd64_as_feature_detection=$enableval,
668               amd64_as_feature_detection=yes)
669 AC_MSG_RESULT($amd64_as_feature_detection)
670
671
672 AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
673                    [A human readable text with the name of the OS])
674
675 # For some systems we know that we have ld_version scripts.
676 # Use it then as default.
677 have_ld_version_script=no
678 case "${host}" in
679     *-*-linux*)
680         have_ld_version_script=yes
681         ;;
682     *-*-gnu*)
683         have_ld_version_script=yes
684         ;;
685 esac
686 AC_ARG_ENABLE([ld-version-script],
687               AC_HELP_STRING([--enable-ld-version-script],
688                              [enable/disable use of linker version script.
689                               (default is system dependent)]),
690               [have_ld_version_script=$enableval],
691               [ : ] )
692 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
693
694 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, "$NAME_OF_DEV_RANDOM",
695                    [defined to the name of the strong random device])
696 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, "$NAME_OF_DEV_URANDOM",
697                    [defined to the name of the weaker random device])
698
699
700 ###############################
701 #### Checks for libraries. ####
702 ###############################
703
704 #
705 # gpg-error is required.
706 #
707 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION")
708 if test "x$GPG_ERROR_LIBS" = "x"; then
709   AC_MSG_ERROR([libgpg-error is needed.
710                 See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ .])
711 fi
712
713 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GCRYPT,
714           [The default error source for libgcrypt.])
715
716 #
717 # Check whether the GNU Pth library is available.  We require this
718 # to build the optional gcryptrnd program.
719 #
720 AC_ARG_WITH(pth-prefix,
721             AC_HELP_STRING([--with-pth-prefix=PFX],
722                            [prefix where GNU Pth is installed (optional)]),
723      pth_config_prefix="$withval", pth_config_prefix="")
724 if test x$pth_config_prefix != x ; then
725    PTH_CONFIG="$pth_config_prefix/bin/pth-config"
726 fi
727 if test "$use_random_daemon" = "yes"; then
728   AC_PATH_PROG(PTH_CONFIG, pth-config, no)
729   if test "$PTH_CONFIG" = "no"; then
730     AC_MSG_WARN([[
731 ***
732 *** To build the Libgcrypt's random number daemon
733 *** we need the support of the GNU Portable Threads Library.
734 *** Download it from ftp://ftp.gnu.org/gnu/pth/
735 *** On a Debian GNU/Linux system you might want to try
736 ***   apt-get install libpth-dev
737 ***]])
738   else
739     GNUPG_PTH_VERSION_CHECK([1.3.7])
740     if test $have_pth = yes; then
741        PTH_CFLAGS=`$PTH_CONFIG --cflags`
742        PTH_LIBS=`$PTH_CONFIG --ldflags`
743        PTH_LIBS="$PTH_LIBS `$PTH_CONFIG --libs --all`"
744        AC_DEFINE(USE_GNU_PTH, 1,
745                 [Defined if the GNU Portable Thread Library should be used])
746        AC_DEFINE(HAVE_PTH, 1,
747                 [Defined if the GNU Pth is available])
748     fi
749   fi
750 fi
751 AC_SUBST(PTH_CFLAGS)
752 AC_SUBST(PTH_LIBS)
753
754 #
755 # Check whether pthreads is available
756 #
757 if test "$have_w32_system" != yes; then
758   AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
759   if test "$have_pthread" = yes; then
760     AC_DEFINE(HAVE_PTHREAD, 1 ,[Define if we have pthread.])
761   fi
762 fi
763
764
765 # Solaris needs -lsocket and -lnsl. Unisys system includes
766 # gethostbyname in libsocket but needs libnsl for socket.
767 AC_SEARCH_LIBS(setsockopt, [socket], ,
768         [AC_SEARCH_LIBS(setsockopt, [socket], , , [-lnsl])])
769 AC_SEARCH_LIBS(setsockopt, [nsl])
770
771 ##################################
772 #### Checks for header files. ####
773 ##################################
774
775 AC_HEADER_STDC
776 AC_CHECK_HEADERS(unistd.h sys/select.h sys/msg.h)
777 INSERT_SYS_SELECT_H=
778 if test x"$ac_cv_header_sys_select_h" = xyes; then
779   INSERT_SYS_SELECT_H=" include <sys/select.h>"
780 fi
781 AC_SUBST(INSERT_SYS_SELECT_H)
782
783
784 ##########################################
785 #### Checks for typedefs, structures, ####
786 ####  and compiler characteristics.   ####
787 ##########################################
788
789 AC_C_CONST
790 AC_C_INLINE
791 AC_TYPE_SIZE_T
792 AC_TYPE_SIGNAL
793 AC_DECL_SYS_SIGLIST
794 AC_TYPE_PID_T
795
796 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
797 GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
798 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
799 GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
800 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
801
802 gl_TYPE_SOCKLEN_T
803 case "${host}" in
804   *-*-mingw32*)
805     # socklen_t may or may not be defined depending on what headers
806     # are included.  To be safe we use int as this is the actual type.
807     FALLBACK_SOCKLEN_T="typedef int gcry_socklen_t;"
808     ;;
809   *)
810     if test ".$gl_cv_socklen_t_equiv" = "."; then
811       FALLBACK_SOCKLEN_T="typedef socklen_t gcry_socklen_t;"
812     else
813       FALLBACK_SOCKLEN_T="typedef ${gl_cv_socklen_t_equiv} gcry_socklen_t;"
814     fi
815 esac
816 AC_SUBST(FALLBACK_SOCKLEN_T)
817
818
819 #
820 # Check for __builtin_bswap32 intrinsic.
821 #
822 AC_CACHE_CHECK(for __builtin_bswap32,
823        [gcry_cv_have_builtin_bswap32],
824        [gcry_cv_have_builtin_bswap32=no
825         AC_LINK_IFELSE([AC_LANG_PROGRAM([],
826           [int x = 0; int y = __builtin_bswap32(x); return y;])],
827           [gcry_cv_have_builtin_bswap32=yes])])
828 if test "$gcry_cv_have_builtin_bswap32" = "yes" ; then
829    AC_DEFINE(HAVE_BUILTIN_BSWAP32,1,
830              [Defined if compiler has '__builtin_bswap32' intrinsic])
831 fi
832
833
834 #
835 # Check for __builtin_bswap64 intrinsic.
836 #
837 AC_CACHE_CHECK(for __builtin_bswap64,
838        [gcry_cv_have_builtin_bswap64],
839        [gcry_cv_have_builtin_bswap64=no
840         AC_LINK_IFELSE([AC_LANG_PROGRAM([],
841           [long long x = 0; long long y = __builtin_bswap64(x); return y;])],
842           [gcry_cv_have_builtin_bswap64=yes])])
843 if test "$gcry_cv_have_builtin_bswap64" = "yes" ; then
844    AC_DEFINE(HAVE_BUILTIN_BSWAP64,1,
845              [Defined if compiler has '__builtin_bswap64' intrinsic])
846 fi
847
848
849 #
850 # Check for __builtin_ctz intrinsic.
851 #
852 AC_CACHE_CHECK(for __builtin_ctz,
853        [gcry_cv_have_builtin_ctz],
854        [gcry_cv_have_builtin_ctz=no
855         AC_LINK_IFELSE([AC_LANG_PROGRAM([],
856           [unsigned int x = 0; int y = __builtin_ctz(x); return y;])],
857           [gcry_cv_have_builtin_ctz=yes])])
858 if test "$gcry_cv_have_builtin_ctz" = "yes" ; then
859    AC_DEFINE(HAVE_BUILTIN_CTZ, 1,
860              [Defined if compiler has '__builtin_ctz' intrinsic])
861 fi
862
863
864 #
865 # Check for VLA support (variable length arrays).
866 #
867 AC_CACHE_CHECK(whether the variable length arrays are supported,
868        [gcry_cv_have_vla],
869        [gcry_cv_have_vla=no
870         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
871           [[void f1(char *, int);
872             char foo(int i) {
873               char b[(i < 0 ? 0 : i) + 1];
874               f1(b, sizeof b); return b[0];}]])],
875           [gcry_cv_have_vla=yes])])
876 if test "$gcry_cv_have_vla" = "yes" ; then
877    AC_DEFINE(HAVE_VLA,1, [Defined if variable length arrays are supported])
878 fi
879
880
881 #
882 # Check for ELF visibility support.
883 #
884 AC_CACHE_CHECK(whether the visibility attribute is supported,
885        gcry_cv_visibility_attribute,
886        [gcry_cv_visibility_attribute=no
887         AC_LANG_CONFTEST([AC_LANG_SOURCE(
888           [[int foo __attribute__ ((visibility ("hidden"))) = 1;
889             int bar __attribute__ ((visibility ("protected"))) = 1;
890           ]])])
891
892         if ${CC-cc} -Werror -S conftest.c -o conftest.s \
893                   1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
894             if grep '\.hidden.*foo' conftest.s >/dev/null 2>&1 ; then
895                 if grep '\.protected.*bar' conftest.s >/dev/null 2>&1; then
896                     gcry_cv_visibility_attribute=yes
897                 fi
898             fi
899         fi
900        ])
901 if test "$gcry_cv_visibility_attribute" = "yes"; then
902     AC_CACHE_CHECK(for broken visibility attribute,
903        gcry_cv_broken_visibility_attribute,
904        [gcry_cv_broken_visibility_attribute=yes
905         AC_LANG_CONFTEST([AC_LANG_SOURCE(
906           [[int foo (int x);
907             int bar (int x) __asm__ ("foo")
908                             __attribute__ ((visibility ("hidden")));
909             int bar (int x) { return x; }
910           ]])])
911
912         if ${CC-cc} -Werror -S conftest.c -o conftest.s \
913                   1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
914            if grep '\.hidden@<:@        _@:>@foo' conftest.s >/dev/null 2>&1;
915             then
916                gcry_cv_broken_visibility_attribute=no
917            fi
918         fi
919        ])
920 fi
921 if test "$gcry_cv_visibility_attribute" = "yes"; then
922     AC_CACHE_CHECK(for broken alias attribute,
923        gcry_cv_broken_alias_attribute,
924        [gcry_cv_broken_alias_attribute=yes
925         AC_LANG_CONFTEST([AC_LANG_SOURCE(
926           [[extern int foo (int x) __asm ("xyzzy");
927             int bar (int x) { return x; }
928             extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
929             extern int dfoo;
930             extern __typeof (dfoo) dfoo __asm ("abccb");
931             int dfoo = 1;
932           ]])])
933
934         if ${CC-cc} -Werror -S conftest.c -o conftest.s \
935                   1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
936            if grep 'xyzzy' conftest.s >/dev/null 2>&1 && \
937               grep 'abccb' conftest.s >/dev/null 2>&1; then
938               gcry_cv_broken_alias_attribute=no
939            fi
940         fi
941         ])
942 fi
943 if test "$gcry_cv_visibility_attribute" = "yes"; then
944     AC_CACHE_CHECK(if gcc supports -fvisibility=hidden,
945        gcry_cv_gcc_has_f_visibility,
946        [gcry_cv_gcc_has_f_visibility=no
947         _gcc_cflags_save=$CFLAGS
948         CFLAGS="-fvisibility=hidden"
949         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
950                           gcry_cv_gcc_has_f_visibility=yes)
951         CFLAGS=$_gcc_cflags_save;
952        ])
953 fi
954 if test "$gcry_cv_visibility_attribute" = "yes" \
955    && test "$gcry_cv_broken_visibility_attribute" != "yes" \
956    && test "$gcry_cv_broken_alias_attribute" != "yes" \
957    && test "$gcry_cv_gcc_has_f_visibility" = "yes"
958  then
959    AC_DEFINE(GCRY_USE_VISIBILITY, 1,
960                [Define to use the GNU C visibility attribute.])
961    CFLAGS="$CFLAGS -fvisibility=hidden"
962 fi
963
964
965 # Following attribute tests depend on warnings to cause compile to fail,
966 # so set -Werror temporarily.
967 _gcc_cflags_save=$CFLAGS
968 CFLAGS="$CFLAGS -Werror"
969
970
971 #
972 # Check whether the compiler supports the GCC style aligned attribute
973 #
974 AC_CACHE_CHECK([whether the GCC style aligned attribute is supported],
975        [gcry_cv_gcc_attribute_aligned],
976        [gcry_cv_gcc_attribute_aligned=no
977         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
978           [[struct { int a; } foo __attribute__ ((aligned (16)));]])],
979           [gcry_cv_gcc_attribute_aligned=yes])])
980 if test "$gcry_cv_gcc_attribute_aligned" = "yes" ; then
981    AC_DEFINE(HAVE_GCC_ATTRIBUTE_ALIGNED,1,
982      [Defined if a GCC style "__attribute__ ((aligned (n))" is supported])
983 fi
984
985
986 #
987 # Check whether the compiler supports the GCC style packed attribute
988 #
989 AC_CACHE_CHECK([whether the GCC style packed attribute is supported],
990        [gcry_cv_gcc_attribute_packed],
991        [gcry_cv_gcc_attribute_packed=no
992         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
993           [[struct foolong_s { long b; } __attribute__ ((packed));
994             struct foo_s { char a; struct foolong_s b; }
995               __attribute__ ((packed));
996             enum bar {
997               FOO = 1 / (sizeof(struct foo_s) == (sizeof(char) + sizeof(long))),
998             };]])],
999           [gcry_cv_gcc_attribute_packed=yes])])
1000 if test "$gcry_cv_gcc_attribute_packed" = "yes" ; then
1001    AC_DEFINE(HAVE_GCC_ATTRIBUTE_PACKED,1,
1002      [Defined if a GCC style "__attribute__ ((packed))" is supported])
1003 fi
1004
1005
1006 #
1007 # Check whether the compiler supports the GCC style may_alias attribute
1008 #
1009 AC_CACHE_CHECK([whether the GCC style may_alias attribute is supported],
1010        [gcry_cv_gcc_attribute_may_alias],
1011        [gcry_cv_gcc_attribute_may_alias=no
1012         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1013           [[typedef struct foo_s { int a; }
1014             __attribute__ ((may_alias)) foo_t;]])],
1015           [gcry_cv_gcc_attribute_may_alias=yes])])
1016 if test "$gcry_cv_gcc_attribute_may_alias" = "yes" ; then
1017    AC_DEFINE(HAVE_GCC_ATTRIBUTE_MAY_ALIAS,1,
1018      [Defined if a GCC style "__attribute__ ((may_alias))" is supported])
1019 fi
1020
1021
1022 # Restore flags.
1023 CFLAGS=$_gcc_cflags_save;
1024
1025
1026 #
1027 # Check whether the compiler supports 'asm' or '__asm__' keyword for
1028 # assembler blocks.
1029 #
1030 AC_CACHE_CHECK([whether 'asm' assembler keyword is supported],
1031        [gcry_cv_have_asm],
1032        [gcry_cv_have_asm=no
1033         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1034           [[void a(void) { asm("":::"memory"); }]])],
1035           [gcry_cv_have_asm=yes])])
1036 AC_CACHE_CHECK([whether '__asm__' assembler keyword is supported],
1037        [gcry_cv_have___asm__],
1038        [gcry_cv_have___asm__=no
1039         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1040           [[void a(void) { __asm__("":::"memory"); }]])],
1041           [gcry_cv_have___asm__=yes])])
1042 if test "$gcry_cv_have_asm" = "no" ; then
1043    if test "$gcry_cv_have___asm__" = "yes" ; then
1044       AC_DEFINE(asm,__asm__,
1045         [Define to supported assembler block keyword, if plain 'asm' was not
1046          supported])
1047    fi
1048 fi
1049
1050
1051 #
1052 # Check whether the compiler supports inline assembly memory barrier.
1053 #
1054 if test "$gcry_cv_have_asm" = "no" ; then
1055    if test "$gcry_cv_have___asm__" = "yes" ; then
1056       AC_CACHE_CHECK([whether inline assembly memory barrier is supported],
1057           [gcry_cv_have_asm_volatile_memory],
1058           [gcry_cv_have_asm_volatile_memory=no
1059            AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1060              [[void a(void) { __asm__ volatile("":::"memory"); }]])],
1061              [gcry_cv_have_asm_volatile_memory=yes])])
1062    fi
1063 else
1064    AC_CACHE_CHECK([whether inline assembly memory barrier is supported],
1065        [gcry_cv_have_asm_volatile_memory],
1066        [gcry_cv_have_asm_volatile_memory=no
1067         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1068           [[void a(void) { asm volatile("":::"memory"); }]])],
1069           [gcry_cv_have_asm_volatile_memory=yes])])
1070 fi
1071 if test "$gcry_cv_have_asm_volatile_memory" = "yes" ; then
1072    AC_DEFINE(HAVE_GCC_ASM_VOLATILE_MEMORY,1,
1073      [Define if inline asm memory barrier is supported])
1074 fi
1075
1076
1077 #
1078 # Check whether GCC assembler supports features needed for our ARM
1079 # implementations.  This needs to be done before setting up the
1080 # assembler stuff.
1081 #
1082 AC_CACHE_CHECK([whether GCC assembler is compatible for ARM assembly implementations],
1083        [gcry_cv_gcc_arm_platform_as_ok],
1084        [gcry_cv_gcc_arm_platform_as_ok=no
1085         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1086           [[__asm__(
1087                 /* Test if assembler supports UAL syntax.  */
1088                 ".syntax unified\n\t"
1089                 ".arm\n\t" /* our assembly code is in ARM mode  */
1090                 /* Following causes error if assembler ignored '.syntax unified'.  */
1091                 "asmfunc:\n\t"
1092                 "add %r0, %r0, %r4, ror #12;\n\t"
1093
1094                 /* Test if '.type' and '.size' are supported.  */
1095                 ".size asmfunc,.-asmfunc;\n\t"
1096                 ".type asmfunc,%function;\n\t"
1097             );]])],
1098           [gcry_cv_gcc_arm_platform_as_ok=yes])])
1099 if test "$gcry_cv_gcc_arm_platform_as_ok" = "yes" ; then
1100    AC_DEFINE(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS,1,
1101      [Defined if underlying assembler is compatible with ARM assembly implementations])
1102 fi
1103
1104
1105 #
1106 # Check whether GCC assembler supports features needed for our ARMv8/Aarch64
1107 # implementations.  This needs to be done before setting up the
1108 # assembler stuff.
1109 #
1110 AC_CACHE_CHECK([whether GCC assembler is compatible for ARMv8/Aarch64 assembly implementations],
1111        [gcry_cv_gcc_aarch64_platform_as_ok],
1112        [gcry_cv_gcc_aarch64_platform_as_ok=no
1113         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1114           [[__asm__(
1115                 "asmfunc:\n\t"
1116                 "eor x0, x0, x30, ror #12;\n\t"
1117                 "add x0, x0, x30, asr #12;\n\t"
1118                 "eor v0.16b, v0.16b, v31.16b;\n\t"
1119
1120                 /* Test if '.type' and '.size' are supported.  */
1121                 ".size asmfunc,.-asmfunc;\n\t"
1122                 ".type asmfunc,@function;\n\t"
1123             );]])],
1124           [gcry_cv_gcc_aarch64_platform_as_ok=yes])])
1125 if test "$gcry_cv_gcc_aarch64_platform_as_ok" = "yes" ; then
1126    AC_DEFINE(HAVE_COMPATIBLE_GCC_AARCH64_PLATFORM_AS,1,
1127      [Defined if underlying assembler is compatible with ARMv8/Aarch64 assembly implementations])
1128 fi
1129
1130
1131 #
1132 # Check whether underscores in symbols are required.  This needs to be
1133 # done before setting up the assembler stuff.
1134 #
1135 GNUPG_SYS_SYMBOL_UNDERSCORE()
1136
1137
1138 #################################
1139 ####                         ####
1140 #### Setup assembler stuff.  ####
1141 #### Define mpi_cpu_arch.    ####
1142 ####                         ####
1143 #################################
1144 AC_ARG_ENABLE(mpi-path,
1145               AC_HELP_STRING([--enable-mpi-path=EXTRA_PATH],
1146               [prepend EXTRA_PATH to list of CPU specific optimizations]),
1147               mpi_extra_path="$enableval",mpi_extra_path="")
1148 AC_MSG_CHECKING(architecture and mpi assembler functions)
1149 if test -f $srcdir/mpi/config.links ; then
1150     . $srcdir/mpi/config.links
1151     AC_CONFIG_LINKS("$mpi_ln_list")
1152     ac_cv_mpi_sflags="$mpi_sflags"
1153     AC_MSG_RESULT($mpi_cpu_arch)
1154 else
1155     AC_MSG_RESULT(failed)
1156     AC_MSG_ERROR([mpi/config.links missing!])
1157 fi
1158 MPI_SFLAGS="$ac_cv_mpi_sflags"
1159 AC_SUBST(MPI_SFLAGS)
1160
1161 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_ADD1, test "$mpi_mod_asm_mpih_add1" = yes)
1162 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_SUB1, test "$mpi_mod_asm_mpih_sub1" = yes)
1163 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL1, test "$mpi_mod_asm_mpih_mul1" = yes)
1164 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL2, test "$mpi_mod_asm_mpih_mul2" = yes)
1165 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL3, test "$mpi_mod_asm_mpih_mul3" = yes)
1166 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_LSHIFT, test "$mpi_mod_asm_mpih_lshift" = yes)
1167 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_RSHIFT, test "$mpi_mod_asm_mpih_rshift" = yes)
1168 AM_CONDITIONAL(MPI_MOD_ASM_UDIV, test "$mpi_mod_asm_udiv" = yes)
1169 AM_CONDITIONAL(MPI_MOD_ASM_UDIV_QRNND, test "$mpi_mod_asm_udiv_qrnnd" = yes)
1170 AM_CONDITIONAL(MPI_MOD_C_MPIH_ADD1, test "$mpi_mod_c_mpih_add1" = yes)
1171 AM_CONDITIONAL(MPI_MOD_C_MPIH_SUB1, test "$mpi_mod_c_mpih_sub1" = yes)
1172 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL1, test "$mpi_mod_c_mpih_mul1" = yes)
1173 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL2, test "$mpi_mod_c_mpih_mul2" = yes)
1174 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL3, test "$mpi_mod_c_mpih_mul3" = yes)
1175 AM_CONDITIONAL(MPI_MOD_C_MPIH_LSHIFT, test "$mpi_mod_c_mpih_lshift" = yes)
1176 AM_CONDITIONAL(MPI_MOD_C_MPIH_RSHIFT, test "$mpi_mod_c_mpih_rshift" = yes)
1177 AM_CONDITIONAL(MPI_MOD_C_UDIV, test "$mpi_mod_c_udiv" = yes)
1178 AM_CONDITIONAL(MPI_MOD_C_UDIV_QRNND, test "$mpi_mod_c_udiv_qrnnd" = yes)
1179
1180 # Reset non applicable feature flags.
1181 if test "$mpi_cpu_arch" != "x86" ; then
1182    aesnisupport="n/a"
1183    pclmulsupport="n/a"
1184    sse41support="n/a"
1185    avxsupport="n/a"
1186    avx2support="n/a"
1187    padlocksupport="n/a"
1188    drngsupport="n/a"
1189 fi
1190
1191 if test "$mpi_cpu_arch" != "arm" ; then
1192    if test "$mpi_cpu_arch" != "aarch64" ; then
1193      neonsupport="n/a"
1194      armcryptosupport="n/a"
1195    fi
1196 fi
1197
1198
1199 #############################################
1200 ####                                     ####
1201 #### Platform specific compiler checks.  ####
1202 ####                                     ####
1203 #############################################
1204
1205
1206 # Following tests depend on warnings to cause compile to fail, so set -Werror
1207 # temporarily.
1208 _gcc_cflags_save=$CFLAGS
1209 CFLAGS="$CFLAGS -Werror"
1210
1211
1212 #
1213 # Check whether compiler supports 'ms_abi' function attribute.
1214 #
1215 AC_CACHE_CHECK([whether compiler supports 'ms_abi' function attribute],
1216        [gcry_cv_gcc_attribute_ms_abi],
1217        [gcry_cv_gcc_attribute_ms_abi=no
1218         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1219           [[int __attribute__ ((ms_abi)) proto(int);]])],
1220           [gcry_cv_gcc_attribute_ms_abi=yes])])
1221 if test "$gcry_cv_gcc_attribute_ms_abi" = "yes" ; then
1222    AC_DEFINE(HAVE_GCC_ATTRIBUTE_MS_ABI,1,
1223      [Defined if compiler supports "__attribute__ ((ms_abi))" function attribute])
1224 fi
1225
1226
1227 #
1228 # Check whether compiler supports 'sysv_abi' function attribute.
1229 #
1230 AC_CACHE_CHECK([whether compiler supports 'sysv_abi' function attribute],
1231        [gcry_cv_gcc_attribute_sysv_abi],
1232        [gcry_cv_gcc_attribute_sysv_abi=no
1233         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1234           [[int __attribute__ ((sysv_abi)) proto(int);]])],
1235           [gcry_cv_gcc_attribute_sysv_abi=yes])])
1236 if test "$gcry_cv_gcc_attribute_sysv_abi" = "yes" ; then
1237    AC_DEFINE(HAVE_GCC_ATTRIBUTE_SYSV_ABI,1,
1238      [Defined if compiler supports "__attribute__ ((sysv_abi))" function attribute])
1239 fi
1240
1241
1242 #
1243 # Check whether default calling convention is 'ms_abi'.
1244 #
1245 if test "$gcry_cv_gcc_attribute_ms_abi" = "yes" ; then
1246    AC_CACHE_CHECK([whether default calling convention is 'ms_abi'],
1247           [gcry_cv_gcc_default_abi_is_ms_abi],
1248           [gcry_cv_gcc_default_abi_is_ms_abi=no
1249            AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1250              [[void *test(void) {
1251                  void *(*def_func)(void) = test;
1252                  void *__attribute__((ms_abi))(*msabi_func)(void);
1253                  /* warning on SysV abi targets, passes on Windows based targets */
1254                  msabi_func = def_func;
1255                  return msabi_func;
1256              }]])],
1257              [gcry_cv_gcc_default_abi_is_ms_abi=yes])])
1258    if test "$gcry_cv_gcc_default_abi_is_ms_abi" = "yes" ; then
1259       AC_DEFINE(HAVE_GCC_DEFAULT_ABI_IS_MS_ABI,1,
1260         [Defined if default calling convention is 'ms_abi'])
1261    fi
1262 fi
1263
1264
1265 #
1266 # Check whether default calling convention is 'sysv_abi'.
1267 #
1268 if test "$gcry_cv_gcc_attribute_sysv_abi" = "yes" ; then
1269    AC_CACHE_CHECK([whether default calling convention is 'sysv_abi'],
1270           [gcry_cv_gcc_default_abi_is_sysv_abi],
1271           [gcry_cv_gcc_default_abi_is_sysv_abi=no
1272            AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1273              [[void *test(void) {
1274                  void *(*def_func)(void) = test;
1275                  void *__attribute__((sysv_abi))(*sysvabi_func)(void);
1276                  /* warning on MS ABI targets, passes on SysV ABI targets */
1277                  sysvabi_func = def_func;
1278                  return sysvabi_func;
1279              }]])],
1280              [gcry_cv_gcc_default_abi_is_sysv_abi=yes])])
1281    if test "$gcry_cv_gcc_default_abi_is_sysv_abi" = "yes" ; then
1282       AC_DEFINE(HAVE_GCC_DEFAULT_ABI_IS_SYSV_ABI,1,
1283         [Defined if default calling convention is 'sysv_abi'])
1284    fi
1285 fi
1286
1287
1288 # Restore flags.
1289 CFLAGS=$_gcc_cflags_save;
1290
1291
1292 #
1293 # Check whether GCC inline assembler supports SSSE3 instructions
1294 # This is required for the AES-NI instructions.
1295 #
1296 AC_CACHE_CHECK([whether GCC inline assembler supports SSSE3 instructions],
1297        [gcry_cv_gcc_inline_asm_ssse3],
1298        [if test "$mpi_cpu_arch" != "x86" ; then
1299           gcry_cv_gcc_inline_asm_ssse3="n/a"
1300         else
1301           gcry_cv_gcc_inline_asm_ssse3=no
1302           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1303           [[static unsigned char be_mask[16] __attribute__ ((aligned (16))) =
1304               { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
1305             void a(void) {
1306               __asm__("pshufb %[mask], %%xmm2\n\t"::[mask]"m"(*be_mask):);
1307             }]])],
1308           [gcry_cv_gcc_inline_asm_ssse3=yes])
1309         fi])
1310 if test "$gcry_cv_gcc_inline_asm_ssse3" = "yes" ; then
1311    AC_DEFINE(HAVE_GCC_INLINE_ASM_SSSE3,1,
1312      [Defined if inline assembler supports SSSE3 instructions])
1313 fi
1314
1315
1316 #
1317 # Check whether GCC inline assembler supports PCLMUL instructions.
1318 #
1319 AC_CACHE_CHECK([whether GCC inline assembler supports PCLMUL instructions],
1320        [gcry_cv_gcc_inline_asm_pclmul],
1321        [if test "$mpi_cpu_arch" != "x86" ; then
1322           gcry_cv_gcc_inline_asm_pclmul="n/a"
1323         else
1324           gcry_cv_gcc_inline_asm_pclmul=no
1325           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1326           [[void a(void) {
1327               __asm__("pclmulqdq \$0, %%xmm1, %%xmm3\n\t":::"cc");
1328             }]])],
1329           [gcry_cv_gcc_inline_asm_pclmul=yes])
1330         fi])
1331 if test "$gcry_cv_gcc_inline_asm_pclmul" = "yes" ; then
1332    AC_DEFINE(HAVE_GCC_INLINE_ASM_PCLMUL,1,
1333      [Defined if inline assembler supports PCLMUL instructions])
1334 fi
1335
1336 #
1337 # Check whether GCC inline assembler supports SSE4.1 instructions.
1338 #
1339 AC_CACHE_CHECK([whether GCC inline assembler supports SSE4.1 instructions],
1340        [gcry_cv_gcc_inline_asm_sse41],
1341        [if test "$mpi_cpu_arch" != "x86" ; then
1342           gcry_cv_gcc_inline_asm_sse41="n/a"
1343         else
1344           gcry_cv_gcc_inline_asm_sse41=no
1345           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1346           [[void a(void) {
1347               int i;
1348               __asm__("pextrd \$2, %%xmm0, %[out]\n\t" : [out] "=m" (i));
1349             }]])],
1350           [gcry_cv_gcc_inline_asm_sse41=yes])
1351         fi])
1352 if test "$gcry_cv_gcc_inline_asm_sse41" = "yes" ; then
1353    AC_DEFINE(HAVE_GCC_INLINE_ASM_SSE41,1,
1354      [Defined if inline assembler supports SSE4.1 instructions])
1355 fi
1356
1357
1358 #
1359 # Check whether GCC inline assembler supports AVX instructions
1360 #
1361 AC_CACHE_CHECK([whether GCC inline assembler supports AVX instructions],
1362        [gcry_cv_gcc_inline_asm_avx],
1363        [if test "$mpi_cpu_arch" != "x86" ; then
1364           gcry_cv_gcc_inline_asm_avx="n/a"
1365         else
1366           gcry_cv_gcc_inline_asm_avx=no
1367           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1368           [[void a(void) {
1369               __asm__("xgetbv; vaesdeclast (%[mem]),%%xmm0,%%xmm7\n\t"::[mem]"r"(0):);
1370             }]])],
1371           [gcry_cv_gcc_inline_asm_avx=yes])
1372         fi])
1373 if test "$gcry_cv_gcc_inline_asm_avx" = "yes" ; then
1374    AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX,1,
1375      [Defined if inline assembler supports AVX instructions])
1376 fi
1377
1378
1379 #
1380 # Check whether GCC inline assembler supports AVX2 instructions
1381 #
1382 AC_CACHE_CHECK([whether GCC inline assembler supports AVX2 instructions],
1383        [gcry_cv_gcc_inline_asm_avx2],
1384        [if test "$mpi_cpu_arch" != "x86" ; then
1385           gcry_cv_gcc_inline_asm_avx2="n/a"
1386         else
1387           gcry_cv_gcc_inline_asm_avx2=no
1388           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1389           [[void a(void) {
1390               __asm__("xgetbv; vpbroadcastb %%xmm7,%%ymm1\n\t":::"cc");
1391             }]])],
1392           [gcry_cv_gcc_inline_asm_avx2=yes])
1393         fi])
1394 if test "$gcry_cv_gcc_inline_asm_avx2" = "yes" ; then
1395    AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX2,1,
1396      [Defined if inline assembler supports AVX2 instructions])
1397 fi
1398
1399
1400 #
1401 # Check whether GCC inline assembler supports BMI2 instructions
1402 #
1403 AC_CACHE_CHECK([whether GCC inline assembler supports BMI2 instructions],
1404        [gcry_cv_gcc_inline_asm_bmi2],
1405        [if test "$mpi_cpu_arch" != "x86" ; then
1406           gcry_cv_gcc_inline_asm_bmi2="n/a"
1407         else
1408           gcry_cv_gcc_inline_asm_bmi2=no
1409           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1410           [[void a(void) {
1411               __asm__("rorxl \$23, %%eax, %%edx\\n\\t":::"memory");
1412             }]])],
1413           [gcry_cv_gcc_inline_asm_bmi2=yes])
1414         fi])
1415 if test "$gcry_cv_gcc_inline_asm_bmi2" = "yes" ; then
1416    AC_DEFINE(HAVE_GCC_INLINE_ASM_BMI2,1,
1417      [Defined if inline assembler supports BMI2 instructions])
1418 fi
1419
1420
1421 #
1422 # Check whether GCC assembler needs "-Wa,--divide" to correctly handle
1423 # constant division
1424 #
1425 if test $amd64_as_feature_detection = yes; then
1426   AC_CACHE_CHECK([whether GCC assembler handles division correctly],
1427        [gcry_cv_gcc_as_const_division_ok],
1428        [gcry_cv_gcc_as_const_division_ok=no
1429         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1430           [[__asm__("xorl \$(123456789/12345678), %ebp;\n\t");]])],
1431           [gcry_cv_gcc_as_const_division_ok=yes])])
1432   if test "$gcry_cv_gcc_as_const_division_ok" = "no" ; then
1433     #
1434     # Add '-Wa,--divide' to CPPFLAGS and try check again.
1435     #
1436     _gcc_cppflags_save="$CPPFLAGS"
1437     CPPFLAGS="$CPPFLAGS -Wa,--divide"
1438     AC_CACHE_CHECK([whether GCC assembler handles division correctly with "-Wa,--divide"],
1439          [gcry_cv_gcc_as_const_division_with_wadivide_ok],
1440          [gcry_cv_gcc_as_const_division_with_wadivide_ok=no
1441           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1442             [[__asm__("xorl \$(123456789/12345678), %ebp;\n\t");]])],
1443             [gcry_cv_gcc_as_const_division_with_wadivide_ok=yes])])
1444     if test "$gcry_cv_gcc_as_const_division_with_wadivide_ok" = "no" ; then
1445       # '-Wa,--divide' did not work, restore old flags.
1446       CPPFLAGS="$_gcc_cppflags_save"
1447     fi
1448   fi
1449 fi
1450
1451
1452 #
1453 # Check whether GCC assembler supports features needed for our amd64
1454 # implementations
1455 #
1456 if test $amd64_as_feature_detection = yes; then
1457   AC_CACHE_CHECK([whether GCC assembler is compatible for amd64 assembly implementations],
1458        [gcry_cv_gcc_amd64_platform_as_ok],
1459        [if test "$mpi_cpu_arch" != "x86" ; then
1460           gcry_cv_gcc_amd64_platform_as_ok="n/a"
1461         else
1462           gcry_cv_gcc_amd64_platform_as_ok=no
1463           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1464           [[__asm__(
1465                 /* Test if '.type' and '.size' are supported.  */
1466                 /* These work only on ELF targets. */
1467                 "asmfunc:\n\t"
1468                 ".size asmfunc,.-asmfunc;\n\t"
1469                 ".type asmfunc,@function;\n\t"
1470                 /* Test if assembler allows use of '/' for constant division
1471                  * (Solaris/x86 issue). If previous constant division check
1472                  * and "-Wa,--divide" workaround failed, this causes assembly
1473                  * to be disable on this machine. */
1474                 "xorl \$(123456789/12345678), %ebp;\n\t"
1475             );]])],
1476           [gcry_cv_gcc_amd64_platform_as_ok=yes])
1477         fi])
1478   if test "$gcry_cv_gcc_amd64_platform_as_ok" = "yes" ; then
1479      AC_DEFINE(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS,1,
1480               [Defined if underlying assembler is compatible with amd64 assembly implementations])
1481   fi
1482   if test "$gcry_cv_gcc_amd64_platform_as_ok" = "no" &&
1483      test "$gcry_cv_gcc_attribute_sysv_abi" = "yes" &&
1484      test "$gcry_cv_gcc_default_abi_is_ms_abi" = "yes"; then
1485     AC_CACHE_CHECK([whether GCC assembler is compatible for WIN64 assembly implementations],
1486       [gcry_cv_gcc_win64_platform_as_ok],
1487       [gcry_cv_gcc_win64_platform_as_ok=no
1488       AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1489         [[__asm__(
1490               ".globl asmfunc\n\t"
1491               "asmfunc:\n\t"
1492               "xorq \$(1234), %rbp;\n\t"
1493           );]])],
1494         [gcry_cv_gcc_win64_platform_as_ok=yes])])
1495     if test "$gcry_cv_gcc_win64_platform_as_ok" = "yes" ; then
1496       AC_DEFINE(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS,1,
1497                 [Defined if underlying assembler is compatible with WIN64 assembly implementations])
1498     fi
1499   fi
1500 fi
1501
1502
1503 #
1504 # Check whether GCC assembler supports features needed for assembly
1505 # implementations that use Intel syntax
1506 #
1507 AC_CACHE_CHECK([whether GCC assembler is compatible for Intel syntax assembly implementations],
1508        [gcry_cv_gcc_platform_as_ok_for_intel_syntax],
1509        [if test "$mpi_cpu_arch" != "x86" ; then
1510           gcry_cv_gcc_platform_as_ok_for_intel_syntax="n/a"
1511         else
1512           gcry_cv_gcc_platform_as_ok_for_intel_syntax=no
1513           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1514           [[__asm__(
1515                 ".intel_syntax noprefix\n\t"
1516                 "pxor xmm1, xmm7;\n\t"
1517                 /* Intel syntax implementation also use GAS macros, so check
1518                  * for them here. */
1519                 "VAL_A = xmm4\n\t"
1520                 "VAL_B = xmm2\n\t"
1521                 ".macro SET_VAL_A p1\n\t"
1522                 "  VAL_A = \\\\p1 \n\t"
1523                 ".endm\n\t"
1524                 ".macro SET_VAL_B p1\n\t"
1525                 "  VAL_B = \\\\p1 \n\t"
1526                 ".endm\n\t"
1527                 "vmovdqa VAL_A, VAL_B;\n\t"
1528                 "SET_VAL_A eax\n\t"
1529                 "SET_VAL_B ebp\n\t"
1530                 "add VAL_A, VAL_B;\n\t"
1531                 "add VAL_B, 0b10101;\n\t"
1532             );]])],
1533           [gcry_cv_gcc_platform_as_ok_for_intel_syntax=yes])
1534         fi])
1535 if test "$gcry_cv_gcc_platform_as_ok_for_intel_syntax" = "yes" ; then
1536   AC_DEFINE(HAVE_INTEL_SYNTAX_PLATFORM_AS,1,
1537             [Defined if underlying assembler is compatible with Intel syntax assembly implementations])
1538 fi
1539
1540
1541 #
1542 # Check whether compiler is configured for ARMv6 or newer architecture
1543 #
1544 AC_CACHE_CHECK([whether compiler is configured for ARMv6 or newer architecture],
1545        [gcry_cv_cc_arm_arch_is_v6],
1546        [if test "$mpi_cpu_arch" != "arm" ; then
1547           gcry_cv_cc_arm_arch_is_v6="n/a"
1548         else
1549           gcry_cv_cc_arm_arch_is_v6=no
1550           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1551           [[
1552            #if defined(__arm__) && \
1553              ((defined(__ARM_ARCH) && __ARM_ARCH >= 6) \
1554              || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
1555              || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \
1556              || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) \
1557              || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
1558              || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
1559              || defined(__ARM_ARCH_7EM__))
1560              /* empty */
1561            #else
1562              /* fail compile if not ARMv6. */
1563              not_armv6 not_armv6 = (not_armv6)not_armv6;
1564            #endif
1565           ]])],
1566           [gcry_cv_cc_arm_arch_is_v6=yes])
1567         fi])
1568 if test "$gcry_cv_cc_arm_arch_is_v6" = "yes" ; then
1569    AC_DEFINE(HAVE_ARM_ARCH_V6,1,
1570      [Defined if ARM architecture is v6 or newer])
1571 fi
1572
1573
1574 #
1575 # Check whether GCC inline assembler supports NEON instructions
1576 #
1577 AC_CACHE_CHECK([whether GCC inline assembler supports NEON instructions],
1578        [gcry_cv_gcc_inline_asm_neon],
1579        [if test "$mpi_cpu_arch" != "arm" ; then
1580           gcry_cv_gcc_inline_asm_neon="n/a"
1581         else
1582           gcry_cv_gcc_inline_asm_neon=no
1583           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1584           [[__asm__(
1585                 ".syntax unified\n\t"
1586                 ".arm\n\t"
1587                 ".fpu neon\n\t"
1588                 "vld1.64 {%q0-%q1}, [%r0]!;\n\t"
1589                 "vrev64.8 %q0, %q3;\n\t"
1590                 "vadd.u64 %q0, %q1;\n\t"
1591                 "vadd.s64 %d3, %d2, %d3;\n\t"
1592                 );
1593             ]])],
1594           [gcry_cv_gcc_inline_asm_neon=yes])
1595         fi])
1596 if test "$gcry_cv_gcc_inline_asm_neon" = "yes" ; then
1597    AC_DEFINE(HAVE_GCC_INLINE_ASM_NEON,1,
1598      [Defined if inline assembler supports NEON instructions])
1599 fi
1600
1601
1602 #
1603 # Check whether GCC inline assembler supports AArch32 Crypto Extension instructions
1604 #
1605 AC_CACHE_CHECK([whether GCC inline assembler supports AArch32 Crypto Extension instructions],
1606        [gcry_cv_gcc_inline_asm_aarch32_crypto],
1607        [if test "$mpi_cpu_arch" != "arm" ; then
1608           gcry_cv_gcc_inline_asm_aarch32_crypto="n/a"
1609         else
1610           gcry_cv_gcc_inline_asm_aarch32_crypto=no
1611           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1612           [[__asm__(
1613                 ".syntax unified\n\t"
1614                 ".arm\n\t"
1615                 ".fpu crypto-neon-fp-armv8\n\t"
1616
1617                 "sha1h.32 q0, q0;\n\t"
1618                 "sha1c.32 q0, q0, q0;\n\t"
1619                 "sha1p.32 q0, q0, q0;\n\t"
1620                 "sha1su0.32 q0, q0, q0;\n\t"
1621                 "sha1su1.32 q0, q0;\n\t"
1622
1623                 "sha256h.32 q0, q0, q0;\n\t"
1624                 "sha256h2.32 q0, q0, q0;\n\t"
1625                 "sha1p.32 q0, q0, q0;\n\t"
1626                 "sha256su0.32 q0, q0;\n\t"
1627                 "sha256su1.32 q0, q0, q15;\n\t"
1628
1629                 "aese.8 q0, q0;\n\t"
1630                 "aesd.8 q0, q0;\n\t"
1631                 "aesmc.8 q0, q0;\n\t"
1632                 "aesimc.8 q0, q0;\n\t"
1633
1634                 "vmull.p64 q0, d0, d0;\n\t"
1635                 );
1636             ]])],
1637           [gcry_cv_gcc_inline_asm_aarch32_crypto=yes])
1638         fi])
1639 if test "$gcry_cv_gcc_inline_asm_aarch32_crypto" = "yes" ; then
1640    AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH32_CRYPTO,1,
1641      [Defined if inline assembler supports AArch32 Crypto Extension instructions])
1642 fi
1643
1644
1645 #
1646 # Check whether GCC inline assembler supports AArch64 NEON instructions
1647 #
1648 AC_CACHE_CHECK([whether GCC inline assembler supports AArch64 NEON instructions],
1649        [gcry_cv_gcc_inline_asm_aarch64_neon],
1650        [if test "$mpi_cpu_arch" != "aarch64" ; then
1651           gcry_cv_gcc_inline_asm_aarch64_neon="n/a"
1652         else
1653           gcry_cv_gcc_inline_asm_aarch64_neon=no
1654           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1655           [[__asm__(
1656                 ".cpu generic+simd\n\t"
1657                 "mov w0, \#42;\n\t"
1658                 "dup v0.8b, w0;\n\t"
1659                 "ld4 {v0.8b,v1.8b,v2.8b,v3.8b},[x0],\#32;\n\t"
1660                 );
1661             ]])],
1662           [gcry_cv_gcc_inline_asm_aarch64_neon=yes])
1663         fi])
1664 if test "$gcry_cv_gcc_inline_asm_aarch64_neon" = "yes" ; then
1665    AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH64_NEON,1,
1666      [Defined if inline assembler supports AArch64 NEON instructions])
1667 fi
1668
1669
1670 #
1671 # Check whether GCC inline assembler supports AArch64 Crypto Extension instructions
1672 #
1673 AC_CACHE_CHECK([whether GCC inline assembler supports AArch64 Crypto Extension instructions],
1674        [gcry_cv_gcc_inline_asm_aarch64_crypto],
1675        [if test "$mpi_cpu_arch" != "aarch64" ; then
1676           gcry_cv_gcc_inline_asm_aarch64_crypto="n/a"
1677         else
1678           gcry_cv_gcc_inline_asm_aarch64_crypto=no
1679           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1680           [[__asm__(
1681                 ".cpu generic+simd+crypto\n\t"
1682
1683                 "mov w0, \#42;\n\t"
1684                 "dup v0.8b, w0;\n\t"
1685                 "ld4 {v0.8b,v1.8b,v2.8b,v3.8b},[x0],\#32;\n\t"
1686
1687                 "sha1h s0, s0;\n\t"
1688                 "sha1c q0, s0, v0.4s;\n\t"
1689                 "sha1p q0, s0, v0.4s;\n\t"
1690                 "sha1su0 v0.4s, v0.4s, v0.4s;\n\t"
1691                 "sha1su1 v0.4s, v0.4s;\n\t"
1692
1693                 "sha256h q0, q0, v0.4s;\n\t"
1694                 "sha256h2 q0, q0, v0.4s;\n\t"
1695                 "sha1p q0, s0, v0.4s;\n\t"
1696                 "sha256su0 v0.4s, v0.4s;\n\t"
1697                 "sha256su1 v0.4s, v0.4s, v31.4s;\n\t"
1698
1699                 "aese v0.16b, v0.16b;\n\t"
1700                 "aesd v0.16b, v0.16b;\n\t"
1701                 "aesmc v0.16b, v0.16b;\n\t"
1702                 "aesimc v0.16b, v0.16b;\n\t"
1703
1704                 "pmull v0.1q, v0.1d, v31.1d;\n\t"
1705                 "pmull2 v0.1q, v0.2d, v31.2d;\n\t"
1706                 );
1707             ]])],
1708           [gcry_cv_gcc_inline_asm_aarch64_crypto=yes])
1709         fi])
1710 if test "$gcry_cv_gcc_inline_asm_aarch64_crypto" = "yes" ; then
1711    AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH64_CRYPTO,1,
1712      [Defined if inline assembler supports AArch64 Crypto Extension instructions])
1713 fi
1714
1715
1716 #######################################
1717 #### Checks for library functions. ####
1718 #######################################
1719
1720 AC_FUNC_VPRINTF
1721 # We have replacements for these in src/missing-string.c
1722 AC_CHECK_FUNCS(stpcpy strcasecmp)
1723 # We have replacements for these in src/g10lib.h
1724 AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise)
1725 # Other checks
1726 AC_CHECK_FUNCS(strerror rand mmap getpagesize sysconf waitpid wait4)
1727 AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime syslog)
1728 AC_CHECK_FUNCS(syscall fcntl ftruncate flockfile)
1729
1730 GNUPG_CHECK_MLOCK
1731
1732 #
1733 # Replacement functions.
1734 #
1735 AC_REPLACE_FUNCS([getpid clock])
1736
1737
1738 #
1739 # Check wether it is necessary to link against libdl.
1740 #
1741 DL_LIBS=""
1742 if test "$use_hmac_binary_check" = yes ; then
1743   _gcry_save_libs="$LIBS"
1744   LIBS=""
1745   AC_SEARCH_LIBS(dlopen, c dl,,,)
1746   DL_LIBS=$LIBS
1747   LIBS="$_gcry_save_libs"
1748   LIBGCRYPT_CONFIG_LIBS="${LIBGCRYPT_CONFIG_LIBS} ${DL_LIBS}"
1749 fi
1750 AC_SUBST(DL_LIBS)
1751
1752
1753 #
1754 # Check whether we can use Linux capabilities as requested.
1755 #
1756 if test "$use_capabilities" = "yes" ; then
1757 use_capabilities=no
1758 AC_CHECK_HEADERS(sys/capability.h)
1759 if test "$ac_cv_header_sys_capability_h" = "yes" ; then
1760   AC_CHECK_LIB(cap, cap_init, ac_need_libcap=1)
1761   if test "$ac_cv_lib_cap_cap_init" = "yes"; then
1762      AC_DEFINE(USE_CAPABILITIES,1,
1763                [define if capabilities should be used])
1764      LIBS="$LIBS -lcap"
1765      use_capabilities=yes
1766   fi
1767 fi
1768 if test "$use_capabilities" = "no" ; then
1769     AC_MSG_WARN([[
1770 ***
1771 *** The use of capabilities on this system is not possible.
1772 *** You need a recent Linux kernel and some patches:
1773 ***   fcaps-2.2.9-990610.patch      (kernel patch for 2.2.9)
1774 ***   fcap-module-990613.tar.gz     (kernel module)
1775 ***   libcap-1.92.tar.gz            (user mode library and utilities)
1776 *** And you have to configure the kernel with CONFIG_VFS_CAP_PLUGIN
1777 *** set (filesystems menu). Be warned: This code is *really* ALPHA.
1778 ***]])
1779 fi
1780 fi
1781
1782 # Check whether a random device is available.
1783 if test "$try_dev_random" = yes ; then
1784     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
1785     [if test -r "$NAME_OF_DEV_RANDOM" && test -r "$NAME_OF_DEV_URANDOM" ; then
1786       ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
1787     if test "$ac_cv_have_dev_random" = yes; then
1788         AC_DEFINE(HAVE_DEV_RANDOM,1,
1789                  [defined if the system supports a random device] )
1790     fi
1791 else
1792     AC_MSG_CHECKING(for random device)
1793     ac_cv_have_dev_random=no
1794     AC_MSG_RESULT(has been disabled)
1795 fi
1796
1797 # Figure out the random modules for this configuration.
1798 if test "$random" = "default"; then
1799
1800     # Select default value.
1801     if test "$ac_cv_have_dev_random" = yes; then
1802         # Try Linuxish random device.
1803         random_modules="linux"
1804     else
1805         case "${host}" in
1806         *-*-mingw32ce*)
1807           # WindowsCE random device.
1808           random_modules="w32ce"
1809           ;;
1810         *-*-mingw32*|*-*-cygwin*)
1811           # Windows random device.
1812           random_modules="w32"
1813           ;;
1814         *)
1815           # Build everything, allow to select at runtime.
1816           random_modules="$auto_random_modules"
1817           ;;
1818         esac
1819     fi
1820 else
1821     if test "$random" = "auto"; then
1822         # Build everything, allow to select at runtime.
1823         random_modules="$auto_random_modules"
1824     else
1825         random_modules="$random"
1826     fi
1827 fi
1828
1829
1830 #
1831 # Other defines
1832 #
1833 if test mym4_isgit = "yes"; then
1834     AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
1835               [Defined if this is not a regular release])
1836 fi
1837
1838
1839 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
1840
1841
1842 # This is handy for debugging so the compiler doesn't rearrange
1843 # things and eliminate variables.
1844 AC_ARG_ENABLE(optimization,
1845        AC_HELP_STRING([--disable-optimization],
1846                       [disable compiler optimization]),
1847                       [if test $enableval = no ; then
1848                          CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
1849                        fi])
1850
1851 # CFLAGS mangling when using gcc.
1852 if test "$GCC" = yes; then
1853     CFLAGS="$CFLAGS -Wall"
1854     if test "$USE_MAINTAINER_MODE" = "yes"; then
1855         CFLAGS="$CFLAGS -Wcast-align -Wshadow -Wstrict-prototypes"
1856         CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
1857
1858         # If -Wno-missing-field-initializers is supported we can enable a
1859         # a bunch of really useful warnings.
1860         AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
1861         _gcc_cflags_save=$CFLAGS
1862         CFLAGS="-Wno-missing-field-initializers"
1863         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
1864         AC_MSG_RESULT($_gcc_wopt)
1865         CFLAGS=$_gcc_cflags_save;
1866         if test x"$_gcc_wopt" = xyes ; then
1867           CFLAGS="$CFLAGS -W -Wextra -Wbad-function-cast"
1868           CFLAGS="$CFLAGS -Wwrite-strings"
1869           CFLAGS="$CFLAGS -Wdeclaration-after-statement"
1870           CFLAGS="$CFLAGS -Wno-missing-field-initializers"
1871           CFLAGS="$CFLAGS -Wno-sign-compare"
1872         fi
1873
1874         AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
1875         _gcc_cflags_save=$CFLAGS
1876         CFLAGS="-Wpointer-arith"
1877         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
1878         AC_MSG_RESULT($_gcc_wopt)
1879         CFLAGS=$_gcc_cflags_save;
1880         if test x"$_gcc_wopt" = xyes ; then
1881           CFLAGS="$CFLAGS -Wpointer-arith"
1882         fi
1883     fi
1884
1885 fi
1886
1887 # Check whether as(1) supports a noeexecstack feature.  This test
1888 # includes an override option.
1889 CL_AS_NOEXECSTACK
1890
1891
1892 AC_SUBST(LIBGCRYPT_CONFIG_API_VERSION)
1893 AC_SUBST(LIBGCRYPT_CONFIG_LIBS)
1894 AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS)
1895 AC_SUBST(LIBGCRYPT_CONFIG_HOST)
1896 AC_SUBST(LIBGCRYPT_THREAD_MODULES)
1897
1898 AC_CONFIG_COMMANDS([gcrypt-conf],[[
1899 chmod +x src/libgcrypt-config
1900 ]],[[
1901 prefix=$prefix
1902 exec_prefix=$exec_prefix
1903 libdir=$libdir
1904 datadir=$datadir
1905 DATADIRNAME=$DATADIRNAME
1906 ]])
1907
1908 #####################
1909 #### Conclusion. ####
1910 #####################
1911
1912 # Check that requested feature can actually be used and define
1913 # ENABLE_foo_SUPPORT macros.
1914
1915 if test x"$aesnisupport" = xyes ; then
1916   if test "$gcry_cv_gcc_inline_asm_ssse3" != "yes" ; then
1917     aesnisupport="no (unsupported by compiler)"
1918   fi
1919 fi
1920 if test x"$pclmulsupport" = xyes ; then
1921   if test "$gcry_cv_gcc_inline_asm_pclmul" != "yes" ; then
1922     pclmulsupport="no (unsupported by compiler)"
1923   fi
1924 fi
1925 if test x"$sse41support" = xyes ; then
1926   if test "$gcry_cv_gcc_inline_asm_sse41" != "yes" ; then
1927     sse41support="no (unsupported by compiler)"
1928   fi
1929 fi
1930 if test x"$avxsupport" = xyes ; then
1931   if test "$gcry_cv_gcc_inline_asm_avx" != "yes" ; then
1932     avxsupport="no (unsupported by compiler)"
1933   fi
1934 fi
1935 if test x"$avx2support" = xyes ; then
1936   if test "$gcry_cv_gcc_inline_asm_avx2" != "yes" ; then
1937     avx2support="no (unsupported by compiler)"
1938   fi
1939 fi
1940 if test x"$neonsupport" = xyes ; then
1941   if test "$gcry_cv_gcc_inline_asm_neon" != "yes" ; then
1942     if test "$gcry_cv_gcc_inline_asm_aarch64_neon" != "yes" ; then
1943       neonsupport="no (unsupported by compiler)"
1944     fi
1945   fi
1946 fi
1947 if test x"$armcryptosupport" = xyes ; then
1948   if test "$gcry_cv_gcc_inline_asm_aarch32_crypto" != "yes" ; then
1949     if test "$gcry_cv_gcc_inline_asm_aarch64_crypto" != "yes" ; then
1950       neonsupport="no (unsupported by compiler)"
1951     fi
1952   fi
1953 fi
1954
1955 if test x"$aesnisupport" = xyes ; then
1956   AC_DEFINE(ENABLE_AESNI_SUPPORT, 1,
1957             [Enable support for Intel AES-NI instructions.])
1958 fi
1959 if test x"$pclmulsupport" = xyes ; then
1960   AC_DEFINE(ENABLE_PCLMUL_SUPPORT, 1,
1961             [Enable support for Intel PCLMUL instructions.])
1962 fi
1963 if test x"$sse41support" = xyes ; then
1964   AC_DEFINE(ENABLE_SSE41_SUPPORT, 1,
1965             [Enable support for Intel SSE4.1 instructions.])
1966 fi
1967 if test x"$avxsupport" = xyes ; then
1968   AC_DEFINE(ENABLE_AVX_SUPPORT,1,
1969             [Enable support for Intel AVX instructions.])
1970 fi
1971 if test x"$avx2support" = xyes ; then
1972   AC_DEFINE(ENABLE_AVX2_SUPPORT,1,
1973             [Enable support for Intel AVX2 instructions.])
1974 fi
1975 if test x"$neonsupport" = xyes ; then
1976   AC_DEFINE(ENABLE_NEON_SUPPORT,1,
1977             [Enable support for ARM NEON instructions.])
1978 fi
1979 if test x"$armcryptosupport" = xyes ; then
1980   AC_DEFINE(ENABLE_ARM_CRYPTO_SUPPORT,1,
1981             [Enable support for ARMv8 Crypto Extension instructions.])
1982 fi
1983 if test x"$padlocksupport" = xyes ; then
1984   AC_DEFINE(ENABLE_PADLOCK_SUPPORT, 1,
1985             [Enable support for the PadLock engine.])
1986 fi
1987 if test x"$drngsupport" = xyes ; then
1988   AC_DEFINE(ENABLE_DRNG_SUPPORT, 1,
1989             [Enable support for Intel DRNG (RDRAND instruction).])
1990 fi
1991
1992
1993 # Define conditional sources and config.h symbols depending on the
1994 # selected ciphers, pubkey-ciphers, digests, kdfs, and random modules.
1995
1996 LIST_MEMBER(arcfour, $enabled_ciphers)
1997 if test "$found" = "1"; then
1998    GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour.lo"
1999    AC_DEFINE(USE_ARCFOUR, 1, [Defined if this module should be included])
2000
2001    case "${host}" in
2002       x86_64-*-*)
2003          # Build with the assembly implementation
2004          GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour-amd64.lo"
2005       ;;
2006    esac
2007 fi
2008
2009 LIST_MEMBER(blowfish, $enabled_ciphers)
2010 if test "$found" = "1" ; then
2011    GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish.lo"
2012    AC_DEFINE(USE_BLOWFISH, 1, [Defined if this module should be included])
2013
2014    case "${host}" in
2015       x86_64-*-*)
2016          # Build with the assembly implementation
2017          GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish-amd64.lo"
2018       ;;
2019       arm*-*-*)
2020          # Build with the assembly implementation
2021          GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish-arm.lo"
2022       ;;
2023    esac
2024 fi
2025
2026 LIST_MEMBER(cast5, $enabled_ciphers)
2027 if test "$found" = "1" ; then
2028    GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5.lo"
2029    AC_DEFINE(USE_CAST5, 1, [Defined if this module should be included])
2030
2031    case "${host}" in
2032       x86_64-*-*)
2033          # Build with the assembly implementation
2034          GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5-amd64.lo"
2035       ;;
2036       arm*-*-*)
2037          # Build with the assembly implementation
2038          GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5-arm.lo"
2039       ;;
2040    esac
2041 fi
2042
2043 LIST_MEMBER(des, $enabled_ciphers)
2044 if test "$found" = "1" ; then
2045    GCRYPT_CIPHERS="$GCRYPT_CIPHERS des.lo"
2046    AC_DEFINE(USE_DES, 1, [Defined if this module should be included])
2047
2048    case "${host}" in
2049       x86_64-*-*)
2050          # Build with the assembly implementation
2051          GCRYPT_CIPHERS="$GCRYPT_CIPHERS des-amd64.lo"
2052       ;;
2053    esac
2054 fi
2055
2056 LIST_MEMBER(aes, $enabled_ciphers)
2057 if test "$found" = "1" ; then
2058    GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael.lo"
2059    AC_DEFINE(USE_AES, 1, [Defined if this module should be included])
2060
2061    case "${host}" in
2062       x86_64-*-*)
2063          # Build with the assembly implementation
2064          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-amd64.lo"
2065
2066          # Build with the SSSE3 implementation
2067          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-ssse3-amd64.lo"
2068          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-ssse3-amd64-asm.lo"
2069       ;;
2070       arm*-*-*)
2071          # Build with the assembly implementation
2072          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-arm.lo"
2073
2074          # Build with the ARMv8/AArch32 CE implementation
2075          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-armv8-ce.lo"
2076          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-armv8-aarch32-ce.lo"
2077       ;;
2078       aarch64-*-*)
2079          # Build with the assembly implementation
2080          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-aarch64.lo"
2081
2082          # Build with the ARMv8/AArch64 CE implementation
2083          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-armv8-ce.lo"
2084          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-armv8-aarch64-ce.lo"
2085       ;;
2086    esac
2087
2088    case "$mpi_cpu_arch" in
2089      x86)
2090          # Build with the AES-NI implementation
2091          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-aesni.lo"
2092
2093          # Build with the Padlock implementation
2094          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-padlock.lo"
2095       ;;
2096    esac
2097 fi
2098
2099 LIST_MEMBER(twofish, $enabled_ciphers)
2100 if test "$found" = "1" ; then
2101    GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish.lo"
2102    AC_DEFINE(USE_TWOFISH, 1, [Defined if this module should be included])
2103
2104    case "${host}" in
2105       x86_64-*-*)
2106          # Build with the assembly implementation
2107          GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish-amd64.lo"
2108
2109          if test x"$avx2support" = xyes ; then
2110             # Build with the AVX2 implementation
2111             GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish-avx2-amd64.lo"
2112          fi
2113       ;;
2114       arm*-*-*)
2115          # Build with the assembly implementation
2116          GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish-arm.lo"
2117       ;;
2118       aarch64-*-*)
2119          # Build with the assembly implementation
2120          GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish-aarch64.lo"
2121       ;;
2122    esac
2123 fi
2124
2125 LIST_MEMBER(serpent, $enabled_ciphers)
2126 if test "$found" = "1" ; then
2127    GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent.lo"
2128    AC_DEFINE(USE_SERPENT, 1, [Defined if this module should be included])
2129
2130    case "${host}" in
2131       x86_64-*-*)
2132          # Build with the SSE2 implementation
2133          GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent-sse2-amd64.lo"
2134       ;;
2135    esac
2136
2137    if test x"$avx2support" = xyes ; then
2138       # Build with the AVX2 implementation
2139       GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent-avx2-amd64.lo"
2140    fi
2141
2142    if test x"$neonsupport" = xyes ; then
2143       # Build with the NEON implementation
2144       GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent-armv7-neon.lo"
2145    fi
2146 fi
2147
2148 LIST_MEMBER(rfc2268, $enabled_ciphers)
2149 if test "$found" = "1" ; then
2150    GCRYPT_CIPHERS="$GCRYPT_CIPHERS rfc2268.lo"
2151    AC_DEFINE(USE_RFC2268, 1, [Defined if this module should be included])
2152 fi
2153
2154 LIST_MEMBER(seed, $enabled_ciphers)
2155 if test "$found" = "1" ; then
2156    GCRYPT_CIPHERS="$GCRYPT_CIPHERS seed.lo"
2157    AC_DEFINE(USE_SEED, 1, [Defined if this module should be included])
2158 fi
2159
2160 LIST_MEMBER(camellia, $enabled_ciphers)
2161 if test "$found" = "1" ; then
2162    GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia.lo camellia-glue.lo"
2163    AC_DEFINE(USE_CAMELLIA, 1, [Defined if this module should be included])
2164
2165    case "${host}" in
2166       arm*-*-*)
2167          # Build with the assembly implementation
2168          GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia-arm.lo"
2169       ;;
2170       aarch64-*-*)
2171          # Build with the assembly implementation
2172          GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia-aarch64.lo"
2173       ;;
2174    esac
2175
2176    if test x"$avxsupport" = xyes ; then
2177       if test x"$aesnisupport" = xyes ; then
2178         # Build with the AES-NI/AVX implementation
2179         GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia-aesni-avx-amd64.lo"
2180       fi
2181    fi
2182
2183    if test x"$avx2support" = xyes ; then
2184       if test x"$aesnisupport" = xyes ; then
2185         # Build with the AES-NI/AVX2 implementation
2186         GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia-aesni-avx2-amd64.lo"
2187       fi
2188    fi
2189 fi
2190
2191 LIST_MEMBER(idea, $enabled_ciphers)
2192 if test "$found" = "1" ; then
2193    GCRYPT_CIPHERS="$GCRYPT_CIPHERS idea.lo"
2194    AC_DEFINE(USE_IDEA, 1, [Defined if this module should be included])
2195 fi
2196
2197 LIST_MEMBER(salsa20, $enabled_ciphers)
2198 if test "$found" = "1" ; then
2199    GCRYPT_CIPHERS="$GCRYPT_CIPHERS salsa20.lo"
2200    AC_DEFINE(USE_SALSA20, 1, [Defined if this module should be included])
2201
2202    case "${host}" in
2203       x86_64-*-*)
2204          # Build with the assembly implementation
2205          GCRYPT_CIPHERS="$GCRYPT_CIPHERS salsa20-amd64.lo"
2206       ;;
2207    esac
2208
2209    if test x"$neonsupport" = xyes ; then
2210      # Build with the NEON implementation
2211      GCRYPT_CIPHERS="$GCRYPT_CIPHERS salsa20-armv7-neon.lo"
2212    fi
2213 fi
2214
2215 LIST_MEMBER(gost28147, $enabled_ciphers)
2216 if test "$found" = "1" ; then
2217    GCRYPT_CIPHERS="$GCRYPT_CIPHERS gost28147.lo"
2218    AC_DEFINE(USE_GOST28147, 1, [Defined if this module should be included])
2219 fi
2220
2221 LIST_MEMBER(chacha20, $enabled_ciphers)
2222 if test "$found" = "1" ; then
2223    GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20.lo"
2224    AC_DEFINE(USE_CHACHA20, 1, [Defined if this module should be included])
2225
2226    case "${host}" in
2227       x86_64-*-*)
2228          # Build with the assembly implementation
2229          GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20-sse2-amd64.lo"
2230          GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20-ssse3-amd64.lo"
2231          GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20-avx2-amd64.lo"
2232       ;;
2233    esac
2234
2235    if test x"$neonsupport" = xyes ; then
2236      # Build with the NEON implementation
2237      GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20-armv7-neon.lo"
2238    fi
2239 fi
2240
2241 case "${host}" in
2242    x86_64-*-*)
2243       # Build with the assembly implementation
2244       GCRYPT_CIPHERS="$GCRYPT_CIPHERS poly1305-sse2-amd64.lo"
2245       GCRYPT_CIPHERS="$GCRYPT_CIPHERS poly1305-avx2-amd64.lo"
2246    ;;
2247 esac
2248
2249 if test x"$neonsupport" = xyes ; then
2250    # Build with the NEON implementation
2251    GCRYPT_CIPHERS="$GCRYPT_CIPHERS poly1305-armv7-neon.lo"
2252 fi
2253
2254 LIST_MEMBER(dsa, $enabled_pubkey_ciphers)
2255 if test "$found" = "1" ; then
2256    GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo"
2257    AC_DEFINE(USE_DSA, 1, [Defined if this module should be included])
2258 fi
2259
2260 LIST_MEMBER(rsa, $enabled_pubkey_ciphers)
2261 if test "$found" = "1" ; then
2262    GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS rsa.lo"
2263    AC_DEFINE(USE_RSA, 1, [Defined if this module should be included])
2264 fi
2265
2266 LIST_MEMBER(elgamal, $enabled_pubkey_ciphers)
2267 if test "$found" = "1" ; then
2268    GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo"
2269    AC_DEFINE(USE_ELGAMAL, 1, [Defined if this module should be included])
2270 fi
2271
2272 LIST_MEMBER(ecc, $enabled_pubkey_ciphers)
2273 if test "$found" = "1" ; then
2274    GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS \
2275                           ecc.lo ecc-curves.lo ecc-misc.lo \
2276                           ecc-ecdsa.lo ecc-eddsa.lo ecc-gost.lo"
2277    AC_DEFINE(USE_ECC, 1, [Defined if this module should be included])
2278 fi
2279
2280 LIST_MEMBER(crc, $enabled_digests)
2281 if test "$found" = "1" ; then
2282    GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc.lo"
2283    AC_DEFINE(USE_CRC, 1, [Defined if this module should be included])
2284
2285    case "${host}" in
2286       i?86-*-* | x86_64-*-*)
2287          # Build with the assembly implementation
2288          GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc-intel-pclmul.lo"
2289       ;;
2290    esac
2291 fi
2292
2293 LIST_MEMBER(gostr3411-94, $enabled_digests)
2294 if test "$found" = "1" ; then
2295    # GOST R 34.11-94 internally uses GOST 28147-89
2296    LIST_MEMBER(gost28147, $enabled_ciphers)
2297    if test "$found" = "1" ; then
2298       GCRYPT_DIGESTS="$GCRYPT_DIGESTS gostr3411-94.lo"
2299       AC_DEFINE(USE_GOST_R_3411_94, 1, [Defined if this module should be included])
2300    fi
2301 fi
2302
2303 LIST_MEMBER(stribog, $enabled_digests)
2304 if test "$found" = "1" ; then
2305    GCRYPT_DIGESTS="$GCRYPT_DIGESTS stribog.lo"
2306    AC_DEFINE(USE_GOST_R_3411_12, 1, [Defined if this module should be included])
2307 fi
2308
2309 LIST_MEMBER(md2, $enabled_digests)
2310 if test "$found" = "1" ; then
2311    GCRYPT_DIGESTS="$GCRYPT_DIGESTS md2.lo"
2312    AC_DEFINE(USE_MD2, 1, [Defined if this module should be included])
2313 fi
2314
2315 LIST_MEMBER(md4, $enabled_digests)
2316 if test "$found" = "1" ; then
2317    GCRYPT_DIGESTS="$GCRYPT_DIGESTS md4.lo"
2318    AC_DEFINE(USE_MD4, 1, [Defined if this module should be included])
2319 fi
2320
2321 LIST_MEMBER(md5, $enabled_digests)
2322 if test "$found" = "1" ; then
2323    GCRYPT_DIGESTS="$GCRYPT_DIGESTS md5.lo"
2324    AC_DEFINE(USE_MD5, 1, [Defined if this module should be included])
2325 fi
2326
2327 LIST_MEMBER(rmd160, $enabled_digests)
2328 if test "$found" = "1" ; then
2329    GCRYPT_DIGESTS="$GCRYPT_DIGESTS rmd160.lo"
2330    AC_DEFINE(USE_RMD160, 1, [Defined if this module should be included])
2331 fi
2332
2333 LIST_MEMBER(sha256, $enabled_digests)
2334 if test "$found" = "1" ; then
2335    GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo"
2336    AC_DEFINE(USE_SHA256, 1, [Defined if this module should be included])
2337
2338    case "${host}" in
2339       x86_64-*-*)
2340          # Build with the assembly implementation
2341          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256-ssse3-amd64.lo"
2342          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256-avx-amd64.lo"
2343          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256-avx2-bmi2-amd64.lo"
2344       ;;
2345       arm*-*-*)
2346          # Build with the assembly implementation
2347          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256-armv8-aarch32-ce.lo"
2348       ;;
2349       aarch64-*-*)
2350          # Build with the assembly implementation
2351          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256-armv8-aarch64-ce.lo"
2352       ;;
2353    esac
2354 fi
2355
2356 LIST_MEMBER(sha512, $enabled_digests)
2357 if test "$found" = "1" ; then
2358    GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512.lo"
2359    AC_DEFINE(USE_SHA512, 1, [Defined if this module should be included])
2360
2361    case "${host}" in
2362       x86_64-*-*)
2363          # Build with the assembly implementation
2364          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-ssse3-amd64.lo"
2365          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-avx-amd64.lo"
2366          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-avx2-bmi2-amd64.lo"
2367       ;;
2368       arm*-*-*)
2369          # Build with the assembly implementation
2370          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-arm.lo"
2371       ;;
2372    esac
2373
2374    if test x"$neonsupport" = xyes ; then
2375      # Build with the NEON implementation
2376      GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-armv7-neon.lo"
2377    fi
2378 fi
2379
2380 LIST_MEMBER(sha3, $enabled_digests)
2381 if test "$found" = "1" ; then
2382    GCRYPT_DIGESTS="$GCRYPT_DIGESTS keccak.lo"
2383    AC_DEFINE(USE_SHA3, 1, [Defined if this module should be included])
2384
2385    case "${host}" in
2386       x86_64-*-*)
2387          # Build with the assembly implementation
2388          :
2389       ;;
2390    esac
2391
2392    if test x"$neonsupport" = xyes ; then
2393      # Build with the NEON implementation
2394      GCRYPT_DIGESTS="$GCRYPT_DIGESTS keccak-armv7-neon.lo"
2395    fi
2396 fi
2397
2398 LIST_MEMBER(tiger, $enabled_digests)
2399 if test "$found" = "1" ; then
2400    GCRYPT_DIGESTS="$GCRYPT_DIGESTS tiger.lo"
2401    AC_DEFINE(USE_TIGER, 1, [Defined if this module should be included])
2402 fi
2403
2404 LIST_MEMBER(whirlpool, $enabled_digests)
2405 if test "$found" = "1" ; then
2406    GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool.lo"
2407    AC_DEFINE(USE_WHIRLPOOL, 1, [Defined if this module should be included])
2408
2409    case "${host}" in
2410       x86_64-*-*)
2411          # Build with the assembly implementation
2412          GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool-sse2-amd64.lo"
2413       ;;
2414    esac
2415 fi
2416
2417 LIST_MEMBER(blake2, $enabled_digests)
2418 if test "$found" = "1" ; then
2419    GCRYPT_DIGESTS="$GCRYPT_DIGESTS blake2.lo"
2420    AC_DEFINE(USE_BLAKE2, 1, [Defined if this module should be included])
2421 fi
2422
2423 # SHA-1 needs to be included always for example because it is used by
2424 # random-csprng.c.
2425 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1.lo"
2426 AC_DEFINE(USE_SHA1, 1,   [Defined if this module should be included])
2427
2428 case "${host}" in
2429   x86_64-*-*)
2430     # Build with the assembly implementation
2431     GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-ssse3-amd64.lo"
2432     GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-avx-amd64.lo"
2433     GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-avx-bmi2-amd64.lo"
2434   ;;
2435   arm*-*-*)
2436     # Build with the assembly implementation
2437     GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-armv7-neon.lo"
2438     GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-armv8-aarch32-ce.lo"
2439   ;;
2440   aarch64-*-*)
2441     # Build with the assembly implementation
2442     GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-armv8-aarch64-ce.lo"
2443   ;;
2444 esac
2445
2446 LIST_MEMBER(scrypt, $enabled_kdfs)
2447 if test "$found" = "1" ; then
2448    GCRYPT_KDFS="$GCRYPT_KDFS scrypt.lo"
2449    AC_DEFINE(USE_SCRYPT, 1, [Defined if this module should be included])
2450 fi
2451
2452 LIST_MEMBER(linux, $random_modules)
2453 if test "$found" = "1" ; then
2454    GCRYPT_RANDOM="$GCRYPT_RANDOM rndlinux.lo"
2455    AC_DEFINE(USE_RNDLINUX, 1, [Defined if the /dev/random RNG should be used.])
2456 fi
2457
2458 LIST_MEMBER(unix, $random_modules)
2459 if test "$found" = "1" ; then
2460    GCRYPT_RANDOM="$GCRYPT_RANDOM rndunix.lo"
2461    AC_DEFINE(USE_RNDUNIX, 1, [Defined if the default Unix RNG should be used.])
2462    print_egd_notice=yes
2463 fi
2464
2465 LIST_MEMBER(egd, $random_modules)
2466 if test "$found" = "1" ; then
2467    GCRYPT_RANDOM="$GCRYPT_RANDOM rndegd.lo"
2468    AC_DEFINE(USE_RNDEGD, 1, [Defined if the EGD based RNG should be used.])
2469 fi
2470
2471 LIST_MEMBER(w32, $random_modules)
2472 if test "$found" = "1" ; then
2473    GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32.lo"
2474    AC_DEFINE(USE_RNDW32, 1,
2475              [Defined if the Windows specific RNG should be used.])
2476 fi
2477
2478 LIST_MEMBER(w32ce, $random_modules)
2479 if test "$found" = "1" ; then
2480    GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32ce.lo"
2481    AC_DEFINE(USE_RNDW32CE, 1,
2482              [Defined if the WindowsCE specific RNG should be used.])
2483 fi
2484
2485 AC_SUBST([GCRYPT_CIPHERS])
2486 AC_SUBST([GCRYPT_PUBKEY_CIPHERS])
2487 AC_SUBST([GCRYPT_DIGESTS])
2488 AC_SUBST([GCRYPT_KDFS])
2489 AC_SUBST([GCRYPT_RANDOM])
2490
2491 AC_SUBST(LIBGCRYPT_CIPHERS, $enabled_ciphers)
2492 AC_SUBST(LIBGCRYPT_PUBKEY_CIPHERS, $enabled_pubkey_ciphers)
2493 AC_SUBST(LIBGCRYPT_DIGESTS, $enabled_digests)
2494
2495 # For printing the configuration we need a colon separated list of
2496 # algorithm names.
2497 tmp=`echo "$enabled_ciphers" | tr ' ' : `
2498 AC_DEFINE_UNQUOTED(LIBGCRYPT_CIPHERS, "$tmp",
2499                    [List of available cipher algorithms])
2500 tmp=`echo "$enabled_pubkey_ciphers" | tr ' ' : `
2501 AC_DEFINE_UNQUOTED(LIBGCRYPT_PUBKEY_CIPHERS, "$tmp",
2502                    [List of available public key cipher algorithms])
2503 tmp=`echo "$enabled_digests" | tr ' ' : `
2504 AC_DEFINE_UNQUOTED(LIBGCRYPT_DIGESTS, "$tmp",
2505                    [List of available digest algorithms])
2506 tmp=`echo "$enabled_kdfs" | tr ' ' : `
2507 AC_DEFINE_UNQUOTED(LIBGCRYPT_KDFS, "$tmp",
2508                    [List of available KDF algorithms])
2509
2510
2511 #
2512 # Define conditional sources depending on the used hardware platform.
2513 # Note that all possible modules must also be listed in
2514 # src/Makefile.am (EXTRA_libgcrypt_la_SOURCES).
2515 #
2516 GCRYPT_HWF_MODULES=
2517 case "$mpi_cpu_arch" in
2518      x86)
2519         AC_DEFINE(HAVE_CPU_ARCH_X86, 1,   [Defined for the x86 platforms])
2520         GCRYPT_HWF_MODULES="hwf-x86.lo"
2521         ;;
2522      alpha)
2523         AC_DEFINE(HAVE_CPU_ARCH_ALPHA, 1, [Defined for Alpha platforms])
2524         ;;
2525      sparc)
2526         AC_DEFINE(HAVE_CPU_ARCH_SPARC, 1, [Defined for SPARC platforms])
2527         ;;
2528      mips)
2529         AC_DEFINE(HAVE_CPU_ARCH_MIPS, 1,  [Defined for MIPS platforms])
2530         ;;
2531      m68k)
2532         AC_DEFINE(HAVE_CPU_ARCH_M68K, 1,  [Defined for M68k platforms])
2533         ;;
2534      ppc)
2535         AC_DEFINE(HAVE_CPU_ARCH_PPC, 1,   [Defined for PPC platforms])
2536         ;;
2537      arm)
2538         AC_DEFINE(HAVE_CPU_ARCH_ARM, 1,   [Defined for ARM platforms])
2539         GCRYPT_HWF_MODULES="hwf-arm.lo"
2540         ;;
2541      aarch64)
2542         AC_DEFINE(HAVE_CPU_ARCH_ARM, 1,   [Defined for ARM AArch64 platforms])
2543         GCRYPT_HWF_MODULES="hwf-arm.lo"
2544         ;;
2545 esac
2546 AC_SUBST([GCRYPT_HWF_MODULES])
2547
2548
2549 #
2550 # Option to disable building of doc file
2551 #
2552 build_doc=yes
2553 AC_ARG_ENABLE([doc], AC_HELP_STRING([--disable-doc],
2554                                     [do not build the documentation]),
2555                      build_doc=$enableval, build_doc=yes)
2556 AM_CONDITIONAL([BUILD_DOC], [test "x$build_doc" != xno])
2557
2558
2559 #
2560 # Provide information about the build.
2561 #
2562 BUILD_REVISION="mym4_revision"
2563 AC_SUBST(BUILD_REVISION)
2564 AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
2565                    [GIT commit id revision used to build this package])
2566
2567 changequote(,)dnl
2568 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
2569 changequote([,])dnl
2570 BUILD_FILEVERSION="${BUILD_FILEVERSION}mym4_revision_dec"
2571 AC_SUBST(BUILD_FILEVERSION)
2572
2573 AC_ARG_ENABLE([build-timestamp],
2574   AC_HELP_STRING([--enable-build-timestamp],
2575                  [set an explicit build timestamp for reproducibility.
2576                   (default is the current time in ISO-8601 format)]),
2577      [if test "$enableval" = "yes"; then
2578         BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
2579       else
2580         BUILD_TIMESTAMP="$enableval"
2581       fi],
2582      [BUILD_TIMESTAMP="<none>"])
2583 AC_SUBST(BUILD_TIMESTAMP)
2584 AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
2585                    [The time this package was configured for a build])
2586
2587
2588 # And create the files.
2589 AC_CONFIG_FILES([
2590 Makefile
2591 m4/Makefile
2592 compat/Makefile
2593 mpi/Makefile
2594 cipher/Makefile
2595 random/Makefile
2596 doc/Makefile
2597 src/Makefile
2598 src/gcrypt.h
2599 src/libgcrypt-config
2600 src/versioninfo.rc
2601 tests/Makefile
2602 ])
2603 AC_CONFIG_FILES([tests/hashtest-256g], [chmod +x tests/hashtest-256g])
2604 AC_CONFIG_FILES([tests/basic-disable-all-hwf], [chmod +x tests/basic-disable-all-hwf])
2605 AC_OUTPUT
2606
2607
2608 detection_module="${GCRYPT_HWF_MODULES%.lo}"
2609 test -n "$detection_module" || detection_module="none"
2610
2611 # Give some feedback
2612 GCRY_MSG_SHOW([],[])
2613 GCRY_MSG_SHOW([Libgcrypt],[v${VERSION} has been configured as follows:])
2614 GCRY_MSG_SHOW([],[])
2615 GCRY_MSG_SHOW([Platform:                 ],[$PRINTABLE_OS_NAME ($host)])
2616 GCRY_MSG_SHOW([Hardware detection module:],[$detection_module])
2617 GCRY_MSG_WRAP([Enabled cipher algorithms:],[$enabled_ciphers])
2618 GCRY_MSG_WRAP([Enabled digest algorithms:],[$enabled_digests])
2619 GCRY_MSG_WRAP([Enabled kdf algorithms:   ],[$enabled_kdfs])
2620 GCRY_MSG_WRAP([Enabled pubkey algorithms:],[$enabled_pubkey_ciphers])
2621 GCRY_MSG_SHOW([Random number generator:  ],[$random])
2622 GCRY_MSG_SHOW([Using linux capabilities: ],[$use_capabilities])
2623 GCRY_MSG_SHOW([Try using Padlock crypto: ],[$padlocksupport])
2624 GCRY_MSG_SHOW([Try using AES-NI crypto:  ],[$aesnisupport])
2625 GCRY_MSG_SHOW([Try using Intel PCLMUL:   ],[$pclmulsupport])
2626 GCRY_MSG_SHOW([Try using Intel SSE4.1:   ],[$sse41support])
2627 GCRY_MSG_SHOW([Try using DRNG (RDRAND):  ],[$drngsupport])
2628 GCRY_MSG_SHOW([Try using Intel AVX:      ],[$avxsupport])
2629 GCRY_MSG_SHOW([Try using Intel AVX2:     ],[$avx2support])
2630 GCRY_MSG_SHOW([Try using ARM NEON:       ],[$neonsupport])
2631 GCRY_MSG_SHOW([Try using ARMv8 crypto:   ],[$armcryptosupport])
2632 GCRY_MSG_SHOW([],[])
2633
2634 if test "x${gpg_config_script_warn}" != x; then
2635 cat <<G10EOF
2636         Mismatches between the target platform and the to
2637         be used libraries have been been detected for:
2638          ${gpg_config_script_warn}
2639         Please check above for warning messages.
2640
2641 G10EOF
2642 fi
2643 if test "$print_egd_notice" = "yes"; then
2644 cat <<G10EOF
2645    The performance of the Unix random gatherer module (rndunix) is not
2646    very good and it does not keep the entropy pool over multiple
2647    invocations of Libgcrypt base applications.  The suggested way to
2648    overcome this problem is to use the
2649
2650                  Entropy Gathering Daemon (EGD)
2651
2652    which provides a entropy source for the whole system.  It is written
2653    in Perl and available at the GnuPG FTP servers.  For more information
2654    consult the GnuPG site:
2655
2656           https://gnupg.org/related_software/swlist.html#egd
2657
2658 G10EOF
2659 fi
2660
2661 if test "$gcry_cv_gcc_attribute_aligned" != "yes" ; then
2662 cat <<G10EOF
2663    Please not that your compiler does not support the GCC style
2664    aligned attribute. Using this software may evoke bus errors.
2665
2666 G10EOF
2667 fi
2668
2669 if test -n "$gpl"; then
2670   echo "Please note that you are building a version of Libgcrypt with"
2671   echo "  $gpl"
2672   echo "included.  These parts are licensed under the GPL and thus the"
2673   echo "use of this library has to comply with the conditions of the GPL."
2674   echo ""
2675 fi