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