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