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