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