bufhelp: use one-byte aligned type for unaligned memory accesses
[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 foo_s { char a; long b; } __attribute__ ((packed));
968             enum bar {
969               FOO = 1 / (sizeof(struct foo_s) == (sizeof(char) + sizeof(long))),
970             };]])],
971           [gcry_cv_gcc_attribute_packed=yes])])
972 if test "$gcry_cv_gcc_attribute_packed" = "yes" ; then
973    AC_DEFINE(HAVE_GCC_ATTRIBUTE_PACKED,1,
974      [Defined if a GCC style "__attribute__ ((packed))" is supported])
975 fi
976
977
978 #
979 # Check whether the compiler supports 'asm' or '__asm__' keyword for
980 # assembler blocks.
981 #
982 AC_CACHE_CHECK([whether 'asm' assembler keyword is supported],
983        [gcry_cv_have_asm],
984        [gcry_cv_have_asm=no
985         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
986           [[void a(void) { asm("":::"memory"); }]])],
987           [gcry_cv_have_asm=yes])])
988 AC_CACHE_CHECK([whether '__asm__' assembler keyword is supported],
989        [gcry_cv_have___asm__],
990        [gcry_cv_have___asm__=no
991         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
992           [[void a(void) { __asm__("":::"memory"); }]])],
993           [gcry_cv_have___asm__=yes])])
994 if test "$gcry_cv_have_asm" = "no" ; then
995    if test "$gcry_cv_have___asm__" = "yes" ; then
996       AC_DEFINE(asm,__asm__,
997         [Define to supported assembler block keyword, if plain 'asm' was not
998          supported])
999    fi
1000 fi
1001
1002
1003 #
1004 # Check whether the compiler supports inline assembly memory barrier.
1005 #
1006 if test "$gcry_cv_have_asm" = "no" ; then
1007    if test "$gcry_cv_have___asm__" = "yes" ; then
1008       AC_CACHE_CHECK([whether inline assembly memory barrier is supported],
1009           [gcry_cv_have_asm_volatile_memory],
1010           [gcry_cv_have_asm_volatile_memory=no
1011            AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1012              [[void a(void) { __asm__ volatile("":::"memory"); }]])],
1013              [gcry_cv_have_asm_volatile_memory=yes])])
1014    fi
1015 else
1016    AC_CACHE_CHECK([whether inline assembly memory barrier is supported],
1017        [gcry_cv_have_asm_volatile_memory],
1018        [gcry_cv_have_asm_volatile_memory=no
1019         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1020           [[void a(void) { asm volatile("":::"memory"); }]])],
1021           [gcry_cv_have_asm_volatile_memory=yes])])
1022 fi
1023 if test "$gcry_cv_have_asm_volatile_memory" = "yes" ; then
1024    AC_DEFINE(HAVE_GCC_ASM_VOLATILE_MEMORY,1,
1025      [Define if inline asm memory barrier is supported])
1026 fi
1027
1028
1029 #
1030 # Check whether GCC assembler supports features needed for our ARM
1031 # implementations.  This needs to be done before setting up the
1032 # assembler stuff.
1033 #
1034 AC_CACHE_CHECK([whether GCC assembler is compatible for ARM assembly implementations],
1035        [gcry_cv_gcc_arm_platform_as_ok],
1036        [gcry_cv_gcc_arm_platform_as_ok=no
1037         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1038           [[__asm__(
1039                 /* Test if assembler supports UAL syntax.  */
1040                 ".syntax unified\n\t"
1041                 ".arm\n\t" /* our assembly code is in ARM mode  */
1042                 /* Following causes error if assembler ignored '.syntax unified'.  */
1043                 "asmfunc:\n\t"
1044                 "add %r0, %r0, %r4, ror #12;\n\t"
1045
1046                 /* Test if '.type' and '.size' are supported.  */
1047                 ".size asmfunc,.-asmfunc;\n\t"
1048                 ".type asmfunc,%function;\n\t"
1049             );]])],
1050           [gcry_cv_gcc_arm_platform_as_ok=yes])])
1051 if test "$gcry_cv_gcc_arm_platform_as_ok" = "yes" ; then
1052    AC_DEFINE(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS,1,
1053      [Defined if underlying assembler is compatible with ARM assembly implementations])
1054 fi
1055
1056
1057 #
1058 # Check whether underscores in symbols are required.  This needs to be
1059 # done before setting up the assembler stuff.
1060 #
1061 GNUPG_SYS_SYMBOL_UNDERSCORE()
1062
1063
1064 #################################
1065 ####                         ####
1066 #### Setup assembler stuff.  ####
1067 #### Define mpi_cpu_arch.    ####
1068 ####                         ####
1069 #################################
1070 AC_ARG_ENABLE(mpi-path,
1071               AC_HELP_STRING([--enable-mpi-path=EXTRA_PATH],
1072               [prepend EXTRA_PATH to list of CPU specific optimizations]),
1073               mpi_extra_path="$enableval",mpi_extra_path="")
1074 AC_MSG_CHECKING(architecture and mpi assembler functions)
1075 if test -f $srcdir/mpi/config.links ; then
1076     . $srcdir/mpi/config.links
1077     AC_CONFIG_LINKS("$mpi_ln_list")
1078     ac_cv_mpi_sflags="$mpi_sflags"
1079     AC_MSG_RESULT($mpi_cpu_arch)
1080 else
1081     AC_MSG_RESULT(failed)
1082     AC_MSG_ERROR([mpi/config.links missing!])
1083 fi
1084 MPI_SFLAGS="$ac_cv_mpi_sflags"
1085 AC_SUBST(MPI_SFLAGS)
1086
1087 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_ADD1, test "$mpi_mod_asm_mpih_add1" = yes)
1088 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_SUB1, test "$mpi_mod_asm_mpih_sub1" = yes)
1089 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL1, test "$mpi_mod_asm_mpih_mul1" = yes)
1090 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL2, test "$mpi_mod_asm_mpih_mul2" = yes)
1091 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL3, test "$mpi_mod_asm_mpih_mul3" = yes)
1092 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_LSHIFT, test "$mpi_mod_asm_mpih_lshift" = yes)
1093 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_RSHIFT, test "$mpi_mod_asm_mpih_rshift" = yes)
1094 AM_CONDITIONAL(MPI_MOD_ASM_UDIV, test "$mpi_mod_asm_udiv" = yes)
1095 AM_CONDITIONAL(MPI_MOD_ASM_UDIV_QRNND, test "$mpi_mod_asm_udiv_qrnnd" = yes)
1096 AM_CONDITIONAL(MPI_MOD_C_MPIH_ADD1, test "$mpi_mod_c_mpih_add1" = yes)
1097 AM_CONDITIONAL(MPI_MOD_C_MPIH_SUB1, test "$mpi_mod_c_mpih_sub1" = yes)
1098 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL1, test "$mpi_mod_c_mpih_mul1" = yes)
1099 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL2, test "$mpi_mod_c_mpih_mul2" = yes)
1100 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL3, test "$mpi_mod_c_mpih_mul3" = yes)
1101 AM_CONDITIONAL(MPI_MOD_C_MPIH_LSHIFT, test "$mpi_mod_c_mpih_lshift" = yes)
1102 AM_CONDITIONAL(MPI_MOD_C_MPIH_RSHIFT, test "$mpi_mod_c_mpih_rshift" = yes)
1103 AM_CONDITIONAL(MPI_MOD_C_UDIV, test "$mpi_mod_c_udiv" = yes)
1104 AM_CONDITIONAL(MPI_MOD_C_UDIV_QRNND, test "$mpi_mod_c_udiv_qrnnd" = yes)
1105
1106 # Reset non applicable feature flags.
1107 if test "$mpi_cpu_arch" != "x86" ; then
1108    aesnisupport="n/a"
1109    pclmulsupport="n/a"
1110    avxsupport="n/a"
1111    avx2support="n/a"
1112    padlocksupport="n/a"
1113    drngsupport="n/a"
1114 fi
1115
1116 if test "$mpi_cpu_arch" != "arm" ; then
1117    neonsupport="n/a"
1118 fi
1119
1120
1121 #############################################
1122 ####                                     ####
1123 #### Platform specific compiler checks.  ####
1124 ####                                     ####
1125 #############################################
1126
1127 #
1128 # Check whether GCC inline assembler supports SSSE3 instructions
1129 # This is required for the AES-NI instructions.
1130 #
1131 AC_CACHE_CHECK([whether GCC inline assembler supports SSSE3 instructions],
1132        [gcry_cv_gcc_inline_asm_ssse3],
1133        [if test "$mpi_cpu_arch" != "x86" ; then
1134           gcry_cv_gcc_inline_asm_ssse3="n/a"
1135         else
1136           gcry_cv_gcc_inline_asm_ssse3=no
1137           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1138           [[static unsigned char be_mask[16] __attribute__ ((aligned (16))) =
1139               { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
1140             void a(void) {
1141               __asm__("pshufb %[mask], %%xmm2\n\t"::[mask]"m"(*be_mask):);
1142             }]])],
1143           [gcry_cv_gcc_inline_asm_ssse3=yes])
1144         fi])
1145 if test "$gcry_cv_gcc_inline_asm_ssse3" = "yes" ; then
1146    AC_DEFINE(HAVE_GCC_INLINE_ASM_SSSE3,1,
1147      [Defined if inline assembler supports SSSE3 instructions])
1148 fi
1149
1150
1151 #
1152 # Check whether GCC inline assembler supports PCLMUL instructions.
1153 #
1154 AC_CACHE_CHECK([whether GCC inline assembler supports PCLMUL instructions],
1155        [gcry_cv_gcc_inline_asm_pclmul],
1156        [if test "$mpi_cpu_arch" != "x86" ; then
1157           gcry_cv_gcc_inline_asm_pclmul="n/a"
1158         else
1159           gcry_cv_gcc_inline_asm_pclmul=no
1160           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1161           [[void a(void) {
1162               __asm__("pclmulqdq \$0, %%xmm1, %%xmm3\n\t":::"cc");
1163             }]])],
1164           [gcry_cv_gcc_inline_asm_pclmul=yes])
1165         fi])
1166 if test "$gcry_cv_gcc_inline_asm_pclmul" = "yes" ; then
1167    AC_DEFINE(HAVE_GCC_INLINE_ASM_PCLMUL,1,
1168      [Defined if inline assembler supports PCLMUL instructions])
1169 fi
1170
1171
1172 #
1173 # Check whether GCC inline assembler supports AVX instructions
1174 #
1175 AC_CACHE_CHECK([whether GCC inline assembler supports AVX instructions],
1176        [gcry_cv_gcc_inline_asm_avx],
1177        [if test "$mpi_cpu_arch" != "x86" ; then
1178           gcry_cv_gcc_inline_asm_avx="n/a"
1179         else
1180           gcry_cv_gcc_inline_asm_avx=no
1181           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1182           [[void a(void) {
1183               __asm__("xgetbv; vaesdeclast (%[mem]),%%xmm0,%%xmm7\n\t"::[mem]"r"(0):);
1184             }]])],
1185           [gcry_cv_gcc_inline_asm_avx=yes])
1186         fi])
1187 if test "$gcry_cv_gcc_inline_asm_avx" = "yes" ; then
1188    AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX,1,
1189      [Defined if inline assembler supports AVX instructions])
1190 fi
1191
1192
1193 #
1194 # Check whether GCC inline assembler supports AVX2 instructions
1195 #
1196 AC_CACHE_CHECK([whether GCC inline assembler supports AVX2 instructions],
1197        [gcry_cv_gcc_inline_asm_avx2],
1198        [if test "$mpi_cpu_arch" != "x86" ; then
1199           gcry_cv_gcc_inline_asm_avx2="n/a"
1200         else
1201           gcry_cv_gcc_inline_asm_avx2=no
1202           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1203           [[void a(void) {
1204               __asm__("xgetbv; vpbroadcastb %%xmm7,%%ymm1\n\t":::"cc");
1205             }]])],
1206           [gcry_cv_gcc_inline_asm_avx2=yes])
1207         fi])
1208 if test "$gcry_cv_gcc_inline_asm_avx2" = "yes" ; then
1209    AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX2,1,
1210      [Defined if inline assembler supports AVX2 instructions])
1211 fi
1212
1213
1214 #
1215 # Check whether GCC inline assembler supports BMI2 instructions
1216 #
1217 AC_CACHE_CHECK([whether GCC inline assembler supports BMI2 instructions],
1218        [gcry_cv_gcc_inline_asm_bmi2],
1219        [if test "$mpi_cpu_arch" != "x86" ; then
1220           gcry_cv_gcc_inline_asm_bmi2="n/a"
1221         else
1222           gcry_cv_gcc_inline_asm_bmi2=no
1223           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1224           [[void a(void) {
1225               __asm__("rorxl \$23, %%eax, %%edx\\n\\t":::"memory");
1226             }]])],
1227           [gcry_cv_gcc_inline_asm_bmi2=yes])
1228         fi])
1229 if test "$gcry_cv_gcc_inline_asm_bmi2" = "yes" ; then
1230    AC_DEFINE(HAVE_GCC_INLINE_ASM_BMI2,1,
1231      [Defined if inline assembler supports BMI2 instructions])
1232 fi
1233
1234
1235 #
1236 # Check whether GCC assembler needs "-Wa,--divide" to correctly handle
1237 # constant division
1238 #
1239 if test $amd64_as_feature_detection = yes; then
1240   AC_CACHE_CHECK([whether GCC assembler handles division correctly],
1241        [gcry_cv_gcc_as_const_division_ok],
1242        [gcry_cv_gcc_as_const_division_ok=no
1243         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1244           [[__asm__("xorl \$(123456789/12345678), %ebp;\n\t");]])],
1245           [gcry_cv_gcc_as_const_division_ok=yes])])
1246   if test "$gcry_cv_gcc_as_const_division_ok" = "no" ; then
1247     #
1248     # Add '-Wa,--divide' to CPPFLAGS and try check again.
1249     #
1250     _gcc_cppflags_save="$CPPFLAGS"
1251     CPPFLAGS="$CPPFLAGS -Wa,--divide"
1252     AC_CACHE_CHECK([whether GCC assembler handles division correctly with "-Wa,--divide"],
1253          [gcry_cv_gcc_as_const_division_with_wadivide_ok],
1254          [gcry_cv_gcc_as_const_division_with_wadivide_ok=no
1255           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1256             [[__asm__("xorl \$(123456789/12345678), %ebp;\n\t");]])],
1257             [gcry_cv_gcc_as_const_division_with_wadivide_ok=yes])])
1258     if test "$gcry_cv_gcc_as_const_division_with_wadivide_ok" = "no" ; then
1259       # '-Wa,--divide' did not work, restore old flags.
1260       CPPFLAGS="$_gcc_cppflags_save"
1261     fi
1262   fi
1263 fi
1264
1265
1266 #
1267 # Check whether GCC assembler supports features needed for our amd64
1268 # implementations
1269 #
1270 if test $amd64_as_feature_detection = yes; then
1271   AC_CACHE_CHECK([whether GCC assembler is compatible for amd64 assembly implementations],
1272        [gcry_cv_gcc_amd64_platform_as_ok],
1273        [if test "$mpi_cpu_arch" != "x86" ; then
1274           gcry_cv_gcc_amd64_platform_as_ok="n/a"
1275         else
1276           gcry_cv_gcc_amd64_platform_as_ok=no
1277           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1278           [[__asm__(
1279                 /* Test if '.type' and '.size' are supported.  */
1280                 /* These work only on ELF targets. */
1281                 /* TODO: add COFF (mingw64, cygwin64) support to assembly
1282                  * implementations.  Mingw64/cygwin64 also require additional
1283                  * work because they use different calling convention. */
1284                 "asmfunc:\n\t"
1285                 ".size asmfunc,.-asmfunc;\n\t"
1286                 ".type asmfunc,@function;\n\t"
1287                 /* Test if assembler allows use of '/' for constant division
1288                  * (Solaris/x86 issue). If previous constant division check
1289                  * and "-Wa,--divide" workaround failed, this causes assembly
1290                  * to be disable on this machine. */
1291                 "xorl \$(123456789/12345678), %ebp;\n\t"
1292             );]])],
1293           [gcry_cv_gcc_amd64_platform_as_ok=yes])
1294         fi])
1295   if test "$gcry_cv_gcc_amd64_platform_as_ok" = "yes" ; then
1296      AC_DEFINE(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS,1,
1297               [Defined if underlying assembler is compatible with amd64 assembly implementations])
1298   fi
1299 fi
1300
1301
1302 #
1303 # Check whether GCC assembler supports features needed for assembly
1304 # implementations that use Intel syntax
1305 #
1306 AC_CACHE_CHECK([whether GCC assembler is compatible for Intel syntax assembly implementations],
1307        [gcry_cv_gcc_platform_as_ok_for_intel_syntax],
1308        [if test "$mpi_cpu_arch" != "x86" ; then
1309           gcry_cv_gcc_platform_as_ok_for_intel_syntax="n/a"
1310         else
1311           gcry_cv_gcc_platform_as_ok_for_intel_syntax=no
1312           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1313           [[__asm__(
1314                 ".intel_syntax noprefix\n\t"
1315                 "pxor xmm1, xmm7;\n\t"
1316                 /* Intel syntax implementation also use GAS macros, so check
1317                  * for them here. */
1318                 "VAL_A = xmm4\n\t"
1319                 "VAL_B = xmm2\n\t"
1320                 ".macro SET_VAL_A p1\n\t"
1321                 "  VAL_A = \\\\p1 \n\t"
1322                 ".endm\n\t"
1323                 ".macro SET_VAL_B p1\n\t"
1324                 "  VAL_B = \\\\p1 \n\t"
1325                 ".endm\n\t"
1326                 "vmovdqa VAL_A, VAL_B;\n\t"
1327                 "SET_VAL_A eax\n\t"
1328                 "SET_VAL_B ebp\n\t"
1329                 "add VAL_A, VAL_B;\n\t"
1330                 "add VAL_B, 0b10101;\n\t"
1331             );]])],
1332           [gcry_cv_gcc_platform_as_ok_for_intel_syntax=yes])
1333         fi])
1334 if test "$gcry_cv_gcc_platform_as_ok_for_intel_syntax" = "yes" ; then
1335   AC_DEFINE(HAVE_INTEL_SYNTAX_PLATFORM_AS,1,
1336             [Defined if underlying assembler is compatible with Intel syntax assembly implementations])
1337 fi
1338
1339
1340 #
1341 # Check whether compiler is configured for ARMv6 or newer architecture
1342 #
1343 AC_CACHE_CHECK([whether compiler is configured for ARMv6 or newer architecture],
1344        [gcry_cv_cc_arm_arch_is_v6],
1345        [if test "$mpi_cpu_arch" != "arm" ; then
1346           gcry_cv_cc_arm_arch_is_v6="n/a"
1347         else
1348           gcry_cv_cc_arm_arch_is_v6=no
1349           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1350           [[
1351            #if defined(__arm__) && \
1352              ((defined(__ARM_ARCH) && __ARM_ARCH >= 6) \
1353              || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
1354              || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \
1355              || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) \
1356              || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
1357              || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
1358              || defined(__ARM_ARCH_7EM__))
1359              /* empty */
1360            #else
1361              /* fail compile if not ARMv6. */
1362              not_armv6 not_armv6 = (not_armv6)not_armv6;
1363            #endif
1364           ]])],
1365           [gcry_cv_cc_arm_arch_is_v6=yes])
1366         fi])
1367 if test "$gcry_cv_cc_arm_arch_is_v6" = "yes" ; then
1368    AC_DEFINE(HAVE_ARM_ARCH_V6,1,
1369      [Defined if ARM architecture is v6 or newer])
1370 fi
1371
1372
1373 #
1374 # Check whether GCC inline assembler supports NEON instructions
1375 #
1376 AC_CACHE_CHECK([whether GCC inline assembler supports NEON instructions],
1377        [gcry_cv_gcc_inline_asm_neon],
1378        [if test "$mpi_cpu_arch" != "arm" ; then
1379           gcry_cv_gcc_inline_asm_neon="n/a"
1380         else
1381           gcry_cv_gcc_inline_asm_neon=no
1382           AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1383           [[__asm__(
1384                 ".syntax unified\n\t"
1385                 ".thumb\n\t"
1386                 ".fpu neon\n\t"
1387                 "vld1.64 {%q0-%q1}, [%r0]!;\n\t"
1388                 "vrev64.8 %q0, %q3;\n\t"
1389                 "vadd.u64 %q0, %q1;\n\t"
1390                 "vadd.s64 %d3, %d2, %d3;\n\t"
1391                 );
1392             ]])],
1393           [gcry_cv_gcc_inline_asm_neon=yes])
1394         fi])
1395 if test "$gcry_cv_gcc_inline_asm_neon" = "yes" ; then
1396    AC_DEFINE(HAVE_GCC_INLINE_ASM_NEON,1,
1397      [Defined if inline assembler supports NEON instructions])
1398 fi
1399
1400
1401 #######################################
1402 #### Checks for library functions. ####
1403 #######################################
1404
1405 AC_FUNC_VPRINTF
1406 # We have replacements for these in src/missing-string.c
1407 AC_CHECK_FUNCS(stpcpy strcasecmp)
1408 # We have replacements for these in src/g10lib.h
1409 AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise)
1410 # Other checks
1411 AC_CHECK_FUNCS(strerror rand mmap getpagesize sysconf waitpid wait4)
1412 AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime syslog)
1413 AC_CHECK_FUNCS(fcntl ftruncate flockfile)
1414
1415 GNUPG_CHECK_MLOCK
1416
1417 #
1418 # Replacement functions.
1419 #
1420 AC_REPLACE_FUNCS([getpid clock])
1421
1422
1423 #
1424 # Check wether it is necessary to link against libdl.
1425 #
1426 DL_LIBS=""
1427 if test "$use_hmac_binary_check" = yes ; then
1428   _gcry_save_libs="$LIBS"
1429   LIBS=""
1430   AC_SEARCH_LIBS(dlopen, c dl,,,)
1431   DL_LIBS=$LIBS
1432   LIBS="$_gcry_save_libs"
1433   LIBGCRYPT_CONFIG_LIBS="${LIBGCRYPT_CONFIG_LIBS} ${DL_LIBS}"
1434 fi
1435 AC_SUBST(DL_LIBS)
1436
1437
1438 #
1439 # Check whether we can use Linux capabilities as requested.
1440 #
1441 if test "$use_capabilities" = "yes" ; then
1442 use_capabilities=no
1443 AC_CHECK_HEADERS(sys/capability.h)
1444 if test "$ac_cv_header_sys_capability_h" = "yes" ; then
1445   AC_CHECK_LIB(cap, cap_init, ac_need_libcap=1)
1446   if test "$ac_cv_lib_cap_cap_init" = "yes"; then
1447      AC_DEFINE(USE_CAPABILITIES,1,
1448                [define if capabilities should be used])
1449      LIBS="$LIBS -lcap"
1450      use_capabilities=yes
1451   fi
1452 fi
1453 if test "$use_capabilities" = "no" ; then
1454     AC_MSG_WARN([[
1455 ***
1456 *** The use of capabilities on this system is not possible.
1457 *** You need a recent Linux kernel and some patches:
1458 ***   fcaps-2.2.9-990610.patch      (kernel patch for 2.2.9)
1459 ***   fcap-module-990613.tar.gz     (kernel module)
1460 ***   libcap-1.92.tar.gz            (user mode library and utilities)
1461 *** And you have to configure the kernel with CONFIG_VFS_CAP_PLUGIN
1462 *** set (filesystems menu). Be warned: This code is *really* ALPHA.
1463 ***]])
1464 fi
1465 fi
1466
1467 # Check whether a random device is available.
1468 if test "$try_dev_random" = yes ; then
1469     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
1470     [if test -r "$NAME_OF_DEV_RANDOM" && test -r "$NAME_OF_DEV_URANDOM" ; then
1471       ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
1472     if test "$ac_cv_have_dev_random" = yes; then
1473         AC_DEFINE(HAVE_DEV_RANDOM,1,
1474                  [defined if the system supports a random device] )
1475     fi
1476 else
1477     AC_MSG_CHECKING(for random device)
1478     ac_cv_have_dev_random=no
1479     AC_MSG_RESULT(has been disabled)
1480 fi
1481
1482 # Figure out the random modules for this configuration.
1483 if test "$random" = "default"; then
1484
1485     # Select default value.
1486     if test "$ac_cv_have_dev_random" = yes; then
1487         # Try Linuxish random device.
1488         random_modules="linux"
1489     else
1490         case "${host}" in
1491         *-*-mingw32ce*)
1492           # WindowsCE random device.
1493           random_modules="w32ce"
1494           ;;
1495         *-*-mingw32*|*-*-cygwin*)
1496           # Windows random device.
1497           random_modules="w32"
1498           ;;
1499         *)
1500           # Build everything, allow to select at runtime.
1501           random_modules="$auto_random_modules"
1502           ;;
1503         esac
1504     fi
1505 else
1506     if test "$random" = "auto"; then
1507         # Build everything, allow to select at runtime.
1508         random_modules="$auto_random_modules"
1509     else
1510         random_modules="$random"
1511     fi
1512 fi
1513
1514
1515 #
1516 # Other defines
1517 #
1518 if test mym4_isgit = "yes"; then
1519     AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
1520               [Defined if this is not a regular release])
1521 fi
1522
1523
1524 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
1525
1526
1527 # This is handy for debugging so the compiler doesn't rearrange
1528 # things and eliminate variables.
1529 AC_ARG_ENABLE(optimization,
1530        AC_HELP_STRING([--disable-optimization],
1531                       [disable compiler optimization]),
1532                       [if test $enableval = no ; then
1533                          CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
1534                        fi])
1535
1536 # CFLAGS mangling when using gcc.
1537 if test "$GCC" = yes; then
1538     CFLAGS="$CFLAGS -Wall"
1539     if test "$USE_MAINTAINER_MODE" = "yes"; then
1540         CFLAGS="$CFLAGS -Wcast-align -Wshadow -Wstrict-prototypes"
1541         CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
1542
1543         # If -Wno-missing-field-initializers is supported we can enable a
1544         # a bunch of really useful warnings.
1545         AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
1546         _gcc_cflags_save=$CFLAGS
1547         CFLAGS="-Wno-missing-field-initializers"
1548         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
1549         AC_MSG_RESULT($_gcc_wopt)
1550         CFLAGS=$_gcc_cflags_save;
1551         if test x"$_gcc_wopt" = xyes ; then
1552           CFLAGS="$CFLAGS -W -Wextra -Wbad-function-cast"
1553           CFLAGS="$CFLAGS -Wwrite-strings"
1554           CFLAGS="$CFLAGS -Wdeclaration-after-statement"
1555           CFLAGS="$CFLAGS -Wno-missing-field-initializers"
1556           CFLAGS="$CFLAGS -Wno-sign-compare"
1557         fi
1558
1559         AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
1560         _gcc_cflags_save=$CFLAGS
1561         CFLAGS="-Wpointer-arith"
1562         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
1563         AC_MSG_RESULT($_gcc_wopt)
1564         CFLAGS=$_gcc_cflags_save;
1565         if test x"$_gcc_wopt" = xyes ; then
1566           CFLAGS="$CFLAGS -Wpointer-arith"
1567         fi
1568     fi
1569
1570 fi
1571
1572 # Check whether as(1) supports a noeexecstack feature.  This test
1573 # includes an override option.
1574 CL_AS_NOEXECSTACK
1575
1576
1577 AC_SUBST(LIBGCRYPT_CONFIG_API_VERSION)
1578 AC_SUBST(LIBGCRYPT_CONFIG_LIBS)
1579 AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS)
1580 AC_SUBST(LIBGCRYPT_CONFIG_HOST)
1581 AC_SUBST(LIBGCRYPT_THREAD_MODULES)
1582
1583 AC_CONFIG_COMMANDS([gcrypt-conf],[[
1584 chmod +x src/libgcrypt-config
1585 ]],[[
1586 prefix=$prefix
1587 exec_prefix=$exec_prefix
1588 libdir=$libdir
1589 datadir=$datadir
1590 DATADIRNAME=$DATADIRNAME
1591 ]])
1592
1593 #####################
1594 #### Conclusion. ####
1595 #####################
1596
1597 # Check that requested feature can actually be used and define
1598 # ENABLE_foo_SUPPORT macros.
1599
1600 if test x"$aesnisupport" = xyes ; then
1601   if test "$gcry_cv_gcc_inline_asm_ssse3" != "yes" ; then
1602     aesnisupport="no (unsupported by compiler)"
1603   fi
1604 fi
1605 if test x"$pclmulsupport" = xyes ; then
1606   if test "$gcry_cv_gcc_inline_asm_pclmul" != "yes" ; then
1607     pclmulsupport="no (unsupported by compiler)"
1608   fi
1609 fi
1610 if test x"$avxsupport" = xyes ; then
1611   if test "$gcry_cv_gcc_inline_asm_avx" != "yes" ; then
1612     avxsupport="no (unsupported by compiler)"
1613   fi
1614 fi
1615 if test x"$avx2support" = xyes ; then
1616   if test "$gcry_cv_gcc_inline_asm_avx2" != "yes" ; then
1617     avx2support="no (unsupported by compiler)"
1618   fi
1619 fi
1620 if test x"$neonsupport" = xyes ; then
1621   if test "$gcry_cv_gcc_inline_asm_neon" != "yes" ; then
1622     neonsupport="no (unsupported by compiler)"
1623   fi
1624 fi
1625
1626 if test x"$aesnisupport" = xyes ; then
1627   AC_DEFINE(ENABLE_AESNI_SUPPORT, 1,
1628             [Enable support for Intel AES-NI instructions.])
1629 fi
1630 if test x"$pclmulsupport" = xyes ; then
1631   AC_DEFINE(ENABLE_PCLMUL_SUPPORT, 1,
1632             [Enable support for Intel PCLMUL instructions.])
1633 fi
1634 if test x"$avxsupport" = xyes ; then
1635   AC_DEFINE(ENABLE_AVX_SUPPORT,1,
1636             [Enable support for Intel AVX instructions.])
1637 fi
1638 if test x"$avx2support" = xyes ; then
1639   AC_DEFINE(ENABLE_AVX2_SUPPORT,1,
1640             [Enable support for Intel AVX2 instructions.])
1641 fi
1642 if test x"$neonsupport" = xyes ; then
1643   AC_DEFINE(ENABLE_NEON_SUPPORT,1,
1644             [Enable support for ARM NEON instructions.])
1645 fi
1646 if test x"$padlocksupport" = xyes ; then
1647   AC_DEFINE(ENABLE_PADLOCK_SUPPORT, 1,
1648             [Enable support for the PadLock engine.])
1649 fi
1650 if test x"$drngsupport" = xyes ; then
1651   AC_DEFINE(ENABLE_DRNG_SUPPORT, 1,
1652             [Enable support for Intel DRNG (RDRAND instruction).])
1653 fi
1654
1655
1656 # Define conditional sources and config.h symbols depending on the
1657 # selected ciphers, pubkey-ciphers, digests, kdfs, and random modules.
1658
1659 LIST_MEMBER(arcfour, $enabled_ciphers)
1660 if test "$found" = "1"; then
1661    GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour.lo"
1662    AC_DEFINE(USE_ARCFOUR, 1, [Defined if this module should be included])
1663
1664    case "${host}" in
1665       x86_64-*-*)
1666          # Build with the assembly implementation
1667          GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour-amd64.lo"
1668       ;;
1669    esac
1670 fi
1671
1672 LIST_MEMBER(blowfish, $enabled_ciphers)
1673 if test "$found" = "1" ; then
1674    GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish.lo"
1675    AC_DEFINE(USE_BLOWFISH, 1, [Defined if this module should be included])
1676
1677    case "${host}" in
1678       x86_64-*-*)
1679          # Build with the assembly implementation
1680          GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish-amd64.lo"
1681       ;;
1682       arm*-*-*)
1683          # Build with the assembly implementation
1684          GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish-arm.lo"
1685       ;;
1686    esac
1687 fi
1688
1689 LIST_MEMBER(cast5, $enabled_ciphers)
1690 if test "$found" = "1" ; then
1691    GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5.lo"
1692    AC_DEFINE(USE_CAST5, 1, [Defined if this module should be included])
1693
1694    case "${host}" in
1695       x86_64-*-*)
1696          # Build with the assembly implementation
1697          GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5-amd64.lo"
1698       ;;
1699       arm*-*-*)
1700          # Build with the assembly implementation
1701          GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5-arm.lo"
1702       ;;
1703    esac
1704 fi
1705
1706 LIST_MEMBER(des, $enabled_ciphers)
1707 if test "$found" = "1" ; then
1708    GCRYPT_CIPHERS="$GCRYPT_CIPHERS des.lo"
1709    AC_DEFINE(USE_DES, 1, [Defined if this module should be included])
1710
1711    case "${host}" in
1712       x86_64-*-*)
1713          # Build with the assembly implementation
1714          GCRYPT_CIPHERS="$GCRYPT_CIPHERS des-amd64.lo"
1715       ;;
1716    esac
1717 fi
1718
1719 LIST_MEMBER(aes, $enabled_ciphers)
1720 if test "$found" = "1" ; then
1721    GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael.lo"
1722    AC_DEFINE(USE_AES, 1, [Defined if this module should be included])
1723
1724    case "${host}" in
1725       x86_64-*-*)
1726          # Build with the assembly implementation
1727          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-amd64.lo"
1728
1729          # Build with the SSSE3 implementation
1730          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-ssse3-amd64.lo"
1731       ;;
1732       arm*-*-*)
1733          # Build with the assembly implementation
1734          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-arm.lo"
1735       ;;
1736    esac
1737
1738    case "$mpi_cpu_arch" in
1739      x86)
1740          # Build with the AES-NI implementation
1741          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-aesni.lo"
1742
1743          # Build with the Padlock implementation
1744          GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael-padlock.lo"
1745       ;;
1746    esac
1747 fi
1748
1749 LIST_MEMBER(twofish, $enabled_ciphers)
1750 if test "$found" = "1" ; then
1751    GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish.lo"
1752    AC_DEFINE(USE_TWOFISH, 1, [Defined if this module should be included])
1753
1754    case "${host}" in
1755       x86_64-*-*)
1756          # Build with the assembly implementation
1757          GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish-amd64.lo"
1758       ;;
1759       arm*-*-*)
1760          # Build with the assembly implementation
1761          GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish-arm.lo"
1762       ;;
1763    esac
1764 fi
1765
1766 LIST_MEMBER(serpent, $enabled_ciphers)
1767 if test "$found" = "1" ; then
1768    GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent.lo"
1769    AC_DEFINE(USE_SERPENT, 1, [Defined if this module should be included])
1770
1771    case "${host}" in
1772       x86_64-*-*)
1773          # Build with the SSE2 implementation
1774          GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent-sse2-amd64.lo"
1775       ;;
1776    esac
1777
1778    if test x"$avx2support" = xyes ; then
1779       # Build with the AVX2 implementation
1780       GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent-avx2-amd64.lo"
1781    fi
1782
1783    if test x"$neonsupport" = xyes ; then
1784       # Build with the NEON implementation
1785       GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent-armv7-neon.lo"
1786    fi
1787 fi
1788
1789 LIST_MEMBER(rfc2268, $enabled_ciphers)
1790 if test "$found" = "1" ; then
1791    GCRYPT_CIPHERS="$GCRYPT_CIPHERS rfc2268.lo"
1792    AC_DEFINE(USE_RFC2268, 1, [Defined if this module should be included])
1793 fi
1794
1795 LIST_MEMBER(seed, $enabled_ciphers)
1796 if test "$found" = "1" ; then
1797    GCRYPT_CIPHERS="$GCRYPT_CIPHERS seed.lo"
1798    AC_DEFINE(USE_SEED, 1, [Defined if this module should be included])
1799 fi
1800
1801 LIST_MEMBER(camellia, $enabled_ciphers)
1802 if test "$found" = "1" ; then
1803    GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia.lo camellia-glue.lo"
1804    AC_DEFINE(USE_CAMELLIA, 1, [Defined if this module should be included])
1805
1806    case "${host}" in
1807       arm*-*-*)
1808          # Build with the assembly implementation
1809          GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia-arm.lo"
1810       ;;
1811    esac
1812
1813    if test x"$avxsupport" = xyes ; then
1814       if test x"$aesnisupport" = xyes ; then
1815         # Build with the AES-NI/AVX implementation
1816         GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia-aesni-avx-amd64.lo"
1817       fi
1818    fi
1819
1820    if test x"$avx2support" = xyes ; then
1821       if test x"$aesnisupport" = xyes ; then
1822         # Build with the AES-NI/AVX2 implementation
1823         GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia-aesni-avx2-amd64.lo"
1824       fi
1825    fi
1826 fi
1827
1828 LIST_MEMBER(idea, $enabled_ciphers)
1829 if test "$found" = "1" ; then
1830    GCRYPT_CIPHERS="$GCRYPT_CIPHERS idea.lo"
1831    AC_DEFINE(USE_IDEA, 1, [Defined if this module should be included])
1832 fi
1833
1834 LIST_MEMBER(salsa20, $enabled_ciphers)
1835 if test "$found" = "1" ; then
1836    GCRYPT_CIPHERS="$GCRYPT_CIPHERS salsa20.lo"
1837    AC_DEFINE(USE_SALSA20, 1, [Defined if this module should be included])
1838
1839    case "${host}" in
1840       x86_64-*-*)
1841          # Build with the assembly implementation
1842          GCRYPT_CIPHERS="$GCRYPT_CIPHERS salsa20-amd64.lo"
1843       ;;
1844    esac
1845
1846    if test x"$neonsupport" = xyes ; then
1847      # Build with the NEON implementation
1848      GCRYPT_CIPHERS="$GCRYPT_CIPHERS salsa20-armv7-neon.lo"
1849    fi
1850 fi
1851
1852 LIST_MEMBER(gost28147, $enabled_ciphers)
1853 if test "$found" = "1" ; then
1854    GCRYPT_CIPHERS="$GCRYPT_CIPHERS gost28147.lo"
1855    AC_DEFINE(USE_GOST28147, 1, [Defined if this module should be included])
1856 fi
1857
1858 LIST_MEMBER(chacha20, $enabled_ciphers)
1859 if test "$found" = "1" ; then
1860    GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20.lo"
1861    AC_DEFINE(USE_CHACHA20, 1, [Defined if this module should be included])
1862
1863    case "${host}" in
1864       x86_64-*-*)
1865          # Build with the assembly implementation
1866          GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20-sse2-amd64.lo"
1867          GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20-ssse3-amd64.lo"
1868          GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20-avx2-amd64.lo"
1869       ;;
1870    esac
1871
1872    if test x"$neonsupport" = xyes ; then
1873      # Build with the NEON implementation
1874      GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20-armv7-neon.lo"
1875    fi
1876 fi
1877
1878 case "${host}" in
1879    x86_64-*-*)
1880       # Build with the assembly implementation
1881       GCRYPT_CIPHERS="$GCRYPT_CIPHERS poly1305-sse2-amd64.lo"
1882       GCRYPT_CIPHERS="$GCRYPT_CIPHERS poly1305-avx2-amd64.lo"
1883    ;;
1884 esac
1885
1886 if test x"$neonsupport" = xyes ; then
1887    # Build with the NEON implementation
1888    GCRYPT_CIPHERS="$GCRYPT_CIPHERS poly1305-armv7-neon.lo"
1889 fi
1890
1891 LIST_MEMBER(dsa, $enabled_pubkey_ciphers)
1892 if test "$found" = "1" ; then
1893    GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo"
1894    AC_DEFINE(USE_DSA, 1, [Defined if this module should be included])
1895 fi
1896
1897 LIST_MEMBER(rsa, $enabled_pubkey_ciphers)
1898 if test "$found" = "1" ; then
1899    GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS rsa.lo"
1900    AC_DEFINE(USE_RSA, 1, [Defined if this module should be included])
1901 fi
1902
1903 LIST_MEMBER(elgamal, $enabled_pubkey_ciphers)
1904 if test "$found" = "1" ; then
1905    GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo"
1906    AC_DEFINE(USE_ELGAMAL, 1, [Defined if this module should be included])
1907 fi
1908
1909 LIST_MEMBER(ecc, $enabled_pubkey_ciphers)
1910 if test "$found" = "1" ; then
1911    GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS \
1912                           ecc.lo ecc-curves.lo ecc-misc.lo \
1913                           ecc-ecdsa.lo ecc-eddsa.lo ecc-gost.lo"
1914    AC_DEFINE(USE_ECC, 1, [Defined if this module should be included])
1915 fi
1916
1917 LIST_MEMBER(crc, $enabled_digests)
1918 if test "$found" = "1" ; then
1919    GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc.lo"
1920    AC_DEFINE(USE_CRC, 1, [Defined if this module should be included])
1921 fi
1922
1923 LIST_MEMBER(gostr3411-94, $enabled_digests)
1924 if test "$found" = "1" ; then
1925    # GOST R 34.11-94 internally uses GOST 28147-89
1926    LIST_MEMBER(gost28147, $enabled_ciphers)
1927    if test "$found" = "1" ; then
1928       GCRYPT_DIGESTS="$GCRYPT_DIGESTS gostr3411-94.lo"
1929       AC_DEFINE(USE_GOST_R_3411_94, 1, [Defined if this module should be included])
1930    fi
1931 fi
1932
1933 LIST_MEMBER(stribog, $enabled_digests)
1934 if test "$found" = "1" ; then
1935    GCRYPT_DIGESTS="$GCRYPT_DIGESTS stribog.lo"
1936    AC_DEFINE(USE_GOST_R_3411_12, 1, [Defined if this module should be included])
1937 fi
1938
1939 LIST_MEMBER(md2, $enabled_digests)
1940 if test "$found" = "1" ; then
1941    GCRYPT_DIGESTS="$GCRYPT_DIGESTS md2.lo"
1942    AC_DEFINE(USE_MD2, 1, [Defined if this module should be included])
1943 fi
1944
1945 LIST_MEMBER(md4, $enabled_digests)
1946 if test "$found" = "1" ; then
1947    GCRYPT_DIGESTS="$GCRYPT_DIGESTS md4.lo"
1948    AC_DEFINE(USE_MD4, 1, [Defined if this module should be included])
1949 fi
1950
1951 LIST_MEMBER(md5, $enabled_digests)
1952 if test "$found" = "1" ; then
1953    GCRYPT_DIGESTS="$GCRYPT_DIGESTS md5.lo"
1954    AC_DEFINE(USE_MD5, 1, [Defined if this module should be included])
1955 fi
1956
1957 LIST_MEMBER(sha256, $enabled_digests)
1958 if test "$found" = "1" ; then
1959    GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo"
1960    AC_DEFINE(USE_SHA256, 1, [Defined if this module should be included])
1961
1962    case "${host}" in
1963       x86_64-*-*)
1964          # Build with the assembly implementation
1965          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256-ssse3-amd64.lo"
1966          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256-avx-amd64.lo"
1967          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256-avx2-bmi2-amd64.lo"
1968       ;;
1969    esac
1970 fi
1971
1972 LIST_MEMBER(sha512, $enabled_digests)
1973 if test "$found" = "1" ; then
1974    GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512.lo"
1975    AC_DEFINE(USE_SHA512, 1, [Defined if this module should be included])
1976
1977    case "${host}" in
1978       x86_64-*-*)
1979          # Build with the assembly implementation
1980          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-ssse3-amd64.lo"
1981          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-avx-amd64.lo"
1982          GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-avx2-bmi2-amd64.lo"
1983       ;;
1984    esac
1985
1986    if test x"$neonsupport" = xyes ; then
1987      # Build with the NEON implementation
1988      GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512-armv7-neon.lo"
1989    fi
1990 fi
1991
1992 LIST_MEMBER(tiger, $enabled_digests)
1993 if test "$found" = "1" ; then
1994    GCRYPT_DIGESTS="$GCRYPT_DIGESTS tiger.lo"
1995    AC_DEFINE(USE_TIGER, 1, [Defined if this module should be included])
1996 fi
1997
1998 LIST_MEMBER(whirlpool, $enabled_digests)
1999 if test "$found" = "1" ; then
2000    GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool.lo"
2001    AC_DEFINE(USE_WHIRLPOOL, 1, [Defined if this module should be included])
2002
2003    case "${host}" in
2004       x86_64-*-*)
2005          # Build with the assembly implementation
2006          GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool-sse2-amd64.lo"
2007       ;;
2008    esac
2009 fi
2010
2011 # rmd160 and sha1 should be included always.
2012 GCRYPT_DIGESTS="$GCRYPT_DIGESTS rmd160.lo sha1.lo"
2013 AC_DEFINE(USE_RMD160, 1, [Defined if this module should be included])
2014 AC_DEFINE(USE_SHA1, 1,   [Defined if this module should be included])
2015
2016 case "${host}" in
2017   x86_64-*-*)
2018     # Build with the assembly implementation
2019     GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-ssse3-amd64.lo"
2020     GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-avx-amd64.lo"
2021     GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-avx-bmi2-amd64.lo"
2022   ;;
2023   arm*-*-*)
2024     # Build with the assembly implementation
2025     GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1-armv7-neon.lo"
2026   ;;
2027 esac
2028
2029 LIST_MEMBER(scrypt, $enabled_kdfs)
2030 if test "$found" = "1" ; then
2031    GCRYPT_KDFS="$GCRYPT_KDFS scrypt.lo"
2032    AC_DEFINE(USE_SCRYPT, 1, [Defined if this module should be included])
2033 fi
2034
2035 LIST_MEMBER(linux, $random_modules)
2036 if test "$found" = "1" ; then
2037    GCRYPT_RANDOM="$GCRYPT_RANDOM rndlinux.lo"
2038    AC_DEFINE(USE_RNDLINUX, 1, [Defined if the /dev/random RNG should be used.])
2039 fi
2040
2041 LIST_MEMBER(unix, $random_modules)
2042 if test "$found" = "1" ; then
2043    GCRYPT_RANDOM="$GCRYPT_RANDOM rndunix.lo"
2044    AC_DEFINE(USE_RNDUNIX, 1, [Defined if the default Unix RNG should be used.])
2045    print_egd_notice=yes
2046 fi
2047
2048 LIST_MEMBER(egd, $random_modules)
2049 if test "$found" = "1" ; then
2050    GCRYPT_RANDOM="$GCRYPT_RANDOM rndegd.lo"
2051    AC_DEFINE(USE_RNDEGD, 1, [Defined if the EGD based RNG should be used.])
2052 fi
2053
2054 LIST_MEMBER(w32, $random_modules)
2055 if test "$found" = "1" ; then
2056    GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32.lo"
2057    AC_DEFINE(USE_RNDW32, 1,
2058              [Defined if the Windows specific RNG should be used.])
2059 fi
2060
2061 LIST_MEMBER(w32ce, $random_modules)
2062 if test "$found" = "1" ; then
2063    GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32ce.lo"
2064    AC_DEFINE(USE_RNDW32CE, 1,
2065              [Defined if the WindowsCE specific RNG should be used.])
2066 fi
2067
2068 AC_SUBST([GCRYPT_CIPHERS])
2069 AC_SUBST([GCRYPT_PUBKEY_CIPHERS])
2070 AC_SUBST([GCRYPT_DIGESTS])
2071 AC_SUBST([GCRYPT_KDFS])
2072 AC_SUBST([GCRYPT_RANDOM])
2073
2074 AC_SUBST(LIBGCRYPT_CIPHERS, $enabled_ciphers)
2075 AC_SUBST(LIBGCRYPT_PUBKEY_CIPHERS, $enabled_pubkey_ciphers)
2076 AC_SUBST(LIBGCRYPT_DIGESTS, $enabled_digests)
2077
2078 # For printing the configuration we need a colon separated list of
2079 # algorithm names.
2080 tmp=`echo "$enabled_ciphers" | tr ' ' : `
2081 AC_DEFINE_UNQUOTED(LIBGCRYPT_CIPHERS, "$tmp",
2082                    [List of available cipher algorithms])
2083 tmp=`echo "$enabled_pubkey_ciphers" | tr ' ' : `
2084 AC_DEFINE_UNQUOTED(LIBGCRYPT_PUBKEY_CIPHERS, "$tmp",
2085                    [List of available public key cipher algorithms])
2086 tmp=`echo "$enabled_digests" | tr ' ' : `
2087 AC_DEFINE_UNQUOTED(LIBGCRYPT_DIGESTS, "$tmp",
2088                    [List of available digest algorithms])
2089 tmp=`echo "$enabled_kdfs" | tr ' ' : `
2090 AC_DEFINE_UNQUOTED(LIBGCRYPT_KDFS, "$tmp",
2091                    [List of available KDF algorithms])
2092
2093
2094 #
2095 # Define conditional sources depending on the used hardware platform.
2096 # Note that all possible modules must also be listed in
2097 # src/Makefile.am (EXTRA_libgcrypt_la_SOURCES).
2098 #
2099 GCRYPT_HWF_MODULES=
2100 case "$mpi_cpu_arch" in
2101      x86)
2102         AC_DEFINE(HAVE_CPU_ARCH_X86, 1,   [Defined for the x86 platforms])
2103         GCRYPT_HWF_MODULES="hwf-x86.lo"
2104         ;;
2105      alpha)
2106         AC_DEFINE(HAVE_CPU_ARCH_ALPHA, 1, [Defined for Alpha platforms])
2107         ;;
2108      sparc)
2109         AC_DEFINE(HAVE_CPU_ARCH_SPARC, 1, [Defined for SPARC platforms])
2110         ;;
2111      mips)
2112         AC_DEFINE(HAVE_CPU_ARCH_MIPS, 1,  [Defined for MIPS platforms])
2113         ;;
2114      m68k)
2115         AC_DEFINE(HAVE_CPU_ARCH_M68K, 1,  [Defined for M68k platforms])
2116         ;;
2117      ppc)
2118         AC_DEFINE(HAVE_CPU_ARCH_PPC, 1,   [Defined for PPC platforms])
2119         ;;
2120      arm)
2121         AC_DEFINE(HAVE_CPU_ARCH_ARM, 1,   [Defined for ARM platforms])
2122         GCRYPT_HWF_MODULES="hwf-arm.lo"
2123         ;;
2124 esac
2125 AC_SUBST([GCRYPT_HWF_MODULES])
2126
2127
2128 #
2129 # Option to disable building of doc file
2130 #
2131 build_doc=yes
2132 AC_ARG_ENABLE([doc], AC_HELP_STRING([--disable-doc],
2133                                     [do not build the documentation]),
2134                      build_doc=$enableval, build_doc=yes)
2135 AM_CONDITIONAL([BUILD_DOC], [test "x$build_doc" != xno])
2136
2137
2138 #
2139 # Provide information about the build.
2140 #
2141 BUILD_REVISION="mym4_revision"
2142 AC_SUBST(BUILD_REVISION)
2143 AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
2144                    [GIT commit id revision used to build this package])
2145
2146 changequote(,)dnl
2147 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
2148 changequote([,])dnl
2149 BUILD_FILEVERSION="${BUILD_FILEVERSION}mym4_revision_dec"
2150 AC_SUBST(BUILD_FILEVERSION)
2151
2152 BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
2153 AC_SUBST(BUILD_TIMESTAMP)
2154 AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
2155                    [The time this package was configured for a build])
2156
2157
2158 # And create the files.
2159 AC_CONFIG_FILES([
2160 Makefile
2161 m4/Makefile
2162 compat/Makefile
2163 mpi/Makefile
2164 cipher/Makefile
2165 random/Makefile
2166 doc/Makefile
2167 src/Makefile
2168 src/gcrypt.h
2169 src/libgcrypt-config
2170 src/versioninfo.rc
2171 tests/Makefile
2172 ])
2173 AC_CONFIG_FILES([tests/hashtest-256g], [chmod +x tests/hashtest-256g])
2174 AC_OUTPUT
2175
2176
2177 detection_module="${GCRYPT_HWF_MODULES%.lo}"
2178 test -n "$detection_module" || detection_module="none"
2179
2180 # Give some feedback
2181 GCRY_MSG_SHOW([],[])
2182 GCRY_MSG_SHOW([Libgcrypt],[v${VERSION} has been configured as follows:])
2183 GCRY_MSG_SHOW([],[])
2184 GCRY_MSG_SHOW([Platform:                 ],[$PRINTABLE_OS_NAME ($host)])
2185 GCRY_MSG_SHOW([Hardware detection module:],[$detection_module])
2186 GCRY_MSG_WRAP([Enabled cipher algorithms:],[$enabled_ciphers])
2187 GCRY_MSG_WRAP([Enabled digest algorithms:],[$enabled_digests])
2188 GCRY_MSG_WRAP([Enabled kdf algorithms:   ],[$enabled_kdfs])
2189 GCRY_MSG_WRAP([Enabled pubkey algorithms:],[$enabled_pubkey_ciphers])
2190 GCRY_MSG_SHOW([Random number generator:  ],[$random])
2191 GCRY_MSG_SHOW([Using linux capabilities: ],[$use_capabilities])
2192 GCRY_MSG_SHOW([Try using Padlock crypto: ],[$padlocksupport])
2193 GCRY_MSG_SHOW([Try using AES-NI crypto:  ],[$aesnisupport])
2194 GCRY_MSG_SHOW([Try using Intel PCLMUL:   ],[$pclmulsupport])
2195 GCRY_MSG_SHOW([Try using DRNG (RDRAND):  ],[$drngsupport])
2196 GCRY_MSG_SHOW([Try using Intel AVX:      ],[$avxsupport])
2197 GCRY_MSG_SHOW([Try using Intel AVX2:     ],[$avx2support])
2198 GCRY_MSG_SHOW([Try using ARM NEON:       ],[$neonsupport])
2199 GCRY_MSG_SHOW([],[])
2200
2201 if test "x${gpg_config_script_warn}" != x; then
2202 cat <<G10EOF
2203         Mismatches between the target platform and the to
2204         be used libraries have been been detected for:
2205          ${gpg_config_script_warn}
2206         Please check above for warning messages.
2207
2208 G10EOF
2209 fi
2210 if test "$print_egd_notice" = "yes"; then
2211 cat <<G10EOF
2212    The performance of the Unix random gatherer module (rndunix) is not
2213    very good and it does not keep the entropy pool over multiple
2214    invocations of Libgcrypt base applications.  The suggested way to
2215    overcome this problem is to use the
2216
2217                  Entropy Gathering Daemon (EGD)
2218
2219    which provides a entropy source for the whole system.  It is written
2220    in Perl and available at the GnuPG FTP servers.  For more information
2221    consult the GnuPG site:
2222
2223           https://gnupg.org/related_software/swlist.html#egd
2224
2225 G10EOF
2226 fi
2227
2228 if test "$gcry_cv_gcc_attribute_aligned" != "yes" ; then
2229 cat <<G10EOF
2230    Please not that your compiler does not support the GCC style
2231    aligned attribute. Using this software may evoke bus errors.
2232
2233 G10EOF
2234 fi
2235
2236 if test -n "$gpl"; then
2237   echo "Please note that you are building a version of Libgcrypt with"
2238   echo "  $gpl"
2239   echo "included.  These parts are licensed under the GPL and thus the"
2240   echo "use of this library has to comply with the conditions of the GPL."
2241   echo ""
2242 fi