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