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