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