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