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