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