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