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