1 dnl -*- mode: shell-script; sh-indentation: 2; -*-
3 dnl Process this file with autoconf to produce a configure script.
5 AC_INIT([nettle], [3.2], [nettle-bugs@lists.lysator.liu.se])
7 AC_CONFIG_SRCDIR([arcfour.c])
8 # Needed to stop autoconf from looking for files in parent directories.
11 AC_CONFIG_HEADER([config.h])
19 dnl Note double square brackets, for extra m4 quoting.
20 MAJOR_VERSION=`echo $PACKAGE_VERSION | sed 's/^\([[^.]]*\)\..*/\1/'`
21 MINOR_VERSION=`echo $PACKAGE_VERSION | sed 's/^[[^.]]*\.\([[0-9]]*\).*/\1/'`
22 AC_SUBST([MAJOR_VERSION])
23 AC_SUBST([MINOR_VERSION])
27 # Command line options
28 AC_ARG_WITH(include-path,
29 AC_HELP_STRING([--with-include-path], [A colon-separated list of directories to search for include files]),,
30 [with_include_path=''])
32 if test x$with_include_path != x ; then
33 CPPFLAGS="$CPPFLAGS -I`echo $with_include_path | sed 's/:/ -I/g'`"
37 AC_HELP_STRING([--with-lib-path], [A colon-separated list of directories to search for libraries]),,
40 if test x$with_lib_path != x ; then
41 LDFLAGS="$LDFLAGS -L`echo $with_lib_path | sed 's/:/ -L/g'`"
44 AC_ARG_ENABLE(public-key,
45 AC_HELP_STRING([--disable-public-key], [Disable public key algorithms]),,
46 [enable_public_key=yes])
48 AC_ARG_ENABLE(assembler,
49 AC_HELP_STRING([--disable-assembler],[Disable assembler code]),,
50 [enable_assembler=yes])
53 AC_HELP_STRING([--disable-static], [Do not build any static library]),,
57 AC_HELP_STRING([--disable-shared], [Do not build any shared library]),,
61 AC_HELP_STRING([--disable-pic],
62 [Do not try to compile library files as position independent code]),,
65 AC_ARG_ENABLE(openssl,
66 AC_HELP_STRING([--disable-openssl], [Do not include openssl glue in the benchmark program]),,
70 AC_HELP_STRING([--enable-gcov], [Instrument for gcov (requires a modern gcc)]),,
73 AC_ARG_ENABLE(documentation,
74 AC_HELP_STRING([--disable-documentation], [Omit building and installing the documentation. (default=auto)]),,
75 [enable_documentation=auto])
77 AC_ARG_ENABLE(fat, AC_HELP_STRING([--enable-fat], [Enable fat library build (default=no)]),,
80 AC_ARG_ENABLE(arm-neon,
81 AC_HELP_STRING([--enable-arm-neon], [Enable ARM Neon assembly. (default=auto)]),,
82 [enable_arm_neon=auto])
84 AC_ARG_ENABLE(x86-aesni,
85 AC_HELP_STRING([--enable-x86-aesni], [Enable x86_64 aes instructions. (default=no)]),,
86 [enable_x86_aesni=no])
88 AC_ARG_ENABLE(mini-gmp,
89 AC_HELP_STRING([--enable-mini-gmp], [Enable mini-gmp, used instead of libgmp.]),,
92 if test "x$enable_mini_gmp" = xyes ; then
94 HOGWEED_EXTRA_SYMBOLS="mpz_*;gmp_*;mpn_*;"
97 HOGWEED_EXTRA_SYMBOLS=""
99 AC_SUBST([NETTLE_USE_MINI_GMP])
100 AC_SUBST([HOGWEED_EXTRA_SYMBOLS])
102 LSH_RPATH_INIT([`echo $with_lib_path | sed 's/:/ /g'` \
103 `echo $exec_prefix | sed "s@^NONE@$prefix/lib@g" | sed "s@^NONE@$ac_default_prefix/lib@g"` \
104 /usr/local/lib /sw/local/lib /sw/lib \
105 /usr/gnu/lib /opt/gnu/lib /sw/gnu/lib /usr/freeware/lib /usr/pkg/lib])
107 # Checks for programs.
112 # When $CC foo.c -o foo creates both foo and foo.exe, autoconf picks
113 # up the foo.exe and sets exeext to .exe. That is correct for cygwin,
114 # which has some kind of magic link from foo to foo.exe, but not for
115 # rntcl. A better check for the cygwin case would check if the
116 # contents of foo and foo.exe are equal; in the rntcl case, foo is a
117 # sh script, and foo.exe is a windows executable.
119 if test "x$CC" = xrntcl ; then
120 AC_MSG_NOTICE([Compiling with rntcl; clearing EXEEXT and disabling assembler])
127 # Used by the testsuite only
131 AC_TRY_COMPILE([],[return 0;],[IF_CXX=''], [IF_CXX='#'])
139 AC_CHECK_TOOL(NM, nm, strings)
140 # Used only for the GNU-stack configure test.
141 AC_CHECK_TOOL(OBJDUMP, objdump, false)
142 AC_CHECK_TOOL(AR, ar, false)
144 if test "x$ac_cv_prog_cc_stdc" = xno ; then
145 AC_ERROR([the C compiler doesn't handle ANSI-C]) #'
150 # According to the autoconf manual, needs install-sh from
151 # autoconf-2.60 or automake-1.10 to avoid races.
156 # Compiler tests for the build system
157 GMP_PROG_CC_FOR_BUILD
158 GMP_PROG_EXEEXT_FOR_BUILD
160 LSH_DEPENDENCY_TRACKING
162 if test x$enable_dependency_tracking = xyes ; then
163 # Since the makefiles use include to get the dependency files, we must
164 # make sure that the files exist. We generate some more files than are
167 AC_CONFIG_COMMANDS([dummy-dep-files],
168 [(cd "$srcdir" && find . '(' -name '*.c' -o -name '*.cxx' ')' -print) \
169 | sed 's/\.cx*$//' | (while read f; do \
170 test -f "$f.o.d" || echo > "$f.o.d"; \
175 if test "x$enable_gcov" = "xyes"; then
176 CFLAGS="$CFLAGS -ftest-coverage -fprofile-arcs"
179 # Checks for typedefs, structures, and compiler characteristics.
185 AC_CHECK_SIZEOF(long)
186 AC_CHECK_SIZEOF(size_t)
188 AC_CHECK_HEADERS([openssl/blowfish.h openssl/des.h openssl/cast.h openssl/aes.h openssl/ecdsa.h],,
192 # For use by the testsuite
193 AC_CHECK_HEADERS([valgrind/memcheck.h])
194 AC_CHECK_HEADERS([dlfcn.h])
195 AC_CHECK_LIB([dl], [dlopen],
196 [AC_DEFINE([HAVE_LIBDL], 1,
197 [Define to 1 if you have dlopen (with -ldl).])])
201 # getenv_secure is used for fat overrides,
202 # getline is used in the testsuite
203 AC_CHECK_FUNCS(secure_getenv getline)
208 # According to Simon Josefsson, looking for uint32_t and friends in
209 # sys/types.h is needed on some systems, in particular cygwin.
210 AX_CREATE_STDINT_H([nettle-stdint.h], [sys/types.h])
212 # Check for file locking. We (AC_PROG_CC?) have already checked for
213 # sys/types.h and unistd.h.
214 AC_CACHE_CHECK([for fcntl file locking],
215 nettle_cv_fcntl_locking,
218 # include <sys/types.h>
228 nettle_cv_fcntl_locking=yes,
229 nettle_cv_fcntl_locking=no)])
231 AH_TEMPLATE([HAVE_FCNTL_LOCKING], [Define if fcntl file locking is available])
232 if test "x$nettle_cv_fcntl_locking" = "xyes" ; then
233 AC_DEFINE(HAVE_FCNTL_LOCKING)
236 # Checks for libraries
237 if test "x$enable_public_key" = "xyes" ; then
238 if test "x$enable_mini_gmp" = "xno" ; then
239 AC_CHECK_LIB(gmp, __gmpz_getlimbn,,
241 [GNU MP not found, or not 3.1 or up, see http://gmplib.org/.
242 Support for public key algorithms will be unavailable.])]
243 enable_public_key=no)
245 # Add -R flags needed to run programs linked with gmp
250 nettle_cv_gmp_numb_bits=0
251 if test "x$enable_public_key" = "xyes" ; then
252 # Check for gmp limb size
253 if test "x$enable_mini_gmp" = "xyes" ; then
254 AC_MSG_CHECKING([for mini-gmp limb size])
255 # With mini-gmp, mp_limb_t is always unsigned long.
256 AC_COMPUTE_INT(nettle_cv_gmp_numb_bits, [(sizeof(unsigned long) * CHAR_BIT)],
257 [#include <limits.h>],
258 [AC_MSG_FAILURE([cannot find value of GMP_NUMB_BITS])])
260 AC_MSG_RESULT([$nettle_cv_gmp_numb_bits bits])
262 AC_MSG_CHECKING([for GMP limb size])
263 AC_COMPUTE_INT(nettle_cv_gmp_numb_bits, [GMP_NUMB_BITS],
265 [AC_MSG_FAILURE([cannot find value of GMP_NUMB_BITS])])
267 AC_MSG_RESULT([$nettle_cv_gmp_numb_bits bits])
271 GMP_NUMB_BITS="$nettle_cv_gmp_numb_bits"
272 AC_SUBST([GMP_NUMB_BITS])
274 # Figure out ABI. Currently, configurable only by setting CFLAGS.
280 #if defined(__x86_64__) || defined(__arch64__)
291 #if defined(__sparcv9) || defined(__arch64__)
302 #if defined(__sgi) && defined(__LP64__)
313 if test "x$ABI" != xstandard ; then
314 AC_MSG_NOTICE([Compiler uses $ABI-bit ABI. To change, set CC.])
315 if test "$libdir" = '${exec_prefix}/lib' ; then
316 # Try setting a better default
317 case "$host_cpu:$host_os:$ABI" in
318 *:solaris*:32|*:sunos*:32)
319 libdir='${exec_prefix}/lib'
321 *:solaris*:64|*:sunos*:64)
322 libdir='${exec_prefix}/lib/64'
324 # Linux conventions are a mess... According to the Linux File
325 # Hierarchy Standard, all architectures except IA64 puts 32-bit
326 # libraries in lib, and 64-bit in lib64. Some distributions,
327 # e.g., Fedora and Gentoo, adhere to this standard, while at
328 # least Debian has decided to put 64-bit libraries in lib and
329 # 32-bit libraries in lib32.
331 # We try to figure out the convention, except if we're cross
332 # compiling. We use lib${ABI} if /usr/lib${ABI} exists and
333 # appears to not be a symlink to a different name.
334 *:linux*:32|*:linux*:64)
335 if test "$cross_compiling" = yes ; then
336 AC_MSG_WARN([Cross compiling for linux. Can't guess if libraries go in lib${ABI} or lib.]); dnl '
338 # The dash builtin pwd tries to be "helpful" and remember
339 # symlink names. Use -P option, and hope it's portable enough.
340 test -d /usr/lib${ABI} \
341 && (cd /usr/lib${ABI} && pwd -P | grep >/dev/null "/lib${ABI}"'$') \
342 && libdir='${exec_prefix}/'"lib${ABI}"
345 # On freebsd, it seems 32-bit libraries are in lib32,
346 # and 64-bit in lib. Don't know about "kfreebsd", does
347 # it follow the Linux fhs conventions?
349 libdir='${exec_prefix}/lib32'
352 libdir='${exec_prefix}/lib'
355 libdir='${exec_prefix}/lib32'
358 libdir='${exec_prefix}/lib64'
361 AC_MSG_WARN([Don't know where to install $ABI-bit libraries on this system.]); dnl '
364 AC_MSG_NOTICE([Libraries to be installed in $libdir.])
368 OPT_NETTLE_SOURCES=""
370 # Select assembler code
372 if test "x$enable_assembler" = xyes ; then
374 [i?86* | k[5-8]* | pentium* | athlon])
378 if test "$ABI" = 64 ; then
380 if test "x$enable_fat" = xyes ; then
381 asm_path="x86_64/fat $asm_path"
382 OPT_NETTLE_SOURCES="fat-x86_64.c $OPT_NETTLE_SOURCES"
383 elif test "x$enable_x86_aesni" = xyes ; then
384 asm_path="x86_64/aesni $asm_path"
391 if test "$ABI" = 64 ; then
399 if test "x$enable_fat" = xyes ; then
400 asm_path="arm/fat $asm_path"
401 OPT_NETTLE_SOURCES="fat-arm.c $OPT_NETTLE_SOURCES"
405 NETTLE_CHECK_ARM_NEON
407 asm_path="arm/v6 arm"
409 if test "x$enable_arm_neon" = xyes ; then
410 asm_path="arm/neon $asm_path"
422 # Files which replace a C source file (or otherwise don't correspond
423 # to a new object file).
424 asm_replace_list="aes-encrypt-internal.asm aes-decrypt-internal.asm \
425 arcfour-crypt.asm camellia-crypt-internal.asm \
426 md5-compress.asm memxor.asm memxor3.asm \
427 poly1305-internal.asm \
428 chacha-core-internal.asm \
429 salsa20-crypt.asm salsa20-core-internal.asm \
430 serpent-encrypt.asm serpent-decrypt.asm \
431 sha1-compress.asm sha256-compress.asm sha512-compress.asm \
432 sha3-permute.asm umac-nh.asm umac-nh-n.asm machine.m4"
434 # Assembler files which generate additional object files if they are used.
435 asm_nettle_optional_list="gcm-hash8.asm cpuid.asm \
436 aes-encrypt-internal-2.asm aes-decrypt-internal-2.asm memxor-2.asm \
437 salsa20-core-internal-2.asm sha1-compress-2.asm sha256-compress-2.asm \
438 sha3-permute-2.asm sha512-compress-2.asm \
439 umac-nh-n-2.asm umac-nh-2.asm"
441 asm_hogweed_optional_list=""
442 if test "x$enable_public_key" = "xyes" ; then
443 asm_hogweed_optional_list="ecc-192-modp.asm ecc-224-modp.asm \
444 ecc-25519-modp.asm ecc-256-redc.asm ecc-384-modp.asm ecc-521-modp.asm"
452 if test "x$enable_assembler" = xyes ; then
453 if test -n "$asm_path"; then
454 AC_MSG_NOTICE([Looking for assembler files in $asm_path.])
455 for tmp_f in $asm_replace_list ; do
456 for asm_dir in $asm_path ; do
457 if test -f "$srcdir/$asm_dir/$tmp_f"; then
458 asm_file_list="$asm_file_list $tmp_f"
459 AC_CONFIG_LINKS($tmp_f:$asm_dir/$tmp_f)
464 dnl Workaround for AC_CONFIG_LINKS, which complains if we use the
465 dnl same destination argument $tmp_f multiple times.
466 for tmp_n in $asm_nettle_optional_list ; do
467 dnl Note extra pair of [] in sed expression
468 tmp_b=`echo "$tmp_n" | sed 's/\.[[^.]]*$//'`
469 for asm_dir in $asm_path ; do
470 if test -f "$srcdir/$asm_dir/$tmp_n"; then
471 asm_file_list="$asm_file_list $tmp_n"
472 AC_CONFIG_LINKS($tmp_n:$asm_dir/$tmp_n)
473 while read tmp_func ; do
474 AC_DEFINE_UNQUOTED(HAVE_NATIVE_$tmp_func)
475 eval HAVE_NATIVE_$tmp_func=yes
477 [`sed -n 's/^.*[^ ]*PROLOGUE(_*\(nettle_\)*\([^)]*\)).*$/\2/p' < "$srcdir/$asm_dir/$tmp_n"`]
479 OPT_NETTLE_OBJS="$OPT_NETTLE_OBJS $tmp_b"'.$(OBJEXT)'
484 for tmp_h in $asm_hogweed_optional_list ; do
485 dnl Note extra pair of [] in sed expression
486 tmp_b=`echo "$tmp_h" | sed 's/\.[[^.]]*$//'`
487 for asm_dir in $asm_path ; do
488 if test -f "$srcdir/$asm_dir/$tmp_h"; then
489 dnl Note double square brackets, for extra m4 quoting.
490 tmp_bits=`grep GMP_NUMB_BITS "$srcdir/$asm_dir/$tmp_h" \
491 | sed 's/^.*GMP_NUMB_BITS(\([[0-9]]*\)).*$/\1/'`
492 if test "$tmp_bits" && test "$tmp_bits" != "${GMP_NUMB_BITS}" ; then
493 AC_MSG_WARN([skipping $tmp_h, because GMP_NUMB_BITS != $tmp_bits])
496 asm_file_list="$asm_file_list $tmp_h"
497 AC_CONFIG_LINKS($tmp_h:$asm_dir/$tmp_h)
498 while read tmp_func ; do
499 AC_DEFINE_UNQUOTED(HAVE_NATIVE_$tmp_func)
500 eval HAVE_NATIVE_$tmp_func=yes
502 [`sed -n 's/[^ ]*PROLOGUE(_*\(nettle_\)*\([^)]*\)).*$/\2/p' < "$srcdir/$asm_dir/$tmp_h"`]
504 OPT_HOGWEED_OBJS="$OPT_HOGWEED_OBJS $tmp_b"'.$(OBJEXT)'
509 if test -z "$asm_file_list"; then
511 AC_MSG_WARN([No assembler files found.])
516 ASM_RODATA='.section __TEXT,__const'
519 ASM_RODATA='.section .rodata'
524 AC_SUBST([OPT_NETTLE_OBJS])
525 AC_SUBST([OPT_HOGWEED_OBJS])
526 AC_SUBST([OPT_NETTLE_SOURCES])
527 AC_SUBST([ASM_RODATA])
528 if test "x$enable_assembler" = xyes ; then
535 AH_VERBATIM([HAVE_NATIVE],
536 [/* Define to 1 each of the following for which a native (ie. CPU specific)
537 implementation of the corresponding routine exists. */
538 #undef HAVE_NATIVE_ecc_192_modp
539 #undef HAVE_NATIVE_ecc_192_redc
540 #undef HAVE_NATIVE_ecc_224_modp
541 #undef HAVE_NATIVE_ecc_224_redc
542 #undef HAVE_NATIVE_ecc_25519_modp
543 #undef HAVE_NATIVE_ecc_256_modp
544 #undef HAVE_NATIVE_ecc_256_redc
545 #undef HAVE_NATIVE_ecc_384_modp
546 #undef HAVE_NATIVE_ecc_384_redc
547 #undef HAVE_NATIVE_ecc_521_modp
548 #undef HAVE_NATIVE_ecc_521_redc
549 #undef HAVE_NATIVE_gcm_hash8
550 #undef HAVE_NATIVE_salsa20_core
551 #undef HAVE_NATIVE_sha1_compress
552 #undef HAVE_NATIVE_sha256_compress
553 #undef HAVE_NATIVE_sha512_compress
554 #undef HAVE_NATIVE_sha3_permute
555 #undef HAVE_NATIVE_umac_nh
556 #undef HAVE_NATIVE_umac_nh_n])
558 if test "x$enable_pic" = xyes; then
566 LIBNETTLE_FILE_SRC='$(LIBNETTLE_FORLINK)'
567 LIBHOGWEED_FILE_SRC='$(LIBHOGWEED_FORLINK)'
573 # The actual DLLs, e.g. libnettle-$major-$minor.dll, are normally
574 # installed into the bin dir (or more exactly $libdir/../bin, for
575 # automake), while libnettle.dll.a, which is a stub file for
576 # linking to the DLL, is installed into the lib dir.
579 LIBNETTLE_FORLINK='libnettle-$(LIBNETTLE_MAJOR)-$(LIBNETTLE_MINOR).dll'
580 LIBHOGWEED_FORLINK='libhogweed-$(LIBHOGWEED_MAJOR)-$(LIBHOGWEED_MINOR).dll'
583 LIBNETTLE_FORLINK='cygnettle-$(LIBNETTLE_MAJOR)-$(LIBNETTLE_MINOR).dll'
584 LIBHOGWEED_FORLINK='cyghogweed-$(LIBHOGWEED_MAJOR)-$(LIBHOGWEED_MINOR).dll'
587 if test "x$cross_compiling" = xyes ; then
597 if test "x$ABI" = x64 ; then
601 LIBNETTLE_FILE='libnettle.dll.a'
602 LIBNETTLE_FILE_SRC='$(LIBNETTLE_FILE)'
603 LIBNETTLE_LINK='$(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,--out-implib=$(LIBNETTLE_FILE) -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive'
604 LIBNETTLE_LIBS='-Wl,--no-whole-archive $(LIBS)'
607 LIBHOGWEED_FILE='libhogweed.dll.a'
608 LIBHOGWEED_FILE_SRC='$(LIBHOGWEED_FILE)'
609 LIBHOGWEED_LINK='$(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,--out-implib=$(LIBHOGWEED_FILE) -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive'
610 LIBHOGWEED_LIBS='-Wl,--no-whole-archive $(LIBS) libnettle.dll.a'
614 LIBNETTLE_FORLINK=libnettle.dylib
615 LIBNETTLE_SONAME='libnettle.$(LIBNETTLE_MAJOR).dylib'
616 LIBNETTLE_FILE='libnettle.$(LIBNETTLE_MAJOR).$(LIBNETTLE_MINOR).dylib'
617 LIBNETTLE_LINK='$(CC) $(CFLAGS) -dynamiclib $(LDFLAGS) -install_name ${libdir}/$(LIBNETTLE_SONAME) -compatibility_version $(LIBNETTLE_MAJOR) -current_version $(LIBNETTLE_MAJOR).$(LIBNETTLE_MINOR)'
620 LIBHOGWEED_FORLINK=libhogweed.dylib
621 LIBHOGWEED_SONAME='libhogweed.$(LIBHOGWEED_MAJOR).dylib'
622 LIBHOGWEED_FILE='libhogweed.$(LIBHOGWEED_MAJOR).$(LIBHOGWEED_MINOR).dylib'
623 LIBHOGWEED_LINK='$(CC) $(CFLAGS) -dynamiclib -L. $(LDFLAGS) -install_name ${libdir}/$(LIBHOGWEED_SONAME) -compatibility_version $(LIBHOGWEED_MAJOR) -current_version $(LIBHOGWEED_MAJOR).$(LIBHOGWEED_MINOR)'
624 LIBHOGWEED_LIBS='-lnettle $(LIBS)'
627 # Sun's ld uses -h to set the soname, and this option is passed
628 # through by both Sun's compiler and gcc. Might not work with GNU
629 # ld, but it's unusual to use GNU ld on Solaris.
630 LIBNETTLE_FORLINK=libnettle.so
631 LIBNETTLE_SONAME='$(LIBNETTLE_FORLINK).$(LIBNETTLE_MAJOR)'
632 LIBNETTLE_FILE='$(LIBNETTLE_SONAME).$(LIBNETTLE_MINOR)'
633 LIBNETTLE_LINK='$(CC) $(CFLAGS) $(LDFLAGS) -G -h $(LIBNETTLE_SONAME)'
636 LIBHOGWEED_FORLINK=libhogweed.so
637 LIBHOGWEED_SONAME='$(LIBHOGWEED_FORLINK).$(LIBHOGWEED_MAJOR)'
638 LIBHOGWEED_FILE='$(LIBHOGWEED_SONAME).$(LIBHOGWEED_MINOR)'
639 LIBHOGWEED_LINK='$(CC) $(CFLAGS) $(LDFLAGS) -G -h $(LIBHOGWEED_SONAME)'
640 LIBHOGWEED_LIBS='libnettle.so $(LIBS)'
643 LIBNETTLE_FORLINK=libnettle.so
644 LIBNETTLE_SONAME='$(LIBNETTLE_FORLINK).$(LIBNETTLE_MAJOR)'
645 LIBNETTLE_FILE='$(LIBNETTLE_SONAME).$(LIBNETTLE_MINOR)'
646 LIBNETTLE_LINK='$(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname=$(LIBNETTLE_SONAME)'
649 LIBHOGWEED_FORLINK=libhogweed.so
650 LIBHOGWEED_SONAME='$(LIBHOGWEED_FORLINK).$(LIBHOGWEED_MAJOR)'
651 LIBHOGWEED_FILE='$(LIBHOGWEED_SONAME).$(LIBHOGWEED_MINOR)'
652 LIBHOGWEED_LINK='$(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname=$(LIBHOGWEED_SONAME)'
653 # Requested by debian, to make linking with only -lhogweed work
654 # (does not work in general, e.g., with static linking all of
655 # -lhogweed -lgmp -lnettle are still required). Also makes dlopen
656 # of libhogweed.so work, without having to use RTLD_GLOBAL.
657 LIBHOGWEED_LIBS='libnettle.so $(LIBS)'
664 # GNU as default is to use @
665 ASM_TYPE_FUNCTION='@function'
666 ASM_TYPE_PROGBITS='@progbits'
667 ASM_MARK_NOEXEC_STACK=''
670 if test x$enable_assembler = xyes ; then
671 AC_CACHE_CHECK([if globals are prefixed by underscore],
672 nettle_cv_asm_underscore,
673 [ # Default is no underscore
674 nettle_cv_asm_underscore=no
676 [AC_LANG_SOURCE([int a_global_symbol;])],
677 [ $NM conftest.$OBJEXT >conftest.out
678 if grep _a_global_symbol conftest.out >/dev/null ; then
679 nettle_cv_asm_underscore=yes
680 elif grep a_global_symbol conftest.out >/dev/null ; then
681 nettle_cv_asm_underscore=no
683 AC_MSG_WARN([nm does not list a_global_symbol at all])
685 [AC_MSG_WARN([test program with a single global could not be compiled!?])])])
686 if test x$nettle_cv_asm_underscore = xyes ; then
687 ASM_SYMBOL_PREFIX='_'
690 AC_CACHE_CHECK([for ELF-style .type,%function pseudo-ops],
691 [nettle_cv_asm_type_percent_function],
699 .size foo, .Lend - foo
701 [nettle_cv_asm_type_percent_function=yes],
702 [nettle_cv_asm_type_percent_function=no])])
704 dnl Needs double quote for the # character
705 AC_CACHE_CHECK([[for ELF-style .type,#function pseudo-ops]],
706 [nettle_cv_asm_type_hash_function],
714 .size foo, .Lend - foo
716 [nettle_cv_asm_type_hash_function=yes],
717 [nettle_cv_asm_type_hash_function=no])])
719 if test x$nettle_cv_asm_type_percent_function = xyes ; then
721 ASM_TYPE_FUNCTION='%function'
722 ASM_TYPE_PROGBITS='%progbits'
724 if test x$nettle_cv_asm_type_hash_function = xyes ; then
726 ASM_TYPE_FUNCTION='#function'
727 ASM_TYPE_PROGBITS='#progbits'
731 AC_CACHE_CHECK([for COFF-style .type directive],
732 [nettle_cv_asm_coff_type],
742 [nettle_cv_asm_coff_type=yes],
743 [nettle_cv_asm_coff_type=no])])
744 if test "x$nettle_cv_asm_coff_type" = "xyes" ; then
748 AC_CACHE_CHECK([if we should use a .note.GNU-stack section],
749 nettle_cv_asm_gnu_stack,
751 nettle_cv_asm_gnu_stack=no
753 cat >conftest.c <<EOF
754 int foo() { return 0; }
756 nettle_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >conftest.out 2>&1"
757 if AC_TRY_EVAL(nettle_compile); then
758 cat conftest.out >&AC_FD_CC
759 $OBJDUMP -x conftest.o | grep '\.note\.GNU-stack' > /dev/null \
760 && nettle_cv_asm_gnu_stack=yes
762 cat conftest.out >&AC_FD_CC
763 echo "configure: failed program was:" >&AC_FD_CC
764 cat conftest.s >&AC_FD_CC
767 if test x$nettle_cv_asm_gnu_stack = xyes ; then
768 ASM_MARK_NOEXEC_STACK='.section .note.GNU-stack,"",TYPE_PROGBITS'
771 AC_CACHE_CHECK([if .align assembly directive is logarithmic],
772 [nettle_cv_asm_align_log],
776 [nettle_cv_asm_align_log=yes],
777 [nettle_cv_asm_align_log=no])])
778 ASM_ALIGN_LOG="$nettle_cv_asm_align_log"
781 AC_SUBST(ASM_SYMBOL_PREFIX)
782 AC_SUBST(ASM_ELF_STYLE)
783 AC_SUBST(ASM_COFF_STYLE)
784 AC_SUBST(ASM_TYPE_FUNCTION)
785 AC_SUBST(ASM_TYPE_PROGBITS)
786 AC_SUBST(ASM_MARK_NOEXEC_STACK)
787 AC_SUBST(ASM_ALIGN_LOG)
791 AC_SUBST(LIBNETTLE_MAJOR)
792 AC_SUBST(LIBNETTLE_MINOR)
793 AC_SUBST(LIBNETTLE_FORLINK)
794 AC_SUBST(LIBNETTLE_SONAME)
795 AC_SUBST(LIBNETTLE_FILE)
796 AC_SUBST(LIBNETTLE_FILE_SRC)
797 AC_SUBST(LIBNETTLE_LINK)
798 AC_SUBST(LIBNETTLE_LIBS)
800 AC_SUBST(LIBHOGWEED_MAJOR)
801 AC_SUBST(LIBHOGWEED_MINOR)
802 AC_SUBST(LIBHOGWEED_FORLINK)
803 AC_SUBST(LIBHOGWEED_SONAME)
804 AC_SUBST(LIBHOGWEED_FILE)
805 AC_SUBST(LIBHOGWEED_FILE_SRC)
806 AC_SUBST(LIBHOGWEED_LINK)
807 AC_SUBST(LIBHOGWEED_LIBS)
809 AC_PATH_PROG(M4, m4, m4)
811 AH_TEMPLATE([WITH_HOGWEED], [Defined if public key features are enabled])
813 if test "x$enable_public_key" = xyes ; then
814 AC_DEFINE(WITH_HOGWEED)
820 if test "x$enable_static" = xyes ; then
827 if test "x$enable_shared" = xyes ; then
830 if test "x$ac_cv_lib_dl_dlopen" = xyes ; then
838 # Documentation tools
839 if test "x$enable_documentation" != "xno"; then
840 AC_PATH_PROG(MAKEINFO, makeinfo, not-found)
842 if test "x$MAKEINFO" != "xnot-found"; then
843 enable_documentation=yes
846 if test "x$enable_documentation" == "xauto" ; then
847 enable_documentation=no
849 AC_MSG_ERROR([Cannot find 'makeinfo', required for documentation.])
854 if test "x$enable_documentation" = "xyes" ; then
860 if test "x$enable_mini_gmp" = "xyes" ; then
869 AC_SUBST(IF_NOT_SHARED)
870 AC_SUBST(IF_DLOPEN_TEST)
871 AC_SUBST(IF_DOCUMENTATION)
873 AC_SUBST(IF_MINI_GMP)
877 # Check for openssl's libcrypto (used only for benchmarking)
878 if test x$enable_openssl = xyes ; then
879 AC_CHECK_LIB(crypto, BF_ecb_encrypt,
880 [OPENSSL_LIBFLAGS='-lcrypto'],
884 AH_TEMPLATE([WITH_OPENSSL],
885 [Define if you have openssl's libcrypto (used for benchmarking)]) dnl'
887 if test x$enable_openssl = xyes ; then
888 AC_DEFINE(WITH_OPENSSL)
891 AC_SUBST(OPENSSL_LIBFLAGS)
894 [#if defined(__x86_64__) || defined(__arch64__)
895 # define HAVE_NATIVE_64_BIT 1
897 /* Needs include of <limits.h> before use. */
898 # define HAVE_NATIVE_64_BIT (SIZEOF_LONG * CHAR_BIT >= 64)
902 # clock_gettime is in librt on *-*-osf5.1 and on glibc, so add -lrt to
903 # BENCH_LIBS if needed. On linux (tested on x86_32, 2.6.26),
904 # clock_getres reports ns accuracy, while in a quick test on osf
905 # clock_getres said only 1 millisecond.
908 AC_SEARCH_LIBS(clock_gettime, rt, [
909 AC_DEFINE([HAVE_CLOCK_GETTIME],1,[Define if clock_gettime is available])])
915 # Set these flags *last*, or else the test programs won't compile
916 if test x$GCC = xyes ; then
917 # Using -ggdb3 makes (some versions of) Redhat's gcc-2.96 dump core
918 if $CC --version | grep '^2\.96$' 1>/dev/null 2>&1; then
921 CFLAGS="$CFLAGS -ggdb3"
923 # FIXME: It would be better to actually test if this option works and/or is needed.
924 # Or perhaps use -funsigned-char.
925 if $CC --version | grep 'gcc.* 4\.' 1>/dev/null 2>&1; then
926 CFLAGS="$CFLAGS -Wno-pointer-sign"
928 CFLAGS="$CFLAGS -Wall -W \
929 -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes \
930 -Wpointer-arith -Wbad-function-cast -Wnested-externs"
932 # Don't enable -Wcast-align as it results in tons of warnings in the
933 # DES code. And when using stdio.
934 # Don't enable -Waggregate-return, as that causes warnings for glibc
938 AC_CONFIG_FILES([config.make config.m4 Makefile version.h])
939 AC_CONFIG_FILES([tools/Makefile testsuite/Makefile examples/Makefile])
940 AC_CONFIG_FILES([nettle.pc hogweed.pc libnettle.map libhogweed.map])
944 AC_MSG_NOTICE([summary of build options:
946 Version: ${PACKAGE_STRING}
949 Assembly files: ${asm_path:-none}
950 Install prefix: ${prefix}
951 Library directory: ${libdir}
953 Static libraries: ${enable_static}
954 Shared libraries: ${enable_shared}
955 Public key crypto: ${enable_public_key}
956 Using mini-gmp: ${enable_mini_gmp}
957 Documentation: ${enable_documentation}