1 # Configure.ac script for Libgcrypt
2 # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006,
3 # 2007, 2008 Free Software Foundation, Inc.
5 # This file is part of Libgcrypt.
7 # Libgcrypt is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Lesser General Public License as
9 # published by the Free Software Foundation; either version 2.1 of
10 # the License, or (at your option) any later version.
12 # Libgcrypt is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
20 # (Process this file with autoconf to produce a configure script.)
21 AC_REVISION($Revision$)
23 min_automake_version="1.10"
26 # Remember to change the version number immediately *after* a release.
27 # Set my_issvn to "yes" for non-released code. Remember to run an
28 # "svn up" and "autogen.sh" right before creating a distribution.
29 m4_define([my_version], [1.4.3])
30 m4_define([my_issvn], [yes])
32 m4_define([svn_revision], m4_esyscmd([printf "%d" $(svn info 2>/dev/null \
33 | sed -n '/^Revision:/ s/[^0-9]//gp'|head -1)]))
35 [my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision])],
36 [bug-libgcrypt@gnupg.org])
37 # LT Version numbers, remember to change them just *before* a release.
38 # (Interfaces removed: CURRENT++, AGE=0, REVISION=0)
39 # (Interfaces added: CURRENT++, AGE++, REVISION=0)
40 # (No interfaces changed: REVISION++)
41 LIBGCRYPT_LT_CURRENT=16
43 LIBGCRYPT_LT_REVISION=0
46 # If the API is changed in an incompatible way: increment the next counter.
47 LIBGCRYPT_CONFIG_API_VERSION=1
49 NEED_GPG_ERROR_VERSION=1.4
51 is_development_version=my_issvn
52 BUILD_REVISION=svn_revision
54 VERSION=$PACKAGE_VERSION
56 AC_CONFIG_SRCDIR([src/libgcrypt.vers])
57 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
58 AM_CONFIG_HEADER(config.h)
63 #ifndef _GCRYPT_CONFIG_H_INCLUDED
64 #define _GCRYPT_CONFIG_H_INCLUDED
65 /* need this, because some autoconf tests rely on this (e.g. stpcpy)
66 * and it should be used for new programs */
71 #define _GCRYPT_IN_LIBGCRYPT 1
73 /* If the configure check for endianness has been disabled, get it from
74 OS macros. This is intended for making fat binary builds on OS X. */
75 #ifdef DISABLED_ENDIAN_CHECK
76 # if defined(__BIG_ENDIAN__)
77 # define WORDS_BIGENDIAN 1
78 # elif defined(__LITTLE_ENDIAN__)
79 # undef WORDS_BIGENDIAN
81 # error "No endianness found"
83 #endif /*DISABLED_ENDIAN_CHECK*/
85 /* We basically use the original Camellia source. Make sure the symbols
87 #define CAMELLIA_EXT_SYM_PREFIX _gcry_
89 /* This error code is only available with gpg-error 1.7. Thus
90 we define it here with the usual gcry prefix. */
91 #define GCRY_GPG_ERR_NOT_OPERATIONAL 176
94 #endif /*_GCRYPT_CONFIG_H_INCLUDED*/
97 AH_VERBATIM([_REENTRANT],
98 [/* To allow the use of Libgcrypt in multithreaded programs we have to use
99 special features from the library. */
101 # define _REENTRANT 1
106 AC_SUBST(LIBGCRYPT_LT_CURRENT)
107 AC_SUBST(LIBGCRYPT_LT_AGE)
108 AC_SUBST(LIBGCRYPT_LT_REVISION)
111 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
112 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
115 ######################
116 ## Basic checks. ### (we need some results later on (e.g. $GCC)
117 ######################
120 missing_dir=`cd $ac_aux_dir && pwd`
121 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
122 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
123 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
124 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
125 # AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
139 ##########################
140 ## General definitions. ##
141 ##########################
143 # Used by libgcrypt-config
144 LIBGCRYPT_CONFIG_LIBS="-lgcrypt"
145 LIBGCRYPT_CONFIG_CFLAGS=""
147 # Definitions for symmetric ciphers.
148 available_ciphers="arcfour blowfish cast5 des aes twofish serpent rfc2268 seed"
149 available_ciphers="$available_ciphers camellia"
152 # Definitions for public-key ciphers.
153 available_pubkey_ciphers="dsa elgamal rsa ecc"
154 enabled_pubkey_ciphers=""
156 # Definitions for message digests.
157 available_digests="crc md4 md5 rmd160 sha1 sha256"
158 available_digests_64="sha512 tiger whirlpool"
161 # Definitions for random modules.
162 available_random_modules="linux egd unix"
163 auto_random_modules="$available_random_modules"
165 # Supported thread backends.
166 LIBGCRYPT_THREAD_MODULES=""
172 # Setup some stuff depending on host.
175 available_random_modules="w32"
176 ac_cv_have_dev_random=no
178 AC_DEFINE(USE_ONLY_8DOT3,1,
179 [set this to limit filenames to the 8.3 format])
180 AC_DEFINE(HAVE_DRIVE_LETTERS,1,
181 [defined if we must run on a stupid file system])
182 AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
183 [defined if we run on some of the PCDOS like systems
184 (DOS, Windoze. OS/2) with special properties like
188 i?86-emx-os2 | i?86-*-os2*emx)
189 # OS/2 with the EMX environment
190 ac_cv_have_dev_random=no
191 AC_DEFINE(HAVE_DRIVE_LETTERS)
192 AC_DEFINE(HAVE_DOSISH_SYSTEM)
196 # DOS with the DJGPP environment
197 ac_cv_have_dev_random=no
198 AC_DEFINE(HAVE_DRIVE_LETTERS)
199 AC_DEFINE(HAVE_DOSISH_SYSTEM)
204 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
205 LDFLAGS="$LDFLAGS -L/usr/local/lib"
209 if test -z "$GCC" ; then
210 CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
214 if test -z "$GCC" ; then
215 # Suppress all warnings
216 # to get rid of the unsigned/signed char mismatch warnings.
226 if test "$have_w32_system" = yes; then
227 AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
229 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
233 # A printable OS Name is sometimes useful.
236 PRINTABLE_OS_NAME="MingW32"
239 i?86-emx-os2 | i?86-*-os2*emx )
240 PRINTABLE_OS_NAME="OS/2"
244 PRINTABLE_OS_NAME="MSDOS/DJGPP"
248 PRINTABLE_OS_NAME="GNU/Linux"
252 PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
257 # Figure out the name of the random device
261 NAME_OF_DEV_RANDOM="/dev/srandom"
262 NAME_OF_DEV_URANDOM="/dev/urandom"
266 NAME_OF_DEV_RANDOM="/dev/random"
267 NAME_OF_DEV_URANDOM="/dev/urandom"
272 AC_ARG_ENABLE(endian-check,
273 AC_HELP_STRING([--disable-endian-check],
274 [disable the endian check and trust the OS provided macros]),
275 endiancheck=$enableval,endiancheck=yes)
276 if test x"$endiancheck" = xyes ; then
279 AC_DEFINE(DISABLED_ENDIAN_CHECK,1,[configure did not test for endianess])
282 AC_CHECK_SIZEOF(unsigned short, 2)
283 AC_CHECK_SIZEOF(unsigned int, 4)
284 AC_CHECK_SIZEOF(unsigned long, 4)
285 AC_CHECK_SIZEOF(unsigned long long, 0)
289 if test "$ac_cv_sizeof_unsigned_short" = "0" \
290 || test "$ac_cv_sizeof_unsigned_int" = "0" \
291 || test "$ac_cv_sizeof_unsigned_long" = "0"; then
292 AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
295 # Do we have any 64-bit data types?
296 if test "$ac_cv_sizeof_unsigned_int" != "8" \
297 && test "$ac_cv_sizeof_unsigned_long" != "8" \
298 && test "$ac_cv_sizeof_unsigned_long_long" != "8" \
299 && test "$ac_cv_sizeof_uint64_t" != "8"; then
300 AC_MSG_WARN([No 64-bit types. Disabling TIGER/192, SHA-384, and SHA-512])
302 available_digests="$available_digests $available_digests_64"
305 # If not specified otherwise, all available algorithms will be
307 default_ciphers="$available_ciphers"
308 default_pubkey_ciphers="$available_pubkey_ciphers"
309 default_digests="$available_digests"
311 ############################
312 ## Command line switches. ##
313 ############################
315 # Implementation of the --enable-ciphers switch.
316 AC_ARG_ENABLE(ciphers,
317 AC_HELP_STRING([--enable-ciphers=ciphers],
318 [select the symmetric ciphers to include]),
319 [enabled_ciphers=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
320 [enabled_ciphers=""])
321 if test "x$enabled_ciphers" = "x" \
322 -o "$enabled_ciphers" = "yes" \
323 -o "$enabled_ciphers" = "no"; then
324 enabled_ciphers=$default_ciphers
326 AC_MSG_CHECKING([which symmetric ciphers to include])
327 for cipher in $enabled_ciphers; do
328 LIST_MEMBER($cipher, $available_ciphers)
329 if test "$found" = "0"; then
330 AC_MSG_ERROR([unsupported cipher "$cipher" specified])
333 AC_MSG_RESULT([$enabled_ciphers])
335 # Implementation of the --enable-pubkey-ciphers switch.
336 AC_ARG_ENABLE(pubkey-ciphers,
337 AC_HELP_STRING([--enable-pubkey-ciphers=ciphers],
338 [select the public-key ciphers to include]),
339 [enabled_pubkey_ciphers=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
340 [enabled_pubkey_ciphers=""])
341 if test "x$enabled_pubkey_ciphers" = "x" \
342 -o "$enabled_pubkey_ciphers" = "yes" \
343 -o "$enabled_pubkey_ciphers" = "no"; then
344 enabled_pubkey_ciphers=$default_pubkey_ciphers
346 AC_MSG_CHECKING([which public-key ciphers to include])
347 for cipher in $enabled_pubkey_ciphers; do
348 LIST_MEMBER($cipher, $available_pubkey_ciphers)
349 if test "$found" = "0"; then
350 AC_MSG_ERROR([unsupported public-key cipher specified])
353 AC_MSG_RESULT([$enabled_pubkey_ciphers])
355 # Implementation of the --enable-digests switch.
356 AC_ARG_ENABLE(digests,
357 AC_HELP_STRING([--enable-digests=digests],
358 [select the message digests to include]),
359 [enabled_digests=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
360 [enabled_digests=""])
361 if test "x$enabled_digests" = "x" \
362 -o "$enabled_digests" = "yes" \
363 -o "$enabled_digests" = "no"; then
364 enabled_digests=$default_digests
366 AC_MSG_CHECKING([which message digests to include])
367 for digest in $enabled_digests; do
368 LIST_MEMBER($digest, $available_digests)
369 if test "$found" = "0"; then
370 AC_MSG_ERROR([unsupported message digest specified])
373 AC_MSG_RESULT([$enabled_digests])
375 # Implementation of the --enable-random switch.
376 AC_ARG_ENABLE(random,
377 AC_HELP_STRING([--enable-random=name],
378 [select which random number generator to use]),
379 [random=`echo $enableval | tr '[A-Z]' '[a-z]'`],
381 if test "x$random" = "x" -o "$random" = "yes" -o "$random" = "no"; then
384 AC_MSG_CHECKING([which random module to use])
385 if test "$random" != "default" -a "$random" != "auto"; then
386 LIST_MEMBER($random, $available_random_modules)
387 if test "$found" = "0"; then
388 AC_MSG_ERROR([unsupported random module specified])
391 AC_MSG_RESULT($random)
393 # Implementation of the --disable-dev-random switch.
394 AC_MSG_CHECKING([whether use of /dev/random is requested])
395 AC_ARG_ENABLE(dev-random,
396 [ --disable-dev-random disable the use of dev random],
397 try_dev_random=$enableval, try_dev_random=yes)
398 AC_MSG_RESULT($try_dev_random)
400 # Implementation of the --with-egd-socket switch.
401 AC_ARG_WITH(egd-socket,
402 [ --with-egd-socket=NAME Use NAME for the EGD socket)],
403 egd_socket_name="$withval", egd_socket_name="" )
404 AC_DEFINE_UNQUOTED(EGD_SOCKET_NAME, "$egd_socket_name",
405 [Define if you don't want the default EGD socket name.
406 For details see cipher/rndegd.c])
408 # Implementation of the --enable-random-daemon
409 AC_MSG_CHECKING([whether the experimental random daemon is requested])
410 AC_ARG_ENABLE([random-daemon],
411 AC_HELP_STRING([--enable-random-daemon],
412 [Build and support the experimental gcryptrnd]),
413 [use_random_daemon=$enableval],
414 [use_random_daemon=no])
415 AC_MSG_RESULT($use_random_daemon)
416 if test x$use_random_daemon = xyes ; then
417 AC_DEFINE(USE_RANDOM_DAEMON,1,
418 [Define to support the experimental random daemon])
420 AM_CONDITIONAL(USE_RANDOM_DAEMON, test x$use_random_daemon = xyes)
423 # Implementation of --disable-asm.
424 AC_MSG_CHECKING([whether MPI assembler modules are requested])
426 AC_HELP_STRING([--disable-asm],
427 [Disable MPI assembler modules]),
428 [try_asm_modules=$enableval],
429 [try_asm_modules=yes])
430 AC_MSG_RESULT($try_asm_modules)
432 # Implementation of the --enable-m-guard switch.
433 AC_MSG_CHECKING([whether memory guard is requested])
434 AC_ARG_ENABLE(m-guard,
435 AC_HELP_STRING([--enable-m-guard],
436 [Enable memory guard facility]),
437 [use_m_guard=$enableval], [use_m_guard=no])
438 AC_MSG_RESULT($use_m_guard)
439 if test "$use_m_guard" = yes ; then
440 AC_DEFINE(M_GUARD,1,[Define to use the (obsolete) malloc guarding feature])
443 # Implementation of the --with-capabilities switch.
444 # Check whether we want to use Linux capabilities
445 AC_MSG_CHECKING([whether use of capabilities is requested])
446 AC_ARG_WITH(capabilities,
447 AC_HELP_STRING([--with-capabilities],
448 [Use linux capabilities [default=no]]),
449 [use_capabilities="$withval"],[use_capabilities=no])
450 AC_MSG_RESULT($use_capabilities)
452 # Implementation of the --enable-hmac-binary-check.
453 AC_MSG_CHECKING([whether a HMAC binary check is requested])
454 AC_ARG_ENABLE(hmac-binary-check,
455 AC_HELP_STRING([--enable-hmac-binary-check],
456 [Enable library integrity check]),
457 [use_hmac_binary_check=$enableval],
458 [use_hmac_binary_check=no])
459 AC_MSG_RESULT($use_hmac_binary_check)
460 if test "$use_hmac_binary_check" = yes ; then
461 AC_DEFINE(ENABLE_HMAC_BINARY_CHECK,1,
462 [Define to support an HMAC based integrity check])
466 # Implementation of the --disable-padlock-support switch.
467 AC_MSG_CHECKING([whether padlock support is requested])
468 AC_ARG_ENABLE(padlock-support,
469 AC_HELP_STRING([--disable-padlock-support],
470 [Disable support for the PadLock Engine of VIA processors]),
471 padlocksupport=$enableval,padlocksupport=yes)
472 AC_MSG_RESULT($padlocksupport)
473 if test x"$padlocksupport" = xyes ; then
474 AC_DEFINE(ENABLE_PADLOCK_SUPPORT, 1,
475 [Enable support for the PadLock engine.])
480 AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
481 [A human readable text with the name of the OS])
483 # For some systems we know that we have ld_version scripts.
484 # Use it then as default.
485 have_ld_version_script=no
488 have_ld_version_script=yes
491 have_ld_version_script=yes
494 AC_ARG_ENABLE([ld-version-script],
495 AC_HELP_STRING([--enable-ld-version-script],
496 [enable/disable use of linker version script.
497 (default is system dependent)]),
498 [have_ld_version_script=$enableval],
500 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
502 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, "$NAME_OF_DEV_RANDOM",
503 [defined to the name of the strong random device])
504 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, "$NAME_OF_DEV_URANDOM",
505 [defined to the name of the weaker random device])
507 ###############################
508 #### Checks for libraries. ####
509 ###############################
512 # gpg-error is required.
514 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION")
515 if test "x$GPG_ERROR_LIBS" = "x"; then
516 AC_MSG_ERROR([libgpg-error is needed.
517 See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ .])
520 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GCRYPT,
521 [The default error source for libgcrypt.])
524 # Check whether the GNU Pth library is available. We require this
525 # to build the optional gcryptrnd program.
527 AC_ARG_WITH(pth-prefix,
528 AC_HELP_STRING([--with-pth-prefix=PFX],
529 [prefix where GNU Pth is installed (optional)]),
530 pth_config_prefix="$withval", pth_config_prefix="")
531 if test x$pth_config_prefix != x ; then
532 PTH_CONFIG="$pth_config_prefix/bin/pth-config"
534 if test "$use_random_daemon" = "yes"; then
535 AC_PATH_PROG(PTH_CONFIG, pth-config, no)
536 if test "$PTH_CONFIG" = "no"; then
539 *** To build the Libgcrypt's random number daemon
540 *** we need the support of the GNU Portable Threads Library.
541 *** Download it from ftp://ftp.gnu.org/gnu/pth/
542 *** On a Debian GNU/Linux system you might want to try
543 *** apt-get install libpth-dev
546 GNUPG_PTH_VERSION_CHECK([1.3.7])
547 if test $have_pth = yes; then
548 PTH_CFLAGS=`$PTH_CONFIG --cflags`
549 PTH_LIBS=`$PTH_CONFIG --ldflags`
550 PTH_LIBS="$PTH_LIBS `$PTH_CONFIG --libs --all`"
551 AC_DEFINE(USE_GNU_PTH, 1,
552 [Defined if the GNU Portable Thread Library should be used])
553 AC_DEFINE(HAVE_PTH, 1,
554 [Defined if the GNU Pth is available])
562 # Solaris needs -lsocket and -lnsl. Unisys system includes
563 # gethostbyname in libsocket but needs libnsl for socket.
564 AC_SEARCH_LIBS(setsockopt, [socket], ,
565 [AC_SEARCH_LIBS(setsockopt, [socket], , , [-lnsl])])
566 AC_SEARCH_LIBS(setsockopt, [nsl])
568 ##################################
569 #### Checks for header files. ####
570 ##################################
573 AC_CHECK_HEADERS(unistd.h sys/select.h)
575 ##########################################
576 #### Checks for typedefs, structures, ####
577 #### and compiler characteristics. ####
578 ##########################################
586 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
587 GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
588 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
589 GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
590 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
595 # socklen_t may or may not be defined depending on what headers
596 # are included. To be safe we use int as this is the actual type.
597 FALLBACK_SOCKLEN_T="typedef int gcry_socklen_t;"
600 if test ".$gl_cv_socklen_t_equiv" = "."; then
601 FALLBACK_SOCKLEN_T="typedef socklen_t gcry_socklen_t;"
603 FALLBACK_SOCKLEN_T="typedef ${gl_cv_socklen_t_equiv} gcry_socklen_t;"
606 AC_SUBST(FALLBACK_SOCKLEN_T)
609 # Check for ELF visibility support.
611 AC_CACHE_CHECK(whether the visibility attribute is supported,
612 gcry_cv_visibility_attribute,
613 [gcry_cv_visibility_attribute=no
614 AC_LANG_CONFTEST([AC_LANG_SOURCE(
615 [[int foo __attribute__ ((visibility ("hidden"))) = 1;
616 int bar __attribute__ ((visibility ("protected"))) = 1;
619 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
620 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
621 if grep '\.hidden.*foo' conftest.s >/dev/null 2>&1 ; then
622 if grep '\.protected.*bar' conftest.s >/dev/null 2>&1; then
623 gcry_cv_visibility_attribute=yes
628 if test "$gcry_cv_visibility_attribute" = "yes"; then
629 AC_CACHE_CHECK(for broken visibility attribute,
630 gcry_cv_broken_visibility_attribute,
631 [gcry_cv_broken_visibility_attribute=yes
632 AC_LANG_CONFTEST([AC_LANG_SOURCE(
634 int bar (int x) __asm__ ("foo")
635 __attribute__ ((visibility ("hidden")));
636 int bar (int x) { return x; }
639 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
640 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
641 if grep '\.hidden@<:@ _@:>@foo' conftest.s >/dev/null 2>&1;
643 gcry_cv_broken_visibility_attribute=no
648 if test "$gcry_cv_visibility_attribute" = "yes"; then
649 AC_CACHE_CHECK(for broken alias attribute,
650 gcry_cv_broken_alias_attribute,
651 [gcry_cv_broken_alias_attribute=yes
652 AC_LANG_CONFTEST([AC_LANG_SOURCE(
653 [[extern int foo (int x) __asm ("xyzzy");
654 int bar (int x) { return x; }
655 extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
657 extern __typeof (dfoo) dfoo __asm ("abccb");
661 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
662 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
663 if grep 'xyzzy' conftest.s >/dev/null 2>&1 && \
664 grep 'abccb' conftest.s >/dev/null 2>&1; then
665 gcry_cv_broken_alias_attribute=no
670 if test "$gcry_cv_visibility_attribute" = "yes"; then
671 AC_CACHE_CHECK(if gcc supports -fvisibility=hidden,
672 gcry_cv_gcc_has_f_visibility,
673 [gcry_cv_gcc_has_f_visibility=no
674 _gcc_cflags_save=$CFLAGS
675 CFLAGS="-fvisibility=hidden"
676 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
677 gcry_cv_gcc_has_f_visibility=yes)
678 CFLAGS=$_gcc_cflags_save;
681 if test "$gcry_cv_visibility_attribute" = "yes" \
682 && test "$gcry_cv_broken_visibility_attribute" != "yes" \
683 && test "$gcry_cv_broken_alias_attribute" != "yes" \
684 && test "$gcry_cv_gcc_has_f_visibility" = "yes"
686 AC_DEFINE(GCRY_USE_VISIBILITY, 1,
687 [Define to use the GNU C visibility attribute.])
688 CFLAGS="$CFLAGS -fvisibility=hidden"
692 #######################################
693 #### Checks for library functions. ####
694 #######################################
697 # We have replacements for these in src/missing-string.c
698 AC_CHECK_FUNCS(stpcpy strcasecmp)
699 # We have replacements for these in src/g10lib.h
700 AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise)
702 AC_CHECK_FUNCS(strerror rand mmap getpagesize sysconf waitpid wait4)
703 AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime)
704 AC_CHECK_FUNCS(fcntl ftruncate)
710 # Check wether it is necessary to link against libdl.
713 if test "$use_hmac_binary_check" = yes ; then
714 _gcry_save_libs="$LIBS"
716 AC_SEARCH_LIBS(dlopen, c dl,,,)
718 LIBS="$_gcry_save_libs"
719 LIBGCRYPT_CONFIG_LIBS="${LIBGCRYPT_CONFIG_LIBS} ${DL_LIBS}"
725 # Check whether we can use Linux capabilities as requested.
727 if test "$use_capabilities" = "yes" ; then
729 AC_CHECK_HEADERS(sys/capability.h)
730 if test "$ac_cv_header_sys_capability_h" = "yes" ; then
731 AC_CHECK_LIB(cap, cap_init, ac_need_libcap=1)
732 if test "$ac_cv_lib_cap_cap_init" = "yes"; then
733 AC_DEFINE(USE_CAPABILITIES,1,
734 [define if capabilities should be used])
739 if test "$use_capabilities" = "no" ; then
742 *** The use of capabilities on this system is not possible.
743 *** You need a recent Linux kernel and some patches:
744 *** fcaps-2.2.9-990610.patch (kernel patch for 2.2.9)
745 *** fcap-module-990613.tar.gz (kernel module)
746 *** libcap-1.92.tar.gz (user mode library and utilities)
747 *** And you have to configure the kernel with CONFIG_VFS_CAP_PLUGIN
748 *** set (filesystems menu). Be warned: This code is *really* ALPHA.
753 # Check whether a random device is available.
754 if test "$try_dev_random" = yes ; then
755 AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
756 [if test -r "$NAME_OF_DEV_RANDOM" && test -r "$NAME_OF_DEV_URANDOM" ; then
757 ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
758 if test "$ac_cv_have_dev_random" = yes; then
759 AC_DEFINE(HAVE_DEV_RANDOM,1,
760 [defined if the system supports a random device] )
763 AC_MSG_CHECKING(for random device)
764 ac_cv_have_dev_random=no
765 AC_MSG_RESULT(has been disabled)
768 # Figure out the random modules for this configuration.
769 if test "$random" = "default"; then
771 # Select default value.
772 if test "$ac_cv_have_dev_random" = yes; then
773 # Try Linuxish random device.
774 random_modules="linux"
777 *-*-mingw32*|*-*-cygwin*)
778 # Windows random device.
782 # Build everything, allow to select at runtime.
783 random_modules="$auto_random_modules"
788 if test "$random" = "auto"; then
789 # Build everything, allow to select at runtime.
790 random_modules="$auto_random_modules"
792 random_modules="$random"
798 # Setup assembler stuff.
800 GNUPG_SYS_SYMBOL_UNDERSCORE()
801 AC_ARG_ENABLE(mpi-path,
802 AC_HELP_STRING([--enable-mpi-path=EXTRA_PATH],
803 [prepend EXTRA_PATH to list of CPU specific optimizations]),
804 mpi_extra_path="$enableval",mpi_extra_path="")
805 AC_MSG_CHECKING(for mpi assembler functions)
806 if test -f $srcdir/mpi/config.links ; then
807 . $srcdir/mpi/config.links
808 AC_CONFIG_LINKS("$mpi_ln_list")
809 ac_cv_mpi_sflags="$mpi_sflags"
812 AC_MSG_RESULT(failed)
813 AC_MSG_ERROR([mpi/config.links missing!])
815 MPI_SFLAGS="$ac_cv_mpi_sflags"
818 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_ADD1, test "$mpi_mod_asm_mpih_add1" = yes)
819 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_SUB1, test "$mpi_mod_asm_mpih_sub1" = yes)
820 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL1, test "$mpi_mod_asm_mpih_mul1" = yes)
821 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL2, test "$mpi_mod_asm_mpih_mul2" = yes)
822 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL3, test "$mpi_mod_asm_mpih_mul3" = yes)
823 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_LSHIFT, test "$mpi_mod_asm_mpih_lshift" = yes)
824 AM_CONDITIONAL(MPI_MOD_ASM_MPIH_RSHIFT, test "$mpi_mod_asm_mpih_rshift" = yes)
825 AM_CONDITIONAL(MPI_MOD_ASM_UDIV, test "$mpi_mod_asm_udiv" = yes)
826 AM_CONDITIONAL(MPI_MOD_ASM_UDIV_QRNND, test "$mpi_mod_asm_udiv_qrnnd" = yes)
827 AM_CONDITIONAL(MPI_MOD_C_MPIH_ADD1, test "$mpi_mod_c_mpih_add1" = yes)
828 AM_CONDITIONAL(MPI_MOD_C_MPIH_SUB1, test "$mpi_mod_c_mpih_sub1" = yes)
829 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL1, test "$mpi_mod_c_mpih_mul1" = yes)
830 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL2, test "$mpi_mod_c_mpih_mul2" = yes)
831 AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL3, test "$mpi_mod_c_mpih_mul3" = yes)
832 AM_CONDITIONAL(MPI_MOD_C_MPIH_LSHIFT, test "$mpi_mod_c_mpih_lshift" = yes)
833 AM_CONDITIONAL(MPI_MOD_C_MPIH_RSHIFT, test "$mpi_mod_c_mpih_rshift" = yes)
834 AM_CONDITIONAL(MPI_MOD_C_UDIV, test "$mpi_mod_c_udiv" = yes)
835 AM_CONDITIONAL(MPI_MOD_C_UDIV_QRNND, test "$mpi_mod_c_udiv_qrnnd" = yes)
837 if test "$is_development_version" = "yes"; then
838 AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
839 [Defined if this is not a regular release])
843 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
846 # This is handy for debugging so the compiler doesn't rearrange
847 # things and eliminate variables.
848 AC_ARG_ENABLE(optimization,
849 AC_HELP_STRING([--disable-optimization],
850 [disable compiler optimization]),
851 [if test $enableval = no ; then
852 CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
855 AC_ARG_ENABLE(gcc-warnings,
856 AC_HELP_STRING([--enable-gcc-warnings],
857 [enable more verbose gcc warnings]),
858 [more_gcc_warnings="$enableval"],
859 [more_gcc_warnings="no"])
861 if test "$GCC" = yes; then
862 if test "$USE_MAINTAINER_MODE" = "yes" ||
863 test "$more_gcc_warnings" = "yes"; then
864 CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
865 if test "$more_gcc_warnings" = "yes"; then
866 CFLAGS="$CFLAGS -W -Wextra -Wbad-function-cast"
867 CFLAGS="$CFLAGS -Wwrite-strings"
868 CFLAGS="$CFLAGS -Wdeclaration-after-statement"
869 CFLAGS="$CFLAGS -Wno-missing-field-initializers"
870 CFLAGS="$CFLAGS -Wno-sign-compare"
871 # Note: We don't use -Wunreachable-code because this gives
872 # warnings for all asserts and many inline functions like
873 # gpg_error (gcc 4.1.2 20060928).
876 CFLAGS="$CFLAGS -Wall"
879 AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
880 _gcc_cflags_save=$CFLAGS
881 CFLAGS="-Wpointer-arith"
882 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no)
883 AC_MSG_RESULT($_gcc_wopt)
884 CFLAGS=$_gcc_cflags_save;
885 if test x"$_gcc_wopt" = xyes ; then
886 CFLAGS="$CFLAGS -Wpointer-arith"
890 # Check whether as(1) supports a noeexecstack feature. This test
891 # includes an override option.
895 AC_SUBST(LIBGCRYPT_CONFIG_API_VERSION)
896 AC_SUBST(LIBGCRYPT_CONFIG_LIBS)
897 AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS)
898 AC_SUBST(LIBGCRYPT_THREAD_MODULES)
900 AC_CONFIG_COMMANDS([gcrypt-conf],[[
901 chmod +x src/libgcrypt-config
904 exec_prefix=$exec_prefix
907 DATADIRNAME=$DATADIRNAME
910 #####################
911 #### Conclusion. ####
912 #####################
914 # Define conditional sources and config.h symbols depending on the
915 # selected ciphers, pubkey-ciphers, digests and random modules.
917 LIST_MEMBER(arcfour, $enabled_ciphers)
918 if test "$found" = "1"; then
919 GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour.lo"
920 AC_DEFINE(USE_ARCFOUR, 1, [Defined if this module should be included])
923 LIST_MEMBER(blowfish, $enabled_ciphers)
924 if test "$found" = "1" ; then
925 GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish.lo"
926 AC_DEFINE(USE_BLOWFISH, 1, [Defined if this module should be included])
929 LIST_MEMBER(cast5, $enabled_ciphers)
930 if test "$found" = "1" ; then
931 GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5.lo"
932 AC_DEFINE(USE_CAST5, 1, [Defined if this module should be included])
935 LIST_MEMBER(des, $enabled_ciphers)
936 if test "$found" = "1" ; then
937 GCRYPT_CIPHERS="$GCRYPT_CIPHERS des.lo"
938 AC_DEFINE(USE_DES, 1, [Defined if this module should be included])
941 LIST_MEMBER(aes, $enabled_ciphers)
942 if test "$found" = "1" ; then
943 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael.lo"
944 AC_DEFINE(USE_AES, 1, [Defined if this module should be included])
947 LIST_MEMBER(twofish, $enabled_ciphers)
948 if test "$found" = "1" ; then
949 GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish.lo"
950 AC_DEFINE(USE_TWOFISH, 1, [Defined if this module should be included])
953 LIST_MEMBER(serpent, $enabled_ciphers)
954 if test "$found" = "1" ; then
955 GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent.lo"
956 AC_DEFINE(USE_SERPENT, 1, [Defined if this module should be included])
959 LIST_MEMBER(rfc2268, $enabled_ciphers)
960 if test "$found" = "1" ; then
961 GCRYPT_CIPHERS="$GCRYPT_CIPHERS rfc2268.lo"
962 AC_DEFINE(USE_RFC2268, 1, [Defined if this module should be included])
965 LIST_MEMBER(seed, $enabled_ciphers)
966 if test "$found" = "1" ; then
967 GCRYPT_CIPHERS="$GCRYPT_CIPHERS seed.lo"
968 AC_DEFINE(USE_SEED, 1, [Defined if this module should be included])
971 LIST_MEMBER(camellia, $enabled_ciphers)
972 if test "$found" = "1" ; then
973 GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia.lo camellia-glue.lo"
974 AC_DEFINE(USE_CAMELLIA, 1, [Defined if this module should be included])
977 LIST_MEMBER(dsa, $enabled_pubkey_ciphers)
978 if test "$found" = "1" ; then
979 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo"
980 AC_DEFINE(USE_DSA, 1, [Defined if this module should be included])
983 LIST_MEMBER(rsa, $enabled_pubkey_ciphers)
984 if test "$found" = "1" ; then
985 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS rsa.lo"
986 AC_DEFINE(USE_RSA, 1, [Defined if this module should be included])
989 LIST_MEMBER(elgamal, $enabled_pubkey_ciphers)
990 if test "$found" = "1" ; then
991 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo"
992 AC_DEFINE(USE_ELGAMAL, 1, [Defined if this module should be included])
995 LIST_MEMBER(ecc, $enabled_pubkey_ciphers)
996 if test "$found" = "1" ; then
997 GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS ecc.lo"
998 AC_DEFINE(USE_ECC, 1, [Defined if this module should be included])
1001 LIST_MEMBER(crc, $enabled_digests)
1002 if test "$found" = "1" ; then
1003 GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc.lo"
1004 AC_DEFINE(USE_CRC, 1, [Defined if this module should be included])
1007 LIST_MEMBER(md4, $enabled_digests)
1008 if test "$found" = "1" ; then
1009 GCRYPT_DIGESTS="$GCRYPT_DIGESTS md4.lo"
1010 AC_DEFINE(USE_MD4, 1, [Defined if this module should be included])
1013 LIST_MEMBER(md5, $enabled_digests)
1014 if test "$found" = "1" ; then
1015 GCRYPT_DIGESTS="$GCRYPT_DIGESTS md5.lo"
1016 AC_DEFINE(USE_MD5, 1, [Defined if this module should be included])
1019 LIST_MEMBER(sha256, $enabled_digests)
1020 if test "$found" = "1" ; then
1021 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo"
1022 AC_DEFINE(USE_SHA256, 1, [Defined if this module should be included])
1025 LIST_MEMBER(sha512, $enabled_digests)
1026 if test "$found" = "1" ; then
1027 GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512.lo"
1028 AC_DEFINE(USE_SHA512, 1, [Defined if this module should be included])
1031 LIST_MEMBER(tiger, $enabled_digests)
1032 if test "$found" = "1" ; then
1033 GCRYPT_DIGESTS="$GCRYPT_DIGESTS tiger.lo"
1034 AC_DEFINE(USE_TIGER, 1, [Defined if this module should be included])
1037 LIST_MEMBER(whirlpool, $enabled_digests)
1038 if test "$found" = "1" ; then
1039 GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool.lo"
1040 AC_DEFINE(USE_WHIRLPOOL, 1, [Defined if this module should be included])
1043 # rmd160 and sha1 should be included always.
1044 GCRYPT_DIGESTS="$GCRYPT_DIGESTS rmd160.lo sha1.lo"
1045 AC_DEFINE(USE_RMD160, 1, [Defined if this module should be included])
1046 AC_DEFINE(USE_SHA1, 1, [Defined if this module should be included])
1048 LIST_MEMBER(linux, $random_modules)
1049 if test "$found" = "1" ; then
1050 GCRYPT_RANDOM="$GCRYPT_RANDOM rndlinux.lo"
1051 AC_DEFINE(USE_RNDLINUX, 1, [Defined if the /dev/random RNG should be used.])
1054 LIST_MEMBER(unix, $random_modules)
1055 if test "$found" = "1" ; then
1056 GCRYPT_RANDOM="$GCRYPT_RANDOM rndunix.lo"
1057 AC_DEFINE(USE_RNDUNIX, 1, [Defined if the default Unix RNG should be used.])
1058 print_egd_notice=yes
1061 LIST_MEMBER(egd, $random_modules)
1062 if test "$found" = "1" ; then
1063 GCRYPT_RANDOM="$GCRYPT_RANDOM rndegd.lo"
1064 AC_DEFINE(USE_RNDEGD, 1, [Defined if the EGD based RNG should be used.])
1067 LIST_MEMBER(w32, $random_modules)
1068 if test "$found" = "1" ; then
1069 GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32.lo"
1070 AC_DEFINE(USE_RNDW32, 1,
1071 [Defined if the Windows specific RNG should be used.])
1074 AC_SUBST([GCRYPT_CIPHERS])
1075 AC_SUBST([GCRYPT_PUBKEY_CIPHERS])
1076 AC_SUBST([GCRYPT_DIGESTS])
1077 AC_SUBST([GCRYPT_RANDOM])
1079 AC_SUBST(LIBGCRYPT_CIPHERS, $enabled_ciphers)
1080 AC_SUBST(LIBGCRYPT_PUBKEY_CIPHERS, $enabled_pubkey_ciphers)
1081 AC_SUBST(LIBGCRYPT_DIGESTS, $enabled_digests)
1083 # For printing the configuration we need a colon separated list of
1085 tmp=`echo "$enabled_ciphers" | tr ' ' : `
1086 AC_DEFINE_UNQUOTED(LIBGCRYPT_CIPHERS, "$tmp",
1087 [List of available cipher algorithms])
1088 tmp=`echo "$enabled_pubkey_ciphers" | tr ' ' : `
1089 AC_DEFINE_UNQUOTED(LIBGCRYPT_PUBKEY_CIPHERS, "$tmp",
1090 [List of available public key cipher algorithms])
1091 tmp=`echo "$enabled_digests" | tr ' ' : `
1092 AC_DEFINE_UNQUOTED(LIBGCRYPT_DIGESTS, "$tmp",
1093 [List of available digest algorithms])
1097 # Generate extended version information for W32.
1098 if test "$have_w32_system" = yes; then
1099 BUILD_TIMESTAMP=`date --iso-8601=minutes`
1101 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
1103 BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
1105 AC_SUBST(BUILD_REVISION)
1106 AC_SUBST(BUILD_TIMESTAMP)
1107 AC_SUBST(BUILD_FILEVERSION)
1108 AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
1109 [Subversion revision used to build this package])
1113 # And create the files.
1123 src/libgcrypt-config
1129 # Give some feedback
1131 Libgcrypt v${VERSION} has been configured as follows:
1133 Platform: $PRINTABLE_OS_NAME ($host)
1137 if test "$print_egd_notice" = "yes"; then
1140 The performance of the Unix random gatherer module (rndunix) is not
1141 very good and it does not keep the entropy pool over multiple
1142 invocations of Libgcrypt base applications. The suggested way to
1143 overcome this problem is to use the
1145 Entropy Gathering Daemon (EGD)
1147 which provides a entropy source for the whole system. It is written
1148 in Perl and available at the GnuPG FTP servers. To enable EGD you
1149 should rerun configure with the option "--enable-static-rnd=egd".
1150 For more information consult the GnuPG webpages:
1152 http://www.gnupg.org/download.html#egd
1157 if test -n "$gpl"; then
1158 echo "Please note that you are building a version of Libgcrypt with"
1160 echo "included. These parts are licensed under the GPL and thus the"
1161 echo "use of this library has to comply with the conditions of the GPL."