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
6 # This file is part of Libgcrypt.
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.
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.
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/>.
21 # (Process this file with autoconf to produce a configure script.)
22 AC_REVISION($Revision$)
24 min_automake_version="1.10"
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])
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])
51 AC_INIT([libgcrypt],[mym4_full_version],[http://bugs.gnupg.org])
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
60 LIBGCRYPT_LT_CURRENT=20
62 LIBGCRYPT_LT_REVISION=0
65 # If the API is changed in an incompatible way: increment the next counter.
66 LIBGCRYPT_CONFIG_API_VERSION=1
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
73 VERSION=$PACKAGE_VERSION
75 AC_CONFIG_SRCDIR([src/libgcrypt.vers])
77 AC_CONFIG_HEADER(config.h)
78 AC_CONFIG_MACRO_DIR([m4])
79 AC_CONFIG_LIBOBJ_DIR([compat])
84 #ifndef _GCRYPT_CONFIG_H_INCLUDED
85 #define _GCRYPT_CONFIG_H_INCLUDED
87 /* Enable gpg-error's strerror macro for W32CE. */
88 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
92 #define _GCRYPT_IN_LIBGCRYPT 1
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
102 # error "No endianness found"
104 #endif /*DISABLED_ENDIAN_CHECK*/
106 /* We basically use the original Camellia source. Make sure the symbols
107 properly prefixed. */
108 #define CAMELLIA_EXT_SYM_PREFIX _gcry_
110 #endif /*_GCRYPT_CONFIG_H_INCLUDED*/
113 AH_VERBATIM([_REENTRANT],
114 [/* To allow the use of Libgcrypt in multithreaded programs we have to use
115 special features from the library. */
117 # define _REENTRANT 1
122 AC_SUBST(LIBGCRYPT_LT_CURRENT)
123 AC_SUBST(LIBGCRYPT_LT_AGE)
124 AC_SUBST(LIBGCRYPT_LT_REVISION)
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)
134 ######################
135 ## Basic checks. ### (we need some results later on (e.g. $GCC)
136 ######################
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)
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
161 AC_MSG_CHECKING(for cc for build)
162 if test "$cross_compiling" = "yes"; then
163 CC_FOR_BUILD="${CC_FOR_BUILD-cc}"
165 CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
167 AC_MSG_RESULT($CC_FOR_BUILD)
168 AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
172 LT_INIT([win32-dll disable-static])
173 LT_LANG([Windows Resource])
176 ##########################
177 ## General definitions. ##
178 ##########################
180 # Used by libgcrypt-config
181 LIBGCRYPT_CONFIG_LIBS="-lgcrypt"
182 LIBGCRYPT_CONFIG_CFLAGS=""
183 LIBGCRYPT_CONFIG_HOST="$host"
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"
190 # Definitions for public-key ciphers.
191 available_pubkey_ciphers="dsa elgamal rsa ecc"
192 enabled_pubkey_ciphers=""
194 # Definitions for message digests.
195 available_digests="crc md4 md5 rmd160 sha1 sha256"
196 available_digests_64="sha512 tiger whirlpool"
199 # Definitions for kdfs (optional ones)
200 available_kdfs="s2k pkdf2"
201 available_kdfs_64="scrypt"
204 # Definitions for random modules.
205 available_random_modules="linux egd unix"
206 auto_random_modules="$available_random_modules"
208 # Supported thread backends.
209 LIBGCRYPT_THREAD_MODULES=""
218 # Setup some stuff depending on host.
221 ac_cv_have_dev_random=no
225 have_w32ce_system=yes
226 available_random_modules="w32ce"
229 available_random_modules="w32"
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
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)
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)
257 if test -z "$GCC" ; then
258 CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
262 if test -z "$GCC" ; then
263 # Suppress all warnings
264 # to get rid of the unsigned/signed char mismatch warnings.
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])
280 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
281 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
285 # A printable OS Name is sometimes useful.
288 PRINTABLE_OS_NAME="W32CE"
292 PRINTABLE_OS_NAME="W32"
295 i?86-emx-os2 | i?86-*-os2*emx )
296 PRINTABLE_OS_NAME="OS/2"
300 PRINTABLE_OS_NAME="MSDOS/DJGPP"
304 PRINTABLE_OS_NAME="GNU/Linux"
308 PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
313 # Figure out the name of the random device
317 NAME_OF_DEV_RANDOM="/dev/srandom"
318 NAME_OF_DEV_URANDOM="/dev/urandom"
322 NAME_OF_DEV_RANDOM="/dev/random"
323 NAME_OF_DEV_URANDOM="/dev/urandom"
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
335 AC_DEFINE(DISABLED_ENDIAN_CHECK,1,[configure did not test for endianess])
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)
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]);
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, \
359 available_digests="$available_digests $available_digests_64"
360 available_kdfs="$available_kdfs $available_kdfs_64"
363 # If not specified otherwise, all available algorithms will be
365 default_ciphers="$available_ciphers"
366 default_pubkey_ciphers="$available_pubkey_ciphers"
367 default_digests="$available_digests"
368 default_kdfs="$available_kdfs"
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:'])
375 ############################
376 ## Command line switches. ##
377 ############################
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
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])
397 AC_MSG_RESULT([$enabled_ciphers])
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
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])
417 AC_MSG_RESULT([$enabled_pubkey_ciphers])
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
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])
437 AC_MSG_RESULT([$enabled_digests])
439 # Implementation of the --enable-kdfs switch.
441 AC_HELP_STRING([--enable-kfds=kdfs],
442 [select the KDFs to include]),
443 [enabled_kdfs=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
445 if test "x$enabled_kdfs" = "x" \
446 -o "$enabled_kdfs" = "yes" \
447 -o "$enabled_kdfs" = "no"; then
448 enabled_kdfs=$default_kdfs
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])
457 AC_MSG_RESULT([$enabled_kdfs])
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]'`],
465 if test "x$random" = "x" -o "$random" = "yes" -o "$random" = "no"; then
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])
475 AC_MSG_RESULT($random)
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)
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])
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])
504 AM_CONDITIONAL(USE_RANDOM_DAEMON, test x$use_random_daemon = xyes)
507 # Implementation of --disable-asm.
508 AC_MSG_CHECKING([whether MPI assembler modules are requested])
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)
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])
527 # Implementation of the --with-capabilities switch.
528 # Check whether we want to use Linux capabilities
529 AC_MSG_CHECKING([whether use of capabilities is requested])
530 AC_ARG_WITH(capabilities,
531 AC_HELP_STRING([--with-capabilities],
532 [Use linux capabilities [default=no]]),
533 [use_capabilities="$withval"],[use_capabilities=no])
534 AC_MSG_RESULT($use_capabilities)
536 # Implementation of the --enable-hmac-binary-check.
537 AC_MSG_CHECKING([whether a HMAC binary check is requested])
538 AC_ARG_ENABLE(hmac-binary-check,
539 AC_HELP_STRING([--enable-hmac-binary-check],
540 [Enable library integrity check]),
541 [use_hmac_binary_check=$enableval],
542 [use_hmac_binary_check=no])
543 AC_MSG_RESULT($use_hmac_binary_check)
544 if test "$use_hmac_binary_check" = yes ; then
545 AC_DEFINE(ENABLE_HMAC_BINARY_CHECK,1,
546 [Define to support an HMAC based integrity check])
550 # Implementation of the --disable-padlock-support switch.
551 AC_MSG_CHECKING([whether padlock support is requested])
552 AC_ARG_ENABLE(padlock-support,
553 AC_HELP_STRING([--disable-padlock-support],
554 [Disable support for the PadLock Engine of VIA processors]),
555 padlocksupport=$enableval,padlocksupport=yes)
556 AC_MSG_RESULT($padlocksupport)
557 if test x"$padlocksupport" = xyes ; then
558 AC_DEFINE(ENABLE_PADLOCK_SUPPORT, 1,
559 [Enable support for the PadLock engine.])
562 # Implementation of the --disable-aesni-support switch.
563 AC_MSG_CHECKING([whether AESNI support is requested])
564 AC_ARG_ENABLE(aesni-support,
565 AC_HELP_STRING([--disable-aesni-support],
566 [Disable support for the Intel AES-NI instructions]),
567 aesnisupport=$enableval,aesnisupport=yes)
568 AC_MSG_RESULT($aesnisupport)
570 # Implementation of the --disable-drng-support switch.
571 AC_MSG_CHECKING([whether DRNG support is requested])
572 AC_ARG_ENABLE(drng-support,
573 AC_HELP_STRING([--disable-drng-support],
574 [Disable support for the Intel DRNG (RDRAND instruction)]),
575 drngsupport=$enableval,drngsupport=yes)
576 AC_MSG_RESULT($drngsupport)
577 if test x"$drngsupport" = xyes ; then
578 AC_DEFINE(ENABLE_DRNG_SUPPORT, 1,
579 [Enable support for Intel DRNG (RDRAND instruction).])
582 # Implementation of the --disable-avx-support switch.
583 AC_MSG_CHECKING([whether AVX support is requested])
584 AC_ARG_ENABLE(avx-support,
585 AC_HELP_STRING([--disable-avx-support],
586 [Disable support for the Intel AVX instructions]),
587 avxsupport=$enableval,avxsupport=yes)
588 AC_MSG_RESULT($avxsupport)
590 # Implementation of the --disable-avx2-support switch.
591 AC_MSG_CHECKING([whether AVX2 support is requested])
592 AC_ARG_ENABLE(avx2-support,
593 AC_HELP_STRING([--disable-avx2-support],
594 [Disable support for the Intel AVX2 instructions]),
595 avx2support=$enableval,avx2support=yes)
596 AC_MSG_RESULT($avx2support)
598 # Implementation of the --disable-neon-support switch.
599 AC_MSG_CHECKING([whether NEON support is requested])
600 AC_ARG_ENABLE(neon-support,
601 AC_HELP_STRING([--disable-neon-support],
602 [Disable support for the ARM NEON instructions]),
603 neonsupport=$enableval,neonsupport=yes)
604 AC_MSG_RESULT($neonsupport)
606 # Implementation of the --disable-O-flag-munging switch.
607 AC_MSG_CHECKING([whether a -O flag munging is requested])
608 AC_ARG_ENABLE([O-flag-munging],
609 AC_HELP_STRING([--disable-O-flag-munging],
610 [Disable modification of the cc -O flag]),
611 [enable_o_flag_munging=$enableval],
612 [enable_o_flag_munging=yes])
613 AC_MSG_RESULT($enable_o_flag_munging)
614 AM_CONDITIONAL(ENABLE_O_FLAG_MUNGING, test "$enable_o_flag_munging" = "yes")
616 # Implementation of the --disable-amd64-as-feature-detection switch.
617 AC_MSG_CHECKING([whether to enable AMD64 as(1) feature detection])
618 AC_ARG_ENABLE(amd64-as-feature-detection,
619 AC_HELP_STRING([--disable-amd64-as-feature-detection],
620 [Disable the auto-detection of AMD64 as(1) features]),
621 amd64_as_feature_detection=$enableval,
622 amd64_as_feature_detection=yes)
623 AC_MSG_RESULT($amd64_as_feature_detection)
626 AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
627 [A human readable text with the name of the OS])
629 # For some systems we know that we have ld_version scripts.
630 # Use it then as default.
631 have_ld_version_script=no
634 have_ld_version_script=yes
637 have_ld_version_script=yes
640 AC_ARG_ENABLE([ld-version-script],
641 AC_HELP_STRING([--enable-ld-version-script],
642 [enable/disable use of linker version script.
643 (default is system dependent)]),
644 [have_ld_version_script=$enableval],
646 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
648 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, "$NAME_OF_DEV_RANDOM",
649 [defined to the name of the strong random device])
650 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, "$NAME_OF_DEV_URANDOM",
651 [defined to the name of the weaker random device])
654 ###############################
655 #### Checks for libraries. ####
656 ###############################
659 # gpg-error is required.
661 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION")
662 if test "x$GPG_ERROR_LIBS" = "x"; then
663 AC_MSG_ERROR([libgpg-error is needed.
664 See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ .])
667 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GCRYPT,
668 [The default error source for libgcrypt.])
671 # Check whether the GNU Pth library is available. We require this
672 # to build the optional gcryptrnd program.
674 AC_ARG_WITH(pth-prefix,
675 AC_HELP_STRING([--with-pth-prefix=PFX],
676 [prefix where GNU Pth is installed (optional)]),
677 pth_config_prefix="$withval", pth_config_prefix="")
678 if test x$pth_config_prefix != x ; then
679 PTH_CONFIG="$pth_config_prefix/bin/pth-config"
681 if test "$use_random_daemon" = "yes"; then
682 AC_PATH_PROG(PTH_CONFIG, pth-config, no)
683 if test "$PTH_CONFIG" = "no"; then
686 *** To build the Libgcrypt's random number daemon
687 *** we need the support of the GNU Portable Threads Library.
688 *** Download it from ftp://ftp.gnu.org/gnu/pth/
689 *** On a Debian GNU/Linux system you might want to try
690 *** apt-get install libpth-dev
693 GNUPG_PTH_VERSION_CHECK([1.3.7])
694 if test $have_pth = yes; then
695 PTH_CFLAGS=`$PTH_CONFIG --cflags`
696 PTH_LIBS=`$PTH_CONFIG --ldflags`
697 PTH_LIBS="$PTH_LIBS `$PTH_CONFIG --libs --all`"
698 AC_DEFINE(USE_GNU_PTH, 1,
699 [Defined if the GNU Portable Thread Library should be used])
700 AC_DEFINE(HAVE_PTH, 1,
701 [Defined if the GNU Pth is available])
709 # Check whether pthreads is available
711 AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
712 if test "$have_pthread" = yes; then
713 AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
717 # See which thread system we have
718 # FIXME: Thus duplicates the above check.
722 # Solaris needs -lsocket and -lnsl. Unisys system includes
723 # gethostbyname in libsocket but needs libnsl for socket.
724 AC_SEARCH_LIBS(setsockopt, [socket], ,
725 [AC_SEARCH_LIBS(setsockopt, [socket], , , [-lnsl])])
726 AC_SEARCH_LIBS(setsockopt, [nsl])
728 ##################################
729 #### Checks for header files. ####
730 ##################################
733 AC_CHECK_HEADERS(unistd.h sys/select.h sys/msg.h)
735 if test x"$ac_cv_header_sys_select_h" = xyes; then
736 INSERT_SYS_SELECT_H=" include <sys/select.h>"
738 AC_SUBST(INSERT_SYS_SELECT_H)
741 ##########################################
742 #### Checks for typedefs, structures, ####
743 #### and compiler characteristics. ####
744 ##########################################
753 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
754 GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
755 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
756 GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
757 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
762 # socklen_t may or may not be defined depending on what headers
763 # are included. To be safe we use int as this is the actual type.
764 FALLBACK_SOCKLEN_T="typedef int gcry_socklen_t;"
767 if test ".$gl_cv_socklen_t_equiv" = "."; then
768 FALLBACK_SOCKLEN_T="typedef socklen_t gcry_socklen_t;"
770 FALLBACK_SOCKLEN_T="typedef ${gl_cv_socklen_t_equiv} gcry_socklen_t;"
773 AC_SUBST(FALLBACK_SOCKLEN_T)
777 # Check for VLA support (variable length arrays).
779 AC_CACHE_CHECK(whether the variable length arrays are supported,
782 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
783 [[void f1(char *, int);
785 char b[(i < 0 ? 0 : i) + 1];
786 f1(b, sizeof b); return b[0];}]])],
787 [gcry_cv_have_vla=yes])])
788 if test "$gcry_cv_have_vla" = "yes" ; then
789 AC_DEFINE(HAVE_VLA,1, [Defined if variable length arrays are supported])
794 # Check for ELF visibility support.
796 AC_CACHE_CHECK(whether the visibility attribute is supported,
797 gcry_cv_visibility_attribute,
798 [gcry_cv_visibility_attribute=no
799 AC_LANG_CONFTEST([AC_LANG_SOURCE(
800 [[int foo __attribute__ ((visibility ("hidden"))) = 1;
801 int bar __attribute__ ((visibility ("protected"))) = 1;
804 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
805 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
806 if grep '\.hidden.*foo' conftest.s >/dev/null 2>&1 ; then
807 if grep '\.protected.*bar' conftest.s >/dev/null 2>&1; then
808 gcry_cv_visibility_attribute=yes
813 if test "$gcry_cv_visibility_attribute" = "yes"; then
814 AC_CACHE_CHECK(for broken visibility attribute,
815 gcry_cv_broken_visibility_attribute,
816 [gcry_cv_broken_visibility_attribute=yes
817 AC_LANG_CONFTEST([AC_LANG_SOURCE(
819 int bar (int x) __asm__ ("foo")
820 __attribute__ ((visibility ("hidden")));
821 int bar (int x) { return x; }
824 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
825 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
826 if grep '\.hidden@<:@ _@:>@foo' conftest.s >/dev/null 2>&1;
828 gcry_cv_broken_visibility_attribute=no
833 if test "$gcry_cv_visibility_attribute" = "yes"; then
834 AC_CACHE_CHECK(for broken alias attribute,
835 gcry_cv_broken_alias_attribute,
836 [gcry_cv_broken_alias_attribute=yes
837 AC_LANG_CONFTEST([AC_LANG_SOURCE(
838 [[extern int foo (int x) __asm ("xyzzy");
839 int bar (int x) { return x; }
840 extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
842 extern __typeof (dfoo) dfoo __asm ("abccb");
846 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
847 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
848 if grep 'xyzzy' conftest.s >/dev/null 2>&1 && \
849 grep 'abccb' conftest.s >/dev/null 2>&1; then
850 gcry_cv_broken_alias_attribute=no
855 if test "$gcry_cv_visibility_attribute" = "yes"; then
856 AC_CACHE_CHECK(if gcc supports -fvisibility=hidden,
857 gcry_cv_gcc_has_f_visibility,
858 [gcry_cv_gcc_has_f_visibility=no
859 _gcc_cflags_save=$CFLAGS
860 CFLAGS="-fvisibility=hidden"
861 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
862 gcry_cv_gcc_has_f_visibility=yes)
863 CFLAGS=$_gcc_cflags_save;
866 if test "$gcry_cv_visibility_attribute" = "yes" \
867 && test "$gcry_cv_broken_visibility_attribute" != "yes" \
868 && test "$gcry_cv_broken_alias_attribute" != "yes" \
869 && test "$gcry_cv_gcc_has_f_visibility" = "yes"
871 AC_DEFINE(GCRY_USE_VISIBILITY, 1,
872 [Define to use the GNU C visibility attribute.])
873 CFLAGS="$CFLAGS -fvisibility=hidden"
878 # Check whether the compiler supports the GCC style aligned attribute
880 AC_CACHE_CHECK([whether the GCC style aligned attribute is supported],
881 [gcry_cv_gcc_attribute_aligned],
882 [gcry_cv_gcc_attribute_aligned=no
883 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
884 [[struct { int a; } foo __attribute__ ((aligned (16)));]])],
885 [gcry_cv_gcc_attribute_aligned=yes])])
886 if test "$gcry_cv_gcc_attribute_aligned" = "yes" ; then
887 AC_DEFINE(HAVE_GCC_ATTRIBUTE_ALIGNED,1,
888 [Defined if a GCC style "__attribute__ ((aligned (n))" is supported])
893 # Check whether the compiler supports 'asm' or '__asm__' keyword for
896 AC_CACHE_CHECK([whether 'asm' assembler keyword is supported],
899 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
900 [[void a(void) { asm("":::"memory"); }]])],
901 [gcry_cv_have_asm=yes])])
902 AC_CACHE_CHECK([whether '__asm__' assembler keyword is supported],
903 [gcry_cv_have___asm__],
904 [gcry_cv_have___asm__=no
905 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
906 [[void a(void) { __asm__("":::"memory"); }]])],
907 [gcry_cv_have___asm__=yes])])
908 if test "$gcry_cv_have_asm" = "no" ; then
909 if test "$gcry_cv_have___asm__" = "yes" ; then
910 AC_DEFINE(asm,__asm__,
911 [Define to supported assembler block keyword, if plain 'asm' was not
918 # Check whether GCC inline assembler supports SSSE3 instructions
919 # This is required for the AES-NI instructions.
921 AC_CACHE_CHECK([whether GCC inline assembler supports SSSE3 instructions],
922 [gcry_cv_gcc_inline_asm_ssse3],
923 [gcry_cv_gcc_inline_asm_ssse3=no
924 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
925 [[static unsigned char be_mask[16] __attribute__ ((aligned (16))) =
926 { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
928 __asm__("pshufb %[mask], %%xmm2\n\t"::[mask]"m"(*be_mask):);
930 [gcry_cv_gcc_inline_asm_ssse3=yes])])
931 if test "$gcry_cv_gcc_inline_asm_ssse3" = "yes" ; then
932 AC_DEFINE(HAVE_GCC_INLINE_ASM_SSSE3,1,
933 [Defined if inline assembler supports SSSE3 instructions])
938 # Check whether GCC inline assembler supports AVX instructions
940 AC_CACHE_CHECK([whether GCC inline assembler supports AVX instructions],
941 [gcry_cv_gcc_inline_asm_avx],
942 [gcry_cv_gcc_inline_asm_avx=no
943 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
945 __asm__("vaesdeclast (%[mem]),%%xmm0,%%xmm7\n\t"::[mem]"r"(0):);
947 [gcry_cv_gcc_inline_asm_avx=yes])])
948 if test "$gcry_cv_gcc_inline_asm_avx" = "yes" ; then
949 AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX,1,
950 [Defined if inline assembler supports AVX instructions])
955 # Check whether GCC inline assembler supports AVX2 instructions
957 AC_CACHE_CHECK([whether GCC inline assembler supports AVX2 instructions],
958 [gcry_cv_gcc_inline_asm_avx2],
959 [gcry_cv_gcc_inline_asm_avx2=no
960 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
962 __asm__("vpbroadcastb %%xmm7,%%ymm1\n\t":::);
964 [gcry_cv_gcc_inline_asm_avx2=yes])])
965 if test "$gcry_cv_gcc_inline_asm_avx2" = "yes" ; then
966 AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX2,1,
967 [Defined if inline assembler supports AVX2 instructions])
972 # Check whether GCC assembler supports features needed for our amd64
975 if test $amd64_as_feature_detection = yes; then
976 AC_CACHE_CHECK([whether GCC assembler is compatible for amd64 assembly implementations],
977 [gcry_cv_gcc_amd64_platform_as_ok],
978 [gcry_cv_gcc_amd64_platform_as_ok=no
979 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
981 /* Test if '.set' is supported by underlying assembler. */
985 "movq a0, b0;\n\t" /* Fails here if .set ignored by as. */
987 /* Test if '.type' and '.size' are supported. */
988 /* These work only on ELF targets. */
989 /* TODO: add COFF (mingw64, cygwin64) support to assembly
990 * implementations. Mingw64/cygwin64 also require additional
991 * work because they use different calling convention. */
992 ".size asmfunc,.-asmfunc;\n\t"
993 ".type asmfunc,@function;\n\t"
995 [gcry_cv_gcc_amd64_platform_as_ok=yes])])
996 if test "$gcry_cv_gcc_amd64_platform_as_ok" = "yes" ; then
997 AC_DEFINE(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS,1,
998 [Defined if underlying assembler is compatible with amd64 assembly implementations])
1004 # Check whether compiler is configured for ARMv6 or newer architecture
1006 AC_CACHE_CHECK([whether compiler is configured for ARMv6 or newer architecture],
1007 [gcry_cv_cc_arm_arch_is_v6],
1009 [#if defined(__arm__) && \
1010 ((defined(__ARM_ARCH) && __ARM_ARCH >= 6) \
1011 || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
1012 || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \
1013 || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) \
1014 || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
1015 || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
1016 || defined(__ARM_ARCH_7EM__))
1019 ], gcry_cv_cc_arm_arch_is_v6=yes, gcry_cv_cc_arm_arch_is_v6=no)])
1020 if test "$gcry_cv_cc_arm_arch_is_v6" = "yes" ; then
1021 AC_DEFINE(HAVE_ARM_ARCH_V6,1,
1022 [Defined if ARM architecture is v6 or newer])
1027 # Check whether GCC inline assembler supports NEON instructions
1029 AC_CACHE_CHECK([whether GCC inline assembler supports NEON instructions],
1030 [gcry_cv_gcc_inline_asm_neon],
1031 [gcry_cv_gcc_inline_asm_neon=no
1032 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1034 ".syntax unified\n\t"
1037 "vld1.64 {%q0-%q1}, [%r0]!;\n\t"
1038 "vrev64.8 %q0, %q3;\n\t"
1039 "vadd.u64 %q0, %q1;\n\t"
1040 "vadd.s64 %d3, %d2, %d3;\n\t"
1043 [gcry_cv_gcc_inline_asm_neon=yes])])
1044 if test "$gcry_cv_gcc_inline_asm_neon" = "yes" ; then
1045 AC_DEFINE(HAVE_GCC_INLINE_ASM_NEON,1,
1046 [Defined if inline assembler supports NEON instructions])
1051 # Check whether GCC assembler supports features needed for our ARM
1054 AC_CACHE_CHECK([whether GCC assembler is compatible for ARM assembly implementations],
1055 [gcry_cv_gcc_arm_platform_as_ok],
1056 [gcry_cv_gcc_arm_platform_as_ok=no
1057 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1059 /* Test if assembler supports UAL syntax. */
1060 ".syntax unified\n\t"
1061 ".thumb\n\t" /* thumb-2 in UAL, thumb-1 otherwise. */
1063 /* Following causes error if assembler ignored '.syntax unified'. */
1065 "add.w %r0, %r4, %r8, ror #12;\n\t"
1067 /* Test if '.type' and '.size' are supported. */
1068 ".size asmfunc,.-asmfunc;\n\t"
1069 ".type asmfunc,%function;\n\t"
1071 [gcry_cv_gcc_arm_platform_as_ok=yes])])
1072 if test "$gcry_cv_gcc_arm_platform_as_ok" = "yes" ; then
1073 AC_DEFINE(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS,1,
1074 [Defined if underlying assembler is compatible with ARM assembly implementations])
1078 #######################################
1079 #### Checks for library functions. ####
1080 #######################################
1083 # We have replacements for these in src/missing-string.c
1084 AC_CHECK_FUNCS(stpcpy strcasecmp)
1085 # We have replacements for these in src/g10lib.h
1086 AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise)
1088 AC_CHECK_FUNCS(strerror rand mmap getpagesize sysconf waitpid wait4)
1089 AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime syslog)
1090 AC_CHECK_FUNCS(fcntl ftruncate)
1095 # Replacement functions.
1097 AC_REPLACE_FUNCS([getpid clock])
1101 # Check wether it is necessary to link against libdl.
1104 if test "$use_hmac_binary_check" = yes ; then
1105 _gcry_save_libs="$LIBS"
1107 AC_SEARCH_LIBS(dlopen, c dl,,,)
1109 LIBS="$_gcry_save_libs"
1110 LIBGCRYPT_CONFIG_LIBS="${LIBGCRYPT_CONFIG_LIBS} ${DL_LIBS}"
1116 # Check whether we can use Linux capabilities as requested.
1118 if test "$use_capabilities" = "yes" ; then
1120 AC_CHECK_HEADERS(sys/capability.h)
1121 if test "$ac_cv_header_sys_capability_h" = "yes" ; then
1122 AC_CHECK_LIB(cap, cap_init, ac_need_libcap=1)
1123 if test "$ac_cv_lib_cap_cap_init" = "yes"; then
1124 AC_DEFINE(USE_CAPABILITIES,1,
1125 [define if capabilities should be used])
1127 use_capabilities=yes
1130 if test "$use_capabilities" = "no" ; then
1133 *** The use of capabilities on this system is not possible.
1134 *** You need a recent Linux kernel and some patches:
1135 *** fcaps-2.2.9-990610.patch (kernel patch for 2.2.9)
1136 *** fcap-module-990613.tar.gz (kernel module)
1137 *** libcap-1.92.tar.gz (user mode library and utilities)
1138 *** And you have to configure the kernel with CONFIG_VFS_CAP_PLUGIN
1139 *** set (filesystems menu). Be warned: This code is *really* ALPHA.
1144 # Check whether a random device is available.
1145 if test "$try_dev_random" = yes ; then
1146 AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
1147 [if test -r "$NAME_OF_DEV_RANDOM" && test -r "$NAME_OF_DEV_URANDOM" ; then
1148 ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
1149 if test "$ac_cv_have_dev_random" = yes; then
1150 AC_DEFINE(HAVE_DEV_RANDOM,1,
1151 [defined if the system supports a random device] )
1154 AC_MSG_CHECKING(for random device)
1155 ac_cv_have_dev_random=no
1156 AC_MSG_RESULT(has been disabled)
1159 # Figure out the random modules for this configuration.
1160 if test "$random" = "default"; then
1162 # Select default value.
1163 if test "$ac_cv_have_dev_random" = yes; then
1164 # Try Linuxish random device.
1165 random_modules="linux"
1169 # WindowsCE random device.
1170 random_modules="w32ce"
1172 *-*-mingw32*|*-*-cygwin*)
1173 # Windows random device.
1174 random_modules="w32"
1177 # Build everything, allow to select at runtime.
1178 random_modules="$auto_random_modules"
1183 if test "$random" = "auto"; then
1184 # Build everything, allow to select at runtime.
1185 random_modules="$auto_random_modules"
1187 random_modules="$random"
1193 # Setup assembler stuff.
1195 # Note that config.links also defines mpi_cpu_arch, which is required
1198 GNUPG_SYS_SYMBOL_UNDERSCORE()
1199 AC_ARG_ENABLE(mpi-path,
1200 AC_HELP_STRING([--enable-mpi-path=EXTRA_PATH],
1201 [prepend EXTRA_PATH to list of CPU specific optimizations]),
1202 mpi_extra_path="$enableval",mpi_extra_path="")
1203 AC_MSG_CHECKING(for mpi assembler functions)
1204 if test -f $srcdir/mpi/config.links ; then
1205 . $srcdir/mpi/config.links
1206 AC_CONFIG_LINKS("$mpi_ln_list")
1207 ac_cv_mpi_sflags="$mpi_sflags"
1210 AC_MSG_RESULT(failed)
1211 AC_MSG_ERROR([mpi/config.links missing!])
1213 MPI_SFLAGS="$ac_cv_mpi_sflags"
1214 AC_SUBST(MPI_SFLAGS)
1216 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_ADD1, test "$mpi_mod_asm_mpih_add1" = yes)
1217 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_SUB1, test "$mpi_mod_asm_mpih_sub1" = yes)
1218 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL1, test "$mpi_mod_asm_mpih_mul1" = yes)
1219 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL2, test "$mpi_mod_asm_mpih_mul2" = yes)
1220 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL3, test "$mpi_mod_asm_mpih_mul3" = yes)
1221 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_LSHIFT, test "$mpi_mod_asm_mpih_lshift" = yes)
1222 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_RSHIFT, test "$mpi_mod_asm_mpih_rshift" = yes)
1223 AM_CONDITIONAL(MPI_MOD_ASM_UDIV, test "$mpi_mod_asm_udiv" = yes)
1224 AM_CONDITIONAL(MPI_MOD_ASM_UDIV_QRNND, test "$mpi_mod_asm_udiv_qrnnd" = yes)
1225 AM_CONDITIONAL(MPI_MOD_C_MPIH_ADD1, test "$mpi_mod_c_mpih_add1" = yes)
1226 AM_CONDITIONAL(MPI_MOD_C_MPIH_SUB1, test "$mpi_mod_c_mpih_sub1" = yes)
1227 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL1, test "$mpi_mod_c_mpih_mul1" = yes)
1228 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL2, test "$mpi_mod_c_mpih_mul2" = yes)
1229 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL3, test "$mpi_mod_c_mpih_mul3" = yes)
1230 AM_CONDITIONAL(MPI_MOD_C_MPIH_LSHIFT, test "$mpi_mod_c_mpih_lshift" = yes)
1231 AM_CONDITIONAL(MPI_MOD_C_MPIH_RSHIFT, test "$mpi_mod_c_mpih_rshift" = yes)
1232 AM_CONDITIONAL(MPI_MOD_C_UDIV, test "$mpi_mod_c_udiv" = yes)
1233 AM_CONDITIONAL(MPI_MOD_C_UDIV_QRNND, test "$mpi_mod_c_udiv_qrnnd" = yes)
1235 if test mym4_isgit = "yes"; then
1236 AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
1237 [Defined if this is not a regular release])
1241 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
1244 # This is handy for debugging so the compiler doesn't rearrange
1245 # things and eliminate variables.
1246 AC_ARG_ENABLE(optimization,
1247 AC_HELP_STRING([--disable-optimization],
1248 [disable compiler optimization]),
1249 [if test $enableval = no ; then
1250 CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
1253 # CFLAGS mangling when using gcc.
1254 if test "$GCC" = yes; then
1255 CFLAGS="$CFLAGS -Wall"
1256 if test "$USE_MAINTAINER_MODE" = "yes"; then
1257 CFLAGS="$CFLAGS -Wcast-align -Wshadow -Wstrict-prototypes"
1258 CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
1260 # If -Wno-missing-field-initializers is supported we can enable a
1261 # a bunch of really useful warnings.
1262 AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
1263 _gcc_cflags_save=$CFLAGS
1264 CFLAGS="-Wno-missing-field-initializers"
1265 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
1266 AC_MSG_RESULT($_gcc_wopt)
1267 CFLAGS=$_gcc_cflags_save;
1268 if test x"$_gcc_wopt" = xyes ; then
1269 CFLAGS="$CFLAGS -W -Wextra -Wbad-function-cast"
1270 CFLAGS="$CFLAGS -Wwrite-strings"
1271 CFLAGS="$CFLAGS -Wdeclaration-after-statement"
1272 CFLAGS="$CFLAGS -Wno-missing-field-initializers"
1273 CFLAGS="$CFLAGS -Wno-sign-compare"
1276 AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
1277 _gcc_cflags_save=$CFLAGS
1278 CFLAGS="-Wpointer-arith"
1279 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
1280 AC_MSG_RESULT($_gcc_wopt)
1281 CFLAGS=$_gcc_cflags_save;
1282 if test x"$_gcc_wopt" = xyes ; then
1283 CFLAGS="$CFLAGS -Wpointer-arith"
1289 # Check whether as(1) supports a noeexecstack feature. This test
1290 # includes an override option.
1294 AC_SUBST(LIBGCRYPT_CONFIG_API_VERSION)
1295 AC_SUBST(LIBGCRYPT_CONFIG_LIBS)
1296 AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS)
1297 AC_SUBST(LIBGCRYPT_CONFIG_HOST)
1298 AC_SUBST(LIBGCRYPT_THREAD_MODULES)
1300 AC_CONFIG_COMMANDS([gcrypt-conf],[[
1301 chmod +x src/libgcrypt-config
1304 exec_prefix=$exec_prefix
1307 DATADIRNAME=$DATADIRNAME
1310 #####################
1311 #### Conclusion. ####
1312 #####################
1314 # Check that requested feature can actually be used and define
1315 # ENABLE_foo_SUPPORT macros.
1317 if test x"$aesnisupport" = xyes ; then
1318 if test "$gcry_cv_gcc_inline_asm_ssse3" != "yes" ; then
1319 aesnisupport="no (unsupported by compiler)"
1322 if test x"$avxsupport" = xyes ; then
1323 if test "$gcry_cv_gcc_inline_asm_avx" != "yes" ; then
1324 avxsupport="no (unsupported by compiler)"
1327 if test x"$avx2support" = xyes ; then
1328 if test "$gcry_cv_gcc_inline_asm_avx2" != "yes" ; then
1329 avx2support="no (unsupported by compiler)"
1332 if test x"$neonsupport" = xyes ; then
1333 if test "$gcry_cv_gcc_inline_asm_neon" != "yes" ; then
1334 neonsupport="no (unsupported by compiler)"
1338 if test x"$aesnisupport" = xyes ; then
1339 AC_DEFINE(ENABLE_AESNI_SUPPORT, 1,
1340 [Enable support for Intel AES-NI instructions.])
1342 if test x"$avxsupport" = xyes ; then
1343 AC_DEFINE(ENABLE_AVX_SUPPORT,1,
1344 [Enable support for Intel AVX instructions.])
1346 if test x"$avx2support" = xyes ; then
1347 AC_DEFINE(ENABLE_AVX2_SUPPORT,1,
1348 [Enable support for Intel AVX2 instructions.])
1350 if test x"$neonsupport" = xyes ; then
1351 AC_DEFINE(ENABLE_NEON_SUPPORT,1,
1352 [Enable support for ARM NEON instructions.])
1356 # Define conditional sources and config.h symbols depending on the
1357 # selected ciphers, pubkey-ciphers, digests, kdfs, and random modules.
1359 LIST_MEMBER(arcfour, $enabled_ciphers)
1360 if test "$found" = "1"; then
1361 GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour.lo"
1362 AC_DEFINE(USE_ARCFOUR, 1, [Defined if this module should be included])
1365 LIST_MEMBER(blowfish, $enabled_ciphers)
1366 if test "$found" = "1" ; then
1367 GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish.lo"
1368 AC_DEFINE(USE_BLOWFISH, 1, [Defined if this module should be included])
1372 # Build with the assembly implementation
1373 GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish-amd64.lo"
1376 # Build with the assembly implementation
1377 GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish-armv6.lo"
1382 LIST_MEMBER(cast5, $enabled_ciphers)
1383 if test "$found" = "1" ; then
1384 GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5.lo"
1385 AC_DEFINE(USE_CAST5, 1, [Defined if this module should be included])
1389 # Build with the assembly implementation
1390 GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5-amd64.lo"
1393 # Build with the assembly implementation
1394 GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5-armv6.lo"
1399 LIST_MEMBER(des, $enabled_ciphers)
1400 if test "$found" = "1" ; then
1401 GCRYPT_CIPHERS="$GCRYPT_CIPHERS des.lo"
1402 AC_DEFINE(USE_DES, 1, [Defined if this module should be included])
1405 LIST_MEMBER(aes, $enabled_ciphers)
1406 if test "$found" = "1" ; then
1407 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael.lo"
1408 AC_DEFINE(USE_AES, 1, [Defined if this module should be included])
1412 # Build with the assembly implementation
1413 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-amd64.lo"
1416 # Build with the assembly implementation
1417 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-armv6.lo"
1422 LIST_MEMBER(twofish, $enabled_ciphers)
1423 if test "$found" = "1" ; then
1424 GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish.lo"
1425 AC_DEFINE(USE_TWOFISH, 1, [Defined if this module should be included])
1429 # Build with the assembly implementation
1430 GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish-amd64.lo"
1435 LIST_MEMBER(serpent, $enabled_ciphers)
1436 if test "$found" = "1" ; then
1437 GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent.lo"
1438 AC_DEFINE(USE_SERPENT, 1, [Defined if this module should be included])
1442 # Build with the SSE2 implementation
1443 GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent-sse2-amd64.lo"
1447 if test x"$avx2support" = xyes ; then
1448 # Build with the AVX2 implementation
1449 GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent-avx2-amd64.lo"
1453 LIST_MEMBER(rfc2268, $enabled_ciphers)
1454 if test "$found" = "1" ; then
1455 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rfc2268.lo"
1456 AC_DEFINE(USE_RFC2268, 1, [Defined if this module should be included])
1459 LIST_MEMBER(seed, $enabled_ciphers)
1460 if test "$found" = "1" ; then
1461 GCRYPT_CIPHERS="$GCRYPT_CIPHERS seed.lo"
1462 AC_DEFINE(USE_SEED, 1, [Defined if this module should be included])
1465 LIST_MEMBER(camellia, $enabled_ciphers)
1466 if test "$found" = "1" ; then
1467 GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia.lo camellia-glue.lo"
1468 AC_DEFINE(USE_CAMELLIA, 1, [Defined if this module should be included])
1472 # Build with the assembly implementation
1473 GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia-armv6.lo"
1477 if test x"$avxsupport" = xyes ; then
1478 if test x"$aesnisupport" = xyes ; then
1479 # Build with the AES-NI/AVX implementation
1480 GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia-aesni-avx-amd64.lo"
1484 if test x"$avx2support" = xyes ; then
1485 if test x"$aesnisupport" = xyes ; then
1486 # Build with the AES-NI/AVX2 implementation
1487 GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia-aesni-avx2-amd64.lo"
1492 LIST_MEMBER(idea, $enabled_ciphers)
1493 if test "$found" = "1" ; then
1494 GCRYPT_CIPHERS="$GCRYPT_CIPHERS idea.lo"
1495 AC_DEFINE(USE_IDEA, 1, [Defined if this module should be included])
1498 LIST_MEMBER(salsa20, $enabled_ciphers)
1499 if test "$found" = "1" ; then
1500 GCRYPT_CIPHERS="$GCRYPT_CIPHERS salsa20.lo"
1501 AC_DEFINE(USE_SALSA20, 1, [Defined if this module should be included])
1504 LIST_MEMBER(dsa, $enabled_pubkey_ciphers)
1505 if test "$found" = "1" ; then
1506 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo"
1507 AC_DEFINE(USE_DSA, 1, [Defined if this module should be included])
1510 LIST_MEMBER(rsa, $enabled_pubkey_ciphers)
1511 if test "$found" = "1" ; then
1512 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS rsa.lo"
1513 AC_DEFINE(USE_RSA, 1, [Defined if this module should be included])
1516 LIST_MEMBER(elgamal, $enabled_pubkey_ciphers)
1517 if test "$found" = "1" ; then
1518 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo"
1519 AC_DEFINE(USE_ELGAMAL, 1, [Defined if this module should be included])
1522 LIST_MEMBER(ecc, $enabled_pubkey_ciphers)
1523 if test "$found" = "1" ; then
1524 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS \
1525 ecc.lo ecc-curves.lo ecc-misc.lo"
1526 AC_DEFINE(USE_ECC, 1, [Defined if this module should be included])
1529 LIST_MEMBER(crc, $enabled_digests)
1530 if test "$found" = "1" ; then
1531 GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc.lo"
1532 AC_DEFINE(USE_CRC, 1, [Defined if this module should be included])
1535 LIST_MEMBER(md4, $enabled_digests)
1536 if test "$found" = "1" ; then
1537 GCRYPT_DIGESTS="$GCRYPT_DIGESTS md4.lo"
1538 AC_DEFINE(USE_MD4, 1, [Defined if this module should be included])
1541 LIST_MEMBER(md5, $enabled_digests)
1542 if test "$found" = "1" ; then
1543 GCRYPT_DIGESTS="$GCRYPT_DIGESTS md5.lo"
1544 AC_DEFINE(USE_MD5, 1, [Defined if this module should be included])
1547 LIST_MEMBER(sha256, $enabled_digests)
1548 if test "$found" = "1" ; then
1549 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo"
1550 AC_DEFINE(USE_SHA256, 1, [Defined if this module should be included])
1553 LIST_MEMBER(sha512, $enabled_digests)
1554 if test "$found" = "1" ; then
1555 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512.lo"
1556 AC_DEFINE(USE_SHA512, 1, [Defined if this module should be included])
1558 if test x"$neonsupport" = xyes ; then
1559 # Build with the NEON implementation
1560 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-armv7-neon.lo"
1564 LIST_MEMBER(tiger, $enabled_digests)
1565 if test "$found" = "1" ; then
1566 GCRYPT_DIGESTS="$GCRYPT_DIGESTS tiger.lo"
1567 AC_DEFINE(USE_TIGER, 1, [Defined if this module should be included])
1570 LIST_MEMBER(whirlpool, $enabled_digests)
1571 if test "$found" = "1" ; then
1572 GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool.lo"
1573 AC_DEFINE(USE_WHIRLPOOL, 1, [Defined if this module should be included])
1576 # rmd160 and sha1 should be included always.
1577 GCRYPT_DIGESTS="$GCRYPT_DIGESTS rmd160.lo sha1.lo"
1578 AC_DEFINE(USE_RMD160, 1, [Defined if this module should be included])
1579 AC_DEFINE(USE_SHA1, 1, [Defined if this module should be included])
1581 LIST_MEMBER(scrypt, $enabled_kdfs)
1582 if test "$found" = "1" ; then
1583 GCRYPT_KDFS="$GCRYPT_KDFS scrypt.lo"
1584 AC_DEFINE(USE_SCRYPT, 1, [Defined if this module should be included])
1587 LIST_MEMBER(linux, $random_modules)
1588 if test "$found" = "1" ; then
1589 GCRYPT_RANDOM="$GCRYPT_RANDOM rndlinux.lo"
1590 AC_DEFINE(USE_RNDLINUX, 1, [Defined if the /dev/random RNG should be used.])
1593 LIST_MEMBER(unix, $random_modules)
1594 if test "$found" = "1" ; then
1595 GCRYPT_RANDOM="$GCRYPT_RANDOM rndunix.lo"
1596 AC_DEFINE(USE_RNDUNIX, 1, [Defined if the default Unix RNG should be used.])
1597 print_egd_notice=yes
1600 LIST_MEMBER(egd, $random_modules)
1601 if test "$found" = "1" ; then
1602 GCRYPT_RANDOM="$GCRYPT_RANDOM rndegd.lo"
1603 AC_DEFINE(USE_RNDEGD, 1, [Defined if the EGD based RNG should be used.])
1606 LIST_MEMBER(w32, $random_modules)
1607 if test "$found" = "1" ; then
1608 GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32.lo"
1609 AC_DEFINE(USE_RNDW32, 1,
1610 [Defined if the Windows specific RNG should be used.])
1613 LIST_MEMBER(w32ce, $random_modules)
1614 if test "$found" = "1" ; then
1615 GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32ce.lo"
1616 AC_DEFINE(USE_RNDW32CE, 1,
1617 [Defined if the WindowsCE specific RNG should be used.])
1620 AC_SUBST([GCRYPT_CIPHERS])
1621 AC_SUBST([GCRYPT_PUBKEY_CIPHERS])
1622 AC_SUBST([GCRYPT_DIGESTS])
1623 AC_SUBST([GCRYPT_KDFS])
1624 AC_SUBST([GCRYPT_RANDOM])
1626 AC_SUBST(LIBGCRYPT_CIPHERS, $enabled_ciphers)
1627 AC_SUBST(LIBGCRYPT_PUBKEY_CIPHERS, $enabled_pubkey_ciphers)
1628 AC_SUBST(LIBGCRYPT_DIGESTS, $enabled_digests)
1630 # For printing the configuration we need a colon separated list of
1632 tmp=`echo "$enabled_ciphers" | tr ' ' : `
1633 AC_DEFINE_UNQUOTED(LIBGCRYPT_CIPHERS, "$tmp",
1634 [List of available cipher algorithms])
1635 tmp=`echo "$enabled_pubkey_ciphers" | tr ' ' : `
1636 AC_DEFINE_UNQUOTED(LIBGCRYPT_PUBKEY_CIPHERS, "$tmp",
1637 [List of available public key cipher algorithms])
1638 tmp=`echo "$enabled_digests" | tr ' ' : `
1639 AC_DEFINE_UNQUOTED(LIBGCRYPT_DIGESTS, "$tmp",
1640 [List of available digest algorithms])
1641 tmp=`echo "$enabled_kdfs" | tr ' ' : `
1642 AC_DEFINE_UNQUOTED(LIBGCRYPT_KDFS, "$tmp",
1643 [List of available KDF algorithms])
1647 # Define conditional sources depending on the used hardware platform.
1648 # Note that all possible modules must also be listed in
1649 # src/Makefile.am (EXTRA_libgcrypt_la_SOURCES).
1652 case "$mpi_cpu_arch" in
1654 AC_DEFINE(HAVE_CPU_ARCH_X86, 1, [Defined for the x86 platforms])
1655 GCRYPT_HWF_MODULES="hwf-x86.lo"
1658 AC_DEFINE(HAVE_CPU_ARCH_ALPHA, 1, [Defined for Alpha platforms])
1661 AC_DEFINE(HAVE_CPU_ARCH_SPARC, 1, [Defined for SPARC platforms])
1664 AC_DEFINE(HAVE_CPU_ARCH_MIPS, 1, [Defined for MIPS platforms])
1667 AC_DEFINE(HAVE_CPU_ARCH_M68K, 1, [Defined for M68k platforms])
1670 AC_DEFINE(HAVE_CPU_ARCH_PPC, 1, [Defined for PPC platforms])
1673 AC_DEFINE(HAVE_CPU_ARCH_ARM, 1, [Defined for ARM platforms])
1674 GCRYPT_HWF_MODULES="hwf-arm.lo"
1677 AC_SUBST([GCRYPT_HWF_MODULES])
1681 # Provide information about the build.
1683 BUILD_REVISION="mym4_revision"
1684 AC_SUBST(BUILD_REVISION)
1685 AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
1686 [GIT commit id revision used to build this package])
1689 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
1691 BUILD_FILEVERSION="${BUILD_FILEVERSION}mym4_revision_dec"
1692 AC_SUBST(BUILD_FILEVERSION)
1694 BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
1695 AC_SUBST(BUILD_TIMESTAMP)
1696 AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
1697 [The time this package was configured for a build])
1700 # And create the files.
1711 src/libgcrypt-config
1718 detection_module="${GCRYPT_HWF_MODULES%.lo}"
1719 test -n "$detection_module" || detection_module="none"
1721 # Give some feedback
1722 GCRY_MSG_SHOW([],[])
1723 GCRY_MSG_SHOW([Libgcrypt],[v${VERSION} has been configured as follows:])
1724 GCRY_MSG_SHOW([],[])
1725 GCRY_MSG_SHOW([Platform: ],[$PRINTABLE_OS_NAME ($host)])
1726 GCRY_MSG_SHOW([Hardware detection module:],[$detection_module])
1727 GCRY_MSG_WRAP([Enabled cipher algorithms:],[$enabled_ciphers])
1728 GCRY_MSG_WRAP([Enabled digest algorithms:],[$enabled_digests])
1729 GCRY_MSG_WRAP([Enabled kdf algorithms: ],[$enabled_kdfs])
1730 GCRY_MSG_WRAP([Enabled pubkey algorithms:],[$enabled_pubkey_ciphers])
1731 GCRY_MSG_SHOW([Random number generator: ],[$random])
1732 GCRY_MSG_SHOW([Using linux capabilities: ],[$use_capabilities])
1733 GCRY_MSG_SHOW([Try using Padlock crypto: ],[$padlocksupport])
1734 GCRY_MSG_SHOW([Try using AES-NI crypto: ],[$aesnisupport])
1735 GCRY_MSG_SHOW([Try using DRNG (RDRAND): ],[$drngsupport])
1736 GCRY_MSG_SHOW([Try using Intel AVX: ],[$avxsupport])
1737 GCRY_MSG_SHOW([Try using Intel AVX2: ],[$avx2support])
1738 GCRY_MSG_SHOW([Try using ARM NEON: ],[$neonsupport])
1739 GCRY_MSG_SHOW([],[])
1741 if test "$print_egd_notice" = "yes"; then
1744 The performance of the Unix random gatherer module (rndunix) is not
1745 very good and it does not keep the entropy pool over multiple
1746 invocations of Libgcrypt base applications. The suggested way to
1747 overcome this problem is to use the
1749 Entropy Gathering Daemon (EGD)
1751 which provides a entropy source for the whole system. It is written
1752 in Perl and available at the GnuPG FTP servers. To enable EGD you
1753 should rerun configure with the option "--enable-static-rnd=egd".
1754 For more information consult the GnuPG webpages:
1756 http://www.gnupg.org/download.html#egd
1761 if test "$gcry_cv_gcc_attribute_aligned" != "yes" ; then
1764 Please not that your compiler does not support the GCC style
1765 aligned attribute. Using this software may evoke bus errors.
1770 if test -n "$gpl"; then
1771 echo "Please note that you are building a version of Libgcrypt with"
1773 echo "included. These parts are licensed under the GPL and thus the"
1774 echo "use of this library has to comply with the conditions of the GPL."