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