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