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
6 # This file is part of Libgcrypt.
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.
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.
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/>.
21 # (Process this file with autoconf to produce a configure script.)
22 AC_REVISION($Revision$)
24 min_automake_version="1.14"
26 # To build a release you need to create a tag with the version number
27 # (git tag -s libgcrypt-n.m.k) and run "./autogen.sh --force". Please
28 # bump the version number immediately after the release and do another
29 # commit and push so that the git magic is able to work. See below
30 # for the LT versions.
31 m4_define(mym4_version_major, [1])
32 m4_define(mym4_version_minor, [8])
33 m4_define(mym4_version_micro, [3])
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])
51 AC_INIT([libgcrypt],[mym4_full_version],[http://bugs.gnupg.org])
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=22
59 LIBGCRYPT_LT_REVISION=3
62 # If the API is changed in an incompatible way: increment the next counter.
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
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
73 VERSION=$PACKAGE_VERSION
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])
85 AC_ARG_VAR(SYSROOT,[locate config scripts also below that directory])
88 #ifndef _GCRYPT_CONFIG_H_INCLUDED
89 #define _GCRYPT_CONFIG_H_INCLUDED
91 /* Enable gpg-error's strerror macro for W32CE. */
92 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
96 #define _GCRYPT_IN_LIBGCRYPT 1
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
106 # error "No endianness found"
108 #endif /*DISABLED_ENDIAN_CHECK*/
110 /* We basically use the original Camellia source. Make sure the symbols
111 properly prefixed. */
112 #define CAMELLIA_EXT_SYM_PREFIX _gcry_
114 #endif /*_GCRYPT_CONFIG_H_INCLUDED*/
117 AH_VERBATIM([_REENTRANT],
118 [/* To allow the use of Libgcrypt in multithreaded programs we have to use
119 special features from the library. */
121 # define _REENTRANT 1
126 AC_SUBST(LIBGCRYPT_LT_CURRENT)
127 AC_SUBST(LIBGCRYPT_LT_AGE)
128 AC_SUBST(LIBGCRYPT_LT_REVISION)
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)
138 ######################
139 ## Basic checks. ### (we need some results later on (e.g. $GCC)
140 ######################
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)
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
165 AC_MSG_CHECKING(for cc for build)
166 if test "$cross_compiling" = "yes"; then
167 CC_FOR_BUILD="${CC_FOR_BUILD-cc}"
169 CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
171 AC_MSG_RESULT($CC_FOR_BUILD)
172 AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
176 LT_INIT([win32-dll disable-static])
177 LT_LANG([Windows Resource])
180 ##########################
181 ## General definitions. ##
182 ##########################
184 # Used by libgcrypt-config
185 LIBGCRYPT_CONFIG_LIBS="-lgcrypt"
186 LIBGCRYPT_CONFIG_CFLAGS=""
187 LIBGCRYPT_CONFIG_HOST="$host"
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"
194 # Definitions for public-key ciphers.
195 available_pubkey_ciphers="dsa elgamal rsa ecc"
196 enabled_pubkey_ciphers=""
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"
203 # Definitions for kdfs (optional ones)
204 available_kdfs="s2k pkdf2 scrypt"
207 # Definitions for random modules.
208 available_random_modules="linux egd unix"
209 auto_random_modules="$available_random_modules"
211 # Supported thread backends.
212 LIBGCRYPT_THREAD_MODULES=""
220 # Setup some stuff depending on host.
223 ac_cv_have_dev_random=no
227 have_w32ce_system=yes
228 available_random_modules="w32ce"
231 available_random_modules="w32"
234 AC_DEFINE(USE_ONLY_8DOT3,1,
235 [set this to limit filenames to the 8.3 format])
236 AC_DEFINE(HAVE_DRIVE_LETTERS,1,
237 [defined if we must run on a stupid file system])
238 AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
239 [defined if we run on some of the PCDOS like systems
240 (DOS, Windoze. OS/2) with special properties like
244 i?86-emx-os2 | i?86-*-os2*emx)
245 # OS/2 with the EMX environment
246 ac_cv_have_dev_random=no
247 AC_DEFINE(HAVE_DRIVE_LETTERS)
248 AC_DEFINE(HAVE_DOSISH_SYSTEM)
252 # DOS with the DJGPP environment
253 ac_cv_have_dev_random=no
254 AC_DEFINE(HAVE_DRIVE_LETTERS)
255 AC_DEFINE(HAVE_DOSISH_SYSTEM)
259 if test -z "$GCC" ; then
260 CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
264 if test -z "$GCC" ; then
265 # Suppress all warnings
266 # to get rid of the unsigned/signed char mismatch warnings.
273 AC_DEFINE(_DARWIN_C_SOURCE, 900000L,
274 Expose all libc features (__DARWIN_C_FULL).)
280 if test "$have_w32_system" = yes; then
281 AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
282 if test "$have_w32ce_system" = yes; then
283 AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE])
286 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
287 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
291 # A printable OS Name is sometimes useful.
294 PRINTABLE_OS_NAME="W32CE"
298 PRINTABLE_OS_NAME="W32"
301 i?86-emx-os2 | i?86-*-os2*emx )
302 PRINTABLE_OS_NAME="OS/2"
306 PRINTABLE_OS_NAME="MSDOS/DJGPP"
310 PRINTABLE_OS_NAME="GNU/Linux"
314 PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
318 NAME_OF_DEV_RANDOM="/dev/random"
319 NAME_OF_DEV_URANDOM="/dev/urandom"
321 AC_ARG_ENABLE(endian-check,
322 AC_HELP_STRING([--disable-endian-check],
323 [disable the endian check and trust the OS provided macros]),
324 endiancheck=$enableval,endiancheck=yes)
325 if test x"$endiancheck" = xyes ; then
328 AC_DEFINE(DISABLED_ENDIAN_CHECK,1,[configure did not test for endianness])
331 AC_CHECK_SIZEOF(unsigned short, 2)
332 AC_CHECK_SIZEOF(unsigned int, 4)
333 AC_CHECK_SIZEOF(unsigned long, 4)
334 AC_CHECK_SIZEOF(unsigned long long, 0)
335 AC_CHECK_SIZEOF(void *, 0)
339 if test "$ac_cv_sizeof_unsigned_short" = "0" \
340 || test "$ac_cv_sizeof_unsigned_int" = "0" \
341 || test "$ac_cv_sizeof_unsigned_long" = "0"; then
342 AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
345 # Ensure that we have UINT64_C before we bother to check for uint64_t
346 AC_CACHE_CHECK([for UINT64_C],[gnupg_cv_uint64_c_works],
347 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <inttypes.h>]],
348 [[uint64_t foo=UINT64_C(42);]])],
349 gnupg_cv_uint64_c_works=yes,gnupg_cv_uint64_c_works=no))
350 if test "$gnupg_cv_uint64_c_works" = "yes" ; then
351 AC_CHECK_SIZEOF(uint64_t)
354 # Do we have any 64-bit data types?
355 if test "$ac_cv_sizeof_unsigned_int" != "8" \
356 && test "$ac_cv_sizeof_unsigned_long" != "8" \
357 && test "$ac_cv_sizeof_unsigned_long_long" != "8" \
358 && test "$ac_cv_sizeof_uint64_t" != "8"; then
361 *** No 64-bit integer type available.
362 *** It is not possible to build Libgcrypt on this platform.
367 # If not specified otherwise, all available algorithms will be
369 default_ciphers="$available_ciphers"
370 default_pubkey_ciphers="$available_pubkey_ciphers"
371 default_digests="$available_digests"
372 default_kdfs="$available_kdfs"
373 # Blacklist MD2 by default
374 default_digests=`echo $default_digests | sed -e 's/md2//g'`
376 # Substitutions to set generated files in a Emacs buffer to read-only.
377 AC_SUBST(emacs_local_vars_begin, ['Local Variables:'])
378 AC_SUBST(emacs_local_vars_read_only, ['buffer-read-only: t'])
379 AC_SUBST(emacs_local_vars_end, ['End:'])
381 ############################
382 ## Command line switches. ##
383 ############################
385 # Implementation of the --enable-ciphers switch.
386 AC_ARG_ENABLE(ciphers,
387 AC_HELP_STRING([--enable-ciphers=ciphers],
388 [select the symmetric ciphers to include]),
389 [enabled_ciphers=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
390 [enabled_ciphers=""])
391 if test "x$enabled_ciphers" = "x" \
392 -o "$enabled_ciphers" = "yes" \
393 -o "$enabled_ciphers" = "no"; then
394 enabled_ciphers=$default_ciphers
396 AC_MSG_CHECKING([which symmetric ciphers to include])
397 for cipher in $enabled_ciphers; do
398 LIST_MEMBER($cipher, $available_ciphers)
399 if test "$found" = "0"; then
400 AC_MSG_ERROR([unsupported cipher "$cipher" specified])
403 AC_MSG_RESULT([$enabled_ciphers])
405 # Implementation of the --enable-pubkey-ciphers switch.
406 AC_ARG_ENABLE(pubkey-ciphers,
407 AC_HELP_STRING([--enable-pubkey-ciphers=ciphers],
408 [select the public-key ciphers to include]),
409 [enabled_pubkey_ciphers=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
410 [enabled_pubkey_ciphers=""])
411 if test "x$enabled_pubkey_ciphers" = "x" \
412 -o "$enabled_pubkey_ciphers" = "yes" \
413 -o "$enabled_pubkey_ciphers" = "no"; then
414 enabled_pubkey_ciphers=$default_pubkey_ciphers
416 AC_MSG_CHECKING([which public-key ciphers to include])
417 for cipher in $enabled_pubkey_ciphers; do
418 LIST_MEMBER($cipher, $available_pubkey_ciphers)
419 if test "$found" = "0"; then
420 AC_MSG_ERROR([unsupported public-key cipher specified])
423 AC_MSG_RESULT([$enabled_pubkey_ciphers])
425 # Implementation of the --enable-digests switch.
426 AC_ARG_ENABLE(digests,
427 AC_HELP_STRING([--enable-digests=digests],
428 [select the message digests to include]),
429 [enabled_digests=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
430 [enabled_digests=""])
431 if test "x$enabled_digests" = "x" \
432 -o "$enabled_digests" = "yes" \
433 -o "$enabled_digests" = "no"; then
434 enabled_digests=$default_digests
436 AC_MSG_CHECKING([which message digests to include])
437 for digest in $enabled_digests; do
438 LIST_MEMBER($digest, $available_digests)
439 if test "$found" = "0"; then
440 AC_MSG_ERROR([unsupported message digest specified])
443 AC_MSG_RESULT([$enabled_digests])
445 # Implementation of the --enable-kdfs switch.
447 AC_HELP_STRING([--enable-kfds=kdfs],
448 [select the KDFs to include]),
449 [enabled_kdfs=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
451 if test "x$enabled_kdfs" = "x" \
452 -o "$enabled_kdfs" = "yes" \
453 -o "$enabled_kdfs" = "no"; then
454 enabled_kdfs=$default_kdfs
456 AC_MSG_CHECKING([which key derivation functions to include])
457 for kdf in $enabled_kdfs; do
458 LIST_MEMBER($kdf, $available_kdfs)
459 if test "$found" = "0"; then
460 AC_MSG_ERROR([unsupported key derivation function specified])
463 AC_MSG_RESULT([$enabled_kdfs])
465 # Implementation of the --enable-random switch.
466 AC_ARG_ENABLE(random,
467 AC_HELP_STRING([--enable-random=name],
468 [select which random number generator to use]),
469 [random=`echo $enableval | tr '[A-Z]' '[a-z]'`],
471 if test "x$random" = "x" -o "$random" = "yes" -o "$random" = "no"; then
474 AC_MSG_CHECKING([which random module to use])
475 if test "$random" != "default" -a "$random" != "auto"; then
476 LIST_MEMBER($random, $available_random_modules)
477 if test "$found" = "0"; then
478 AC_MSG_ERROR([unsupported random module specified])
481 AC_MSG_RESULT($random)
483 # Implementation of the --disable-dev-random switch.
484 AC_MSG_CHECKING([whether use of /dev/random is requested])
485 AC_ARG_ENABLE(dev-random,
486 [ --disable-dev-random disable the use of dev random],
487 try_dev_random=$enableval, try_dev_random=yes)
488 AC_MSG_RESULT($try_dev_random)
490 # Implementation of the --with-egd-socket switch.
491 AC_ARG_WITH(egd-socket,
492 [ --with-egd-socket=NAME Use NAME for the EGD socket)],
493 egd_socket_name="$withval", egd_socket_name="" )
494 AC_DEFINE_UNQUOTED(EGD_SOCKET_NAME, "$egd_socket_name",
495 [Define if you don't want the default EGD socket name.
496 For details see cipher/rndegd.c])
498 # Implementation of the --enable-random-daemon
499 AC_MSG_CHECKING([whether the experimental random daemon is requested])
500 AC_ARG_ENABLE([random-daemon],
501 AC_HELP_STRING([--enable-random-daemon],
502 [Build and support the experimental gcryptrnd]),
503 [use_random_daemon=$enableval],
504 [use_random_daemon=no])
505 AC_MSG_RESULT($use_random_daemon)
506 if test x$use_random_daemon = xyes ; then
507 AC_DEFINE(USE_RANDOM_DAEMON,1,
508 [Define to support the experimental random daemon])
510 AM_CONDITIONAL(USE_RANDOM_DAEMON, test x$use_random_daemon = xyes)
513 # Implementation of --disable-asm.
514 AC_MSG_CHECKING([whether MPI assembler modules are requested])
516 AC_HELP_STRING([--disable-asm],
517 [Disable MPI assembler modules]),
518 [try_asm_modules=$enableval],
519 [try_asm_modules=yes])
520 AC_MSG_RESULT($try_asm_modules)
522 # Implementation of the --enable-m-guard switch.
523 AC_MSG_CHECKING([whether memory guard is requested])
524 AC_ARG_ENABLE(m-guard,
525 AC_HELP_STRING([--enable-m-guard],
526 [Enable memory guard facility]),
527 [use_m_guard=$enableval], [use_m_guard=no])
528 AC_MSG_RESULT($use_m_guard)
529 if test "$use_m_guard" = yes ; then
530 AC_DEFINE(M_GUARD,1,[Define to use the (obsolete) malloc guarding feature])
533 # Implementation of the --enable-large-data-tests switch.
534 AC_MSG_CHECKING([whether to run large data tests])
535 AC_ARG_ENABLE(large-data-tests,
536 AC_HELP_STRING([--enable-large-data-tests],
537 [Enable the real long ruinning large data tests]),
538 large_data_tests=$enableval,large_data_tests=no)
539 AC_MSG_RESULT($large_data_tests)
540 AC_SUBST(RUN_LARGE_DATA_TESTS, $large_data_tests)
543 # Implementation of the --with-capabilities switch.
544 # Check whether we want to use Linux capabilities
545 AC_MSG_CHECKING([whether use of capabilities is requested])
546 AC_ARG_WITH(capabilities,
547 AC_HELP_STRING([--with-capabilities],
548 [Use linux capabilities [default=no]]),
549 [use_capabilities="$withval"],[use_capabilities=no])
550 AC_MSG_RESULT($use_capabilities)
552 # Implementation of the --enable-hmac-binary-check.
553 AC_MSG_CHECKING([whether a HMAC binary check is requested])
554 AC_ARG_ENABLE(hmac-binary-check,
555 AC_HELP_STRING([--enable-hmac-binary-check],
556 [Enable library integrity check]),
557 [use_hmac_binary_check=$enableval],
558 [use_hmac_binary_check=no])
559 AC_MSG_RESULT($use_hmac_binary_check)
560 if test "$use_hmac_binary_check" = yes ; then
561 AC_DEFINE(ENABLE_HMAC_BINARY_CHECK,1,
562 [Define to support an HMAC based integrity check])
566 # Implementation of the --disable-jent-support switch.
567 AC_MSG_CHECKING([whether jitter entropy support is requested])
568 AC_ARG_ENABLE(jent-support,
569 AC_HELP_STRING([--disable-jent-support],
570 [Disable support for the Jitter entropy collector]),
571 jentsupport=$enableval,jentsupport=yes)
572 AC_MSG_RESULT($jentsupport)
574 # Implementation of the --disable-padlock-support switch.
575 AC_MSG_CHECKING([whether padlock support is requested])
576 AC_ARG_ENABLE(padlock-support,
577 AC_HELP_STRING([--disable-padlock-support],
578 [Disable support for the PadLock Engine of VIA processors]),
579 padlocksupport=$enableval,padlocksupport=yes)
580 AC_MSG_RESULT($padlocksupport)
582 # Implementation of the --disable-aesni-support switch.
583 AC_MSG_CHECKING([whether AESNI support is requested])
584 AC_ARG_ENABLE(aesni-support,
585 AC_HELP_STRING([--disable-aesni-support],
586 [Disable support for the Intel AES-NI instructions]),
587 aesnisupport=$enableval,aesnisupport=yes)
588 AC_MSG_RESULT($aesnisupport)
590 # Implementation of the --disable-pclmul-support switch.
591 AC_MSG_CHECKING([whether PCLMUL support is requested])
592 AC_ARG_ENABLE(pclmul-support,
593 AC_HELP_STRING([--disable-pclmul-support],
594 [Disable support for the Intel PCLMUL instructions]),
595 pclmulsupport=$enableval,pclmulsupport=yes)
596 AC_MSG_RESULT($pclmulsupport)
598 # Implementation of the --disable-sse41-support switch.
599 AC_MSG_CHECKING([whether SSE4.1 support is requested])
600 AC_ARG_ENABLE(sse41-support,
601 AC_HELP_STRING([--disable-sse41-support],
602 [Disable support for the Intel SSE4.1 instructions]),
603 sse41support=$enableval,sse41support=yes)
604 AC_MSG_RESULT($sse41support)
606 # Implementation of the --disable-drng-support switch.
607 AC_MSG_CHECKING([whether DRNG support is requested])
608 AC_ARG_ENABLE(drng-support,
609 AC_HELP_STRING([--disable-drng-support],
610 [Disable support for the Intel DRNG (RDRAND instruction)]),
611 drngsupport=$enableval,drngsupport=yes)
612 AC_MSG_RESULT($drngsupport)
614 # Implementation of the --disable-avx-support switch.
615 AC_MSG_CHECKING([whether AVX support is requested])
616 AC_ARG_ENABLE(avx-support,
617 AC_HELP_STRING([--disable-avx-support],
618 [Disable support for the Intel AVX instructions]),
619 avxsupport=$enableval,avxsupport=yes)
620 AC_MSG_RESULT($avxsupport)
622 # Implementation of the --disable-avx2-support switch.
623 AC_MSG_CHECKING([whether AVX2 support is requested])
624 AC_ARG_ENABLE(avx2-support,
625 AC_HELP_STRING([--disable-avx2-support],
626 [Disable support for the Intel AVX2 instructions]),
627 avx2support=$enableval,avx2support=yes)
628 AC_MSG_RESULT($avx2support)
630 # Implementation of the --disable-neon-support switch.
631 AC_MSG_CHECKING([whether NEON support is requested])
632 AC_ARG_ENABLE(neon-support,
633 AC_HELP_STRING([--disable-neon-support],
634 [Disable support for the ARM NEON instructions]),
635 neonsupport=$enableval,neonsupport=yes)
636 AC_MSG_RESULT($neonsupport)
638 # Implementation of the --disable-arm-crypto-support switch.
639 AC_MSG_CHECKING([whether ARMv8 Crypto Extension support is requested])
640 AC_ARG_ENABLE(arm-crypto-support,
641 AC_HELP_STRING([--disable-arm-crypto-support],
642 [Disable support for the ARMv8 Crypto Extension instructions]),
643 armcryptosupport=$enableval,armcryptosupport=yes)
644 AC_MSG_RESULT($armcryptosupport)
646 # Implementation of the --disable-O-flag-munging switch.
647 AC_MSG_CHECKING([whether a -O flag munging is requested])
648 AC_ARG_ENABLE([O-flag-munging],
649 AC_HELP_STRING([--disable-O-flag-munging],
650 [Disable modification of the cc -O flag]),
651 [enable_o_flag_munging=$enableval],
652 [enable_o_flag_munging=yes])
653 AC_MSG_RESULT($enable_o_flag_munging)
654 AM_CONDITIONAL(ENABLE_O_FLAG_MUNGING, test "$enable_o_flag_munging" = "yes")
656 # Implementation of the --disable-amd64-as-feature-detection switch.
657 AC_MSG_CHECKING([whether to enable AMD64 as(1) feature detection])
658 AC_ARG_ENABLE(amd64-as-feature-detection,
659 AC_HELP_STRING([--disable-amd64-as-feature-detection],
660 [Disable the auto-detection of AMD64 as(1) features]),
661 amd64_as_feature_detection=$enableval,
662 amd64_as_feature_detection=yes)
663 AC_MSG_RESULT($amd64_as_feature_detection)
666 AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
667 [A human readable text with the name of the OS])
669 # For some systems we know that we have ld_version scripts.
670 # Use it then as default.
671 have_ld_version_script=no
674 have_ld_version_script=yes
677 have_ld_version_script=yes
680 AC_ARG_ENABLE([ld-version-script],
681 AC_HELP_STRING([--enable-ld-version-script],
682 [enable/disable use of linker version script.
683 (default is system dependent)]),
684 [have_ld_version_script=$enableval],
686 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
688 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, "$NAME_OF_DEV_RANDOM",
689 [defined to the name of the strong random device])
690 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, "$NAME_OF_DEV_URANDOM",
691 [defined to the name of the weaker random device])
694 ###############################
695 #### Checks for libraries. ####
696 ###############################
699 # gpg-error is required.
701 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION")
702 if test "x$GPG_ERROR_LIBS" = "x"; then
703 AC_MSG_ERROR([libgpg-error is needed.
704 See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ .])
707 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GCRYPT,
708 [The default error source for libgcrypt.])
711 # Check whether the GNU Pth library is available. We require this
712 # to build the optional gcryptrnd program.
714 AC_ARG_WITH(pth-prefix,
715 AC_HELP_STRING([--with-pth-prefix=PFX],
716 [prefix where GNU Pth is installed (optional)]),
717 pth_config_prefix="$withval", pth_config_prefix="")
718 if test x$pth_config_prefix != x ; then
719 PTH_CONFIG="$pth_config_prefix/bin/pth-config"
721 if test "$use_random_daemon" = "yes"; then
722 AC_PATH_PROG(PTH_CONFIG, pth-config, no)
723 if test "$PTH_CONFIG" = "no"; then
726 *** To build the Libgcrypt's random number daemon
727 *** we need the support of the GNU Portable Threads Library.
728 *** Download it from ftp://ftp.gnu.org/gnu/pth/
729 *** On a Debian GNU/Linux system you might want to try
730 *** apt-get install libpth-dev
733 GNUPG_PTH_VERSION_CHECK([1.3.7])
734 if test $have_pth = yes; then
735 PTH_CFLAGS=`$PTH_CONFIG --cflags`
736 PTH_LIBS=`$PTH_CONFIG --ldflags`
737 PTH_LIBS="$PTH_LIBS `$PTH_CONFIG --libs --all`"
738 AC_DEFINE(USE_GNU_PTH, 1,
739 [Defined if the GNU Portable Thread Library should be used])
740 AC_DEFINE(HAVE_PTH, 1,
741 [Defined if the GNU Pth is available])
749 # Check whether pthreads is available
751 if test "$have_w32_system" != yes; then
752 AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
753 if test "$have_pthread" = yes; then
754 AC_DEFINE(HAVE_PTHREAD, 1 ,[Define if we have pthread.])
759 # Solaris needs -lsocket and -lnsl. Unisys system includes
760 # gethostbyname in libsocket but needs libnsl for socket.
761 AC_SEARCH_LIBS(setsockopt, [socket], ,
762 [AC_SEARCH_LIBS(setsockopt, [socket], , , [-lnsl])])
763 AC_SEARCH_LIBS(setsockopt, [nsl])
765 ##################################
766 #### Checks for header files. ####
767 ##################################
770 AC_CHECK_HEADERS(unistd.h sys/select.h sys/msg.h)
772 if test x"$ac_cv_header_sys_select_h" = xyes; then
773 INSERT_SYS_SELECT_H=" include <sys/select.h>"
775 AC_SUBST(INSERT_SYS_SELECT_H)
778 ##########################################
779 #### Checks for typedefs, structures, ####
780 #### and compiler characteristics. ####
781 ##########################################
790 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
791 GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
792 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
793 GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
794 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
799 # socklen_t may or may not be defined depending on what headers
800 # are included. To be safe we use int as this is the actual type.
801 FALLBACK_SOCKLEN_T="typedef int gcry_socklen_t;"
804 if test ".$gl_cv_socklen_t_equiv" = "."; then
805 FALLBACK_SOCKLEN_T="typedef socklen_t gcry_socklen_t;"
807 FALLBACK_SOCKLEN_T="typedef ${gl_cv_socklen_t_equiv} gcry_socklen_t;"
810 AC_SUBST(FALLBACK_SOCKLEN_T)
814 # Check for __builtin_bswap32 intrinsic.
816 AC_CACHE_CHECK(for __builtin_bswap32,
817 [gcry_cv_have_builtin_bswap32],
818 [gcry_cv_have_builtin_bswap32=no
819 AC_LINK_IFELSE([AC_LANG_PROGRAM([],
820 [int x = 0; int y = __builtin_bswap32(x); return y;])],
821 [gcry_cv_have_builtin_bswap32=yes])])
822 if test "$gcry_cv_have_builtin_bswap32" = "yes" ; then
823 AC_DEFINE(HAVE_BUILTIN_BSWAP32,1,
824 [Defined if compiler has '__builtin_bswap32' intrinsic])
829 # Check for __builtin_bswap64 intrinsic.
831 AC_CACHE_CHECK(for __builtin_bswap64,
832 [gcry_cv_have_builtin_bswap64],
833 [gcry_cv_have_builtin_bswap64=no
834 AC_LINK_IFELSE([AC_LANG_PROGRAM([],
835 [long long x = 0; long long y = __builtin_bswap64(x); return y;])],
836 [gcry_cv_have_builtin_bswap64=yes])])
837 if test "$gcry_cv_have_builtin_bswap64" = "yes" ; then
838 AC_DEFINE(HAVE_BUILTIN_BSWAP64,1,
839 [Defined if compiler has '__builtin_bswap64' intrinsic])
844 # Check for __builtin_ctz intrinsic.
846 AC_CACHE_CHECK(for __builtin_ctz,
847 [gcry_cv_have_builtin_ctz],
848 [gcry_cv_have_builtin_ctz=no
849 AC_LINK_IFELSE([AC_LANG_PROGRAM([],
850 [unsigned int x = 0; int y = __builtin_ctz(x); return y;])],
851 [gcry_cv_have_builtin_ctz=yes])])
852 if test "$gcry_cv_have_builtin_ctz" = "yes" ; then
853 AC_DEFINE(HAVE_BUILTIN_CTZ, 1,
854 [Defined if compiler has '__builtin_ctz' intrinsic])
859 # Check for VLA support (variable length arrays).
861 AC_CACHE_CHECK(whether the variable length arrays are supported,
864 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
865 [[void f1(char *, int);
867 char b[(i < 0 ? 0 : i) + 1];
868 f1(b, sizeof b); return b[0];}]])],
869 [gcry_cv_have_vla=yes])])
870 if test "$gcry_cv_have_vla" = "yes" ; then
871 AC_DEFINE(HAVE_VLA,1, [Defined if variable length arrays are supported])
876 # Check for ELF visibility support.
878 AC_CACHE_CHECK(whether the visibility attribute is supported,
879 gcry_cv_visibility_attribute,
880 [gcry_cv_visibility_attribute=no
881 AC_LANG_CONFTEST([AC_LANG_SOURCE(
882 [[int foo __attribute__ ((visibility ("hidden"))) = 1;
883 int bar __attribute__ ((visibility ("protected"))) = 1;
886 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
887 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
888 if grep '\.hidden.*foo' conftest.s >/dev/null 2>&1 ; then
889 if grep '\.protected.*bar' conftest.s >/dev/null 2>&1; then
890 gcry_cv_visibility_attribute=yes
895 if test "$gcry_cv_visibility_attribute" = "yes"; then
896 AC_CACHE_CHECK(for broken visibility attribute,
897 gcry_cv_broken_visibility_attribute,
898 [gcry_cv_broken_visibility_attribute=yes
899 AC_LANG_CONFTEST([AC_LANG_SOURCE(
901 int bar (int x) __asm__ ("foo")
902 __attribute__ ((visibility ("hidden")));
903 int bar (int x) { return x; }
906 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
907 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
908 if grep '\.hidden@<:@ _@:>@foo' conftest.s >/dev/null 2>&1;
910 gcry_cv_broken_visibility_attribute=no
915 if test "$gcry_cv_visibility_attribute" = "yes"; then
916 AC_CACHE_CHECK(for broken alias attribute,
917 gcry_cv_broken_alias_attribute,
918 [gcry_cv_broken_alias_attribute=yes
919 AC_LANG_CONFTEST([AC_LANG_SOURCE(
920 [[extern int foo (int x) __asm ("xyzzy");
921 int bar (int x) { return x; }
922 extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
924 extern __typeof (dfoo) dfoo __asm ("abccb");
928 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
929 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
930 if grep 'xyzzy' conftest.s >/dev/null 2>&1 && \
931 grep 'abccb' conftest.s >/dev/null 2>&1; then
932 gcry_cv_broken_alias_attribute=no
937 if test "$gcry_cv_visibility_attribute" = "yes"; then
938 AC_CACHE_CHECK(if gcc supports -fvisibility=hidden,
939 gcry_cv_gcc_has_f_visibility,
940 [gcry_cv_gcc_has_f_visibility=no
941 _gcc_cflags_save=$CFLAGS
942 CFLAGS="-fvisibility=hidden"
943 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
944 gcry_cv_gcc_has_f_visibility=yes)
945 CFLAGS=$_gcc_cflags_save;
948 if test "$gcry_cv_visibility_attribute" = "yes" \
949 && test "$gcry_cv_broken_visibility_attribute" != "yes" \
950 && test "$gcry_cv_broken_alias_attribute" != "yes" \
951 && test "$gcry_cv_gcc_has_f_visibility" = "yes"
953 AC_DEFINE(GCRY_USE_VISIBILITY, 1,
954 [Define to use the GNU C visibility attribute.])
955 CFLAGS="$CFLAGS -fvisibility=hidden"
959 # Following attribute tests depend on warnings to cause compile to fail,
960 # so set -Werror temporarily.
961 _gcc_cflags_save=$CFLAGS
962 CFLAGS="$CFLAGS -Werror"
966 # Check whether the compiler supports the GCC style aligned attribute
968 AC_CACHE_CHECK([whether the GCC style aligned attribute is supported],
969 [gcry_cv_gcc_attribute_aligned],
970 [gcry_cv_gcc_attribute_aligned=no
971 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
972 [[struct { int a; } foo __attribute__ ((aligned (16)));]])],
973 [gcry_cv_gcc_attribute_aligned=yes])])
974 if test "$gcry_cv_gcc_attribute_aligned" = "yes" ; then
975 AC_DEFINE(HAVE_GCC_ATTRIBUTE_ALIGNED,1,
976 [Defined if a GCC style "__attribute__ ((aligned (n))" is supported])
981 # Check whether the compiler supports the GCC style packed attribute
983 AC_CACHE_CHECK([whether the GCC style packed attribute is supported],
984 [gcry_cv_gcc_attribute_packed],
985 [gcry_cv_gcc_attribute_packed=no
986 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
987 [[struct foolong_s { long b; } __attribute__ ((packed));
988 struct foo_s { char a; struct foolong_s b; }
989 __attribute__ ((packed));
991 FOO = 1 / (sizeof(struct foo_s) == (sizeof(char) + sizeof(long))),
993 [gcry_cv_gcc_attribute_packed=yes])])
994 if test "$gcry_cv_gcc_attribute_packed" = "yes" ; then
995 AC_DEFINE(HAVE_GCC_ATTRIBUTE_PACKED,1,
996 [Defined if a GCC style "__attribute__ ((packed))" is supported])
1001 # Check whether the compiler supports the GCC style may_alias attribute
1003 AC_CACHE_CHECK([whether the GCC style may_alias attribute is supported],
1004 [gcry_cv_gcc_attribute_may_alias],
1005 [gcry_cv_gcc_attribute_may_alias=no
1006 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1007 [[typedef struct foo_s { int a; }
1008 __attribute__ ((may_alias)) foo_t;]])],
1009 [gcry_cv_gcc_attribute_may_alias=yes])])
1010 if test "$gcry_cv_gcc_attribute_may_alias" = "yes" ; then
1011 AC_DEFINE(HAVE_GCC_ATTRIBUTE_MAY_ALIAS,1,
1012 [Defined if a GCC style "__attribute__ ((may_alias))" is supported])
1017 CFLAGS=$_gcc_cflags_save;
1021 # Check whether the compiler supports 'asm' or '__asm__' keyword for
1024 AC_CACHE_CHECK([whether 'asm' assembler keyword is supported],
1026 [gcry_cv_have_asm=no
1027 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1028 [[void a(void) { asm("":::"memory"); }]])],
1029 [gcry_cv_have_asm=yes])])
1030 AC_CACHE_CHECK([whether '__asm__' assembler keyword is supported],
1031 [gcry_cv_have___asm__],
1032 [gcry_cv_have___asm__=no
1033 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1034 [[void a(void) { __asm__("":::"memory"); }]])],
1035 [gcry_cv_have___asm__=yes])])
1036 if test "$gcry_cv_have_asm" = "no" ; then
1037 if test "$gcry_cv_have___asm__" = "yes" ; then
1038 AC_DEFINE(asm,__asm__,
1039 [Define to supported assembler block keyword, if plain 'asm' was not
1046 # Check whether the compiler supports inline assembly memory barrier.
1048 if test "$gcry_cv_have_asm" = "no" ; then
1049 if test "$gcry_cv_have___asm__" = "yes" ; then
1050 AC_CACHE_CHECK([whether inline assembly memory barrier is supported],
1051 [gcry_cv_have_asm_volatile_memory],
1052 [gcry_cv_have_asm_volatile_memory=no
1053 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1054 [[void a(void) { __asm__ volatile("":::"memory"); }]])],
1055 [gcry_cv_have_asm_volatile_memory=yes])])
1058 AC_CACHE_CHECK([whether inline assembly memory barrier is supported],
1059 [gcry_cv_have_asm_volatile_memory],
1060 [gcry_cv_have_asm_volatile_memory=no
1061 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1062 [[void a(void) { asm volatile("":::"memory"); }]])],
1063 [gcry_cv_have_asm_volatile_memory=yes])])
1065 if test "$gcry_cv_have_asm_volatile_memory" = "yes" ; then
1066 AC_DEFINE(HAVE_GCC_ASM_VOLATILE_MEMORY,1,
1067 [Define if inline asm memory barrier is supported])
1072 # Check whether GCC assembler supports features needed for our ARM
1073 # implementations. This needs to be done before setting up the
1076 AC_CACHE_CHECK([whether GCC assembler is compatible for ARM assembly implementations],
1077 [gcry_cv_gcc_arm_platform_as_ok],
1078 [gcry_cv_gcc_arm_platform_as_ok=no
1079 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1081 /* Test if assembler supports UAL syntax. */
1082 ".syntax unified\n\t"
1083 ".arm\n\t" /* our assembly code is in ARM mode */
1084 /* Following causes error if assembler ignored '.syntax unified'. */
1086 "add %r0, %r0, %r4, ror #12;\n\t"
1088 /* Test if '.type' and '.size' are supported. */
1089 ".size asmfunc,.-asmfunc;\n\t"
1090 ".type asmfunc,%function;\n\t"
1092 [gcry_cv_gcc_arm_platform_as_ok=yes])])
1093 if test "$gcry_cv_gcc_arm_platform_as_ok" = "yes" ; then
1094 AC_DEFINE(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS,1,
1095 [Defined if underlying assembler is compatible with ARM assembly implementations])
1100 # Check whether GCC assembler supports features needed for our ARMv8/Aarch64
1101 # implementations. This needs to be done before setting up the
1104 AC_CACHE_CHECK([whether GCC assembler is compatible for ARMv8/Aarch64 assembly implementations],
1105 [gcry_cv_gcc_aarch64_platform_as_ok],
1106 [gcry_cv_gcc_aarch64_platform_as_ok=no
1107 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1110 "eor x0, x0, x30, ror #12;\n\t"
1111 "add x0, x0, x30, asr #12;\n\t"
1112 "eor v0.16b, v0.16b, v31.16b;\n\t"
1114 /* Test if '.type' and '.size' are supported. */
1115 ".size asmfunc,.-asmfunc;\n\t"
1116 ".type asmfunc,@function;\n\t"
1118 [gcry_cv_gcc_aarch64_platform_as_ok=yes])])
1119 if test "$gcry_cv_gcc_aarch64_platform_as_ok" = "yes" ; then
1120 AC_DEFINE(HAVE_COMPATIBLE_GCC_AARCH64_PLATFORM_AS,1,
1121 [Defined if underlying assembler is compatible with ARMv8/Aarch64 assembly implementations])
1126 # Check whether underscores in symbols are required. This needs to be
1127 # done before setting up the assembler stuff.
1129 GNUPG_SYS_SYMBOL_UNDERSCORE()
1132 #################################
1134 #### Setup assembler stuff. ####
1135 #### Define mpi_cpu_arch. ####
1137 #################################
1138 AC_ARG_ENABLE(mpi-path,
1139 AC_HELP_STRING([--enable-mpi-path=EXTRA_PATH],
1140 [prepend EXTRA_PATH to list of CPU specific optimizations]),
1141 mpi_extra_path="$enableval",mpi_extra_path="")
1142 AC_MSG_CHECKING(architecture and mpi assembler functions)
1143 if test -f $srcdir/mpi/config.links ; then
1144 . $srcdir/mpi/config.links
1145 AC_CONFIG_LINKS("$mpi_ln_list")
1146 ac_cv_mpi_sflags="$mpi_sflags"
1147 AC_MSG_RESULT($mpi_cpu_arch)
1149 AC_MSG_RESULT(failed)
1150 AC_MSG_ERROR([mpi/config.links missing!])
1152 MPI_SFLAGS="$ac_cv_mpi_sflags"
1153 AC_SUBST(MPI_SFLAGS)
1155 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_ADD1, test "$mpi_mod_asm_mpih_add1" = yes)
1156 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_SUB1, test "$mpi_mod_asm_mpih_sub1" = yes)
1157 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL1, test "$mpi_mod_asm_mpih_mul1" = yes)
1158 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL2, test "$mpi_mod_asm_mpih_mul2" = yes)
1159 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL3, test "$mpi_mod_asm_mpih_mul3" = yes)
1160 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_LSHIFT, test "$mpi_mod_asm_mpih_lshift" = yes)
1161 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_RSHIFT, test "$mpi_mod_asm_mpih_rshift" = yes)
1162 AM_CONDITIONAL(MPI_MOD_ASM_UDIV, test "$mpi_mod_asm_udiv" = yes)
1163 AM_CONDITIONAL(MPI_MOD_ASM_UDIV_QRNND, test "$mpi_mod_asm_udiv_qrnnd" = yes)
1164 AM_CONDITIONAL(MPI_MOD_C_MPIH_ADD1, test "$mpi_mod_c_mpih_add1" = yes)
1165 AM_CONDITIONAL(MPI_MOD_C_MPIH_SUB1, test "$mpi_mod_c_mpih_sub1" = yes)
1166 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL1, test "$mpi_mod_c_mpih_mul1" = yes)
1167 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL2, test "$mpi_mod_c_mpih_mul2" = yes)
1168 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL3, test "$mpi_mod_c_mpih_mul3" = yes)
1169 AM_CONDITIONAL(MPI_MOD_C_MPIH_LSHIFT, test "$mpi_mod_c_mpih_lshift" = yes)
1170 AM_CONDITIONAL(MPI_MOD_C_MPIH_RSHIFT, test "$mpi_mod_c_mpih_rshift" = yes)
1171 AM_CONDITIONAL(MPI_MOD_C_UDIV, test "$mpi_mod_c_udiv" = yes)
1172 AM_CONDITIONAL(MPI_MOD_C_UDIV_QRNND, test "$mpi_mod_c_udiv_qrnnd" = yes)
1174 # Reset non applicable feature flags.
1175 if test "$mpi_cpu_arch" != "x86" ; then
1181 padlocksupport="n/a"
1186 if test "$mpi_cpu_arch" != "arm" ; then
1187 if test "$mpi_cpu_arch" != "aarch64" ; then
1189 armcryptosupport="n/a"
1194 #############################################
1196 #### Platform specific compiler checks. ####
1198 #############################################
1201 # Following tests depend on warnings to cause compile to fail, so set -Werror
1203 _gcc_cflags_save=$CFLAGS
1204 CFLAGS="$CFLAGS -Werror"
1208 # Check whether compiler supports 'ms_abi' function attribute.
1210 AC_CACHE_CHECK([whether compiler supports 'ms_abi' function attribute],
1211 [gcry_cv_gcc_attribute_ms_abi],
1212 [gcry_cv_gcc_attribute_ms_abi=no
1213 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1214 [[int __attribute__ ((ms_abi)) proto(int);]])],
1215 [gcry_cv_gcc_attribute_ms_abi=yes])])
1216 if test "$gcry_cv_gcc_attribute_ms_abi" = "yes" ; then
1217 AC_DEFINE(HAVE_GCC_ATTRIBUTE_MS_ABI,1,
1218 [Defined if compiler supports "__attribute__ ((ms_abi))" function attribute])
1223 # Check whether compiler supports 'sysv_abi' function attribute.
1225 AC_CACHE_CHECK([whether compiler supports 'sysv_abi' function attribute],
1226 [gcry_cv_gcc_attribute_sysv_abi],
1227 [gcry_cv_gcc_attribute_sysv_abi=no
1228 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1229 [[int __attribute__ ((sysv_abi)) proto(int);]])],
1230 [gcry_cv_gcc_attribute_sysv_abi=yes])])
1231 if test "$gcry_cv_gcc_attribute_sysv_abi" = "yes" ; then
1232 AC_DEFINE(HAVE_GCC_ATTRIBUTE_SYSV_ABI,1,
1233 [Defined if compiler supports "__attribute__ ((sysv_abi))" function attribute])
1238 # Check whether default calling convention is 'ms_abi'.
1240 if test "$gcry_cv_gcc_attribute_ms_abi" = "yes" ; then
1241 AC_CACHE_CHECK([whether default calling convention is 'ms_abi'],
1242 [gcry_cv_gcc_default_abi_is_ms_abi],
1243 [gcry_cv_gcc_default_abi_is_ms_abi=no
1244 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1245 [[void *test(void) {
1246 void *(*def_func)(void) = test;
1247 void *__attribute__((ms_abi))(*msabi_func)(void);
1248 /* warning on SysV abi targets, passes on Windows based targets */
1249 msabi_func = def_func;
1252 [gcry_cv_gcc_default_abi_is_ms_abi=yes])])
1253 if test "$gcry_cv_gcc_default_abi_is_ms_abi" = "yes" ; then
1254 AC_DEFINE(HAVE_GCC_DEFAULT_ABI_IS_MS_ABI,1,
1255 [Defined if default calling convention is 'ms_abi'])
1261 # Check whether default calling convention is 'sysv_abi'.
1263 if test "$gcry_cv_gcc_attribute_sysv_abi" = "yes" ; then
1264 AC_CACHE_CHECK([whether default calling convention is 'sysv_abi'],
1265 [gcry_cv_gcc_default_abi_is_sysv_abi],
1266 [gcry_cv_gcc_default_abi_is_sysv_abi=no
1267 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1268 [[void *test(void) {
1269 void *(*def_func)(void) = test;
1270 void *__attribute__((sysv_abi))(*sysvabi_func)(void);
1271 /* warning on MS ABI targets, passes on SysV ABI targets */
1272 sysvabi_func = def_func;
1273 return sysvabi_func;
1275 [gcry_cv_gcc_default_abi_is_sysv_abi=yes])])
1276 if test "$gcry_cv_gcc_default_abi_is_sysv_abi" = "yes" ; then
1277 AC_DEFINE(HAVE_GCC_DEFAULT_ABI_IS_SYSV_ABI,1,
1278 [Defined if default calling convention is 'sysv_abi'])
1284 CFLAGS=$_gcc_cflags_save;
1288 # Check whether GCC inline assembler supports SSSE3 instructions
1289 # This is required for the AES-NI instructions.
1291 AC_CACHE_CHECK([whether GCC inline assembler supports SSSE3 instructions],
1292 [gcry_cv_gcc_inline_asm_ssse3],
1293 [if test "$mpi_cpu_arch" != "x86" ; then
1294 gcry_cv_gcc_inline_asm_ssse3="n/a"
1296 gcry_cv_gcc_inline_asm_ssse3=no
1297 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1298 [[static unsigned char be_mask[16] __attribute__ ((aligned (16))) =
1299 { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
1301 __asm__("pshufb %[mask], %%xmm2\n\t"::[mask]"m"(*be_mask):);
1303 [gcry_cv_gcc_inline_asm_ssse3=yes])
1305 if test "$gcry_cv_gcc_inline_asm_ssse3" = "yes" ; then
1306 AC_DEFINE(HAVE_GCC_INLINE_ASM_SSSE3,1,
1307 [Defined if inline assembler supports SSSE3 instructions])
1312 # Check whether GCC inline assembler supports PCLMUL instructions.
1314 AC_CACHE_CHECK([whether GCC inline assembler supports PCLMUL instructions],
1315 [gcry_cv_gcc_inline_asm_pclmul],
1316 [if test "$mpi_cpu_arch" != "x86" ; then
1317 gcry_cv_gcc_inline_asm_pclmul="n/a"
1319 gcry_cv_gcc_inline_asm_pclmul=no
1320 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1322 __asm__("pclmulqdq \$0, %%xmm1, %%xmm3\n\t":::"cc");
1324 [gcry_cv_gcc_inline_asm_pclmul=yes])
1326 if test "$gcry_cv_gcc_inline_asm_pclmul" = "yes" ; then
1327 AC_DEFINE(HAVE_GCC_INLINE_ASM_PCLMUL,1,
1328 [Defined if inline assembler supports PCLMUL instructions])
1332 # Check whether GCC inline assembler supports SSE4.1 instructions.
1334 AC_CACHE_CHECK([whether GCC inline assembler supports SSE4.1 instructions],
1335 [gcry_cv_gcc_inline_asm_sse41],
1336 [if test "$mpi_cpu_arch" != "x86" ; then
1337 gcry_cv_gcc_inline_asm_sse41="n/a"
1339 gcry_cv_gcc_inline_asm_sse41=no
1340 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1343 __asm__("pextrd \$2, %%xmm0, %[out]\n\t" : [out] "=m" (i));
1345 [gcry_cv_gcc_inline_asm_sse41=yes])
1347 if test "$gcry_cv_gcc_inline_asm_sse41" = "yes" ; then
1348 AC_DEFINE(HAVE_GCC_INLINE_ASM_SSE41,1,
1349 [Defined if inline assembler supports SSE4.1 instructions])
1354 # Check whether GCC inline assembler supports AVX instructions
1356 AC_CACHE_CHECK([whether GCC inline assembler supports AVX instructions],
1357 [gcry_cv_gcc_inline_asm_avx],
1358 [if test "$mpi_cpu_arch" != "x86" ; then
1359 gcry_cv_gcc_inline_asm_avx="n/a"
1361 gcry_cv_gcc_inline_asm_avx=no
1362 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1364 __asm__("xgetbv; vaesdeclast (%[mem]),%%xmm0,%%xmm7\n\t"::[mem]"r"(0):);
1366 [gcry_cv_gcc_inline_asm_avx=yes])
1368 if test "$gcry_cv_gcc_inline_asm_avx" = "yes" ; then
1369 AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX,1,
1370 [Defined if inline assembler supports AVX instructions])
1375 # Check whether GCC inline assembler supports AVX2 instructions
1377 AC_CACHE_CHECK([whether GCC inline assembler supports AVX2 instructions],
1378 [gcry_cv_gcc_inline_asm_avx2],
1379 [if test "$mpi_cpu_arch" != "x86" ; then
1380 gcry_cv_gcc_inline_asm_avx2="n/a"
1382 gcry_cv_gcc_inline_asm_avx2=no
1383 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1385 __asm__("xgetbv; vpbroadcastb %%xmm7,%%ymm1\n\t":::"cc");
1387 [gcry_cv_gcc_inline_asm_avx2=yes])
1389 if test "$gcry_cv_gcc_inline_asm_avx2" = "yes" ; then
1390 AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX2,1,
1391 [Defined if inline assembler supports AVX2 instructions])
1396 # Check whether GCC inline assembler supports BMI2 instructions
1398 AC_CACHE_CHECK([whether GCC inline assembler supports BMI2 instructions],
1399 [gcry_cv_gcc_inline_asm_bmi2],
1400 [if test "$mpi_cpu_arch" != "x86" ; then
1401 gcry_cv_gcc_inline_asm_bmi2="n/a"
1403 gcry_cv_gcc_inline_asm_bmi2=no
1404 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1405 [[unsigned int a(unsigned int x, unsigned int y) {
1406 unsigned int tmp1, tmp2;
1407 asm ("rorxl %2, %1, %0"
1409 : "rm0" (x), "J" (32 - ((23) & 31)));
1410 asm ("andnl %2, %1, %0"
1412 : "r0" (x), "rm" (y));
1415 [gcry_cv_gcc_inline_asm_bmi2=yes])
1417 if test "$gcry_cv_gcc_inline_asm_bmi2" = "yes" ; then
1418 AC_DEFINE(HAVE_GCC_INLINE_ASM_BMI2,1,
1419 [Defined if inline assembler supports BMI2 instructions])
1424 # Check whether GCC assembler needs "-Wa,--divide" to correctly handle
1427 if test $amd64_as_feature_detection = yes; then
1428 AC_CACHE_CHECK([whether GCC assembler handles division correctly],
1429 [gcry_cv_gcc_as_const_division_ok],
1430 [gcry_cv_gcc_as_const_division_ok=no
1431 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1432 [[__asm__("xorl \$(123456789/12345678), %ebp;\n\t");]])],
1433 [gcry_cv_gcc_as_const_division_ok=yes])])
1434 if test "$gcry_cv_gcc_as_const_division_ok" = "no" ; then
1436 # Add '-Wa,--divide' to CPPFLAGS and try check again.
1438 _gcc_cppflags_save="$CPPFLAGS"
1439 CPPFLAGS="$CPPFLAGS -Wa,--divide"
1440 AC_CACHE_CHECK([whether GCC assembler handles division correctly with "-Wa,--divide"],
1441 [gcry_cv_gcc_as_const_division_with_wadivide_ok],
1442 [gcry_cv_gcc_as_const_division_with_wadivide_ok=no
1443 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1444 [[__asm__("xorl \$(123456789/12345678), %ebp;\n\t");]])],
1445 [gcry_cv_gcc_as_const_division_with_wadivide_ok=yes])])
1446 if test "$gcry_cv_gcc_as_const_division_with_wadivide_ok" = "no" ; then
1447 # '-Wa,--divide' did not work, restore old flags.
1448 CPPFLAGS="$_gcc_cppflags_save"
1455 # Check whether GCC assembler supports features needed for our amd64
1458 if test $amd64_as_feature_detection = yes; then
1459 AC_CACHE_CHECK([whether GCC assembler is compatible for amd64 assembly implementations],
1460 [gcry_cv_gcc_amd64_platform_as_ok],
1461 [if test "$mpi_cpu_arch" != "x86" ; then
1462 gcry_cv_gcc_amd64_platform_as_ok="n/a"
1464 gcry_cv_gcc_amd64_platform_as_ok=no
1465 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1467 /* Test if '.type' and '.size' are supported. */
1468 /* These work only on ELF targets. */
1470 ".size asmfunc,.-asmfunc;\n\t"
1471 ".type asmfunc,@function;\n\t"
1472 /* Test if assembler allows use of '/' for constant division
1473 * (Solaris/x86 issue). If previous constant division check
1474 * and "-Wa,--divide" workaround failed, this causes assembly
1475 * to be disable on this machine. */
1476 "xorl \$(123456789/12345678), %ebp;\n\t"
1478 [gcry_cv_gcc_amd64_platform_as_ok=yes])
1480 if test "$gcry_cv_gcc_amd64_platform_as_ok" = "yes" ; then
1481 AC_DEFINE(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS,1,
1482 [Defined if underlying assembler is compatible with amd64 assembly implementations])
1484 if test "$gcry_cv_gcc_amd64_platform_as_ok" = "no" &&
1485 test "$gcry_cv_gcc_attribute_sysv_abi" = "yes" &&
1486 test "$gcry_cv_gcc_default_abi_is_ms_abi" = "yes"; then
1487 AC_CACHE_CHECK([whether GCC assembler is compatible for WIN64 assembly implementations],
1488 [gcry_cv_gcc_win64_platform_as_ok],
1489 [gcry_cv_gcc_win64_platform_as_ok=no
1490 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1492 ".globl asmfunc\n\t"
1494 "xorq \$(1234), %rbp;\n\t"
1496 [gcry_cv_gcc_win64_platform_as_ok=yes])])
1497 if test "$gcry_cv_gcc_win64_platform_as_ok" = "yes" ; then
1498 AC_DEFINE(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS,1,
1499 [Defined if underlying assembler is compatible with WIN64 assembly implementations])
1506 # Check whether GCC assembler supports features needed for assembly
1507 # implementations that use Intel syntax
1509 AC_CACHE_CHECK([whether GCC assembler is compatible for Intel syntax assembly implementations],
1510 [gcry_cv_gcc_platform_as_ok_for_intel_syntax],
1511 [if test "$mpi_cpu_arch" != "x86" ; then
1512 gcry_cv_gcc_platform_as_ok_for_intel_syntax="n/a"
1514 gcry_cv_gcc_platform_as_ok_for_intel_syntax=no
1515 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1517 ".intel_syntax noprefix\n\t"
1518 "pxor xmm1, xmm7;\n\t"
1519 /* Intel syntax implementation also use GAS macros, so check
1523 ".macro SET_VAL_A p1\n\t"
1524 " VAL_A = \\\\p1 \n\t"
1526 ".macro SET_VAL_B p1\n\t"
1527 " VAL_B = \\\\p1 \n\t"
1529 "vmovdqa VAL_A, VAL_B;\n\t"
1532 "add VAL_A, VAL_B;\n\t"
1533 "add VAL_B, 0b10101;\n\t"
1535 [gcry_cv_gcc_platform_as_ok_for_intel_syntax=yes])
1537 if test "$gcry_cv_gcc_platform_as_ok_for_intel_syntax" = "yes" ; then
1538 AC_DEFINE(HAVE_INTEL_SYNTAX_PLATFORM_AS,1,
1539 [Defined if underlying assembler is compatible with Intel syntax assembly implementations])
1544 # Check whether compiler is configured for ARMv6 or newer architecture
1546 AC_CACHE_CHECK([whether compiler is configured for ARMv6 or newer architecture],
1547 [gcry_cv_cc_arm_arch_is_v6],
1548 [if test "$mpi_cpu_arch" != "arm" ; then
1549 gcry_cv_cc_arm_arch_is_v6="n/a"
1551 gcry_cv_cc_arm_arch_is_v6=no
1552 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1554 #if defined(__arm__) && \
1555 ((defined(__ARM_ARCH) && __ARM_ARCH >= 6) \
1556 || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
1557 || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \
1558 || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) \
1559 || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
1560 || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
1561 || defined(__ARM_ARCH_7EM__))
1564 /* fail compile if not ARMv6. */
1565 not_armv6 not_armv6 = (not_armv6)not_armv6;
1568 [gcry_cv_cc_arm_arch_is_v6=yes])
1570 if test "$gcry_cv_cc_arm_arch_is_v6" = "yes" ; then
1571 AC_DEFINE(HAVE_ARM_ARCH_V6,1,
1572 [Defined if ARM architecture is v6 or newer])
1577 # Check whether GCC inline assembler supports NEON instructions
1579 AC_CACHE_CHECK([whether GCC inline assembler supports NEON instructions],
1580 [gcry_cv_gcc_inline_asm_neon],
1581 [if test "$mpi_cpu_arch" != "arm" ; then
1582 gcry_cv_gcc_inline_asm_neon="n/a"
1584 gcry_cv_gcc_inline_asm_neon=no
1585 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1587 ".syntax unified\n\t"
1590 "vld1.64 {%q0-%q1}, [%r0]!;\n\t"
1591 "vrev64.8 %q0, %q3;\n\t"
1592 "vadd.u64 %q0, %q1;\n\t"
1593 "vadd.s64 %d3, %d2, %d3;\n\t"
1596 [gcry_cv_gcc_inline_asm_neon=yes])
1598 if test "$gcry_cv_gcc_inline_asm_neon" = "yes" ; then
1599 AC_DEFINE(HAVE_GCC_INLINE_ASM_NEON,1,
1600 [Defined if inline assembler supports NEON instructions])
1605 # Check whether GCC inline assembler supports AArch32 Crypto Extension instructions
1607 AC_CACHE_CHECK([whether GCC inline assembler supports AArch32 Crypto Extension instructions],
1608 [gcry_cv_gcc_inline_asm_aarch32_crypto],
1609 [if test "$mpi_cpu_arch" != "arm" ; then
1610 gcry_cv_gcc_inline_asm_aarch32_crypto="n/a"
1612 gcry_cv_gcc_inline_asm_aarch32_crypto=no
1613 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1615 ".syntax unified\n\t"
1618 ".fpu crypto-neon-fp-armv8\n\t"
1620 "sha1h.32 q0, q0;\n\t"
1621 "sha1c.32 q0, q0, q0;\n\t"
1622 "sha1p.32 q0, q0, q0;\n\t"
1623 "sha1su0.32 q0, q0, q0;\n\t"
1624 "sha1su1.32 q0, q0;\n\t"
1626 "sha256h.32 q0, q0, q0;\n\t"
1627 "sha256h2.32 q0, q0, q0;\n\t"
1628 "sha1p.32 q0, q0, q0;\n\t"
1629 "sha256su0.32 q0, q0;\n\t"
1630 "sha256su1.32 q0, q0, q15;\n\t"
1632 "aese.8 q0, q0;\n\t"
1633 "aesd.8 q0, q0;\n\t"
1634 "aesmc.8 q0, q0;\n\t"
1635 "aesimc.8 q0, q0;\n\t"
1637 "vmull.p64 q0, d0, d0;\n\t"
1640 [gcry_cv_gcc_inline_asm_aarch32_crypto=yes])
1642 if test "$gcry_cv_gcc_inline_asm_aarch32_crypto" = "yes" ; then
1643 AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH32_CRYPTO,1,
1644 [Defined if inline assembler supports AArch32 Crypto Extension instructions])
1649 # Check whether GCC inline assembler supports AArch64 NEON instructions
1651 AC_CACHE_CHECK([whether GCC inline assembler supports AArch64 NEON instructions],
1652 [gcry_cv_gcc_inline_asm_aarch64_neon],
1653 [if test "$mpi_cpu_arch" != "aarch64" ; then
1654 gcry_cv_gcc_inline_asm_aarch64_neon="n/a"
1656 gcry_cv_gcc_inline_asm_aarch64_neon=no
1657 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1659 ".cpu generic+simd\n\t"
1661 "dup v0.8b, w0;\n\t"
1662 "ld4 {v0.8b,v1.8b,v2.8b,v3.8b},[x0],\#32;\n\t"
1665 [gcry_cv_gcc_inline_asm_aarch64_neon=yes])
1667 if test "$gcry_cv_gcc_inline_asm_aarch64_neon" = "yes" ; then
1668 AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH64_NEON,1,
1669 [Defined if inline assembler supports AArch64 NEON instructions])
1674 # Check whether GCC inline assembler supports AArch64 Crypto Extension instructions
1676 AC_CACHE_CHECK([whether GCC inline assembler supports AArch64 Crypto Extension instructions],
1677 [gcry_cv_gcc_inline_asm_aarch64_crypto],
1678 [if test "$mpi_cpu_arch" != "aarch64" ; then
1679 gcry_cv_gcc_inline_asm_aarch64_crypto="n/a"
1681 gcry_cv_gcc_inline_asm_aarch64_crypto=no
1682 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1684 ".cpu generic+simd+crypto\n\t"
1687 "dup v0.8b, w0;\n\t"
1688 "ld4 {v0.8b,v1.8b,v2.8b,v3.8b},[x0],\#32;\n\t"
1691 "sha1c q0, s0, v0.4s;\n\t"
1692 "sha1p q0, s0, v0.4s;\n\t"
1693 "sha1su0 v0.4s, v0.4s, v0.4s;\n\t"
1694 "sha1su1 v0.4s, v0.4s;\n\t"
1696 "sha256h q0, q0, v0.4s;\n\t"
1697 "sha256h2 q0, q0, v0.4s;\n\t"
1698 "sha1p q0, s0, v0.4s;\n\t"
1699 "sha256su0 v0.4s, v0.4s;\n\t"
1700 "sha256su1 v0.4s, v0.4s, v31.4s;\n\t"
1702 "aese v0.16b, v0.16b;\n\t"
1703 "aesd v0.16b, v0.16b;\n\t"
1704 "aesmc v0.16b, v0.16b;\n\t"
1705 "aesimc v0.16b, v0.16b;\n\t"
1707 "pmull v0.1q, v0.1d, v31.1d;\n\t"
1708 "pmull2 v0.1q, v0.2d, v31.2d;\n\t"
1711 [gcry_cv_gcc_inline_asm_aarch64_crypto=yes])
1713 if test "$gcry_cv_gcc_inline_asm_aarch64_crypto" = "yes" ; then
1714 AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH64_CRYPTO,1,
1715 [Defined if inline assembler supports AArch64 Crypto Extension instructions])
1719 #######################################
1720 #### Checks for library functions. ####
1721 #######################################
1724 # We have replacements for these in src/missing-string.c
1725 AC_CHECK_FUNCS(stpcpy strcasecmp)
1726 # We have replacements for these in src/g10lib.h
1727 AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise)
1729 AC_CHECK_FUNCS(strerror rand mmap getpagesize sysconf waitpid wait4)
1730 AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime syslog)
1731 AC_CHECK_FUNCS(syscall fcntl ftruncate flockfile)
1736 # Replacement functions.
1738 AC_REPLACE_FUNCS([getpid clock])
1742 # Check whether it is necessary to link against libdl.
1745 if test "$use_hmac_binary_check" = yes ; then
1746 _gcry_save_libs="$LIBS"
1748 AC_SEARCH_LIBS(dlopen, c dl,,,)
1750 LIBS="$_gcry_save_libs"
1751 LIBGCRYPT_CONFIG_LIBS="${LIBGCRYPT_CONFIG_LIBS} ${DL_LIBS}"
1757 # Check whether we can use Linux capabilities as requested.
1759 if test "$use_capabilities" = "yes" ; then
1761 AC_CHECK_HEADERS(sys/capability.h)
1762 if test "$ac_cv_header_sys_capability_h" = "yes" ; then
1763 AC_CHECK_LIB(cap, cap_init, ac_need_libcap=1)
1764 if test "$ac_cv_lib_cap_cap_init" = "yes"; then
1765 AC_DEFINE(USE_CAPABILITIES,1,
1766 [define if capabilities should be used])
1768 use_capabilities=yes
1771 if test "$use_capabilities" = "no" ; then
1774 *** The use of capabilities on this system is not possible.
1775 *** You need a recent Linux kernel and some patches:
1776 *** fcaps-2.2.9-990610.patch (kernel patch for 2.2.9)
1777 *** fcap-module-990613.tar.gz (kernel module)
1778 *** libcap-1.92.tar.gz (user mode library and utilities)
1779 *** And you have to configure the kernel with CONFIG_VFS_CAP_PLUGIN
1780 *** set (filesystems menu). Be warned: This code is *really* ALPHA.
1785 # Check whether a random device is available.
1786 if test "$try_dev_random" = yes ; then
1787 AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
1788 [if test -r "$NAME_OF_DEV_RANDOM" && test -r "$NAME_OF_DEV_URANDOM" ; then
1789 ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
1790 if test "$ac_cv_have_dev_random" = yes; then
1791 AC_DEFINE(HAVE_DEV_RANDOM,1,
1792 [defined if the system supports a random device] )
1795 AC_MSG_CHECKING(for random device)
1796 ac_cv_have_dev_random=no
1797 AC_MSG_RESULT(has been disabled)
1800 # Figure out the random modules for this configuration.
1801 if test "$random" = "default"; then
1803 # Select default value.
1804 if test "$ac_cv_have_dev_random" = yes; then
1805 # Try Linuxish random device.
1806 random_modules="linux"
1810 # WindowsCE random device.
1811 random_modules="w32ce"
1813 *-*-mingw32*|*-*-cygwin*)
1814 # Windows random device.
1815 random_modules="w32"
1818 # Build everything, allow to select at runtime.
1819 random_modules="$auto_random_modules"
1824 if test "$random" = "auto"; then
1825 # Build everything, allow to select at runtime.
1826 random_modules="$auto_random_modules"
1828 random_modules="$random"
1836 if test mym4_isgit = "yes"; then
1837 AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
1838 [Defined if this is not a regular release])
1842 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
1845 # This is handy for debugging so the compiler doesn't rearrange
1846 # things and eliminate variables.
1847 AC_ARG_ENABLE(optimization,
1848 AC_HELP_STRING([--disable-optimization],
1849 [disable compiler optimization]),
1850 [if test $enableval = no ; then
1851 CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
1854 AC_MSG_NOTICE([checking for cc features])
1855 # CFLAGS mangling when using gcc.
1856 if test "$GCC" = yes; then
1857 AC_MSG_CHECKING([if gcc supports -fno-delete-null-pointer-checks])
1858 _gcc_cflags_save=$CFLAGS
1859 CFLAGS="-fno-delete-null-pointer-checks"
1860 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
1861 AC_MSG_RESULT($_gcc_wopt)
1862 CFLAGS=$_gcc_cflags_save;
1863 if test x"$_gcc_wopt" = xyes ; then
1864 CFLAGS="$CFLAGS -fno-delete-null-pointer-checks"
1867 CFLAGS="$CFLAGS -Wall"
1868 if test "$USE_MAINTAINER_MODE" = "yes"; then
1869 CFLAGS="$CFLAGS -Wcast-align -Wshadow -Wstrict-prototypes"
1870 CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
1872 # If -Wno-missing-field-initializers is supported we can enable a
1873 # a bunch of really useful warnings.
1874 AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
1875 _gcc_cflags_save=$CFLAGS
1876 CFLAGS="-Wno-missing-field-initializers"
1877 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
1878 AC_MSG_RESULT($_gcc_wopt)
1879 CFLAGS=$_gcc_cflags_save;
1880 if test x"$_gcc_wopt" = xyes ; then
1881 CFLAGS="$CFLAGS -W -Wextra -Wbad-function-cast"
1882 CFLAGS="$CFLAGS -Wwrite-strings"
1883 CFLAGS="$CFLAGS -Wdeclaration-after-statement"
1884 CFLAGS="$CFLAGS -Wno-missing-field-initializers"
1885 CFLAGS="$CFLAGS -Wno-sign-compare"
1888 AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
1889 _gcc_cflags_save=$CFLAGS
1890 CFLAGS="-Wpointer-arith"
1891 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
1892 AC_MSG_RESULT($_gcc_wopt)
1893 CFLAGS=$_gcc_cflags_save;
1894 if test x"$_gcc_wopt" = xyes ; then
1895 CFLAGS="$CFLAGS -Wpointer-arith"
1900 # Check whether as(1) supports a noeexecstack feature. This test
1901 # includes an override option.
1905 AC_SUBST(LIBGCRYPT_CONFIG_API_VERSION)
1906 AC_SUBST(LIBGCRYPT_CONFIG_LIBS)
1907 AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS)
1908 AC_SUBST(LIBGCRYPT_CONFIG_HOST)
1909 AC_SUBST(LIBGCRYPT_THREAD_MODULES)
1911 AC_CONFIG_COMMANDS([gcrypt-conf],[[
1912 chmod +x src/libgcrypt-config
1915 exec_prefix=$exec_prefix
1918 DATADIRNAME=$DATADIRNAME
1921 #####################
1922 #### Conclusion. ####
1923 #####################
1925 # Check that requested feature can actually be used and define
1926 # ENABLE_foo_SUPPORT macros.
1928 if test x"$aesnisupport" = xyes ; then
1929 if test "$gcry_cv_gcc_inline_asm_ssse3" != "yes" ; then
1930 aesnisupport="no (unsupported by compiler)"
1933 if test x"$pclmulsupport" = xyes ; then
1934 if test "$gcry_cv_gcc_inline_asm_pclmul" != "yes" ; then
1935 pclmulsupport="no (unsupported by compiler)"
1938 if test x"$sse41support" = xyes ; then
1939 if test "$gcry_cv_gcc_inline_asm_sse41" != "yes" ; then
1940 sse41support="no (unsupported by compiler)"
1943 if test x"$avxsupport" = xyes ; then
1944 if test "$gcry_cv_gcc_inline_asm_avx" != "yes" ; then
1945 avxsupport="no (unsupported by compiler)"
1948 if test x"$avx2support" = xyes ; then
1949 if test "$gcry_cv_gcc_inline_asm_avx2" != "yes" ; then
1950 avx2support="no (unsupported by compiler)"
1953 if test x"$neonsupport" = xyes ; then
1954 if test "$gcry_cv_gcc_inline_asm_neon" != "yes" ; then
1955 if test "$gcry_cv_gcc_inline_asm_aarch64_neon" != "yes" ; then
1956 neonsupport="no (unsupported by compiler)"
1960 if test x"$armcryptosupport" = xyes ; then
1961 if test "$gcry_cv_gcc_inline_asm_aarch32_crypto" != "yes" ; then
1962 if test "$gcry_cv_gcc_inline_asm_aarch64_crypto" != "yes" ; then
1963 neonsupport="no (unsupported by compiler)"
1968 if test x"$aesnisupport" = xyes ; then
1969 AC_DEFINE(ENABLE_AESNI_SUPPORT, 1,
1970 [Enable support for Intel AES-NI instructions.])
1972 if test x"$pclmulsupport" = xyes ; then
1973 AC_DEFINE(ENABLE_PCLMUL_SUPPORT, 1,
1974 [Enable support for Intel PCLMUL instructions.])
1976 if test x"$sse41support" = xyes ; then
1977 AC_DEFINE(ENABLE_SSE41_SUPPORT, 1,
1978 [Enable support for Intel SSE4.1 instructions.])
1980 if test x"$avxsupport" = xyes ; then
1981 AC_DEFINE(ENABLE_AVX_SUPPORT,1,
1982 [Enable support for Intel AVX instructions.])
1984 if test x"$avx2support" = xyes ; then
1985 AC_DEFINE(ENABLE_AVX2_SUPPORT,1,
1986 [Enable support for Intel AVX2 instructions.])
1988 if test x"$neonsupport" = xyes ; then
1989 AC_DEFINE(ENABLE_NEON_SUPPORT,1,
1990 [Enable support for ARM NEON instructions.])
1992 if test x"$armcryptosupport" = xyes ; then
1993 AC_DEFINE(ENABLE_ARM_CRYPTO_SUPPORT,1,
1994 [Enable support for ARMv8 Crypto Extension instructions.])
1996 if test x"$jentsupport" = xyes ; then
1997 AC_DEFINE(ENABLE_JENT_SUPPORT, 1,
1998 [Enable support for the jitter entropy collector.])
2000 if test x"$padlocksupport" = xyes ; then
2001 AC_DEFINE(ENABLE_PADLOCK_SUPPORT, 1,
2002 [Enable support for the PadLock engine.])
2004 if test x"$drngsupport" = xyes ; then
2005 AC_DEFINE(ENABLE_DRNG_SUPPORT, 1,
2006 [Enable support for Intel DRNG (RDRAND instruction).])
2010 # Define conditional sources and config.h symbols depending on the
2011 # selected ciphers, pubkey-ciphers, digests, kdfs, and random modules.
2013 LIST_MEMBER(arcfour, $enabled_ciphers)
2014 if test "$found" = "1"; then
2015 GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour.lo"
2016 AC_DEFINE(USE_ARCFOUR, 1, [Defined if this module should be included])
2020 # Build with the assembly implementation
2021 GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour-amd64.lo"
2026 LIST_MEMBER(blowfish, $enabled_ciphers)
2027 if test "$found" = "1" ; then
2028 GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish.lo"
2029 AC_DEFINE(USE_BLOWFISH, 1, [Defined if this module should be included])
2033 # Build with the assembly implementation
2034 GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish-amd64.lo"
2037 # Build with the assembly implementation
2038 GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish-arm.lo"
2043 LIST_MEMBER(cast5, $enabled_ciphers)
2044 if test "$found" = "1" ; then
2045 GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5.lo"
2046 AC_DEFINE(USE_CAST5, 1, [Defined if this module should be included])
2050 # Build with the assembly implementation
2051 GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5-amd64.lo"
2054 # Build with the assembly implementation
2055 GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5-arm.lo"
2060 LIST_MEMBER(des, $enabled_ciphers)
2061 if test "$found" = "1" ; then
2062 GCRYPT_CIPHERS="$GCRYPT_CIPHERS des.lo"
2063 AC_DEFINE(USE_DES, 1, [Defined if this module should be included])
2067 # Build with the assembly implementation
2068 GCRYPT_CIPHERS="$GCRYPT_CIPHERS des-amd64.lo"
2073 LIST_MEMBER(aes, $enabled_ciphers)
2074 if test "$found" = "1" ; then
2075 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael.lo"
2076 AC_DEFINE(USE_AES, 1, [Defined if this module should be included])
2080 # Build with the assembly implementation
2081 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-amd64.lo"
2083 # Build with the SSSE3 implementation
2084 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-ssse3-amd64.lo"
2085 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-ssse3-amd64-asm.lo"
2088 # Build with the assembly implementation
2089 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-arm.lo"
2091 # Build with the ARMv8/AArch32 CE implementation
2092 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-armv8-ce.lo"
2093 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-armv8-aarch32-ce.lo"
2096 # Build with the assembly implementation
2097 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-aarch64.lo"
2099 # Build with the ARMv8/AArch64 CE implementation
2100 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-armv8-ce.lo"
2101 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-armv8-aarch64-ce.lo"
2105 case "$mpi_cpu_arch" in
2107 # Build with the AES-NI implementation
2108 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-aesni.lo"
2110 # Build with the Padlock implementation
2111 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-padlock.lo"
2116 LIST_MEMBER(twofish, $enabled_ciphers)
2117 if test "$found" = "1" ; then
2118 GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish.lo"
2119 AC_DEFINE(USE_TWOFISH, 1, [Defined if this module should be included])
2123 # Build with the assembly implementation
2124 GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish-amd64.lo"
2126 if test x"$avx2support" = xyes ; then
2127 # Build with the AVX2 implementation
2128 GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish-avx2-amd64.lo"
2132 # Build with the assembly implementation
2133 GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish-arm.lo"
2136 # Build with the assembly implementation
2137 GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish-aarch64.lo"
2142 LIST_MEMBER(serpent, $enabled_ciphers)
2143 if test "$found" = "1" ; then
2144 GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent.lo"
2145 AC_DEFINE(USE_SERPENT, 1, [Defined if this module should be included])
2149 # Build with the SSE2 implementation
2150 GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent-sse2-amd64.lo"
2154 if test x"$avx2support" = xyes ; then
2155 # Build with the AVX2 implementation
2156 GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent-avx2-amd64.lo"
2159 if test x"$neonsupport" = xyes ; then
2160 # Build with the NEON implementation
2161 GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent-armv7-neon.lo"
2165 LIST_MEMBER(rfc2268, $enabled_ciphers)
2166 if test "$found" = "1" ; then
2167 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rfc2268.lo"
2168 AC_DEFINE(USE_RFC2268, 1, [Defined if this module should be included])
2171 LIST_MEMBER(seed, $enabled_ciphers)
2172 if test "$found" = "1" ; then
2173 GCRYPT_CIPHERS="$GCRYPT_CIPHERS seed.lo"
2174 AC_DEFINE(USE_SEED, 1, [Defined if this module should be included])
2177 LIST_MEMBER(camellia, $enabled_ciphers)
2178 if test "$found" = "1" ; then
2179 GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia.lo camellia-glue.lo"
2180 AC_DEFINE(USE_CAMELLIA, 1, [Defined if this module should be included])
2184 # Build with the assembly implementation
2185 GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia-arm.lo"
2188 # Build with the assembly implementation
2189 GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia-aarch64.lo"
2193 if test x"$avxsupport" = xyes ; then
2194 if test x"$aesnisupport" = xyes ; then
2195 # Build with the AES-NI/AVX implementation
2196 GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia-aesni-avx-amd64.lo"
2200 if test x"$avx2support" = xyes ; then
2201 if test x"$aesnisupport" = xyes ; then
2202 # Build with the AES-NI/AVX2 implementation
2203 GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia-aesni-avx2-amd64.lo"
2208 LIST_MEMBER(idea, $enabled_ciphers)
2209 if test "$found" = "1" ; then
2210 GCRYPT_CIPHERS="$GCRYPT_CIPHERS idea.lo"
2211 AC_DEFINE(USE_IDEA, 1, [Defined if this module should be included])
2214 LIST_MEMBER(salsa20, $enabled_ciphers)
2215 if test "$found" = "1" ; then
2216 GCRYPT_CIPHERS="$GCRYPT_CIPHERS salsa20.lo"
2217 AC_DEFINE(USE_SALSA20, 1, [Defined if this module should be included])
2221 # Build with the assembly implementation
2222 GCRYPT_CIPHERS="$GCRYPT_CIPHERS salsa20-amd64.lo"
2226 if test x"$neonsupport" = xyes ; then
2227 # Build with the NEON implementation
2228 GCRYPT_CIPHERS="$GCRYPT_CIPHERS salsa20-armv7-neon.lo"
2232 LIST_MEMBER(gost28147, $enabled_ciphers)
2233 if test "$found" = "1" ; then
2234 GCRYPT_CIPHERS="$GCRYPT_CIPHERS gost28147.lo"
2235 AC_DEFINE(USE_GOST28147, 1, [Defined if this module should be included])
2238 LIST_MEMBER(chacha20, $enabled_ciphers)
2239 if test "$found" = "1" ; then
2240 GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20.lo"
2241 AC_DEFINE(USE_CHACHA20, 1, [Defined if this module should be included])
2245 # Build with the assembly implementation
2246 GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20-sse2-amd64.lo"
2247 GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20-ssse3-amd64.lo"
2248 GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20-avx2-amd64.lo"
2252 if test x"$neonsupport" = xyes ; then
2253 # Build with the NEON implementation
2254 GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20-armv7-neon.lo"
2260 # Build with the assembly implementation
2261 GCRYPT_CIPHERS="$GCRYPT_CIPHERS poly1305-sse2-amd64.lo"
2262 GCRYPT_CIPHERS="$GCRYPT_CIPHERS poly1305-avx2-amd64.lo"
2266 if test x"$neonsupport" = xyes ; then
2267 # Build with the NEON implementation
2268 GCRYPT_CIPHERS="$GCRYPT_CIPHERS poly1305-armv7-neon.lo"
2271 LIST_MEMBER(dsa, $enabled_pubkey_ciphers)
2272 if test "$found" = "1" ; then
2273 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo"
2274 AC_DEFINE(USE_DSA, 1, [Defined if this module should be included])
2277 LIST_MEMBER(rsa, $enabled_pubkey_ciphers)
2278 if test "$found" = "1" ; then
2279 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS rsa.lo"
2280 AC_DEFINE(USE_RSA, 1, [Defined if this module should be included])
2283 LIST_MEMBER(elgamal, $enabled_pubkey_ciphers)
2284 if test "$found" = "1" ; then
2285 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo"
2286 AC_DEFINE(USE_ELGAMAL, 1, [Defined if this module should be included])
2289 LIST_MEMBER(ecc, $enabled_pubkey_ciphers)
2290 if test "$found" = "1" ; then
2291 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS \
2292 ecc.lo ecc-curves.lo ecc-misc.lo \
2293 ecc-ecdsa.lo ecc-eddsa.lo ecc-gost.lo"
2294 AC_DEFINE(USE_ECC, 1, [Defined if this module should be included])
2297 LIST_MEMBER(crc, $enabled_digests)
2298 if test "$found" = "1" ; then
2299 GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc.lo"
2300 AC_DEFINE(USE_CRC, 1, [Defined if this module should be included])
2303 i?86-*-* | x86_64-*-*)
2304 # Build with the assembly implementation
2305 GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc-intel-pclmul.lo"
2310 LIST_MEMBER(gostr3411-94, $enabled_digests)
2311 if test "$found" = "1" ; then
2312 # GOST R 34.11-94 internally uses GOST 28147-89
2313 LIST_MEMBER(gost28147, $enabled_ciphers)
2314 if test "$found" = "1" ; then
2315 GCRYPT_DIGESTS="$GCRYPT_DIGESTS gostr3411-94.lo"
2316 AC_DEFINE(USE_GOST_R_3411_94, 1, [Defined if this module should be included])
2320 LIST_MEMBER(stribog, $enabled_digests)
2321 if test "$found" = "1" ; then
2322 GCRYPT_DIGESTS="$GCRYPT_DIGESTS stribog.lo"
2323 AC_DEFINE(USE_GOST_R_3411_12, 1, [Defined if this module should be included])
2326 LIST_MEMBER(md2, $enabled_digests)
2327 if test "$found" = "1" ; then
2328 GCRYPT_DIGESTS="$GCRYPT_DIGESTS md2.lo"
2329 AC_DEFINE(USE_MD2, 1, [Defined if this module should be included])
2332 LIST_MEMBER(md4, $enabled_digests)
2333 if test "$found" = "1" ; then
2334 GCRYPT_DIGESTS="$GCRYPT_DIGESTS md4.lo"
2335 AC_DEFINE(USE_MD4, 1, [Defined if this module should be included])
2338 LIST_MEMBER(md5, $enabled_digests)
2339 if test "$found" = "1" ; then
2340 GCRYPT_DIGESTS="$GCRYPT_DIGESTS md5.lo"
2341 AC_DEFINE(USE_MD5, 1, [Defined if this module should be included])
2344 LIST_MEMBER(rmd160, $enabled_digests)
2345 if test "$found" = "1" ; then
2346 GCRYPT_DIGESTS="$GCRYPT_DIGESTS rmd160.lo"
2347 AC_DEFINE(USE_RMD160, 1, [Defined if this module should be included])
2350 LIST_MEMBER(sha256, $enabled_digests)
2351 if test "$found" = "1" ; then
2352 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo"
2353 AC_DEFINE(USE_SHA256, 1, [Defined if this module should be included])
2357 # Build with the assembly implementation
2358 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256-ssse3-amd64.lo"
2359 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256-avx-amd64.lo"
2360 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256-avx2-bmi2-amd64.lo"
2363 # Build with the assembly implementation
2364 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256-armv8-aarch32-ce.lo"
2367 # Build with the assembly implementation
2368 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256-armv8-aarch64-ce.lo"
2373 LIST_MEMBER(sha512, $enabled_digests)
2374 if test "$found" = "1" ; then
2375 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512.lo"
2376 AC_DEFINE(USE_SHA512, 1, [Defined if this module should be included])
2380 # Build with the assembly implementation
2381 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-ssse3-amd64.lo"
2382 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-avx-amd64.lo"
2383 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-avx2-bmi2-amd64.lo"
2386 # Build with the assembly implementation
2387 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-arm.lo"
2391 if test x"$neonsupport" = xyes ; then
2392 # Build with the NEON implementation
2393 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-armv7-neon.lo"
2397 LIST_MEMBER(sha3, $enabled_digests)
2398 if test "$found" = "1" ; then
2399 GCRYPT_DIGESTS="$GCRYPT_DIGESTS keccak.lo"
2400 AC_DEFINE(USE_SHA3, 1, [Defined if this module should be included])
2404 # Build with the assembly implementation
2409 if test x"$neonsupport" = xyes ; then
2410 # Build with the NEON implementation
2411 GCRYPT_DIGESTS="$GCRYPT_DIGESTS keccak-armv7-neon.lo"
2415 LIST_MEMBER(tiger, $enabled_digests)
2416 if test "$found" = "1" ; then
2417 GCRYPT_DIGESTS="$GCRYPT_DIGESTS tiger.lo"
2418 AC_DEFINE(USE_TIGER, 1, [Defined if this module should be included])
2421 LIST_MEMBER(whirlpool, $enabled_digests)
2422 if test "$found" = "1" ; then
2423 GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool.lo"
2424 AC_DEFINE(USE_WHIRLPOOL, 1, [Defined if this module should be included])
2428 # Build with the assembly implementation
2429 GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool-sse2-amd64.lo"
2434 LIST_MEMBER(blake2, $enabled_digests)
2435 if test "$found" = "1" ; then
2436 GCRYPT_DIGESTS="$GCRYPT_DIGESTS blake2.lo"
2437 AC_DEFINE(USE_BLAKE2, 1, [Defined if this module should be included])
2440 # SHA-1 needs to be included always for example because it is used by
2442 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1.lo"
2443 AC_DEFINE(USE_SHA1, 1, [Defined if this module should be included])
2447 # Build with the assembly implementation
2448 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-ssse3-amd64.lo"
2449 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-avx-amd64.lo"
2450 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-avx-bmi2-amd64.lo"
2453 # Build with the assembly implementation
2454 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-armv7-neon.lo"
2455 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-armv8-aarch32-ce.lo"
2458 # Build with the assembly implementation
2459 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-armv8-aarch64-ce.lo"
2463 LIST_MEMBER(scrypt, $enabled_kdfs)
2464 if test "$found" = "1" ; then
2465 GCRYPT_KDFS="$GCRYPT_KDFS scrypt.lo"
2466 AC_DEFINE(USE_SCRYPT, 1, [Defined if this module should be included])
2469 LIST_MEMBER(linux, $random_modules)
2470 if test "$found" = "1" ; then
2471 GCRYPT_RANDOM="$GCRYPT_RANDOM rndlinux.lo"
2472 AC_DEFINE(USE_RNDLINUX, 1, [Defined if the /dev/random RNG should be used.])
2475 LIST_MEMBER(unix, $random_modules)
2476 if test "$found" = "1" ; then
2477 GCRYPT_RANDOM="$GCRYPT_RANDOM rndunix.lo"
2478 AC_DEFINE(USE_RNDUNIX, 1, [Defined if the default Unix RNG should be used.])
2481 LIST_MEMBER(egd, $random_modules)
2482 if test "$found" = "1" ; then
2483 GCRYPT_RANDOM="$GCRYPT_RANDOM rndegd.lo"
2484 AC_DEFINE(USE_RNDEGD, 1, [Defined if the EGD based RNG should be used.])
2487 LIST_MEMBER(w32, $random_modules)
2488 if test "$found" = "1" ; then
2489 GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32.lo"
2490 AC_DEFINE(USE_RNDW32, 1,
2491 [Defined if the Windows specific RNG should be used.])
2494 LIST_MEMBER(w32ce, $random_modules)
2495 if test "$found" = "1" ; then
2496 GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32ce.lo"
2497 AC_DEFINE(USE_RNDW32CE, 1,
2498 [Defined if the WindowsCE specific RNG should be used.])
2501 AC_SUBST([GCRYPT_CIPHERS])
2502 AC_SUBST([GCRYPT_PUBKEY_CIPHERS])
2503 AC_SUBST([GCRYPT_DIGESTS])
2504 AC_SUBST([GCRYPT_KDFS])
2505 AC_SUBST([GCRYPT_RANDOM])
2507 AC_SUBST(LIBGCRYPT_CIPHERS, $enabled_ciphers)
2508 AC_SUBST(LIBGCRYPT_PUBKEY_CIPHERS, $enabled_pubkey_ciphers)
2509 AC_SUBST(LIBGCRYPT_DIGESTS, $enabled_digests)
2511 # For printing the configuration we need a colon separated list of
2513 tmp=`echo "$enabled_ciphers" | tr ' ' : `
2514 AC_DEFINE_UNQUOTED(LIBGCRYPT_CIPHERS, "$tmp",
2515 [List of available cipher algorithms])
2516 tmp=`echo "$enabled_pubkey_ciphers" | tr ' ' : `
2517 AC_DEFINE_UNQUOTED(LIBGCRYPT_PUBKEY_CIPHERS, "$tmp",
2518 [List of available public key cipher algorithms])
2519 tmp=`echo "$enabled_digests" | tr ' ' : `
2520 AC_DEFINE_UNQUOTED(LIBGCRYPT_DIGESTS, "$tmp",
2521 [List of available digest algorithms])
2522 tmp=`echo "$enabled_kdfs" | tr ' ' : `
2523 AC_DEFINE_UNQUOTED(LIBGCRYPT_KDFS, "$tmp",
2524 [List of available KDF algorithms])
2528 # Define conditional sources depending on the used hardware platform.
2529 # Note that all possible modules must also be listed in
2530 # src/Makefile.am (EXTRA_libgcrypt_la_SOURCES).
2533 case "$mpi_cpu_arch" in
2535 AC_DEFINE(HAVE_CPU_ARCH_X86, 1, [Defined for the x86 platforms])
2536 GCRYPT_HWF_MODULES="hwf-x86.lo"
2539 AC_DEFINE(HAVE_CPU_ARCH_ALPHA, 1, [Defined for Alpha platforms])
2542 AC_DEFINE(HAVE_CPU_ARCH_SPARC, 1, [Defined for SPARC platforms])
2545 AC_DEFINE(HAVE_CPU_ARCH_MIPS, 1, [Defined for MIPS platforms])
2548 AC_DEFINE(HAVE_CPU_ARCH_M68K, 1, [Defined for M68k platforms])
2551 AC_DEFINE(HAVE_CPU_ARCH_PPC, 1, [Defined for PPC platforms])
2554 AC_DEFINE(HAVE_CPU_ARCH_ARM, 1, [Defined for ARM platforms])
2555 GCRYPT_HWF_MODULES="hwf-arm.lo"
2558 AC_DEFINE(HAVE_CPU_ARCH_ARM, 1, [Defined for ARM AArch64 platforms])
2559 GCRYPT_HWF_MODULES="hwf-arm.lo"
2562 AC_SUBST([GCRYPT_HWF_MODULES])
2566 # Option to disable building of doc file
2569 AC_ARG_ENABLE([doc], AC_HELP_STRING([--disable-doc],
2570 [do not build the documentation]),
2571 build_doc=$enableval, build_doc=yes)
2572 AM_CONDITIONAL([BUILD_DOC], [test "x$build_doc" != xno])
2576 # Provide information about the build.
2578 BUILD_REVISION="mym4_revision"
2579 AC_SUBST(BUILD_REVISION)
2580 AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
2581 [GIT commit id revision used to build this package])
2584 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
2586 BUILD_FILEVERSION="${BUILD_FILEVERSION}mym4_revision_dec"
2587 AC_SUBST(BUILD_FILEVERSION)
2589 AC_ARG_ENABLE([build-timestamp],
2590 AC_HELP_STRING([--enable-build-timestamp],
2591 [set an explicit build timestamp for reproducibility.
2592 (default is the current time in ISO-8601 format)]),
2593 [if test "$enableval" = "yes"; then
2594 BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
2596 BUILD_TIMESTAMP="$enableval"
2598 [BUILD_TIMESTAMP="<none>"])
2599 AC_SUBST(BUILD_TIMESTAMP)
2600 AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
2601 [The time this package was configured for a build])
2604 # And create the files.
2615 src/libgcrypt-config
2619 AC_CONFIG_FILES([tests/hashtest-256g], [chmod +x tests/hashtest-256g])
2620 AC_CONFIG_FILES([tests/basic-disable-all-hwf], [chmod +x tests/basic-disable-all-hwf])
2624 detection_module="${GCRYPT_HWF_MODULES%.lo}"
2625 test -n "$detection_module" || detection_module="none"
2627 # Give some feedback
2628 GCRY_MSG_SHOW([],[])
2629 GCRY_MSG_SHOW([Libgcrypt],[v${VERSION} has been configured as follows:])
2630 GCRY_MSG_SHOW([],[])
2631 GCRY_MSG_SHOW([Platform: ],[$PRINTABLE_OS_NAME ($host)])
2632 GCRY_MSG_SHOW([Hardware detection module:],[$detection_module])
2633 GCRY_MSG_WRAP([Enabled cipher algorithms:],[$enabled_ciphers])
2634 GCRY_MSG_WRAP([Enabled digest algorithms:],[$enabled_digests])
2635 GCRY_MSG_WRAP([Enabled kdf algorithms: ],[$enabled_kdfs])
2636 GCRY_MSG_WRAP([Enabled pubkey algorithms:],[$enabled_pubkey_ciphers])
2637 GCRY_MSG_SHOW([Random number generator: ],[$random])
2638 GCRY_MSG_SHOW([Try using jitter entropy: ],[$jentsupport])
2639 GCRY_MSG_SHOW([Using linux capabilities: ],[$use_capabilities])
2640 GCRY_MSG_SHOW([Try using Padlock crypto: ],[$padlocksupport])
2641 GCRY_MSG_SHOW([Try using AES-NI crypto: ],[$aesnisupport])
2642 GCRY_MSG_SHOW([Try using Intel PCLMUL: ],[$pclmulsupport])
2643 GCRY_MSG_SHOW([Try using Intel SSE4.1: ],[$sse41support])
2644 GCRY_MSG_SHOW([Try using DRNG (RDRAND): ],[$drngsupport])
2645 GCRY_MSG_SHOW([Try using Intel AVX: ],[$avxsupport])
2646 GCRY_MSG_SHOW([Try using Intel AVX2: ],[$avx2support])
2647 GCRY_MSG_SHOW([Try using ARM NEON: ],[$neonsupport])
2648 GCRY_MSG_SHOW([Try using ARMv8 crypto: ],[$armcryptosupport])
2649 GCRY_MSG_SHOW([],[])
2651 if test "x${gpg_config_script_warn}" != x; then
2653 Mismatches between the target platform and the to
2654 be used libraries have been been detected for:
2655 ${gpg_config_script_warn}
2656 Please check above for warning messages.
2661 if test "$gcry_cv_gcc_attribute_aligned" != "yes" ; then
2663 Please not that your compiler does not support the GCC style
2664 aligned attribute. Using this software may evoke bus errors.
2669 if test -n "$gpl"; then
2670 echo "Please note that you are building a version of Libgcrypt with"
2672 echo "included. These parts are licensed under the GPL and thus the"
2673 echo "use of this library has to comply with the conditions of the GPL."