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