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-2021 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_package],[libgcrypt])
32 m4_define([mym4_major], [1])
33 m4_define([mym4_minor], [10])
34 m4_define([mym4_micro], [1])
36 # Below is m4 magic to extract and compute the git revision number,
37 # the decimalized short revision number, a beta version string and a
38 # flag indicating a development version (mym4_isbeta). Note that the
39 # m4 processing is done by autoconf and not during the configure run.
40 m4_define([mym4_verslist], m4_split(m4_esyscmd([./autogen.sh --find-version] \
41 mym4_package mym4_major mym4_minor mym4_micro),[:]))
42 m4_define([mym4_isbeta], m4_argn(2, mym4_verslist))
43 m4_define([mym4_version], m4_argn(4, mym4_verslist))
44 m4_define([mym4_revision], m4_argn(7, mym4_verslist))
45 m4_define([mym4_revision_dec], m4_argn(8, mym4_verslist))
46 m4_esyscmd([echo ]mym4_version[>VERSION])
47 AC_INIT([mym4_package],[mym4_version],[https://bugs.gnupg.org])
49 # LT Version numbers, remember to change them just *before* a release.
50 # (Code changed: REVISION++)
51 # (Interfaces added/removed/changed: CURRENT++, REVISION=0)
52 # (Interfaces added: AGE++)
53 # (Interfaces removed: AGE=0)
55 # (Interfaces removed: CURRENT++, AGE=0, REVISION=0)
56 # (Interfaces added: CURRENT++, AGE++, REVISION=0)
57 # (No interfaces changed: REVISION++)
58 LIBGCRYPT_LT_CURRENT=24
60 LIBGCRYPT_LT_REVISION=1
61 ################################################
63 AC_SUBST(LIBGCRYPT_LT_CURRENT)
64 AC_SUBST(LIBGCRYPT_LT_AGE)
65 AC_SUBST(LIBGCRYPT_LT_REVISION)
67 # If the API is changed in an incompatible way: increment the next counter.
69 # 1.6: ABI and API change but the change is to most users irrelevant
70 # and thus the API version number has not been incremented.
71 LIBGCRYPT_CONFIG_API_VERSION=1
73 # If you change the required gpg-error version, please remove
74 # unnecessary error code defines in src/gcrypt-int.h.
75 NEED_GPG_ERROR_VERSION=1.27
77 AC_CONFIG_AUX_DIR([build-aux])
78 AC_CONFIG_SRCDIR([src/libgcrypt.vers])
79 AM_INIT_AUTOMAKE([serial-tests dist-bzip2])
80 AC_CONFIG_HEADERS([config.h])
81 AC_CONFIG_MACRO_DIR([m4])
82 AC_CONFIG_LIBOBJ_DIR([compat])
87 AC_ARG_VAR(SYSROOT,[locate config scripts also below that directory])
90 #ifndef _GCRYPT_CONFIG_H_INCLUDED
91 #define _GCRYPT_CONFIG_H_INCLUDED
93 /* Enable gpg-error's strerror macro for W32CE. */
94 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
98 #define _GCRYPT_IN_LIBGCRYPT 1
100 /* Add .note.gnu.property section for Intel CET in assembler sources
101 when CET is enabled. */
102 #if defined(__ASSEMBLER__) && defined(__CET__)
106 /* If the configure check for endianness has been disabled, get it from
107 OS macros. This is intended for making fat binary builds on OS X. */
108 #ifdef DISABLED_ENDIAN_CHECK
109 # if defined(__BIG_ENDIAN__)
110 # define WORDS_BIGENDIAN 1
111 # elif defined(__LITTLE_ENDIAN__)
112 # undef WORDS_BIGENDIAN
114 # error "No endianness found"
116 #endif /*DISABLED_ENDIAN_CHECK*/
118 /* We basically use the original Camellia source. Make sure the symbols
119 properly prefixed. */
120 #define CAMELLIA_EXT_SYM_PREFIX _gcry_
122 #endif /*_GCRYPT_CONFIG_H_INCLUDED*/
125 AH_VERBATIM([_REENTRANT],
126 [/* To allow the use of Libgcrypt in multithreaded programs we have to use
127 special features from the library. */
129 # define _REENTRANT 1
134 ######################
135 ## Basic checks. ### (we need some results later on (e.g. $GCC)
136 ######################
139 missing_dir=`cd $ac_aux_dir && pwd`
140 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
141 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
142 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
143 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
144 # AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
149 AC_SEARCH_LIBS([strerror],[cposix])
153 AC_USE_SYSTEM_EXTENSIONS
155 # Taken from mpfr-4.0.1, then modified for LDADD_FOR_TESTS_KLUDGE
156 dnl Under Linux, make sure that the old dtags are used if LD_LIBRARY_PATH
157 dnl is defined. The issue is that with the new dtags, LD_LIBRARY_PATH has
158 dnl the precedence over the run path, so that if a compatible MPFR library
159 dnl is installed in some directory from $LD_LIBRARY_PATH, then the tested
160 dnl MPFR library will be this library instead of the MPFR library from the
161 dnl build tree. Other OS with the same issue might be added later.
164 dnl https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=859732
165 dnl http://lists.gnu.org/archive/html/libtool/2017-05/msg00000.html
167 dnl We need to check whether --disable-new-dtags is supported as alternate
168 dnl linkers may be used (e.g., with tcc: CC=tcc LD=tcc).
172 if test -n "$LD_LIBRARY_PATH"; then
173 saved_LDFLAGS="$LDFLAGS"
174 LDADD_FOR_TESTS_KLUDGE="-Wl,--disable-new-dtags"
175 LDFLAGS="$LDFLAGS $LDADD_FOR_TESTS_KLUDGE"
176 AC_MSG_CHECKING(whether --disable-new-dtags is supported by the linker)
177 AC_LINK_IFELSE([AC_LANG_SOURCE([[
178 int main (void) { return 0; }
180 [AC_MSG_RESULT(yes (use it since LD_LIBRARY_PATH is set))],
182 LDADD_FOR_TESTS_KLUDGE=""
184 LDFLAGS="$saved_LDFLAGS"
188 AC_SUBST([LDADD_FOR_TESTS_KLUDGE])
190 VERSION_NUMBER=m4_esyscmd(printf "0x%02x%02x%02x" mym4_major \
191 mym4_minor mym4_micro)
192 AC_SUBST(VERSION_NUMBER)
194 # We need to compile and run a program on the build machine.
199 LT_INIT([win32-dll disable-static])
200 LT_LANG([Windows Resource])
203 ##########################
204 ## General definitions. ##
205 ##########################
207 # Used by libgcrypt-config
208 LIBGCRYPT_CONFIG_LIBS="-lgcrypt"
209 LIBGCRYPT_CONFIG_CFLAGS=""
210 LIBGCRYPT_CONFIG_HOST="$host"
212 # Definitions for symmetric ciphers.
213 available_ciphers="arcfour blowfish cast5 des aes twofish serpent rfc2268 seed"
214 available_ciphers="$available_ciphers camellia idea salsa20 gost28147 chacha20"
215 available_ciphers="$available_ciphers sm4"
218 # Definitions for public-key ciphers.
219 available_pubkey_ciphers="dsa elgamal rsa ecc"
220 enabled_pubkey_ciphers=""
222 # Definitions for message digests.
223 available_digests="crc gostr3411-94 md2 md4 md5 rmd160 sha1 sha256 sha512"
224 available_digests="$available_digests sha3 tiger whirlpool stribog blake2"
225 available_digests="$available_digests sm3"
228 # Definitions for kdfs (optional ones)
229 available_kdfs="s2k pkdf2 scrypt"
232 # Definitions for random modules.
233 available_random_modules="getentropy linux egd unix"
234 auto_random_modules="$available_random_modules"
236 # Supported thread backends.
237 LIBGCRYPT_THREAD_MODULES=""
245 # Setup some stuff depending on host.
248 ac_cv_have_dev_random=no
252 have_w32ce_system=yes
253 available_random_modules="w32ce"
256 available_random_modules="w32"
259 AC_DEFINE(USE_ONLY_8DOT3,1,
260 [set this to limit filenames to the 8.3 format])
261 AC_DEFINE(HAVE_DRIVE_LETTERS,1,
262 [defined if we must run on a stupid file system])
263 AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
264 [defined if we run on some of the PCDOS like systems
265 (DOS, Windoze. OS/2) with special properties like
269 i?86-emx-os2 | i?86-*-os2*emx)
270 # OS/2 with the EMX environment
271 ac_cv_have_dev_random=no
272 AC_DEFINE(HAVE_DRIVE_LETTERS)
273 AC_DEFINE(HAVE_DOSISH_SYSTEM)
277 # DOS with the DJGPP environment
278 ac_cv_have_dev_random=no
279 AC_DEFINE(HAVE_DRIVE_LETTERS)
280 AC_DEFINE(HAVE_DOSISH_SYSTEM)
284 if test -z "$GCC" ; then
285 CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
289 if test -z "$GCC" ; then
290 # Suppress all warnings
291 # to get rid of the unsigned/signed char mismatch warnings.
298 AC_DEFINE(_DARWIN_C_SOURCE, 1,
299 Expose all libc features (__DARWIN_C_FULL).)
300 AC_DEFINE(USE_POSIX_SPAWN_FOR_TESTS, 1,
301 [defined if we use posix_spawn in test program])
302 AC_CHECK_HEADERS(spawn.h)
308 if test "$have_w32_system" = yes; then
309 AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
310 if test "$have_w32ce_system" = yes; then
311 AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE])
314 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
315 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
319 # A printable OS Name is sometimes useful.
322 PRINTABLE_OS_NAME="W32CE"
326 PRINTABLE_OS_NAME="W32"
329 i?86-emx-os2 | i?86-*-os2*emx )
330 PRINTABLE_OS_NAME="OS/2"
334 PRINTABLE_OS_NAME="MSDOS/DJGPP"
338 PRINTABLE_OS_NAME="GNU/Linux"
342 PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
346 NAME_OF_DEV_RANDOM="/dev/random"
347 NAME_OF_DEV_URANDOM="/dev/urandom"
349 AC_ARG_ENABLE(endian-check,
350 AS_HELP_STRING([--disable-endian-check],
351 [disable the endian check and trust the OS provided macros]),
352 endiancheck=$enableval,endiancheck=yes)
353 if test x"$endiancheck" = xyes ; then
356 AC_DEFINE(DISABLED_ENDIAN_CHECK,1,[configure did not test for endianness])
359 AC_CHECK_SIZEOF(unsigned short, 2)
360 AC_CHECK_SIZEOF(unsigned int, 4)
361 AC_CHECK_SIZEOF(unsigned long, 4)
362 AC_CHECK_SIZEOF(unsigned long long, 0)
363 AC_CHECK_SIZEOF(void *, 0)
367 if test "$ac_cv_sizeof_unsigned_short" = "0" \
368 || test "$ac_cv_sizeof_unsigned_int" = "0" \
369 || test "$ac_cv_sizeof_unsigned_long" = "0"; then
370 AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
373 # Ensure that we have UINT64_C before we bother to check for uint64_t
374 AC_CACHE_CHECK([for UINT64_C],[gnupg_cv_uint64_c_works],
375 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <inttypes.h>]],
376 [[uint64_t foo=UINT64_C(42);]])],
377 gnupg_cv_uint64_c_works=yes,gnupg_cv_uint64_c_works=no))
378 if test "$gnupg_cv_uint64_c_works" = "yes" ; then
379 AC_CHECK_SIZEOF(uint64_t)
382 # Do we have any 64-bit data types?
383 if test "$ac_cv_sizeof_unsigned_int" != "8" \
384 && test "$ac_cv_sizeof_unsigned_long" != "8" \
385 && test "$ac_cv_sizeof_unsigned_long_long" != "8" \
386 && test "$ac_cv_sizeof_uint64_t" != "8"; then
389 *** No 64-bit integer type available.
390 *** It is not possible to build Libgcrypt on this platform.
395 # If not specified otherwise, all available algorithms will be
397 default_ciphers="$available_ciphers"
398 default_pubkey_ciphers="$available_pubkey_ciphers"
399 default_digests="$available_digests"
400 default_kdfs="$available_kdfs"
401 # Blacklist MD2 by default
402 default_digests=`echo $default_digests | sed -e 's/md2//g'`
404 # Substitutions to set generated files in a Emacs buffer to read-only.
405 AC_SUBST(emacs_local_vars_begin, ['Local Variables:'])
406 AC_SUBST(emacs_local_vars_read_only, ['buffer-read-only: t'])
407 AC_SUBST(emacs_local_vars_end, ['End:'])
409 ############################
410 ## Command line switches. ##
411 ############################
413 # Implementation of the --enable-ciphers switch.
414 AC_ARG_ENABLE(ciphers,
415 AS_HELP_STRING([--enable-ciphers=ciphers],
416 [select the symmetric ciphers to include]),
417 [enabled_ciphers=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
418 [enabled_ciphers=""])
419 if test "x$enabled_ciphers" = "x" \
420 -o "$enabled_ciphers" = "yes" \
421 -o "$enabled_ciphers" = "no"; then
422 enabled_ciphers=$default_ciphers
424 AC_MSG_CHECKING([which symmetric ciphers to include])
425 for cipher in $enabled_ciphers; do
426 LIST_MEMBER($cipher, $available_ciphers)
427 if test "$found" = "0"; then
428 AC_MSG_ERROR([unsupported cipher "$cipher" specified])
431 AC_MSG_RESULT([$enabled_ciphers])
433 # Implementation of the --enable-pubkey-ciphers switch.
434 AC_ARG_ENABLE(pubkey-ciphers,
435 AS_HELP_STRING([--enable-pubkey-ciphers=ciphers],
436 [select the public-key ciphers to include]),
437 [enabled_pubkey_ciphers=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
438 [enabled_pubkey_ciphers=""])
439 if test "x$enabled_pubkey_ciphers" = "x" \
440 -o "$enabled_pubkey_ciphers" = "yes" \
441 -o "$enabled_pubkey_ciphers" = "no"; then
442 enabled_pubkey_ciphers=$default_pubkey_ciphers
444 AC_MSG_CHECKING([which public-key ciphers to include])
445 for cipher in $enabled_pubkey_ciphers; do
446 LIST_MEMBER($cipher, $available_pubkey_ciphers)
447 if test "$found" = "0"; then
448 AC_MSG_ERROR([unsupported public-key cipher specified])
451 AC_MSG_RESULT([$enabled_pubkey_ciphers])
453 # Implementation of the --enable-digests switch.
454 AC_ARG_ENABLE(digests,
455 AS_HELP_STRING([--enable-digests=digests],
456 [select the message digests to include]),
457 [enabled_digests=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
458 [enabled_digests=""])
459 if test "x$enabled_digests" = "x" \
460 -o "$enabled_digests" = "yes" \
461 -o "$enabled_digests" = "no"; then
462 enabled_digests=$default_digests
464 AC_MSG_CHECKING([which message digests to include])
465 for digest in $enabled_digests; do
466 LIST_MEMBER($digest, $available_digests)
467 if test "$found" = "0"; then
468 AC_MSG_ERROR([unsupported message digest specified])
471 AC_MSG_RESULT([$enabled_digests])
473 # Implementation of the --enable-kdfs switch.
475 AS_HELP_STRING([--enable-kfds=kdfs],
476 [select the KDFs to include]),
477 [enabled_kdfs=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
479 if test "x$enabled_kdfs" = "x" \
480 -o "$enabled_kdfs" = "yes" \
481 -o "$enabled_kdfs" = "no"; then
482 enabled_kdfs=$default_kdfs
484 AC_MSG_CHECKING([which key derivation functions to include])
485 for kdf in $enabled_kdfs; do
486 LIST_MEMBER($kdf, $available_kdfs)
487 if test "$found" = "0"; then
488 AC_MSG_ERROR([unsupported key derivation function specified])
491 AC_MSG_RESULT([$enabled_kdfs])
493 # Implementation of the --enable-random switch.
494 AC_ARG_ENABLE(random,
495 AS_HELP_STRING([--enable-random=name],
496 [select which random number generator to use]),
497 [random=`echo $enableval | tr '[A-Z]' '[a-z]'`],
499 if test "x$random" = "x" -o "$random" = "yes" -o "$random" = "no"; then
502 AC_MSG_CHECKING([which random module to use])
503 if test "$random" != "default" -a "$random" != "auto"; then
504 LIST_MEMBER($random, $available_random_modules)
505 if test "$found" = "0"; then
506 AC_MSG_ERROR([unsupported random module specified])
509 AC_MSG_RESULT($random)
511 # Implementation of the --disable-dev-random switch.
512 AC_MSG_CHECKING([whether use of /dev/random is requested])
513 AC_ARG_ENABLE(dev-random,
514 [ --disable-dev-random disable the use of dev random],
515 try_dev_random=$enableval, try_dev_random=yes)
516 AC_MSG_RESULT($try_dev_random)
518 # Implementation of the --with-egd-socket switch.
519 AC_ARG_WITH(egd-socket,
520 [ --with-egd-socket=NAME Use NAME for the EGD socket)],
521 egd_socket_name="$withval", egd_socket_name="" )
522 AC_DEFINE_UNQUOTED(EGD_SOCKET_NAME, "$egd_socket_name",
523 [Define if you don't want the default EGD socket name.
524 For details see cipher/rndegd.c])
526 # Implementation of the --enable-random-daemon
527 AC_MSG_CHECKING([whether the experimental random daemon is requested])
528 AC_ARG_ENABLE([random-daemon],
529 AS_HELP_STRING([--enable-random-daemon],
530 [Build the experimental gcryptrnd]),
531 [enable_random_daemon=$enableval],
532 [enable_random_daemon=no])
533 AC_MSG_RESULT($enable_random_daemon)
534 AM_CONDITIONAL(ENABLE_RANDOM_DAEMON, test x$enable_random_daemon = xyes)
537 # Implementation of --disable-asm.
538 AC_MSG_CHECKING([whether MPI and cipher assembler modules are requested])
540 AS_HELP_STRING([--disable-asm],
541 [Disable MPI and cipher assembler modules]),
542 [try_asm_modules=$enableval],
543 [try_asm_modules=yes])
544 AC_MSG_RESULT($try_asm_modules)
545 if test "$try_asm_modules" != yes ; then
546 AC_DEFINE(ASM_DISABLED,1,[Defined if --disable-asm was used to configure])
549 # Implementation of the --enable-m-guard switch.
550 AC_MSG_CHECKING([whether memory guard is requested])
551 AC_ARG_ENABLE(m-guard,
552 AS_HELP_STRING([--enable-m-guard],
553 [Enable memory guard facility]),
554 [use_m_guard=$enableval], [use_m_guard=no])
555 AC_MSG_RESULT($use_m_guard)
556 if test "$use_m_guard" = yes ; then
557 AC_DEFINE(M_GUARD,1,[Define to use the (obsolete) malloc guarding feature])
560 # Implementation of the --enable-large-data-tests switch.
561 AC_MSG_CHECKING([whether to run large data tests])
562 AC_ARG_ENABLE(large-data-tests,
563 AS_HELP_STRING([--enable-large-data-tests],
564 [Enable the real long ruinning large data tests]),
565 large_data_tests=$enableval,large_data_tests=no)
566 AC_MSG_RESULT($large_data_tests)
567 AC_SUBST(RUN_LARGE_DATA_TESTS, $large_data_tests)
569 # Implementation of --enable-force-soft-hwfeatures
570 AC_MSG_CHECKING([whether 'soft' HW feature bits are forced on])
571 AC_ARG_ENABLE([force-soft-hwfeatures],
572 AS_HELP_STRING([--enable-force-soft-hwfeatures],
573 [Enable forcing 'soft' HW feature bits on]),
574 [force_soft_hwfeatures=$enableval],
575 [force_soft_hwfeatures=no])
576 AC_MSG_RESULT($force_soft_hwfeatures)
579 # Implementation of the --with-capabilities switch.
580 # Check whether we want to use Linux capabilities
581 AC_MSG_CHECKING([whether use of capabilities is requested])
582 AC_ARG_WITH(capabilities,
583 AS_HELP_STRING([--with-capabilities],
584 [Use linux capabilities [default=no]]),
585 [use_capabilities="$withval"],[use_capabilities=no])
586 AC_MSG_RESULT($use_capabilities)
588 # Implementation of the --enable-hmac-binary-check.
589 AC_MSG_CHECKING([whether a HMAC binary check is requested])
590 AC_ARG_ENABLE(hmac-binary-check,
591 AS_HELP_STRING([--enable-hmac-binary-check],
592 [Enable library integrity check]),
593 [use_hmac_binary_check="$enableval"],
594 [use_hmac_binary_check=no])
595 AC_MSG_RESULT($use_hmac_binary_check)
596 if test "$use_hmac_binary_check" = no ; then
597 DEF_HMAC_BINARY_CHECK=''
599 AC_DEFINE(ENABLE_HMAC_BINARY_CHECK,1,
600 [Define to support an HMAC based integrity check])
601 AC_CHECK_TOOL(OBJCOPY, [objcopy])
602 AC_CHECK_TOOL(READELF, [readelf])
603 if test "$use_hmac_binary_check" != yes ; then
604 DEF_HMAC_BINARY_CHECK=-DKEY_FOR_BINARY_CHECK="'\"$use_hmac_binary_check\"'"
607 AM_CONDITIONAL(USE_HMAC_BINARY_CHECK, test "x$use_hmac_binary_check" != xno)
608 AC_SUBST(DEF_HMAC_BINARY_CHECK)
610 # Implementation of the --with-fips-module-version.
611 AC_ARG_WITH(fips-module-version,
612 AS_HELP_STRING([--with-fips-module-version=VERSION],
613 [Specify the FIPS module version for the build]),
614 fips_module_version="$withval", fips_module_version="" )
615 AC_DEFINE_UNQUOTED(FIPS_MODULE_VERSION, "$fips_module_version",
616 [Define FIPS module version for certification])
618 # Implementation of the --disable-jent-support switch.
619 AC_MSG_CHECKING([whether jitter entropy support is requested])
620 AC_ARG_ENABLE(jent-support,
621 AS_HELP_STRING([--disable-jent-support],
622 [Disable support for the Jitter entropy collector]),
623 jentsupport=$enableval,jentsupport=yes)
624 AC_MSG_RESULT($jentsupport)
626 # Implementation of the --disable-padlock-support switch.
627 AC_MSG_CHECKING([whether padlock support is requested])
628 AC_ARG_ENABLE(padlock-support,
629 AS_HELP_STRING([--disable-padlock-support],
630 [Disable support for the PadLock Engine of VIA processors]),
631 padlocksupport=$enableval,padlocksupport=yes)
632 AC_MSG_RESULT($padlocksupport)
634 # Implementation of the --disable-aesni-support switch.
635 AC_MSG_CHECKING([whether AESNI support is requested])
636 AC_ARG_ENABLE(aesni-support,
637 AS_HELP_STRING([--disable-aesni-support],
638 [Disable support for the Intel AES-NI instructions]),
639 aesnisupport=$enableval,aesnisupport=yes)
640 AC_MSG_RESULT($aesnisupport)
642 # Implementation of the --disable-shaext-support switch.
643 AC_MSG_CHECKING([whether SHAEXT support is requested])
644 AC_ARG_ENABLE(shaext-support,
645 AS_HELP_STRING([--disable-shaext-support],
646 [Disable support for the Intel SHAEXT instructions]),
647 shaextsupport=$enableval,shaextsupport=yes)
648 AC_MSG_RESULT($shaextsupport)
650 # Implementation of the --disable-pclmul-support switch.
651 AC_MSG_CHECKING([whether PCLMUL support is requested])
652 AC_ARG_ENABLE(pclmul-support,
653 AS_HELP_STRING([--disable-pclmul-support],
654 [Disable support for the Intel PCLMUL instructions]),
655 pclmulsupport=$enableval,pclmulsupport=yes)
656 AC_MSG_RESULT($pclmulsupport)
658 # Implementation of the --disable-sse41-support switch.
659 AC_MSG_CHECKING([whether SSE4.1 support is requested])
660 AC_ARG_ENABLE(sse41-support,
661 AS_HELP_STRING([--disable-sse41-support],
662 [Disable support for the Intel SSE4.1 instructions]),
663 sse41support=$enableval,sse41support=yes)
664 AC_MSG_RESULT($sse41support)
666 # Implementation of the --disable-drng-support switch.
667 AC_MSG_CHECKING([whether DRNG support is requested])
668 AC_ARG_ENABLE(drng-support,
669 AS_HELP_STRING([--disable-drng-support],
670 [Disable support for the Intel DRNG (RDRAND instruction)]),
671 drngsupport=$enableval,drngsupport=yes)
672 AC_MSG_RESULT($drngsupport)
674 # Implementation of the --disable-avx-support switch.
675 AC_MSG_CHECKING([whether AVX support is requested])
676 AC_ARG_ENABLE(avx-support,
677 AS_HELP_STRING([--disable-avx-support],
678 [Disable support for the Intel AVX instructions]),
679 avxsupport=$enableval,avxsupport=yes)
680 AC_MSG_RESULT($avxsupport)
682 # Implementation of the --disable-avx2-support switch.
683 AC_MSG_CHECKING([whether AVX2 support is requested])
684 AC_ARG_ENABLE(avx2-support,
685 AS_HELP_STRING([--disable-avx2-support],
686 [Disable support for the Intel AVX2 instructions]),
687 avx2support=$enableval,avx2support=yes)
688 AC_MSG_RESULT($avx2support)
690 # Implementation of the --disable-neon-support switch.
691 AC_MSG_CHECKING([whether NEON support is requested])
692 AC_ARG_ENABLE(neon-support,
693 AS_HELP_STRING([--disable-neon-support],
694 [Disable support for the ARM NEON instructions]),
695 neonsupport=$enableval,neonsupport=yes)
696 AC_MSG_RESULT($neonsupport)
698 # Implementation of the --disable-arm-crypto-support switch.
699 AC_MSG_CHECKING([whether ARMv8 Crypto Extension support is requested])
700 AC_ARG_ENABLE(arm-crypto-support,
701 AS_HELP_STRING([--disable-arm-crypto-support],
702 [Disable support for the ARMv8 Crypto Extension instructions]),
703 armcryptosupport=$enableval,armcryptosupport=yes)
704 AC_MSG_RESULT($armcryptosupport)
706 # Implementation of the --disable-ppc-crypto-support switch.
707 AC_MSG_CHECKING([whether PPC crypto support is requested])
708 AC_ARG_ENABLE(ppc-crypto-support,
709 AS_HELP_STRING([--disable-ppc-crypto-support],
710 [Disable support for the PPC crypto instructions introduced in POWER 8 (PowerISA 2.07)]),
711 ppccryptosupport=$enableval,ppccryptosupport=yes)
712 AC_MSG_RESULT($ppccryptosupport)
714 # Implementation of the --disable-O-flag-munging switch.
715 AC_MSG_CHECKING([whether a -O flag munging is requested])
716 AC_ARG_ENABLE([O-flag-munging],
717 AS_HELP_STRING([--disable-O-flag-munging],
718 [Disable modification of the cc -O flag]),
719 [enable_o_flag_munging=$enableval],
720 [enable_o_flag_munging=yes])
721 AC_MSG_RESULT($enable_o_flag_munging)
722 AM_CONDITIONAL(ENABLE_O_FLAG_MUNGING, test "$enable_o_flag_munging" = "yes")
724 # Implementation of the --disable-instrumentation-munging switch.
725 AC_MSG_CHECKING([whether a instrumentation (-fprofile, -fsanitize) munging is requested])
726 AC_ARG_ENABLE([instrumentation-munging],
727 AS_HELP_STRING([--disable-instrumentation-munging],
728 [Disable modification of the cc instrumentation options]),
729 [enable_instrumentation_munging=$enableval],
730 [enable_instrumentation_munging=yes])
731 AC_MSG_RESULT($enable_instrumentation_munging)
732 AM_CONDITIONAL(ENABLE_INSTRUMENTATION_MUNGING,
733 test "$enable_instrumentation_munging" = "yes")
735 # Implementation of the --disable-amd64-as-feature-detection switch.
736 AC_MSG_CHECKING([whether to enable AMD64 as(1) feature detection])
737 AC_ARG_ENABLE(amd64-as-feature-detection,
738 AS_HELP_STRING([--disable-amd64-as-feature-detection],
739 [Disable the auto-detection of AMD64 as(1) features]),
740 amd64_as_feature_detection=$enableval,
741 amd64_as_feature_detection=yes)
742 AC_MSG_RESULT($amd64_as_feature_detection)
745 AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
746 [A human readable text with the name of the OS])
748 # For some systems we know that we have ld_version scripts.
749 # Use it then as default.
750 have_ld_version_script=no
753 have_ld_version_script=yes
756 have_ld_version_script=yes
759 AC_ARG_ENABLE([ld-version-script],
760 AS_HELP_STRING([--enable-ld-version-script],
761 [enable/disable use of linker version script.
762 (default is system dependent)]),
763 [have_ld_version_script=$enableval],
765 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
767 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, "$NAME_OF_DEV_RANDOM",
768 [defined to the name of the strong random device])
769 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, "$NAME_OF_DEV_URANDOM",
770 [defined to the name of the weaker random device])
773 ###############################
774 #### Checks for libraries. ####
775 ###############################
778 # gpg-error is required.
780 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION")
781 if test "x$GPG_ERROR_LIBS" = "x"; then
782 AC_MSG_ERROR([libgpg-error is needed.
783 See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ .])
786 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GCRYPT,
787 [The default error source for libgcrypt.])
790 # Check whether the GNU Pth library is available. We require this
791 # to build the optional gcryptrnd program.
793 AC_ARG_WITH(pth-prefix,
794 AS_HELP_STRING([--with-pth-prefix=PFX],
795 [prefix where GNU Pth is installed (optional)]),
796 pth_config_prefix="$withval", pth_config_prefix="")
797 if test x$pth_config_prefix != x ; then
798 PTH_CONFIG="$pth_config_prefix/bin/pth-config"
800 if test "$enable_random_daemon" = "yes"; then
801 AC_PATH_PROG(PTH_CONFIG, pth-config, no)
802 if test "$PTH_CONFIG" = "no"; then
805 *** To build the Libgcrypt's random number daemon
806 *** we need the support of the GNU Portable Threads Library.
807 *** Download it from ftp://ftp.gnu.org/gnu/pth/
808 *** On a Debian GNU/Linux system you might want to try
809 *** apt-get install libpth-dev
812 GNUPG_PTH_VERSION_CHECK([1.3.7])
813 if test $have_pth = yes; then
814 PTH_CFLAGS=`$PTH_CONFIG --cflags`
815 PTH_LIBS=`$PTH_CONFIG --ldflags`
816 PTH_LIBS="$PTH_LIBS `$PTH_CONFIG --libs --all`"
817 AC_DEFINE(USE_GNU_PTH, 1,
818 [Defined if the GNU Portable Thread Library should be used])
819 AC_DEFINE(HAVE_PTH, 1,
820 [Defined if the GNU Pth is available])
828 # Check whether pthreads is available
830 if test "$have_w32_system" != yes; then
831 AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
832 if test "$have_pthread" = yes; then
833 AC_DEFINE(HAVE_PTHREAD, 1 ,[Define if we have pthread.])
838 # Solaris needs -lsocket and -lnsl. Unisys system includes
839 # gethostbyname in libsocket but needs libnsl for socket.
840 AC_SEARCH_LIBS(setsockopt, [socket], ,
841 [AC_SEARCH_LIBS(setsockopt, [socket], , , [-lnsl])])
842 AC_SEARCH_LIBS(setsockopt, [nsl])
844 ##################################
845 #### Checks for header files. ####
846 ##################################
848 AC_CHECK_HEADERS(unistd.h sys/auxv.h sys/random.h)
851 ##########################################
852 #### Checks for typedefs, structures, ####
853 #### and compiler characteristics. ####
854 ##########################################
861 AC_CHECK_TYPES([byte, ushort, u16, u32, u64])
866 # Check for __builtin_bswap32 intrinsic.
868 AC_CACHE_CHECK(for __builtin_bswap32,
869 [gcry_cv_have_builtin_bswap32],
870 [gcry_cv_have_builtin_bswap32=no
871 AC_LINK_IFELSE([AC_LANG_PROGRAM([],
872 [int x = 0; int y = __builtin_bswap32(x); return y;])],
873 [gcry_cv_have_builtin_bswap32=yes])])
874 if test "$gcry_cv_have_builtin_bswap32" = "yes" ; then
875 AC_DEFINE(HAVE_BUILTIN_BSWAP32,1,
876 [Defined if compiler has '__builtin_bswap32' intrinsic])
881 # Check for __builtin_bswap64 intrinsic.
883 AC_CACHE_CHECK(for __builtin_bswap64,
884 [gcry_cv_have_builtin_bswap64],
885 [gcry_cv_have_builtin_bswap64=no
886 AC_LINK_IFELSE([AC_LANG_PROGRAM([],
887 [long long x = 0; long long y = __builtin_bswap64(x); return y;])],
888 [gcry_cv_have_builtin_bswap64=yes])])
889 if test "$gcry_cv_have_builtin_bswap64" = "yes" ; then
890 AC_DEFINE(HAVE_BUILTIN_BSWAP64,1,
891 [Defined if compiler has '__builtin_bswap64' intrinsic])
896 # Check for __builtin_ctz intrinsic.
898 AC_CACHE_CHECK(for __builtin_ctz,
899 [gcry_cv_have_builtin_ctz],
900 [gcry_cv_have_builtin_ctz=no
901 AC_LINK_IFELSE([AC_LANG_PROGRAM([],
902 [unsigned int x = 0; int y = __builtin_ctz(x); return y;])],
903 [gcry_cv_have_builtin_ctz=yes])])
904 if test "$gcry_cv_have_builtin_ctz" = "yes" ; then
905 AC_DEFINE(HAVE_BUILTIN_CTZ, 1,
906 [Defined if compiler has '__builtin_ctz' intrinsic])
911 # Check for __builtin_ctzl intrinsic.
913 AC_CACHE_CHECK(for __builtin_ctzl,
914 [gcry_cv_have_builtin_ctzl],
915 [gcry_cv_have_builtin_ctzl=no
916 AC_LINK_IFELSE([AC_LANG_PROGRAM([],
917 [unsigned long x = 0; long y = __builtin_ctzl(x); return y;])],
918 [gcry_cv_have_builtin_ctzl=yes])])
919 if test "$gcry_cv_have_builtin_ctzl" = "yes" ; then
920 AC_DEFINE(HAVE_BUILTIN_CTZL, 1,
921 [Defined if compiler has '__builtin_ctzl' intrinsic])
926 # Check for __builtin_clz intrinsic.
928 AC_CACHE_CHECK(for __builtin_clz,
929 [gcry_cv_have_builtin_clz],
930 [gcry_cv_have_builtin_clz=no
931 AC_LINK_IFELSE([AC_LANG_PROGRAM([],
932 [unsigned int x = 0; int y = __builtin_clz(x); return y;])],
933 [gcry_cv_have_builtin_clz=yes])])
934 if test "$gcry_cv_have_builtin_clz" = "yes" ; then
935 AC_DEFINE(HAVE_BUILTIN_CLZ, 1,
936 [Defined if compiler has '__builtin_clz' intrinsic])
941 # Check for __builtin_clzl intrinsic.
943 AC_CACHE_CHECK(for __builtin_clzl,
944 [gcry_cv_have_builtin_clzl],
945 [gcry_cv_have_builtin_clzl=no
946 AC_LINK_IFELSE([AC_LANG_PROGRAM([],
947 [unsigned long x = 0; long y = __builtin_clzl(x); return y;])],
948 [gcry_cv_have_builtin_clzl=yes])])
949 if test "$gcry_cv_have_builtin_clzl" = "yes" ; then
950 AC_DEFINE(HAVE_BUILTIN_CLZL, 1,
951 [Defined if compiler has '__builtin_clzl' intrinsic])
956 # Check for __sync_synchronize intrinsic.
958 AC_CACHE_CHECK(for __sync_synchronize,
959 [gcry_cv_have_sync_synchronize],
960 [gcry_cv_have_sync_synchronize=no
961 AC_LINK_IFELSE([AC_LANG_PROGRAM([],
962 [__sync_synchronize(); return 0;])],
963 [gcry_cv_have_sync_synchronize=yes])])
964 if test "$gcry_cv_have_sync_synchronize" = "yes" ; then
965 AC_DEFINE(HAVE_SYNC_SYNCHRONIZE, 1,
966 [Defined if compiler has '__sync_synchronize' intrinsic])
971 # Check for VLA support (variable length arrays).
973 AC_CACHE_CHECK(whether the variable length arrays are supported,
976 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
977 [[void f1(char *, int);
979 char b[(i < 0 ? 0 : i) + 1];
980 f1(b, sizeof b); return b[0];}]])],
981 [gcry_cv_have_vla=yes])])
982 if test "$gcry_cv_have_vla" = "yes" ; then
983 AC_DEFINE(HAVE_VLA,1, [Defined if variable length arrays are supported])
988 # Check for ELF visibility support.
990 AC_CACHE_CHECK(whether the visibility attribute is supported,
991 gcry_cv_visibility_attribute,
992 [gcry_cv_visibility_attribute=no
993 AC_LANG_CONFTEST([AC_LANG_SOURCE(
994 [[int foo __attribute__ ((visibility ("hidden"))) = 1;
995 int bar __attribute__ ((visibility ("protected"))) = 1;
998 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
999 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
1000 if grep '\.hidden.*foo' conftest.s >/dev/null 2>&1 ; then
1001 if grep '\.protected.*bar' conftest.s >/dev/null 2>&1; then
1002 gcry_cv_visibility_attribute=yes
1007 if test "$gcry_cv_visibility_attribute" = "yes"; then
1008 AC_CACHE_CHECK(for broken visibility attribute,
1009 gcry_cv_broken_visibility_attribute,
1010 [gcry_cv_broken_visibility_attribute=yes
1011 AC_LANG_CONFTEST([AC_LANG_SOURCE(
1013 int bar (int x) __asm__ ("foo")
1014 __attribute__ ((visibility ("hidden")));
1015 int bar (int x) { return x; }
1018 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
1019 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
1020 if grep '\.hidden@<:@ _@:>@foo' conftest.s >/dev/null 2>&1;
1022 gcry_cv_broken_visibility_attribute=no
1027 if test "$gcry_cv_visibility_attribute" = "yes"; then
1028 AC_CACHE_CHECK(for broken alias attribute,
1029 gcry_cv_broken_alias_attribute,
1030 [gcry_cv_broken_alias_attribute=yes
1031 AC_LANG_CONFTEST([AC_LANG_SOURCE(
1032 [[extern int foo (int x) __asm ("xyzzy");
1033 int bar (int x) { return x; }
1034 extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
1036 extern __typeof (dfoo) dfoo __asm ("abccb");
1040 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
1041 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
1042 if grep 'xyzzy' conftest.s >/dev/null 2>&1 && \
1043 grep 'abccb' conftest.s >/dev/null 2>&1; then
1044 gcry_cv_broken_alias_attribute=no
1049 if test "$gcry_cv_visibility_attribute" = "yes"; then
1050 AC_CACHE_CHECK(if gcc supports -fvisibility=hidden,
1051 gcry_cv_gcc_has_f_visibility,
1052 [gcry_cv_gcc_has_f_visibility=no
1053 _gcc_cflags_save=$CFLAGS
1054 CFLAGS="-fvisibility=hidden"
1055 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
1056 gcry_cv_gcc_has_f_visibility=yes)
1057 CFLAGS=$_gcc_cflags_save;
1060 if test "$gcry_cv_visibility_attribute" = "yes" \
1061 && test "$gcry_cv_broken_visibility_attribute" != "yes" \
1062 && test "$gcry_cv_broken_alias_attribute" != "yes" \
1063 && test "$gcry_cv_gcc_has_f_visibility" = "yes"
1065 AC_DEFINE(GCRY_USE_VISIBILITY, 1,
1066 [Define to use the GNU C visibility attribute.])
1067 CFLAGS="$CFLAGS -fvisibility=hidden"
1071 # Following attribute tests depend on warnings to cause compile to fail,
1072 # so set -Werror temporarily.
1073 _gcc_cflags_save=$CFLAGS
1074 CFLAGS="$CFLAGS -Werror"
1078 # Check whether the compiler supports the GCC style aligned attribute
1080 AC_CACHE_CHECK([whether the GCC style aligned attribute is supported],
1081 [gcry_cv_gcc_attribute_aligned],
1082 [gcry_cv_gcc_attribute_aligned=no
1083 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1084 [[struct { int a; } foo __attribute__ ((aligned (16)));]])],
1085 [gcry_cv_gcc_attribute_aligned=yes])])
1086 if test "$gcry_cv_gcc_attribute_aligned" = "yes" ; then
1087 AC_DEFINE(HAVE_GCC_ATTRIBUTE_ALIGNED,1,
1088 [Defined if a GCC style "__attribute__ ((aligned (n))" is supported])
1093 # Check whether the compiler supports the GCC style packed attribute
1095 AC_CACHE_CHECK([whether the GCC style packed attribute is supported],
1096 [gcry_cv_gcc_attribute_packed],
1097 [gcry_cv_gcc_attribute_packed=no
1098 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1099 [[struct foolong_s { long b; } __attribute__ ((packed));
1100 struct foo_s { char a; struct foolong_s b; }
1101 __attribute__ ((packed));
1103 FOO = 1 / (sizeof(struct foo_s) == (sizeof(char) + sizeof(long))),
1105 [gcry_cv_gcc_attribute_packed=yes])])
1106 if test "$gcry_cv_gcc_attribute_packed" = "yes" ; then
1107 AC_DEFINE(HAVE_GCC_ATTRIBUTE_PACKED,1,
1108 [Defined if a GCC style "__attribute__ ((packed))" is supported])
1113 # Check whether the compiler supports the GCC style may_alias attribute
1115 AC_CACHE_CHECK([whether the GCC style may_alias attribute is supported],
1116 [gcry_cv_gcc_attribute_may_alias],
1117 [gcry_cv_gcc_attribute_may_alias=no
1118 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1119 [[typedef struct foo_s { int a; }
1120 __attribute__ ((may_alias)) foo_t;]])],
1121 [gcry_cv_gcc_attribute_may_alias=yes])])
1122 if test "$gcry_cv_gcc_attribute_may_alias" = "yes" ; then
1123 AC_DEFINE(HAVE_GCC_ATTRIBUTE_MAY_ALIAS,1,
1124 [Defined if a GCC style "__attribute__ ((may_alias))" is supported])
1129 CFLAGS=$_gcc_cflags_save;
1133 # Check whether the compiler supports 'asm' or '__asm__' keyword for
1136 AC_CACHE_CHECK([whether 'asm' assembler keyword is supported],
1138 [gcry_cv_have_asm=no
1139 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1140 [[void a(void) { asm("":::"memory"); }]])],
1141 [gcry_cv_have_asm=yes])])
1142 AC_CACHE_CHECK([whether '__asm__' assembler keyword is supported],
1143 [gcry_cv_have___asm__],
1144 [gcry_cv_have___asm__=no
1145 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1146 [[void a(void) { __asm__("":::"memory"); }]])],
1147 [gcry_cv_have___asm__=yes])])
1148 if test "$gcry_cv_have_asm" = "no" ; then
1149 if test "$gcry_cv_have___asm__" = "yes" ; then
1150 AC_DEFINE(asm,__asm__,
1151 [Define to supported assembler block keyword, if plain 'asm' was not
1158 # Check whether the compiler supports inline assembly memory barrier.
1160 if test "$gcry_cv_have_asm" = "no" ; then
1161 if test "$gcry_cv_have___asm__" = "yes" ; then
1162 AC_CACHE_CHECK([whether inline assembly memory barrier is supported],
1163 [gcry_cv_have_asm_volatile_memory],
1164 [gcry_cv_have_asm_volatile_memory=no
1165 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1168 __asm__ volatile("":::"memory");
1169 __asm__ volatile("":"+r"(x)::"memory");
1171 [gcry_cv_have_asm_volatile_memory=yes])])
1174 AC_CACHE_CHECK([whether inline assembly memory barrier is supported],
1175 [gcry_cv_have_asm_volatile_memory],
1176 [gcry_cv_have_asm_volatile_memory=no
1177 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1180 asm volatile("":::"memory");
1181 asm volatile("":"+r"(x)::"memory"); }]])],
1182 [gcry_cv_have_asm_volatile_memory=yes])])
1184 if test "$gcry_cv_have_asm_volatile_memory" = "yes" ; then
1185 AC_DEFINE(HAVE_GCC_ASM_VOLATILE_MEMORY,1,
1186 [Define if inline asm memory barrier is supported])
1191 # Check whether GCC assembler supports features needed for our ARM
1192 # implementations. This needs to be done before setting up the
1195 AC_CACHE_CHECK([whether GCC assembler is compatible for ARM assembly implementations],
1196 [gcry_cv_gcc_arm_platform_as_ok],
1197 [if test "$try_asm_modules" != "yes" ; then
1198 gcry_cv_gcc_arm_platform_as_ok="n/a"
1200 gcry_cv_gcc_arm_platform_as_ok=no
1201 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1203 /* Test if assembler supports UAL syntax. */
1204 ".syntax unified\n\t"
1205 ".arm\n\t" /* our assembly code is in ARM mode */
1207 /* Following causes error if assembler ignored '.syntax unified'. */
1209 "add %r0, %r0, %r4, ror #12;\n\t"
1211 /* Test if '.type' and '.size' are supported. */
1212 ".size asmfunc,.-asmfunc;\n\t"
1213 ".type asmfunc,%function;\n\t"
1214 );]], [ asmfunc(); ] )],
1215 [gcry_cv_gcc_arm_platform_as_ok=yes])
1217 if test "$gcry_cv_gcc_arm_platform_as_ok" = "yes" ; then
1218 AC_DEFINE(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS,1,
1219 [Defined if underlying assembler is compatible with ARM assembly implementations])
1224 # Check whether GCC assembler supports features needed for our ARMv8/Aarch64
1225 # implementations. This needs to be done before setting up the
1228 AC_CACHE_CHECK([whether GCC assembler is compatible for ARMv8/Aarch64 assembly implementations],
1229 [gcry_cv_gcc_aarch64_platform_as_ok],
1230 [if test "$try_asm_modules" != "yes" ; then
1231 gcry_cv_gcc_aarch64_platform_as_ok="n/a"
1233 gcry_cv_gcc_aarch64_platform_as_ok=no
1234 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1238 "eor x0, x0, x30, ror #12;\n\t"
1239 "add x0, x0, x30, asr #12;\n\t"
1240 "eor v0.16b, v0.16b, v31.16b;\n\t"
1241 );]], [ asmfunc(); ] )],
1242 [gcry_cv_gcc_aarch64_platform_as_ok=yes])
1244 if test "$gcry_cv_gcc_aarch64_platform_as_ok" = "yes" ; then
1245 AC_DEFINE(HAVE_COMPATIBLE_GCC_AARCH64_PLATFORM_AS,1,
1246 [Defined if underlying assembler is compatible with ARMv8/Aarch64 assembly implementations])
1250 # Check whether GCC assembler supports for CFI directives.
1252 AC_CACHE_CHECK([whether GCC assembler supports for CFI directives],
1253 [gcry_cv_gcc_asm_cfi_directives],
1254 [gcry_cv_gcc_asm_cfi_directives=no
1255 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1259 ".cfi_startproc\n\t"
1260 ".cfi_remember_state\n\t"
1261 ".cfi_adjust_cfa_offset 8\n\t"
1262 ".cfi_rel_offset 0, 8\n\t"
1263 ".cfi_def_cfa_register 1\n\t"
1264 ".cfi_register 2, 3\n\t"
1265 ".cfi_restore 2\n\t"
1266 ".cfi_escape 0x0f, 0x02, 0x11, 0x00\n\t"
1267 ".cfi_restore_state\n\t"
1271 [gcry_cv_gcc_asm_cfi_directives=yes])])
1272 if test "$gcry_cv_gcc_asm_cfi_directives" = "yes" ; then
1273 AC_DEFINE(HAVE_GCC_ASM_CFI_DIRECTIVES,1,
1274 [Defined if underlying assembler supports for CFI directives])
1279 # Check whether GCC assembler supports for ELF directives.
1281 AC_CACHE_CHECK([whether GCC assembler supports for ELF directives],
1282 [gcry_cv_gcc_asm_elf_directives],
1283 [gcry_cv_gcc_asm_elf_directives=no
1284 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1286 /* Test if ELF directives '.type' and '.size' are supported. */
1289 ".size asmfunc,.-asmfunc;\n\t"
1290 ".type asmfunc,STT_FUNC;\n\t"
1292 [gcry_cv_gcc_asm_elf_directives=yes])])
1293 if test "$gcry_cv_gcc_asm_elf_directives" = "yes" ; then
1294 AC_DEFINE(HAVE_GCC_ASM_ELF_DIRECTIVES,1,
1295 [Defined if underlying assembler supports for ELF directives])
1300 # Check whether underscores in symbols are required. This needs to be
1301 # done before setting up the assembler stuff.
1303 GNUPG_SYS_SYMBOL_UNDERSCORE()
1306 #################################
1308 #### Setup assembler stuff. ####
1309 #### Define mpi_cpu_arch. ####
1311 #################################
1312 AC_ARG_ENABLE(mpi-path,
1313 AS_HELP_STRING([--enable-mpi-path=EXTRA_PATH],
1314 [prepend EXTRA_PATH to list of CPU specific optimizations]),
1315 mpi_extra_path="$enableval",mpi_extra_path="")
1316 AC_MSG_CHECKING(architecture and mpi assembler functions)
1317 if test -f $srcdir/mpi/config.links ; then
1318 . $srcdir/mpi/config.links
1319 AC_CONFIG_LINKS("$mpi_ln_list")
1320 ac_cv_mpi_sflags="$mpi_sflags"
1321 AC_MSG_RESULT($mpi_cpu_arch)
1323 AC_MSG_RESULT(failed)
1324 AC_MSG_ERROR([mpi/config.links missing!])
1326 MPI_SFLAGS="$ac_cv_mpi_sflags"
1327 AC_SUBST(MPI_SFLAGS)
1329 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_ADD1, test "$mpi_mod_asm_mpih_add1" = yes)
1330 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_SUB1, test "$mpi_mod_asm_mpih_sub1" = yes)
1331 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL1, test "$mpi_mod_asm_mpih_mul1" = yes)
1332 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL2, test "$mpi_mod_asm_mpih_mul2" = yes)
1333 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL3, test "$mpi_mod_asm_mpih_mul3" = yes)
1334 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_LSHIFT, test "$mpi_mod_asm_mpih_lshift" = yes)
1335 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_RSHIFT, test "$mpi_mod_asm_mpih_rshift" = yes)
1336 AM_CONDITIONAL(MPI_MOD_ASM_UDIV, test "$mpi_mod_asm_udiv" = yes)
1337 AM_CONDITIONAL(MPI_MOD_ASM_UDIV_QRNND, test "$mpi_mod_asm_udiv_qrnnd" = yes)
1338 AM_CONDITIONAL(MPI_MOD_C_MPIH_ADD1, test "$mpi_mod_c_mpih_add1" = yes)
1339 AM_CONDITIONAL(MPI_MOD_C_MPIH_SUB1, test "$mpi_mod_c_mpih_sub1" = yes)
1340 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL1, test "$mpi_mod_c_mpih_mul1" = yes)
1341 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL2, test "$mpi_mod_c_mpih_mul2" = yes)
1342 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL3, test "$mpi_mod_c_mpih_mul3" = yes)
1343 AM_CONDITIONAL(MPI_MOD_C_MPIH_LSHIFT, test "$mpi_mod_c_mpih_lshift" = yes)
1344 AM_CONDITIONAL(MPI_MOD_C_MPIH_RSHIFT, test "$mpi_mod_c_mpih_rshift" = yes)
1345 AM_CONDITIONAL(MPI_MOD_C_UDIV, test "$mpi_mod_c_udiv" = yes)
1346 AM_CONDITIONAL(MPI_MOD_C_UDIV_QRNND, test "$mpi_mod_c_udiv_qrnnd" = yes)
1348 # Reset non applicable feature flags.
1349 if test "$mpi_cpu_arch" != "x86" ; then
1356 padlocksupport="n/a"
1360 if test "$mpi_cpu_arch" != "arm" ; then
1361 if test "$mpi_cpu_arch" != "aarch64" ; then
1363 armcryptosupport="n/a"
1367 if test "$mpi_cpu_arch" != "ppc"; then
1368 ppccryptosupport="n/a"
1371 #############################################
1373 #### Platform specific compiler checks. ####
1375 #############################################
1378 # Following tests depend on warnings to cause compile to fail, so set -Werror
1380 _gcc_cflags_save=$CFLAGS
1381 CFLAGS="$CFLAGS -Werror"
1385 # Check whether compiler supports 'ms_abi' function attribute.
1387 AC_CACHE_CHECK([whether compiler supports 'ms_abi' function attribute],
1388 [gcry_cv_gcc_attribute_ms_abi],
1389 [gcry_cv_gcc_attribute_ms_abi=no
1390 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1391 [[int __attribute__ ((ms_abi)) proto(int);]])],
1392 [gcry_cv_gcc_attribute_ms_abi=yes])])
1393 if test "$gcry_cv_gcc_attribute_ms_abi" = "yes" ; then
1394 AC_DEFINE(HAVE_GCC_ATTRIBUTE_MS_ABI,1,
1395 [Defined if compiler supports "__attribute__ ((ms_abi))" function attribute])
1400 # Check whether compiler supports 'sysv_abi' function attribute.
1402 AC_CACHE_CHECK([whether compiler supports 'sysv_abi' function attribute],
1403 [gcry_cv_gcc_attribute_sysv_abi],
1404 [gcry_cv_gcc_attribute_sysv_abi=no
1405 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1406 [[int __attribute__ ((sysv_abi)) proto(int);]])],
1407 [gcry_cv_gcc_attribute_sysv_abi=yes])])
1408 if test "$gcry_cv_gcc_attribute_sysv_abi" = "yes" ; then
1409 AC_DEFINE(HAVE_GCC_ATTRIBUTE_SYSV_ABI,1,
1410 [Defined if compiler supports "__attribute__ ((sysv_abi))" function attribute])
1415 # Check whether default calling convention is 'ms_abi'.
1417 if test "$gcry_cv_gcc_attribute_ms_abi" = "yes" ; then
1418 AC_CACHE_CHECK([whether default calling convention is 'ms_abi'],
1419 [gcry_cv_gcc_default_abi_is_ms_abi],
1420 [gcry_cv_gcc_default_abi_is_ms_abi=no
1421 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1422 [[void *test(void) {
1423 void *(*def_func)(void) = test;
1424 void *__attribute__((ms_abi))(*msabi_func)(void);
1425 /* warning on SysV abi targets, passes on Windows based targets */
1426 msabi_func = def_func;
1429 [gcry_cv_gcc_default_abi_is_ms_abi=yes])])
1430 if test "$gcry_cv_gcc_default_abi_is_ms_abi" = "yes" ; then
1431 AC_DEFINE(HAVE_GCC_DEFAULT_ABI_IS_MS_ABI,1,
1432 [Defined if default calling convention is 'ms_abi'])
1438 # Check whether default calling convention is 'sysv_abi'.
1440 if test "$gcry_cv_gcc_attribute_sysv_abi" = "yes" ; then
1441 AC_CACHE_CHECK([whether default calling convention is 'sysv_abi'],
1442 [gcry_cv_gcc_default_abi_is_sysv_abi],
1443 [gcry_cv_gcc_default_abi_is_sysv_abi=no
1444 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1445 [[void *test(void) {
1446 void *(*def_func)(void) = test;
1447 void *__attribute__((sysv_abi))(*sysvabi_func)(void);
1448 /* warning on MS ABI targets, passes on SysV ABI targets */
1449 sysvabi_func = def_func;
1450 return sysvabi_func;
1452 [gcry_cv_gcc_default_abi_is_sysv_abi=yes])])
1453 if test "$gcry_cv_gcc_default_abi_is_sysv_abi" = "yes" ; then
1454 AC_DEFINE(HAVE_GCC_DEFAULT_ABI_IS_SYSV_ABI,1,
1455 [Defined if default calling convention is 'sysv_abi'])
1461 CFLAGS=$_gcc_cflags_save;
1465 # Check whether GCC inline assembler supports SSSE3 instructions
1466 # This is required for the AES-NI instructions.
1468 AC_CACHE_CHECK([whether GCC inline assembler supports SSSE3 instructions],
1469 [gcry_cv_gcc_inline_asm_ssse3],
1470 [if test "$mpi_cpu_arch" != "x86" ||
1471 test "$try_asm_modules" != "yes" ; then
1472 gcry_cv_gcc_inline_asm_ssse3="n/a"
1474 gcry_cv_gcc_inline_asm_ssse3=no
1475 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1476 [[static unsigned char be_mask[16] __attribute__ ((aligned (16))) =
1477 { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
1479 __asm__("pshufb %[mask], %%xmm2\n\t"::[mask]"m"(*be_mask):);
1481 [gcry_cv_gcc_inline_asm_ssse3=yes])
1483 if test "$gcry_cv_gcc_inline_asm_ssse3" = "yes" ; then
1484 AC_DEFINE(HAVE_GCC_INLINE_ASM_SSSE3,1,
1485 [Defined if inline assembler supports SSSE3 instructions])
1490 # Check whether GCC inline assembler supports PCLMUL instructions.
1492 AC_CACHE_CHECK([whether GCC inline assembler supports PCLMUL instructions],
1493 [gcry_cv_gcc_inline_asm_pclmul],
1494 [if test "$mpi_cpu_arch" != "x86" ||
1495 test "$try_asm_modules" != "yes" ; then
1496 gcry_cv_gcc_inline_asm_pclmul="n/a"
1498 gcry_cv_gcc_inline_asm_pclmul=no
1499 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1501 __asm__("pclmulqdq \$0, %%xmm1, %%xmm3\n\t":::"cc");
1503 [gcry_cv_gcc_inline_asm_pclmul=yes])
1505 if test "$gcry_cv_gcc_inline_asm_pclmul" = "yes" ; then
1506 AC_DEFINE(HAVE_GCC_INLINE_ASM_PCLMUL,1,
1507 [Defined if inline assembler supports PCLMUL instructions])
1512 # Check whether GCC inline assembler supports SHA Extensions instructions.
1514 AC_CACHE_CHECK([whether GCC inline assembler supports SHA Extensions instructions],
1515 [gcry_cv_gcc_inline_asm_shaext],
1516 [if test "$mpi_cpu_arch" != "x86" ||
1517 test "$try_asm_modules" != "yes" ; then
1518 gcry_cv_gcc_inline_asm_shaext="n/a"
1520 gcry_cv_gcc_inline_asm_shaext=no
1521 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1523 __asm__("sha1rnds4 \$0, %%xmm1, %%xmm3\n\t":::"cc");
1524 __asm__("sha1nexte %%xmm1, %%xmm3\n\t":::"cc");
1525 __asm__("sha1msg1 %%xmm1, %%xmm3\n\t":::"cc");
1526 __asm__("sha1msg2 %%xmm1, %%xmm3\n\t":::"cc");
1527 __asm__("sha256rnds2 %%xmm0, %%xmm1, %%xmm3\n\t":::"cc");
1528 __asm__("sha256msg1 %%xmm1, %%xmm3\n\t":::"cc");
1529 __asm__("sha256msg2 %%xmm1, %%xmm3\n\t":::"cc");
1531 [gcry_cv_gcc_inline_asm_shaext=yes])
1533 if test "$gcry_cv_gcc_inline_asm_shaext" = "yes" ; then
1534 AC_DEFINE(HAVE_GCC_INLINE_ASM_SHAEXT,1,
1535 [Defined if inline assembler supports SHA Extensions instructions])
1540 # Check whether GCC inline assembler supports SSE4.1 instructions.
1542 AC_CACHE_CHECK([whether GCC inline assembler supports SSE4.1 instructions],
1543 [gcry_cv_gcc_inline_asm_sse41],
1544 [if test "$mpi_cpu_arch" != "x86" ||
1545 test "$try_asm_modules" != "yes" ; then
1546 gcry_cv_gcc_inline_asm_sse41="n/a"
1548 gcry_cv_gcc_inline_asm_sse41=no
1549 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1552 __asm__("pextrd \$2, %%xmm0, %[out]\n\t" : [out] "=m" (i));
1554 [gcry_cv_gcc_inline_asm_sse41=yes])
1556 if test "$gcry_cv_gcc_inline_asm_sse41" = "yes" ; then
1557 AC_DEFINE(HAVE_GCC_INLINE_ASM_SSE41,1,
1558 [Defined if inline assembler supports SSE4.1 instructions])
1563 # Check whether GCC inline assembler supports AVX instructions
1565 AC_CACHE_CHECK([whether GCC inline assembler supports AVX instructions],
1566 [gcry_cv_gcc_inline_asm_avx],
1567 [if test "$mpi_cpu_arch" != "x86" ||
1568 test "$try_asm_modules" != "yes" ; then
1569 gcry_cv_gcc_inline_asm_avx="n/a"
1571 gcry_cv_gcc_inline_asm_avx=no
1572 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1574 __asm__("xgetbv; vaesdeclast (%[mem]),%%xmm0,%%xmm7\n\t"::[mem]"r"(0):);
1576 [gcry_cv_gcc_inline_asm_avx=yes])
1578 if test "$gcry_cv_gcc_inline_asm_avx" = "yes" ; then
1579 AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX,1,
1580 [Defined if inline assembler supports AVX instructions])
1585 # Check whether GCC inline assembler supports AVX2 instructions
1587 AC_CACHE_CHECK([whether GCC inline assembler supports AVX2 instructions],
1588 [gcry_cv_gcc_inline_asm_avx2],
1589 [if test "$mpi_cpu_arch" != "x86" ||
1590 test "$try_asm_modules" != "yes" ; then
1591 gcry_cv_gcc_inline_asm_avx2="n/a"
1593 gcry_cv_gcc_inline_asm_avx2=no
1594 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1596 __asm__("xgetbv; vpbroadcastb %%xmm7,%%ymm1\n\t":::"cc");
1598 [gcry_cv_gcc_inline_asm_avx2=yes])
1600 if test "$gcry_cv_gcc_inline_asm_avx2" = "yes" ; then
1601 AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX2,1,
1602 [Defined if inline assembler supports AVX2 instructions])
1607 # Check whether GCC inline assembler supports VAES and VPCLMUL instructions
1609 AC_CACHE_CHECK([whether GCC inline assembler supports VAES and VPCLMUL instructions],
1610 [gcry_cv_gcc_inline_asm_vaes_vpclmul],
1611 [if test "$mpi_cpu_arch" != "x86" ||
1612 test "$try_asm_modules" != "yes" ; then
1613 gcry_cv_gcc_inline_asm_vaes_vpclmul="n/a"
1615 gcry_cv_gcc_inline_asm_vaes_vpclmul=no
1616 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1618 __asm__("vaesenclast %%ymm7,%%ymm7,%%ymm1\n\t":::"cc");/*256-bit*/
1619 __asm__("vaesenclast %%zmm7,%%zmm7,%%zmm1\n\t":::"cc");/*512-bit*/
1620 __asm__("vpclmulqdq \$0,%%ymm7,%%ymm7,%%ymm1\n\t":::"cc");/*256-bit*/
1621 __asm__("vpclmulqdq \$0,%%zmm7,%%zmm7,%%zmm1\n\t":::"cc");/*512-bit*/
1623 [gcry_cv_gcc_inline_asm_vaes_vpclmul=yes])
1625 if test "$gcry_cv_gcc_inline_asm_vaes_vpclmul" = "yes" ; then
1626 AC_DEFINE(HAVE_GCC_INLINE_ASM_VAES_VPCLMUL,1,
1627 [Defined if inline assembler supports VAES and VPCLMUL instructions])
1632 # Check whether GCC inline assembler supports BMI2 instructions
1634 AC_CACHE_CHECK([whether GCC inline assembler supports BMI2 instructions],
1635 [gcry_cv_gcc_inline_asm_bmi2],
1636 [if test "$mpi_cpu_arch" != "x86" ||
1637 test "$try_asm_modules" != "yes" ; then
1638 gcry_cv_gcc_inline_asm_bmi2="n/a"
1640 gcry_cv_gcc_inline_asm_bmi2=no
1641 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1642 [[unsigned int a(unsigned int x, unsigned int y) {
1643 unsigned int tmp1, tmp2;
1644 asm ("rorxl %2, %1, %0"
1646 : "rm0" (x), "J" (32 - ((23) & 31)));
1647 asm ("andnl %2, %1, %0"
1649 : "r0" (x), "rm" (y));
1651 }]], [ a(1, 2); ] )],
1652 [gcry_cv_gcc_inline_asm_bmi2=yes])
1654 if test "$gcry_cv_gcc_inline_asm_bmi2" = "yes" ; then
1655 AC_DEFINE(HAVE_GCC_INLINE_ASM_BMI2,1,
1656 [Defined if inline assembler supports BMI2 instructions])
1661 # Check whether GCC assembler needs "-Wa,--divide" to correctly handle
1664 if test $amd64_as_feature_detection = yes; then
1665 AC_CACHE_CHECK([whether GCC assembler handles division correctly],
1666 [gcry_cv_gcc_as_const_division_ok],
1667 [gcry_cv_gcc_as_const_division_ok=no
1668 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1669 [[__asm__(".text\n\tfn:\n\t xorl \$(123456789/12345678), %ebp;\n\t");]],
1671 [gcry_cv_gcc_as_const_division_ok=yes])])
1672 if test "$gcry_cv_gcc_as_const_division_ok" = "no" ; then
1674 # Add '-Wa,--divide' to CPPFLAGS and try check again.
1676 _gcc_cppflags_save="$CPPFLAGS"
1677 CPPFLAGS="$CPPFLAGS -Wa,--divide"
1678 AC_CACHE_CHECK([whether GCC assembler handles division correctly with "-Wa,--divide"],
1679 [gcry_cv_gcc_as_const_division_with_wadivide_ok],
1680 [gcry_cv_gcc_as_const_division_with_wadivide_ok=no
1681 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1682 [[__asm__(".text\n\tfn:\n\t xorl \$(123456789/12345678), %ebp;\n\t");]],
1684 [gcry_cv_gcc_as_const_division_with_wadivide_ok=yes])])
1685 if test "$gcry_cv_gcc_as_const_division_with_wadivide_ok" = "no" ; then
1686 # '-Wa,--divide' did not work, restore old flags.
1687 CPPFLAGS="$_gcc_cppflags_save"
1694 # Check whether GCC assembler supports features needed for our amd64
1697 if test $amd64_as_feature_detection = yes; then
1698 AC_CACHE_CHECK([whether GCC assembler is compatible for amd64 assembly implementations],
1699 [gcry_cv_gcc_amd64_platform_as_ok],
1700 [if test "$mpi_cpu_arch" != "x86" ||
1701 test "$try_asm_modules" != "yes" ; then
1702 gcry_cv_gcc_amd64_platform_as_ok="n/a"
1704 gcry_cv_gcc_amd64_platform_as_ok=no
1705 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1707 /* Test if '.type' and '.size' are supported. */
1708 /* These work only on ELF targets. */
1711 ".size asmfunc,.-asmfunc;\n\t"
1712 ".type asmfunc,@function;\n\t"
1713 /* Test if assembler allows use of '/' for constant division
1714 * (Solaris/x86 issue). If previous constant division check
1715 * and "-Wa,--divide" workaround failed, this causes assembly
1716 * to be disable on this machine. */
1717 "xorl \$(123456789/12345678), %ebp;\n\t"
1718 );]], [ asmfunc(); ])],
1719 [gcry_cv_gcc_amd64_platform_as_ok=yes])
1721 if test "$gcry_cv_gcc_amd64_platform_as_ok" = "yes" ; then
1722 AC_DEFINE(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS,1,
1723 [Defined if underlying assembler is compatible with amd64 assembly implementations])
1725 if test "$gcry_cv_gcc_amd64_platform_as_ok" = "no" &&
1726 test "$gcry_cv_gcc_attribute_sysv_abi" = "yes" &&
1727 test "$gcry_cv_gcc_default_abi_is_ms_abi" = "yes"; then
1728 AC_CACHE_CHECK([whether GCC assembler is compatible for WIN64 assembly implementations],
1729 [gcry_cv_gcc_win64_platform_as_ok],
1730 [gcry_cv_gcc_win64_platform_as_ok=no
1731 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1734 ".globl asmfunc\n\t"
1736 "xorq \$(1234), %rbp;\n\t"
1737 );]], [ asmfunc(); ])],
1738 [gcry_cv_gcc_win64_platform_as_ok=yes])])
1739 if test "$gcry_cv_gcc_win64_platform_as_ok" = "yes" ; then
1740 AC_DEFINE(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS,1,
1741 [Defined if underlying assembler is compatible with WIN64 assembly implementations])
1748 # Check whether GCC assembler supports features needed for assembly
1749 # implementations that use Intel syntax
1751 AC_CACHE_CHECK([whether GCC assembler is compatible for Intel syntax assembly implementations],
1752 [gcry_cv_gcc_platform_as_ok_for_intel_syntax],
1753 [if test "$mpi_cpu_arch" != "x86" ||
1754 test "$try_asm_modules" != "yes" ; then
1755 gcry_cv_gcc_platform_as_ok_for_intel_syntax="n/a"
1757 gcry_cv_gcc_platform_as_ok_for_intel_syntax=no
1758 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1760 ".intel_syntax noprefix\n\t"
1763 "pxor xmm1, xmm7;\n\t"
1764 "vperm2i128 ymm2, ymm3, ymm0, 1;\n\t"
1766 "rorx eax, ebp, 1;\n\t"
1767 "sub eax, [esp + 4];\n\t"
1768 "add dword ptr [esp + eax], 0b10101;\n\t"
1769 ".att_syntax prefix\n\t"
1770 );]], [ actest(); ])],
1771 [gcry_cv_gcc_platform_as_ok_for_intel_syntax=yes])
1773 if test "$gcry_cv_gcc_platform_as_ok_for_intel_syntax" = "yes" ; then
1774 AC_DEFINE(HAVE_INTEL_SYNTAX_PLATFORM_AS,1,
1775 [Defined if underlying assembler is compatible with Intel syntax assembly implementations])
1780 # Check whether compiler is configured for ARMv6 or newer architecture
1782 AC_CACHE_CHECK([whether compiler is configured for ARMv6 or newer architecture],
1783 [gcry_cv_cc_arm_arch_is_v6],
1784 [if test "$mpi_cpu_arch" != "arm" ||
1785 test "$try_asm_modules" != "yes" ; then
1786 gcry_cv_cc_arm_arch_is_v6="n/a"
1788 gcry_cv_cc_arm_arch_is_v6=no
1789 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1791 #if defined(__arm__) && \
1792 ((defined(__ARM_ARCH) && __ARM_ARCH >= 6) \
1793 || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
1794 || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \
1795 || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) \
1796 || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
1797 || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
1798 || defined(__ARM_ARCH_7EM__))
1801 /* fail compile if not ARMv6. */
1802 not_armv6 not_armv6 = (not_armv6)not_armv6;
1805 [gcry_cv_cc_arm_arch_is_v6=yes])
1807 if test "$gcry_cv_cc_arm_arch_is_v6" = "yes" ; then
1808 AC_DEFINE(HAVE_ARM_ARCH_V6,1,
1809 [Defined if ARM architecture is v6 or newer])
1814 # Check whether GCC inline assembler supports NEON instructions
1816 AC_CACHE_CHECK([whether GCC inline assembler supports NEON instructions],
1817 [gcry_cv_gcc_inline_asm_neon],
1818 [if test "$mpi_cpu_arch" != "arm" ||
1819 test "$try_asm_modules" != "yes" ; then
1820 gcry_cv_gcc_inline_asm_neon="n/a"
1822 gcry_cv_gcc_inline_asm_neon=no
1823 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1825 ".syntax unified\n\t"
1830 "vld1.64 {%q0-%q1}, [%r0]!;\n\t"
1831 "vrev64.8 %q0, %q3;\n\t"
1832 "vadd.u64 %q0, %q1;\n\t"
1833 "vadd.s64 %d3, %d2, %d3;\n\t"
1835 ]], [ testfn(); ])],
1836 [gcry_cv_gcc_inline_asm_neon=yes])
1838 if test "$gcry_cv_gcc_inline_asm_neon" = "yes" ; then
1839 AC_DEFINE(HAVE_GCC_INLINE_ASM_NEON,1,
1840 [Defined if inline assembler supports NEON instructions])
1845 # Check whether GCC inline assembler supports AArch32 Crypto Extension instructions
1847 AC_CACHE_CHECK([whether GCC inline assembler supports AArch32 Crypto Extension instructions],
1848 [gcry_cv_gcc_inline_asm_aarch32_crypto],
1849 [if test "$mpi_cpu_arch" != "arm" ||
1850 test "$try_asm_modules" != "yes" ; then
1851 gcry_cv_gcc_inline_asm_aarch32_crypto="n/a"
1853 gcry_cv_gcc_inline_asm_aarch32_crypto=no
1854 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1856 ".syntax unified\n\t"
1859 ".fpu crypto-neon-fp-armv8\n\t"
1863 "sha1h.32 q0, q0;\n\t"
1864 "sha1c.32 q0, q0, q0;\n\t"
1865 "sha1p.32 q0, q0, q0;\n\t"
1866 "sha1su0.32 q0, q0, q0;\n\t"
1867 "sha1su1.32 q0, q0;\n\t"
1869 "sha256h.32 q0, q0, q0;\n\t"
1870 "sha256h2.32 q0, q0, q0;\n\t"
1871 "sha1p.32 q0, q0, q0;\n\t"
1872 "sha256su0.32 q0, q0;\n\t"
1873 "sha256su1.32 q0, q0, q15;\n\t"
1875 "aese.8 q0, q0;\n\t"
1876 "aesd.8 q0, q0;\n\t"
1877 "aesmc.8 q0, q0;\n\t"
1878 "aesimc.8 q0, q0;\n\t"
1880 "vmull.p64 q0, d0, d0;\n\t"
1882 ]], [ testfn(); ])],
1883 [gcry_cv_gcc_inline_asm_aarch32_crypto=yes])
1885 if test "$gcry_cv_gcc_inline_asm_aarch32_crypto" = "yes" ; then
1886 AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH32_CRYPTO,1,
1887 [Defined if inline assembler supports AArch32 Crypto Extension instructions])
1892 # Check whether GCC inline assembler supports AArch64 NEON instructions
1894 AC_CACHE_CHECK([whether GCC inline assembler supports AArch64 NEON instructions],
1895 [gcry_cv_gcc_inline_asm_aarch64_neon],
1896 [if test "$mpi_cpu_arch" != "aarch64" ||
1897 test "$try_asm_modules" != "yes" ; then
1898 gcry_cv_gcc_inline_asm_aarch64_neon="n/a"
1900 gcry_cv_gcc_inline_asm_aarch64_neon=no
1901 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1903 ".cpu generic+simd\n\t"
1907 "dup v0.8b, w0;\n\t"
1908 "ld4 {v0.8b,v1.8b,v2.8b,v3.8b},[x0],\#32;\n\t"
1910 ]], [ testfn(); ])],
1911 [gcry_cv_gcc_inline_asm_aarch64_neon=yes])
1913 if test "$gcry_cv_gcc_inline_asm_aarch64_neon" = "yes" ; then
1914 AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH64_NEON,1,
1915 [Defined if inline assembler supports AArch64 NEON instructions])
1920 # Check whether GCC inline assembler supports AArch64 Crypto Extension instructions
1922 AC_CACHE_CHECK([whether GCC inline assembler supports AArch64 Crypto Extension instructions],
1923 [gcry_cv_gcc_inline_asm_aarch64_crypto],
1924 [if test "$mpi_cpu_arch" != "aarch64" ||
1925 test "$try_asm_modules" != "yes" ; then
1926 gcry_cv_gcc_inline_asm_aarch64_crypto="n/a"
1928 gcry_cv_gcc_inline_asm_aarch64_crypto=no
1929 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1931 ".cpu generic+simd+crypto\n\t"
1935 "dup v0.8b, w0;\n\t"
1936 "ld4 {v0.8b,v1.8b,v2.8b,v3.8b},[x0],\#32;\n\t"
1939 "sha1c q0, s0, v0.4s;\n\t"
1940 "sha1p q0, s0, v0.4s;\n\t"
1941 "sha1su0 v0.4s, v0.4s, v0.4s;\n\t"
1942 "sha1su1 v0.4s, v0.4s;\n\t"
1944 "sha256h q0, q0, v0.4s;\n\t"
1945 "sha256h2 q0, q0, v0.4s;\n\t"
1946 "sha1p q0, s0, v0.4s;\n\t"
1947 "sha256su0 v0.4s, v0.4s;\n\t"
1948 "sha256su1 v0.4s, v0.4s, v31.4s;\n\t"
1950 "aese v0.16b, v0.16b;\n\t"
1951 "aesd v0.16b, v0.16b;\n\t"
1952 "aesmc v0.16b, v0.16b;\n\t"
1953 "aesimc v0.16b, v0.16b;\n\t"
1955 "pmull v0.1q, v0.1d, v31.1d;\n\t"
1956 "pmull2 v0.1q, v0.2d, v31.2d;\n\t"
1958 ]], [ testfn(); ])],
1959 [gcry_cv_gcc_inline_asm_aarch64_crypto=yes])
1961 if test "$gcry_cv_gcc_inline_asm_aarch64_crypto" = "yes" ; then
1962 AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH64_CRYPTO,1,
1963 [Defined if inline assembler supports AArch64 Crypto Extension instructions])
1968 # Check whether PowerPC AltiVec/VSX intrinsics
1970 AC_CACHE_CHECK([whether compiler supports PowerPC AltiVec/VSX intrinsics],
1971 [gcry_cv_cc_ppc_altivec],
1972 [if test "$mpi_cpu_arch" != "ppc" ||
1973 test "$try_asm_modules" != "yes" ; then
1974 gcry_cv_cc_ppc_altivec="n/a"
1976 gcry_cv_cc_ppc_altivec=no
1977 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1978 [[#include <altivec.h>
1979 typedef vector unsigned char block;
1980 typedef vector unsigned int vecu32;
1983 block t = vec_perm (in, in, vec_vsx_ld (0, (unsigned char*)0));
1984 vecu32 y = vec_vsx_ld (0, (unsigned int*)0);
1985 return vec_cipher_be (t, in) ^ (block)y;
1988 [gcry_cv_cc_ppc_altivec=yes])
1990 if test "$gcry_cv_cc_ppc_altivec" = "yes" ; then
1991 AC_DEFINE(HAVE_COMPATIBLE_CC_PPC_ALTIVEC,1,
1992 [Defined if underlying compiler supports PowerPC AltiVec/VSX/crypto intrinsics])
1995 _gcc_cflags_save=$CFLAGS
1996 CFLAGS="$CFLAGS -maltivec -mvsx -mcrypto"
1998 if test "$gcry_cv_cc_ppc_altivec" = "no" &&
1999 test "$mpi_cpu_arch" = "ppc" &&
2000 test "$try_asm_modules" == "yes" ; then
2001 AC_CACHE_CHECK([whether compiler supports PowerPC AltiVec/VSX/crypto intrinsics with extra GCC flags],
2002 [gcry_cv_cc_ppc_altivec_cflags],
2003 [gcry_cv_cc_ppc_altivec_cflags=no
2004 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
2005 [[#include <altivec.h>
2006 typedef vector unsigned char block;
2007 typedef vector unsigned int vecu32;
2010 block t = vec_perm (in, in, vec_vsx_ld (0, (unsigned char*)0));
2011 vecu32 y = vec_vsx_ld (0, (unsigned int*)0);
2012 return vec_cipher_be (t, in) ^ (block)y;
2014 [gcry_cv_cc_ppc_altivec_cflags=yes])])
2015 if test "$gcry_cv_cc_ppc_altivec_cflags" = "yes" ; then
2016 AC_DEFINE(HAVE_COMPATIBLE_CC_PPC_ALTIVEC,1,
2017 [Defined if underlying compiler supports PowerPC AltiVec/VSX/crypto intrinsics])
2018 AC_DEFINE(HAVE_COMPATIBLE_CC_PPC_ALTIVEC_WITH_CFLAGS,1,
2019 [Defined if underlying compiler supports PowerPC AltiVec/VSX/crypto intrinsics with extra GCC flags])
2023 AM_CONDITIONAL(ENABLE_PPC_VCRYPTO_EXTRA_CFLAGS,
2024 test "$gcry_cv_cc_ppc_altivec_cflags" = "yes")
2027 CFLAGS=$_gcc_cflags_save;
2031 # Check whether GCC inline assembler supports PowerPC AltiVec/VSX/crypto instructions
2033 AC_CACHE_CHECK([whether GCC inline assembler supports PowerPC AltiVec/VSX/crypto instructions],
2034 [gcry_cv_gcc_inline_asm_ppc_altivec],
2035 [if test "$mpi_cpu_arch" != "ppc" ||
2036 test "$try_asm_modules" != "yes" ; then
2037 gcry_cv_gcc_inline_asm_ppc_altivec="n/a"
2039 gcry_cv_gcc_inline_asm_ppc_altivec=no
2040 AC_LINK_IFELSE([AC_LANG_PROGRAM(
2041 [[__asm__(".globl testfn;\n"
2044 "stvx %v31,%r12,%r0;\n"
2045 "lvx %v20,%r12,%r0;\n"
2046 "vcipher %v0, %v1, %v22;\n"
2047 "lxvw4x %vs32, %r0, %r1;\n"
2048 "vadduwm %v0, %v1, %v22;\n"
2049 "vshasigmaw %v0, %v1, 0, 15;\n"
2050 "vshasigmad %v0, %v1, 0, 15;\n"
2051 "vpmsumd %v11, %v11, %v11;\n"
2053 ]], [ testfn(); ] )],
2054 [gcry_cv_gcc_inline_asm_ppc_altivec=yes])
2056 if test "$gcry_cv_gcc_inline_asm_ppc_altivec" = "yes" ; then
2057 AC_DEFINE(HAVE_GCC_INLINE_ASM_PPC_ALTIVEC,1,
2058 [Defined if inline assembler supports PowerPC AltiVec/VSX/crypto instructions])
2063 # Check whether GCC inline assembler supports PowerISA 3.00 instructions
2065 AC_CACHE_CHECK([whether GCC inline assembler supports PowerISA 3.00 instructions],
2066 [gcry_cv_gcc_inline_asm_ppc_arch_3_00],
2067 [if test "$mpi_cpu_arch" != "ppc" ||
2068 test "$try_asm_modules" != "yes" ; then
2069 gcry_cv_gcc_inline_asm_ppc_arch_3_00="n/a"
2071 gcry_cv_gcc_inline_asm_ppc_arch_3_00=no
2072 AC_LINK_IFELSE([AC_LANG_PROGRAM(
2073 [[__asm__(".text\n\t"
2076 "stxvb16x %r1,%v12,%v30;\n"
2078 ]], [ testfn(); ])],
2079 [gcry_cv_gcc_inline_asm_ppc_arch_3_00=yes])
2081 if test "$gcry_cv_gcc_inline_asm_ppc_arch_3_00" = "yes" ; then
2082 AC_DEFINE(HAVE_GCC_INLINE_ASM_PPC_ARCH_3_00,1,
2083 [Defined if inline assembler supports PowerISA 3.00 instructions])
2088 # Check whether GCC inline assembler supports zSeries instructions
2090 AC_CACHE_CHECK([whether GCC inline assembler supports zSeries instructions],
2091 [gcry_cv_gcc_inline_asm_s390x],
2092 [if test "$mpi_cpu_arch" != "s390x" ||
2093 test "$try_asm_modules" != "yes" ; then
2094 gcry_cv_gcc_inline_asm_s390x="n/a"
2096 gcry_cv_gcc_inline_asm_s390x=no
2097 AC_LINK_IFELSE([AC_LANG_PROGRAM(
2098 [[typedef unsigned int u128_t __attribute__ ((mode (TI)));
2099 unsigned int testfunc(unsigned int x, void *y, unsigned int z)
2101 unsigned long fac[8];
2102 register unsigned long reg0 asm("0") = 0;
2103 register unsigned long reg1 asm("1") = x;
2104 u128_t r1 = ((u128_t)(unsigned long)y << 64) | (unsigned long)z;
2107 asm volatile (".insn rre,0xb92e << 16, %[r1], %[r2]\n\t"
2108 : [r1] "+a" (r1), [r2] "+a" (r2)
2109 : "r" (reg0), "r" (reg1)
2111 asm volatile (".insn rrf,0xb929 << 16, %[r1], %[r2], %[r3], 0\n\t"
2112 : [r1] "+a" (r1), [r2] "+a" (r2), [r3] "+a" (r3)
2113 : "r" (reg0), "r" (reg1)
2117 : "+d" (reg0), "=Q" (fac[0])
2120 asm volatile ("mvc 0(16, %0), 0(%1)\n\t"
2122 : "a" (y), "a" (fac)
2124 asm volatile ("xc 0(16, %0), 0(%0)\n\t"
2128 asm volatile ("risbgn %%r11, %%r11, 0, 129, 0\n\t"
2132 asm volatile ("algrk %%r14, %%r14, %%r14\n\t"
2136 return (unsigned int)r1 ^ reg0;
2138 ]] , [ testfunc(0, 0, 0); ])],
2139 [gcry_cv_gcc_inline_asm_s390x=yes])
2141 if test "$gcry_cv_gcc_inline_asm_s390x" = "yes" ; then
2142 AC_DEFINE(HAVE_GCC_INLINE_ASM_S390X,1,
2143 [Defined if inline assembler supports zSeries instructions])
2148 # Check whether GCC inline assembler supports zSeries vector instructions
2150 AC_CACHE_CHECK([whether GCC inline assembler supports zSeries vector instructions],
2151 [gcry_cv_gcc_inline_asm_s390x_vx],
2152 [if test "$mpi_cpu_arch" != "s390x" ||
2153 test "$try_asm_modules" != "yes" ; then
2154 gcry_cv_gcc_inline_asm_s390x_vx="n/a"
2156 gcry_cv_gcc_inline_asm_s390x_vx=no
2157 if test "$gcry_cv_gcc_inline_asm_s390x" = "yes" ; then
2158 AC_LINK_IFELSE([AC_LANG_PROGRAM(
2159 [[void testfunc(void)
2161 asm volatile (".machine \"z13+vx\"\n\t"
2162 "vx %%v0, %%v1, %%v31\n\t"
2163 "verllf %%v11, %%v11, (16)(0)\n\t"
2168 ]], [ testfunc(); ])],
2169 [gcry_cv_gcc_inline_asm_s390x_vx=yes])
2172 if test "$gcry_cv_gcc_inline_asm_s390x_vx" = "yes" ; then
2173 AC_DEFINE(HAVE_GCC_INLINE_ASM_S390X_VX,1,
2174 [Defined if inline assembler supports zSeries vector instructions])
2178 #######################################
2179 #### Checks for library functions. ####
2180 #######################################
2183 # We have replacements for these in src/missing-string.c
2184 AC_CHECK_FUNCS(stpcpy strcasecmp)
2185 # We have replacements for these in src/g10lib.h
2186 AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise)
2188 AC_CHECK_FUNCS(strerror rand mmap getpagesize sysconf waitpid wait4)
2189 AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime syslog)
2190 AC_CHECK_FUNCS(syscall fcntl ftruncate flockfile getauxval elf_aux_info)
2191 AC_CHECK_FUNCS(explicit_bzero explicit_memset getentropy)
2196 # Replacement functions.
2198 AC_REPLACE_FUNCS([getpid clock])
2202 # Check whether it is necessary to link against libdl.
2205 if test "$use_hmac_binary_check" != no ; then
2206 _gcry_save_libs="$LIBS"
2208 AC_SEARCH_LIBS(dlopen, c dl,,,)
2210 LIBS="$_gcry_save_libs"
2216 # Check whether we can use Linux capabilities as requested.
2218 if test "$use_capabilities" = "yes" ; then
2220 AC_CHECK_HEADERS(sys/capability.h)
2221 if test "$ac_cv_header_sys_capability_h" = "yes" ; then
2222 AC_CHECK_LIB(cap, cap_init, ac_need_libcap=1)
2223 if test "$ac_cv_lib_cap_cap_init" = "yes"; then
2224 AC_DEFINE(USE_CAPABILITIES,1,
2225 [define if capabilities should be used])
2227 use_capabilities=yes
2230 if test "$use_capabilities" = "no" ; then
2233 *** The use of capabilities on this system is not possible.
2234 *** You need a recent Linux kernel and some patches:
2235 *** fcaps-2.2.9-990610.patch (kernel patch for 2.2.9)
2236 *** fcap-module-990613.tar.gz (kernel module)
2237 *** libcap-1.92.tar.gz (user mode library and utilities)
2238 *** And you have to configure the kernel with CONFIG_VFS_CAP_PLUGIN
2239 *** set (filesystems menu). Be warned: This code is *really* ALPHA.
2244 # Check whether a random device is available.
2245 if test "$try_dev_random" = yes ; then
2246 AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
2247 [if test -r "$NAME_OF_DEV_RANDOM" && test -r "$NAME_OF_DEV_URANDOM" ; then
2248 ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
2249 if test "$ac_cv_have_dev_random" = yes; then
2250 AC_DEFINE(HAVE_DEV_RANDOM,1,
2251 [defined if the system supports a random device] )
2254 AC_MSG_CHECKING(for random device)
2255 ac_cv_have_dev_random=no
2256 AC_MSG_RESULT(has been disabled)
2259 # Figure out the random modules for this configuration.
2260 if test "$random" = "default"; then
2262 # Select default value.
2263 if test "$ac_cv_func_getentropy" = yes; then
2264 random_modules="getentropy"
2265 elif test "$ac_cv_have_dev_random" = yes; then
2266 # Try Linuxish random device.
2267 random_modules="linux"
2271 # WindowsCE random device.
2272 random_modules="w32ce"
2274 *-*-mingw32*|*-*-cygwin*)
2275 # Windows random device.
2276 random_modules="w32"
2279 # Build everything, allow to select at runtime.
2280 random_modules="$auto_random_modules"
2285 if test "$random" = "auto"; then
2286 # Build everything, allow to select at runtime.
2287 random_modules="$auto_random_modules"
2289 random_modules="$random"
2297 if test mym4_isgit = "yes"; then
2298 AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
2299 [Defined if this is not a regular release])
2303 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
2306 # This is handy for debugging so the compiler doesn't rearrange
2307 # things and eliminate variables.
2308 AC_ARG_ENABLE(optimization,
2309 AS_HELP_STRING([--disable-optimization],
2310 [disable compiler optimization]),
2311 [if test $enableval = no ; then
2312 CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
2315 AC_MSG_NOTICE([checking for cc features])
2316 # CFLAGS mangling when using gcc.
2317 if test "$GCC" = yes; then
2318 AC_MSG_CHECKING([if gcc supports -fno-delete-null-pointer-checks])
2319 _gcc_cflags_save=$CFLAGS
2320 CFLAGS="-fno-delete-null-pointer-checks"
2321 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
2322 AC_MSG_RESULT($_gcc_wopt)
2323 CFLAGS=$_gcc_cflags_save;
2324 if test x"$_gcc_wopt" = xyes ; then
2325 CFLAGS="$CFLAGS -fno-delete-null-pointer-checks"
2328 CFLAGS="$CFLAGS -Wall"
2329 if test "$USE_MAINTAINER_MODE" = "yes"; then
2330 CFLAGS="$CFLAGS -Wcast-align -Wshadow -Wstrict-prototypes"
2331 CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
2333 # If -Wno-missing-field-initializers is supported we can enable a
2334 # a bunch of really useful warnings.
2335 AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
2336 _gcc_cflags_save=$CFLAGS
2337 CFLAGS="-Wno-missing-field-initializers"
2338 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
2339 AC_MSG_RESULT($_gcc_wopt)
2340 CFLAGS=$_gcc_cflags_save;
2341 if test x"$_gcc_wopt" = xyes ; then
2342 CFLAGS="$CFLAGS -W -Wextra -Wbad-function-cast"
2343 CFLAGS="$CFLAGS -Wwrite-strings"
2344 CFLAGS="$CFLAGS -Wdeclaration-after-statement"
2345 CFLAGS="$CFLAGS -Wno-missing-field-initializers"
2346 CFLAGS="$CFLAGS -Wno-sign-compare"
2349 AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
2350 _gcc_cflags_save=$CFLAGS
2351 CFLAGS="-Wpointer-arith"
2352 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
2353 AC_MSG_RESULT($_gcc_wopt)
2354 CFLAGS=$_gcc_cflags_save;
2355 if test x"$_gcc_wopt" = xyes ; then
2356 CFLAGS="$CFLAGS -Wpointer-arith"
2361 # Check whether as(1) supports a noeexecstack feature. This test
2362 # includes an override option.
2366 AC_SUBST(LIBGCRYPT_CONFIG_API_VERSION)
2367 AC_SUBST(LIBGCRYPT_CONFIG_LIBS)
2368 AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS)
2369 AC_SUBST(LIBGCRYPT_CONFIG_HOST)
2370 AC_SUBST(LIBGCRYPT_THREAD_MODULES)
2372 AC_CONFIG_COMMANDS([gcrypt-conf],[[
2373 chmod +x src/libgcrypt-config
2376 exec_prefix=$exec_prefix
2379 DATADIRNAME=$DATADIRNAME
2382 #####################
2383 #### Conclusion. ####
2384 #####################
2386 # Check that requested feature can actually be used and define
2387 # ENABLE_foo_SUPPORT macros.
2389 if test x"$aesnisupport" = xyes ; then
2390 if test "$gcry_cv_gcc_inline_asm_ssse3" != "yes" ; then
2391 aesnisupport="no (unsupported by compiler)"
2394 if test x"$shaextsupport" = xyes ; then
2395 if test "$gcry_cv_gcc_inline_asm_shaext" != "yes" ; then
2396 shaextsupport="no (unsupported by compiler)"
2399 if test x"$pclmulsupport" = xyes ; then
2400 if test "$gcry_cv_gcc_inline_asm_pclmul" != "yes" ; then
2401 pclmulsupport="no (unsupported by compiler)"
2404 if test x"$sse41support" = xyes ; then
2405 if test "$gcry_cv_gcc_inline_asm_sse41" != "yes" ; then
2406 sse41support="no (unsupported by compiler)"
2409 if test x"$avxsupport" = xyes ; then
2410 if test "$gcry_cv_gcc_inline_asm_avx" != "yes" ; then
2411 avxsupport="no (unsupported by compiler)"
2414 if test x"$avx2support" = xyes ; then
2415 if test "$gcry_cv_gcc_inline_asm_avx2" != "yes" ; then
2416 avx2support="no (unsupported by compiler)"
2419 if test x"$neonsupport" = xyes ; then
2420 if test "$gcry_cv_gcc_inline_asm_neon" != "yes" ; then
2421 if test "$gcry_cv_gcc_inline_asm_aarch64_neon" != "yes" ; then
2422 neonsupport="no (unsupported by compiler)"
2426 if test x"$armcryptosupport" = xyes ; then
2427 if test "$gcry_cv_gcc_inline_asm_aarch32_crypto" != "yes" ; then
2428 if test "$gcry_cv_gcc_inline_asm_aarch64_crypto" != "yes" ; then
2429 neonsupport="no (unsupported by compiler)"
2434 if test x"$aesnisupport" = xyes ; then
2435 AC_DEFINE(ENABLE_AESNI_SUPPORT, 1,
2436 [Enable support for Intel AES-NI instructions.])
2438 if test x"$shaextsupport" = xyes ; then
2439 AC_DEFINE(ENABLE_SHAEXT_SUPPORT, 1,
2440 [Enable support for Intel SHAEXT instructions.])
2442 if test x"$pclmulsupport" = xyes ; then
2443 AC_DEFINE(ENABLE_PCLMUL_SUPPORT, 1,
2444 [Enable support for Intel PCLMUL instructions.])
2446 if test x"$sse41support" = xyes ; then
2447 AC_DEFINE(ENABLE_SSE41_SUPPORT, 1,
2448 [Enable support for Intel SSE4.1 instructions.])
2450 if test x"$avxsupport" = xyes ; then
2451 AC_DEFINE(ENABLE_AVX_SUPPORT,1,
2452 [Enable support for Intel AVX instructions.])
2454 if test x"$avx2support" = xyes ; then
2455 AC_DEFINE(ENABLE_AVX2_SUPPORT,1,
2456 [Enable support for Intel AVX2 instructions.])
2458 if test x"$neonsupport" = xyes ; then
2459 AC_DEFINE(ENABLE_NEON_SUPPORT,1,
2460 [Enable support for ARM NEON instructions.])
2462 if test x"$armcryptosupport" = xyes ; then
2463 AC_DEFINE(ENABLE_ARM_CRYPTO_SUPPORT,1,
2464 [Enable support for ARMv8 Crypto Extension instructions.])
2466 if test x"$ppccryptosupport" = xyes ; then
2467 AC_DEFINE(ENABLE_PPC_CRYPTO_SUPPORT,1,
2468 [Enable support for POWER 8 (PowerISA 2.07) crypto extension.])
2470 if test x"$jentsupport" = xyes ; then
2471 AC_DEFINE(ENABLE_JENT_SUPPORT, 1,
2472 [Enable support for the jitter entropy collector.])
2474 if test x"$padlocksupport" = xyes ; then
2475 AC_DEFINE(ENABLE_PADLOCK_SUPPORT, 1,
2476 [Enable support for the PadLock engine.])
2478 if test x"$drngsupport" = xyes ; then
2479 AC_DEFINE(ENABLE_DRNG_SUPPORT, 1,
2480 [Enable support for Intel DRNG (RDRAND instruction).])
2484 if test x"$force_soft_hwfeatures" = xyes ; then
2485 AC_DEFINE(ENABLE_FORCE_SOFT_HWFEATURES, 1,
2486 [Enable forcing 'soft' HW feature bits on (for testing).])
2489 # Define conditional sources and config.h symbols depending on the
2490 # selected ciphers, pubkey-ciphers, digests, kdfs, and random modules.
2492 LIST_MEMBER(arcfour, $enabled_ciphers)
2493 if test "$found" = "1"; then
2494 GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour.lo"
2495 AC_DEFINE(USE_ARCFOUR, 1, [Defined if this module should be included])
2499 # Build with the assembly implementation
2500 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS arcfour-amd64.lo"
2505 LIST_MEMBER(blowfish, $enabled_ciphers)
2506 if test "$found" = "1" ; then
2507 GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish.lo"
2508 AC_DEFINE(USE_BLOWFISH, 1, [Defined if this module should be included])
2512 # Build with the assembly implementation
2513 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS blowfish-amd64.lo"
2516 # Build with the assembly implementation
2517 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS blowfish-arm.lo"
2522 LIST_MEMBER(cast5, $enabled_ciphers)
2523 if test "$found" = "1" ; then
2524 GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5.lo"
2525 AC_DEFINE(USE_CAST5, 1, [Defined if this module should be included])
2529 # Build with the assembly implementation
2530 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS cast5-amd64.lo"
2533 # Build with the assembly implementation
2534 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS cast5-arm.lo"
2539 LIST_MEMBER(des, $enabled_ciphers)
2540 if test "$found" = "1" ; then
2541 GCRYPT_CIPHERS="$GCRYPT_CIPHERS des.lo"
2542 AC_DEFINE(USE_DES, 1, [Defined if this module should be included])
2546 # Build with the assembly implementation
2547 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS des-amd64.lo"
2552 LIST_MEMBER(aes, $enabled_ciphers)
2553 if test "$found" = "1" ; then
2554 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael.lo"
2555 AC_DEFINE(USE_AES, 1, [Defined if this module should be included])
2559 # Build with the assembly implementation
2560 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-amd64.lo"
2562 # Build with the SSSE3 implementation
2563 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-ssse3-amd64.lo"
2564 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-ssse3-amd64-asm.lo"
2566 # Build with the VAES/AVX2 implementation
2567 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-vaes.lo"
2568 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-vaes-avx2-amd64.lo"
2571 # Build with the assembly implementation
2572 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-arm.lo"
2574 # Build with the ARMv8/AArch32 CE implementation
2575 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-armv8-ce.lo"
2576 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-armv8-aarch32-ce.lo"
2579 # Build with the assembly implementation
2580 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-aarch64.lo"
2582 # Build with the ARMv8/AArch64 CE implementation
2583 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-armv8-ce.lo"
2584 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-armv8-aarch64-ce.lo"
2587 # Build with the crypto extension implementation
2588 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-ppc.lo"
2589 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-ppc9le.lo"
2591 if test "$gcry_cv_gcc_inline_asm_ppc_altivec" = "yes" &&
2592 test "$gcry_cv_gcc_inline_asm_ppc_arch_3_00" = "yes" ; then
2593 # Build with AES-GCM bulk implementation for P10
2594 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-gcm-p10le.lo"
2595 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-p10le.lo"
2600 # Build with the crypto extension implementation
2601 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-ppc.lo"
2605 # Build with the crypto extension implementation
2606 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-ppc.lo"
2610 # Build with the crypto extension implementation
2611 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-s390x.lo"
2615 case "$mpi_cpu_arch" in
2617 # Build with the AES-NI implementation
2618 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-aesni.lo"
2620 # Build with the Padlock implementation
2621 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-padlock.lo"
2626 LIST_MEMBER(twofish, $enabled_ciphers)
2627 if test "$found" = "1" ; then
2628 GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish.lo"
2629 AC_DEFINE(USE_TWOFISH, 1, [Defined if this module should be included])
2633 # Build with the assembly implementation
2634 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS twofish-amd64.lo"
2636 if test x"$avx2support" = xyes ; then
2637 # Build with the AVX2 implementation
2638 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS twofish-avx2-amd64.lo"
2642 # Build with the assembly implementation
2643 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS twofish-arm.lo"
2646 # Build with the assembly implementation
2647 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS twofish-aarch64.lo"
2652 LIST_MEMBER(serpent, $enabled_ciphers)
2653 if test "$found" = "1" ; then
2654 GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent.lo"
2655 AC_DEFINE(USE_SERPENT, 1, [Defined if this module should be included])
2659 # Build with the SSE2 implementation
2660 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS serpent-sse2-amd64.lo"
2664 if test x"$avx2support" = xyes ; then
2665 # Build with the AVX2 implementation
2666 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS serpent-avx2-amd64.lo"
2669 if test x"$neonsupport" = xyes ; then
2670 # Build with the NEON implementation
2671 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS serpent-armv7-neon.lo"
2675 LIST_MEMBER(rfc2268, $enabled_ciphers)
2676 if test "$found" = "1" ; then
2677 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rfc2268.lo"
2678 AC_DEFINE(USE_RFC2268, 1, [Defined if this module should be included])
2681 LIST_MEMBER(seed, $enabled_ciphers)
2682 if test "$found" = "1" ; then
2683 GCRYPT_CIPHERS="$GCRYPT_CIPHERS seed.lo"
2684 AC_DEFINE(USE_SEED, 1, [Defined if this module should be included])
2687 LIST_MEMBER(camellia, $enabled_ciphers)
2688 if test "$found" = "1" ; then
2689 GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia.lo camellia-glue.lo"
2690 AC_DEFINE(USE_CAMELLIA, 1, [Defined if this module should be included])
2694 # Build with the assembly implementation
2695 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-arm.lo"
2698 # Build with the assembly implementation
2699 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-aarch64.lo"
2703 if test x"$avxsupport" = xyes ; then
2704 if test x"$aesnisupport" = xyes ; then
2705 # Build with the AES-NI/AVX implementation
2706 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-aesni-avx-amd64.lo"
2710 if test x"$avx2support" = xyes ; then
2711 if test x"$aesnisupport" = xyes ; then
2712 # Build with the AES-NI/AVX2 implementation
2713 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-aesni-avx2-amd64.lo"
2715 # Build with the VAES/AVX2 implementation
2716 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-vaes-avx2-amd64.lo"
2721 LIST_MEMBER(idea, $enabled_ciphers)
2722 if test "$found" = "1" ; then
2723 GCRYPT_CIPHERS="$GCRYPT_CIPHERS idea.lo"
2724 AC_DEFINE(USE_IDEA, 1, [Defined if this module should be included])
2727 LIST_MEMBER(salsa20, $enabled_ciphers)
2728 if test "$found" = "1" ; then
2729 GCRYPT_CIPHERS="$GCRYPT_CIPHERS salsa20.lo"
2730 AC_DEFINE(USE_SALSA20, 1, [Defined if this module should be included])
2734 # Build with the assembly implementation
2735 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS salsa20-amd64.lo"
2739 if test x"$neonsupport" = xyes ; then
2740 # Build with the NEON implementation
2741 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS salsa20-armv7-neon.lo"
2745 LIST_MEMBER(gost28147, $enabled_ciphers)
2746 if test "$found" = "1" ; then
2747 GCRYPT_CIPHERS="$GCRYPT_CIPHERS gost28147.lo"
2748 AC_DEFINE(USE_GOST28147, 1, [Defined if this module should be included])
2751 LIST_MEMBER(chacha20, $enabled_ciphers)
2752 if test "$found" = "1" ; then
2753 GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20.lo"
2754 AC_DEFINE(USE_CHACHA20, 1, [Defined if this module should be included])
2758 # Build with the assembly implementation
2759 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-amd64-ssse3.lo"
2760 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-amd64-avx2.lo"
2763 # Build with the assembly implementation
2764 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-aarch64.lo"
2767 # Build with the ppc8 vector implementation
2768 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-ppc.lo"
2771 # Build with the ppc8 vector implementation
2772 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-ppc.lo"
2775 # Build with the ppc8 vector implementation
2776 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-ppc.lo"
2779 # Build with the s390x/zSeries vector implementation
2780 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-s390x.lo"
2784 if test x"$neonsupport" = xyes ; then
2785 # Build with the NEON implementation
2786 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-armv7-neon.lo"
2790 LIST_MEMBER(sm4, $enabled_ciphers)
2791 if test "$found" = "1" ; then
2792 GCRYPT_CIPHERS="$GCRYPT_CIPHERS sm4.lo"
2793 AC_DEFINE(USE_SM4, 1, [Defined if this module should be included])
2797 # Build with the assembly implementation
2798 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS sm4-aesni-avx-amd64.lo"
2799 GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS sm4-aesni-avx2-amd64.lo"
2804 LIST_MEMBER(dsa, $enabled_pubkey_ciphers)
2805 if test "$found" = "1" ; then
2806 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo"
2807 AC_DEFINE(USE_DSA, 1, [Defined if this module should be included])
2810 LIST_MEMBER(rsa, $enabled_pubkey_ciphers)
2811 if test "$found" = "1" ; then
2812 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS rsa.lo"
2813 AC_DEFINE(USE_RSA, 1, [Defined if this module should be included])
2816 LIST_MEMBER(elgamal, $enabled_pubkey_ciphers)
2817 if test "$found" = "1" ; then
2818 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo"
2819 AC_DEFINE(USE_ELGAMAL, 1, [Defined if this module should be included])
2822 LIST_MEMBER(ecc, $enabled_pubkey_ciphers)
2823 if test "$found" = "1" ; then
2824 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS \
2825 ecc.lo ecc-curves.lo ecc-misc.lo \
2826 ecc-ecdh.lo ecc-ecdsa.lo ecc-eddsa.lo ecc-gost.lo \
2828 AC_DEFINE(USE_ECC, 1, [Defined if this module should be included])
2831 LIST_MEMBER(crc, $enabled_digests)
2832 if test "$found" = "1" ; then
2833 GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc.lo"
2834 AC_DEFINE(USE_CRC, 1, [Defined if this module should be included])
2837 i?86-*-* | x86_64-*-*)
2838 # Build with the assembly implementation
2839 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS crc-intel-pclmul.lo"
2842 # Build with the assembly implementation
2843 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS crc-armv8-ce.lo"
2844 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS crc-armv8-aarch64-ce.lo"
2847 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS crc-ppc.lo"
2850 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS crc-ppc.lo"
2853 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS crc-ppc.lo"
2858 LIST_MEMBER(gostr3411-94, $enabled_digests)
2859 if test "$found" = "1" ; then
2860 # GOST R 34.11-94 internally uses GOST 28147-89
2861 LIST_MEMBER(gost28147, $enabled_ciphers)
2862 if test "$found" = "1" ; then
2863 GCRYPT_DIGESTS="$GCRYPT_DIGESTS gostr3411-94.lo"
2864 AC_DEFINE(USE_GOST_R_3411_94, 1, [Defined if this module should be included])
2868 LIST_MEMBER(stribog, $enabled_digests)
2869 if test "$found" = "1" ; then
2870 GCRYPT_DIGESTS="$GCRYPT_DIGESTS stribog.lo"
2871 AC_DEFINE(USE_GOST_R_3411_12, 1, [Defined if this module should be included])
2874 LIST_MEMBER(md2, $enabled_digests)
2875 if test "$found" = "1" ; then
2876 GCRYPT_DIGESTS="$GCRYPT_DIGESTS md2.lo"
2877 AC_DEFINE(USE_MD2, 1, [Defined if this module should be included])
2880 LIST_MEMBER(md4, $enabled_digests)
2881 if test "$found" = "1" ; then
2882 GCRYPT_DIGESTS="$GCRYPT_DIGESTS md4.lo"
2883 AC_DEFINE(USE_MD4, 1, [Defined if this module should be included])
2886 LIST_MEMBER(md5, $enabled_digests)
2887 if test "$found" = "1" ; then
2888 GCRYPT_DIGESTS="$GCRYPT_DIGESTS md5.lo"
2889 AC_DEFINE(USE_MD5, 1, [Defined if this module should be included])
2892 LIST_MEMBER(rmd160, $enabled_digests)
2893 if test "$found" = "1" ; then
2894 GCRYPT_DIGESTS="$GCRYPT_DIGESTS rmd160.lo"
2895 AC_DEFINE(USE_RMD160, 1, [Defined if this module should be included])
2898 LIST_MEMBER(sha256, $enabled_digests)
2899 if test "$found" = "1" ; then
2900 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo"
2901 AC_DEFINE(USE_SHA256, 1, [Defined if this module should be included])
2905 # Build with the assembly implementation
2906 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-ssse3-amd64.lo"
2907 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-avx-amd64.lo"
2908 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-avx2-bmi2-amd64.lo"
2911 # Build with the assembly implementation
2912 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-armv8-aarch32-ce.lo"
2915 # Build with the assembly implementation
2916 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-armv8-aarch64-ce.lo"
2919 # Build with the crypto extension implementation
2920 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-ppc.lo"
2924 # Build with the crypto extension implementation
2925 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-ppc.lo"
2929 # Build with the crypto extension implementation
2930 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-ppc.lo"
2933 case "$mpi_cpu_arch" in
2935 # Build with the SHAEXT implementation
2936 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-intel-shaext.lo"
2941 LIST_MEMBER(sha512, $enabled_digests)
2942 if test "$found" = "1" ; then
2943 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512.lo"
2944 AC_DEFINE(USE_SHA512, 1, [Defined if this module should be included])
2948 # Build with the assembly implementation
2949 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-ssse3-amd64.lo"
2950 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-avx-amd64.lo"
2951 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-avx2-bmi2-amd64.lo"
2954 # Build with the assembly implementation
2955 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-ssse3-i386.lo"
2958 # Build with the assembly implementation
2959 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-arm.lo"
2962 # Build with the crypto extension implementation
2963 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-ppc.lo"
2967 # Build with the crypto extension implementation
2968 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-ppc.lo"
2972 # Build with the crypto extension implementation
2973 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-ppc.lo"
2976 if test x"$neonsupport" = xyes ; then
2977 # Build with the NEON implementation
2978 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-armv7-neon.lo"
2982 LIST_MEMBER(sha3, $enabled_digests)
2983 if test "$found" = "1" ; then
2984 GCRYPT_DIGESTS="$GCRYPT_DIGESTS keccak.lo"
2985 AC_DEFINE(USE_SHA3, 1, [Defined if this module should be included])
2989 # Build with the assembly implementation
2994 if test x"$neonsupport" = xyes ; then
2995 # Build with the NEON implementation
2996 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS keccak-armv7-neon.lo"
3000 LIST_MEMBER(tiger, $enabled_digests)
3001 if test "$found" = "1" ; then
3002 GCRYPT_DIGESTS="$GCRYPT_DIGESTS tiger.lo"
3003 AC_DEFINE(USE_TIGER, 1, [Defined if this module should be included])
3006 LIST_MEMBER(whirlpool, $enabled_digests)
3007 if test "$found" = "1" ; then
3008 GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool.lo"
3009 AC_DEFINE(USE_WHIRLPOOL, 1, [Defined if this module should be included])
3013 # Build with the assembly implementation
3014 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS whirlpool-sse2-amd64.lo"
3019 LIST_MEMBER(blake2, $enabled_digests)
3020 if test "$found" = "1" ; then
3021 GCRYPT_DIGESTS="$GCRYPT_DIGESTS blake2.lo"
3022 AC_DEFINE(USE_BLAKE2, 1, [Defined if this module should be included])
3026 # Build with the assembly implementation
3027 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS blake2b-amd64-avx2.lo"
3028 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS blake2s-amd64-avx.lo"
3033 LIST_MEMBER(sm3, $enabled_digests)
3034 if test "$found" = "1" ; then
3035 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sm3.lo"
3036 AC_DEFINE(USE_SM3, 1, [Defined if this module should be included])
3040 # Build with the assembly implementation
3041 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sm3-avx-bmi2-amd64.lo"
3044 # Build with the assembly implementation
3045 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sm3-aarch64.lo"
3050 # SHA-1 needs to be included always for example because it is used by
3052 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1.lo"
3053 AC_DEFINE(USE_SHA1, 1, [Defined if this module should be included])
3057 # Build with the assembly implementation
3058 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-ssse3-amd64.lo"
3059 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-avx-amd64.lo"
3060 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-avx-bmi2-amd64.lo"
3061 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-avx2-bmi2-amd64.lo"
3064 # Build with the assembly implementation
3065 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-armv7-neon.lo"
3066 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-armv8-aarch32-ce.lo"
3069 # Build with the assembly implementation
3070 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-armv8-aarch64-ce.lo"
3074 case "$mpi_cpu_arch" in
3076 # Build with the SHAEXT implementation
3077 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-intel-shaext.lo"
3081 # Arch specific GCM implementations
3083 i?86-*-* | x86_64-*-*)
3084 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS cipher-gcm-intel-pclmul.lo"
3087 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS cipher-gcm-armv7-neon.lo"
3088 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS cipher-gcm-armv8-aarch32-ce.lo"
3091 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS cipher-gcm-armv8-aarch64-ce.lo"
3093 powerpc64le-*-* | powerpc64-*-* | powerpc-*-*)
3094 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS cipher-gcm-ppc.lo"
3098 # Arch specific MAC implementations
3101 GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS poly1305-s390x.lo"
3105 LIST_MEMBER(scrypt, $enabled_kdfs)
3106 if test "$found" = "1" ; then
3107 GCRYPT_KDFS="$GCRYPT_KDFS scrypt.lo"
3108 AC_DEFINE(USE_SCRYPT, 1, [Defined if this module should be included])
3111 LIST_MEMBER(getentropy, $random_modules)
3112 if test "$found" = "1" ; then
3113 GCRYPT_RANDOM="$GCRYPT_RANDOM rndgetentropy.lo"
3114 AC_DEFINE(USE_RNDGETENTROPY, 1, [Defined if the getentropy RNG should be used.])
3117 LIST_MEMBER(linux, $random_modules)
3118 if test "$found" = "1" ; then
3119 GCRYPT_RANDOM="$GCRYPT_RANDOM rndoldlinux.lo"
3120 AC_DEFINE(USE_RNDOLDLINUX, 1, [Defined if the /dev/random RNG should be used.])
3123 LIST_MEMBER(unix, $random_modules)
3124 if test "$found" = "1" ; then
3125 GCRYPT_RANDOM="$GCRYPT_RANDOM rndunix.lo"
3126 AC_DEFINE(USE_RNDUNIX, 1, [Defined if the default Unix RNG should be used.])
3129 LIST_MEMBER(egd, $random_modules)
3130 if test "$found" = "1" ; then
3131 GCRYPT_RANDOM="$GCRYPT_RANDOM rndegd.lo"
3132 AC_DEFINE(USE_RNDEGD, 1, [Defined if the EGD based RNG should be used.])
3135 LIST_MEMBER(w32, $random_modules)
3136 if test "$found" = "1" ; then
3137 GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32.lo"
3138 AC_DEFINE(USE_RNDW32, 1,
3139 [Defined if the Windows specific RNG should be used.])
3142 LIST_MEMBER(w32ce, $random_modules)
3143 if test "$found" = "1" ; then
3144 GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32ce.lo"
3145 AC_DEFINE(USE_RNDW32CE, 1,
3146 [Defined if the WindowsCE specific RNG should be used.])
3149 if test "$try_asm_modules" = yes ; then
3150 # Build with assembly implementations
3151 GCRYPT_CIPHERS="$GCRYPT_CIPHERS $GCRYPT_ASM_CIPHERS"
3152 GCRYPT_DIGESTS="$GCRYPT_DIGESTS $GCRYPT_ASM_DIGESTS"
3155 AC_SUBST([GCRYPT_CIPHERS])
3156 AC_SUBST([GCRYPT_PUBKEY_CIPHERS])
3157 AC_SUBST([GCRYPT_DIGESTS])
3158 AC_SUBST([GCRYPT_KDFS])
3159 AC_SUBST([GCRYPT_RANDOM])
3161 AC_SUBST(LIBGCRYPT_CIPHERS, $enabled_ciphers)
3162 AC_SUBST(LIBGCRYPT_PUBKEY_CIPHERS, $enabled_pubkey_ciphers)
3163 AC_SUBST(LIBGCRYPT_DIGESTS, $enabled_digests)
3165 # For printing the configuration we need a colon separated list of
3167 tmp=`echo "$enabled_ciphers" | tr ' ' : `
3168 AC_DEFINE_UNQUOTED(LIBGCRYPT_CIPHERS, "$tmp",
3169 [List of available cipher algorithms])
3170 tmp=`echo "$enabled_pubkey_ciphers" | tr ' ' : `
3171 AC_DEFINE_UNQUOTED(LIBGCRYPT_PUBKEY_CIPHERS, "$tmp",
3172 [List of available public key cipher algorithms])
3173 tmp=`echo "$enabled_digests" | tr ' ' : `
3174 AC_DEFINE_UNQUOTED(LIBGCRYPT_DIGESTS, "$tmp",
3175 [List of available digest algorithms])
3176 tmp=`echo "$enabled_kdfs" | tr ' ' : `
3177 AC_DEFINE_UNQUOTED(LIBGCRYPT_KDFS, "$tmp",
3178 [List of available KDF algorithms])
3182 # Define conditional sources depending on the used hardware platform.
3183 # Note that all possible modules must also be listed in
3184 # src/Makefile.am (EXTRA_libgcrypt_la_SOURCES).
3187 case "$mpi_cpu_arch" in
3189 AC_DEFINE(HAVE_CPU_ARCH_X86, 1, [Defined for the x86 platforms])
3190 GCRYPT_HWF_MODULES="libgcrypt_la-hwf-x86.lo"
3193 AC_DEFINE(HAVE_CPU_ARCH_ALPHA, 1, [Defined for Alpha platforms])
3196 AC_DEFINE(HAVE_CPU_ARCH_SPARC, 1, [Defined for SPARC platforms])
3199 AC_DEFINE(HAVE_CPU_ARCH_MIPS, 1, [Defined for MIPS platforms])
3202 AC_DEFINE(HAVE_CPU_ARCH_M68K, 1, [Defined for M68k platforms])
3205 AC_DEFINE(HAVE_CPU_ARCH_PPC, 1, [Defined for PPC platforms])
3206 GCRYPT_HWF_MODULES="libgcrypt_la-hwf-ppc.lo"
3209 AC_DEFINE(HAVE_CPU_ARCH_ARM, 1, [Defined for ARM platforms])
3210 GCRYPT_HWF_MODULES="libgcrypt_la-hwf-arm.lo"
3213 AC_DEFINE(HAVE_CPU_ARCH_ARM, 1, [Defined for ARM AArch64 platforms])
3214 GCRYPT_HWF_MODULES="libgcrypt_la-hwf-arm.lo"
3217 AC_DEFINE(HAVE_CPU_ARCH_S390X, 1, [Defined for s390x/zSeries platforms])
3218 GCRYPT_HWF_MODULES="libgcrypt_la-hwf-s390x.lo"
3221 AC_SUBST([GCRYPT_HWF_MODULES])
3225 # Option to disable building of doc file
3228 AC_ARG_ENABLE([doc], AS_HELP_STRING([--disable-doc],
3229 [do not build the documentation]),
3230 build_doc=$enableval, build_doc=yes)
3231 AM_CONDITIONAL([BUILD_DOC], [test "x$build_doc" != xno])
3235 # Provide information about the build.
3237 BUILD_REVISION="mym4_revision"
3238 AC_SUBST(BUILD_REVISION)
3239 AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
3240 [GIT commit id revision used to build this package])
3243 BUILD_VERSION=`echo "$PACKAGE_VERSION" | sed 's/\([0-9.]*\).*/\1./'`
3245 BUILD_VERSION="${BUILD_VERSION}mym4_revision_dec"
3246 BUILD_FILEVERSION=`echo "${BUILD_VERSION}" | tr . ,`
3247 AC_SUBST(BUILD_VERSION)
3248 AC_SUBST(BUILD_FILEVERSION)
3250 AC_ARG_ENABLE([build-timestamp],
3251 AS_HELP_STRING([--enable-build-timestamp],
3252 [set an explicit build timestamp for reproducibility.
3253 (default is the current time in ISO-8601 format)]),
3254 [if test "$enableval" = "yes"; then
3255 BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
3257 BUILD_TIMESTAMP="$enableval"
3259 [BUILD_TIMESTAMP="<none>"])
3260 AC_SUBST(BUILD_TIMESTAMP)
3261 AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
3262 [The time this package was configured for a build])
3265 # And create the files.
3276 src/libgcrypt-config
3281 AC_CONFIG_FILES([tests/hashtest-256g], [chmod +x tests/hashtest-256g])
3282 AC_CONFIG_FILES([tests/basic-disable-all-hwf], [chmod +x tests/basic-disable-all-hwf])
3286 detection_module="${GCRYPT_HWF_MODULES%.lo}"
3287 test -n "$detection_module" || detection_module="none"
3289 # Give some feedback
3290 GCRY_MSG_SHOW([],[])
3291 GCRY_MSG_SHOW([Libgcrypt],[v${VERSION} has been configured as follows:])
3292 GCRY_MSG_SHOW([],[])
3293 GCRY_MSG_SHOW([Platform: ],[$PRINTABLE_OS_NAME ($host)])
3294 GCRY_MSG_SHOW([Hardware detection module:],[$detection_module])
3295 GCRY_MSG_WRAP([Enabled cipher algorithms:],[$enabled_ciphers])
3296 GCRY_MSG_WRAP([Enabled digest algorithms:],[$enabled_digests])
3297 GCRY_MSG_WRAP([Enabled kdf algorithms: ],[$enabled_kdfs])
3298 GCRY_MSG_WRAP([Enabled pubkey algorithms:],[$enabled_pubkey_ciphers])
3299 GCRY_MSG_SHOW([Random number generator: ],[$random])
3300 GCRY_MSG_SHOW([Try using jitter entropy: ],[$jentsupport])
3301 GCRY_MSG_SHOW([Using linux capabilities: ],[$use_capabilities])
3302 GCRY_MSG_SHOW([FIPS module version: ],[$fips_module_version])
3303 GCRY_MSG_SHOW([Try using Padlock crypto: ],[$padlocksupport])
3304 GCRY_MSG_SHOW([Try using AES-NI crypto: ],[$aesnisupport])
3305 GCRY_MSG_SHOW([Try using Intel SHAEXT: ],[$shaextsupport])
3306 GCRY_MSG_SHOW([Try using Intel PCLMUL: ],[$pclmulsupport])
3307 GCRY_MSG_SHOW([Try using Intel SSE4.1: ],[$sse41support])
3308 GCRY_MSG_SHOW([Try using DRNG (RDRAND): ],[$drngsupport])
3309 GCRY_MSG_SHOW([Try using Intel AVX: ],[$avxsupport])
3310 GCRY_MSG_SHOW([Try using Intel AVX2: ],[$avx2support])
3311 GCRY_MSG_SHOW([Try using ARM NEON: ],[$neonsupport])
3312 GCRY_MSG_SHOW([Try using ARMv8 crypto: ],[$armcryptosupport])
3313 GCRY_MSG_SHOW([Try using PPC crypto: ],[$ppccryptosupport])
3314 GCRY_MSG_SHOW([],[])
3316 if test "x${gpg_config_script_warn}" != x; then
3318 Mismatches between the target platform and the to
3319 be used libraries have been been detected for:
3320 ${gpg_config_script_warn}
3321 Please check above for warning messages.
3326 if test "$gcry_cv_gcc_attribute_aligned" != "yes" ; then
3328 Please not that your compiler does not support the GCC style
3329 aligned attribute. Using this software may evoke bus errors.
3334 if test -n "$gpl"; then
3335 echo "Please note that you are building a version of Libgcrypt with"
3337 echo "included. These parts are licensed under the GPL and thus the"
3338 echo "use of this library has to comply with the conditions of the GPL."