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