1 dnl -*- mode: shell-script; sh-indentation: 2; -*-
3 dnl Process this file with autoconf to produce a configure script.
5 AC_INIT([nettle], [2.1], [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])
21 # Command line options
22 AC_ARG_WITH(include-path,
23 AC_HELP_STRING([--with-include-path], [A colon-separated list of directories to search for include files]),,
24 [with_include_path=''])
26 if test x$with_include_path != x ; then
27 CPPFLAGS="$CPPFLAGS -I`echo $with_include_path | sed 's/:/ -I/g'`"
31 AC_HELP_STRING([--with-lib-path], [A colon-separated list of directories to search for libraries]),,
34 if test x$with_lib_path != x ; then
35 LDFLAGS="$LDFLAGS -L`echo $with_lib_path | sed 's/:/ -L/g'`"
38 AC_ARG_ENABLE(public-key,
39 AC_HELP_STRING([--disable-public-key], [Disable public key algorithms]),,
40 [enable_public_key=yes])
42 AC_ARG_ENABLE(assembler,
43 AC_HELP_STRING([--disable-assembler],[Disable assembler code]),,
44 [enable_assembler=yes])
47 AC_HELP_STRING([--enable-shared], [Build a shared library]),,
51 AC_HELP_STRING([--disable-pic],
52 [Do not try to compile library files as position independent code]),,
55 AC_ARG_ENABLE(openssl,
56 AC_HELP_STRING([--disable-openssl], [Do not include openssl glue in the benchmark program]),,
59 LSH_RPATH_INIT([`echo $with_lib_path | sed 's/:/ /g'` \
60 `echo $exec_prefix | sed "s@^NONE@$prefix/lib@g" | sed "s@^NONE@$ac_default_prefix/lib@g"` \
61 /usr/local/lib /sw/local/lib /sw/lib \
62 /usr/gnu/lib /opt/gnu/lib /sw/gnu/lib /usr/freeware/lib /usr/pkg/lib])
64 # Checks for programs.
67 # When $CC foo.c -o foo creates both foo and foo.exe, autoconf picks
68 # up the foo.exe and sets exeext to .exe. That is correct for cygwin,
69 # which has some kind of magic link from foo to foo.exe, but not for
70 # rntcl. A better check for the cygwin case would check if the
71 # contents of foo and foo.exe are equal; in the rntcl case, foo is a
72 # sh script, and foo.exe is a windows executable.
74 if test "x$CC" = xrntcl ; then
75 AC_MSG_NOTICE([Compiling with rntcl; clearing EXEEXT and disabling assembler])
82 # Used by the testsuite only
86 AC_TRY_COMPILE([],[return 0;],[CXX_TESTS='cxx-test$(EXEEXT)'], [CXX_TESTS=''])
92 AC_CHECK_TOOL(NM, nm, strings)
93 # Used only for the GNU-stack configure test.
94 AC_CHECK_TOOL(OBJDUMP, objdump, false)
96 if test "x$ac_cv_prog_cc_stdc" = xno ; then
97 AC_ERROR([the C compiler doesn't handle ANSI-C]) #'
102 # According to the autoconf manual, needs install-sh from
103 # autoconf-2.60 or automake-1.10 to avoid races.
106 LSH_DEPENDENCY_TRACKING
108 if test x$enable_dependency_tracking = xyes ; then
109 # Since the makefiles use include to get the dependency files, we must
110 # make sure that the files exist. We generate some more files than are
113 AC_CONFIG_COMMANDS([dummy-dep-files],
114 [(cd "$srcdir" && find . -name '*.c' -print) \
115 | sed 's/\.c$//' | (while read f; do echo > "$f.o.d"; echo > "$f.po.d"; done)
119 # Figure out ABI. Currently, configurable only be setting CFLAGS.
125 #if defined(__x86_64__) || defined(__arch64__)
136 #if defined(__sparcv9) || defined(__arch64__)
147 if test "x$ABI" != xstandard ; then
148 AC_MSG_NOTICE([Compiler uses $ABI-bit ABI. To change, set CC.])
149 if test "$libdir" = '${exec_prefix}/lib' ; then
150 # Try setting a better default
151 case "$host_cpu:$host_os:$ABI" in
152 *:solaris*:32|*:sunos*:32)
153 libdir='${exec_prefix}/lib'
155 *:solaris*:64|*:sunos*:64)
156 libdir='${exec_prefix}/lib/64'
158 # According to the fhs, all architectures except IA64
159 # puts 32-bit libraries in lib, and 64-bit in lib64.
161 libdir='${exec_prefix}/lib'
164 libdir='${exec_prefix}/lib64'
166 # On freebsd, it seems 32-bit libraries are in lib32,
167 # and 64-bit in lib. Don't know about "kfreebsd", does
168 # it follow the Linux fhs conventions?
170 libdir='${exec_prefix}/lib32'
173 libdir='${exec_prefix}/lib'
176 AC_MSG_WARN([Don't know where to install $ABI-bit libraries on this system.]); #'
179 AC_MSG_NOTICE([Libraries to be installed in $libdir.])
183 # Select assembler code
186 [i?86* | k[5-8]* | pentium* | athlon])
190 if test "$ABI" = 64 ; then
197 if test "$ABI" = 64 ; then
208 # echo "enable_assembler: $enable_assembler, asm_path: $asm_path"
210 if test "x$enable_assembler" = xyes ; then
211 if test -n "$asm_path"; then
212 AC_MSG_NOTICE([Looking for assembler files in $asm_path/.])
214 for tmp_f in aes-encrypt-internal.asm aes-decrypt-internal.asm \
215 arcfour-crypt.asm camellia-crypt-internal.asm \
216 md5-compress.asm sha1-compress.asm machine.m4; do
217 # echo "Looking for $srcdir/$asm_path/$tmp_f"
218 if test -f "$srcdir/$asm_path/$tmp_f"; then
221 AC_CONFIG_LINKS($tmp_f:$asm_path/$tmp_f)
224 if test "$found" = no; then
226 AC_MSG_WARN([No assembler files found.])
237 LIBNETTLE_FORLINK='cygnettle-$(LIBNETTLE_MAJOR)-$(LIBNETTLE_MINOR).dll'
239 LIBNETTLE_FILE='libnettle.dll.a'
240 LIBNETTLE_LINK='$(CC) $(LDFLAGS) -shared -Wl,--out-implib=$(LIBNETTLE_LIBFILE) -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive'
241 LIBNETTLE_LIBS='-Wl,--no-whole-archive $(LIBS)'
243 LIBHOGWEED_FORLINK='cyghogweed-$(LIBHOGWEED_MAJOR)-$(LIBHOGWEED_MINOR).dll'
245 LIBHOGWEED_FILE='libhogweed.dll.a'
246 LIBHOGWEED_LINK='$(CC) $(LDFLAGS) -shared -Wl,--out-implib=$(LIBHOGWEED_LIBFILE) -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive'
247 LIBHOGWEED_LIBS='-Wl,--no-whole-archive $(LIBS)'
250 LIBNETTLE_FORLINK=libnettle.dylib
251 LIBNETTLE_SONAME='$(LIBNETTLE_FORLINK).$(LIBNETTLE_MAJOR)'
252 LIBNETTLE_FILE='$(LIBNETTLE_SONAME).$(LIBNETTLE_MINOR)'
253 LIBNETTLE_LINK='$(CC) -dynamiclib $(LDFLAGS)'
256 LIBHOGWEED_FORLINK=libhogweed.dylib
257 LIBHOGWEED_SONAME='$(LIBHOGWEED_FORLINK).$(LIBHOGWEED_MAJOR)'
258 LIBHOGWEED_FILE='$(LIBHOGWEED_SONAME).$(LIBHOGWEED_MINOR)'
259 LIBHOGWEED_LINK='$(CC) -dynamiclib $(LDFLAGS)'
263 LIBNETTLE_FORLINK=libnettle.so
264 LIBNETTLE_SONAME='$(LIBNETTLE_FORLINK).$(LIBNETTLE_MAJOR)'
265 LIBNETTLE_FILE='$(LIBNETTLE_SONAME).$(LIBNETTLE_MINOR)'
266 LIBNETTLE_LINK='$(CC) $(LDFLAGS) -shared -Wl,-soname=$(LIBNETTLE_SONAME)'
269 LIBHOGWEED_FORLINK=libhogweed.so
270 LIBHOGWEED_SONAME='$(LIBHOGWEED_FORLINK).$(LIBHOGWEED_MAJOR)'
271 LIBHOGWEED_FILE='$(LIBHOGWEED_SONAME).$(LIBHOGWEED_MINOR)'
272 LIBHOGWEED_LINK='$(CC) $(LDFLAGS) -L. -shared -Wl,-soname=$(LIBHOGWEED_SONAME)'
273 # Requested by debian, to make linking with only -lhogweed work
274 # (does not work in general, e.g., with static linking all of
275 # -lhogweed -lgmp -lnettle are still required). Also makes dlopen
276 # of libhogweed.so work, without having to use RTLD_GLOBAL.
277 # Depends on -L. above, to locate nettle.so.
278 LIBHOGWEED_LIBS='-lnettle -lgmp'
282 if test "x$enable_pic" = xyes; then
287 AC_SUBST([CCPIC_MAYBE])
292 ASM_MARK_NOEXEC_STACK=''
295 if test x$enable_assembler = xyes ; then
296 AC_CACHE_CHECK([if globals are prefixed by underscore],
297 nettle_cv_asm_underscore,
298 [ # Default is no underscore
299 nettle_cv_asm_underscore=no
301 [int a_global_symbol;],
302 [ $NM conftest.$OBJEXT >conftest.out
303 if grep _a_global_symbol conftest.out >/dev/null ; then
304 nettle_cv_asm_underscore=yes
305 elif grep a_global_symbol conftest.out >/dev/null ; then
306 nettle_cv_asm_underscore=no
308 AC_MSG_WARN([nm doesn't list a_global_symbol at all])
310 [AC_MSG_WARN([test program with a single global could not be compiled!?])])])
311 if test x$nettle_cv_asm_underscore = xyes ; then
312 ASM_SYMBOL_PREFIX='_'
315 AC_CACHE_CHECK([if we should use a .note.GNU-stack section],
316 nettle_cv_asm_gnu_stack,
318 nettle_cv_asm_gnu_stack=no
320 cat >conftest.c <<EOF
321 int foo() { return 0; }
323 nettle_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >conftest.out 2>&1"
324 if AC_TRY_EVAL(nettle_compile); then
325 cat conftest.out >&AC_FD_CC
326 $OBJDUMP -x conftest.o | grep '\.note\.GNU-stack' > /dev/null \
327 && nettle_cv_asm_gnu_stack=yes
329 cat conftest.out >&AC_FD_CC
330 echo "configure: failed program was:" >&AC_FD_CC
331 cat conftest.s >&AC_FD_CC
334 if test x$nettle_cv_asm_gnu_stack = xyes ; then
335 ASM_MARK_NOEXEC_STACK='.section .note.GNU-stack,"",@progbits'
338 AC_CACHE_CHECK([for ELF-style .type,%function pseudo-ops],
339 [nettle_cv_asm_type_percent_function],
347 .size foo, .Lend - foo
349 [nettle_cv_asm_type_percent_function=yes],
350 [nettle_cv_asm_type_percent_function=no])])
352 dnl Needs double quote for the # character
353 AC_CACHE_CHECK([[for ELF-style .type,#function pseudo-ops]],
354 [nettle_cv_asm_type_hash_function],
362 .size foo, .Lend - foo
364 [nettle_cv_asm_type_hash_function=yes],
365 [nettle_cv_asm_type_hash_function=no])])
367 if test x$nettle_cv_asm_type_percent_function = xyes ; then
369 ASM_TYPE_FUNCTION='%function'
371 if test x$nettle_cv_asm_type_hash_function = xyes ; then
373 ASM_TYPE_FUNCTION='#function'
376 AC_CACHE_CHECK([if .align assembly directive is logarithmic],
377 [nettle_cv_asm_align_log],
381 [nettle_cv_asm_align_log=yes],
382 [nettle_cv_asm_align_log=no])])
383 if test x$nettle_cv_asm_align_log = xyes ; then
388 AC_SUBST(ASM_SYMBOL_PREFIX)
389 AC_SUBST(ASM_ELF_STYLE)
390 AC_SUBST(ASM_TYPE_FUNCTION)
391 AC_SUBST(ASM_MARK_NOEXEC_STACK)
392 AC_SUBST(ASM_ALIGN_LOG)
394 AC_SUBST(SHLIBCFLAGS)
396 AC_SUBST(LIBNETTLE_MAJOR)
397 AC_SUBST(LIBNETTLE_MINOR)
398 AC_SUBST(LIBNETTLE_FORLINK)
399 AC_SUBST(LIBNETTLE_SONAME)
400 AC_SUBST(LIBNETTLE_FILE)
401 AC_SUBST(LIBNETTLE_LINK)
402 AC_SUBST(LIBNETTLE_LIBS)
404 AC_SUBST(LIBHOGWEED_MAJOR)
405 AC_SUBST(LIBHOGWEED_MINOR)
406 AC_SUBST(LIBHOGWEED_FORLINK)
407 AC_SUBST(LIBHOGWEED_SONAME)
408 AC_SUBST(LIBHOGWEED_FILE)
409 AC_SUBST(LIBHOGWEED_LINK)
410 AC_SUBST(LIBHOGWEED_LIBS)
412 AC_PATH_PROG(M4, m4, m4)
414 # Checks for typedefs, structures, and compiler characteristics.
420 # Used by eratosthenes.c
421 AC_CHECK_SIZEOF(long)
423 AC_CHECK_HEADERS([openssl/blowfish.h openssl/des.h openssl/cast.h openssl/aes.h],,
429 # Needed by the supplied memcmp.c
431 AC_REPLACE_FUNCS(memxor)
435 # According to Simon Josefsson, looking for uint32_t and friends in
436 # sys/types.h is needed on some systems, in particular cygwin.
437 AX_CREATE_STDINT_H([nettle-stdint.h], [sys/types.h])
439 # Check for file locking. We (AC_PROG_CC?) have already checked for
440 # sys/types.h and unistd.h.
441 AC_CACHE_CHECK([for fcntl file locking],
442 nettle_cv_fcntl_locking,
445 # include <sys/types.h>
455 nettle_cv_fcntl_locking=yes,
456 nettle_cv_fcntl_locking=no)])
458 AH_TEMPLATE([HAVE_FCNTL_LOCKING], [Define if fcntl file locking is available])
459 if test "x$nettle_cv_fcntl_locking" = "xyes" ; then
460 AC_DEFINE(HAVE_FCNTL_LOCKING)
463 # Checks for libraries
464 AC_CHECK_LIB(gmp, __gmpz_getlimbn,,
466 [GNU MP not found, or not 3.1 or up, see http://www.swox.com/gmp.
467 Support for public key algorithms will be unavailable.])]
468 enable_public_key=no)
470 # Add -R flags needed to run programs linked with gmp
473 AH_TEMPLATE([HAVE_MPZ_POWM_SEC], [Define if mpz_powm_sec is available (appeared in GMP-5)])
474 AC_CHECK_FUNC(__gmpz_powm_sec, [AC_DEFINE(HAVE_MPZ_POWM_SEC)])
476 AH_TEMPLATE([WITH_HOGWEED], [Defined if public key features are enabled])
478 if test "x$enable_public_key" = xyes ; then
479 AC_DEFINE(WITH_HOGWEED)
485 if test "x$enable_shared" = xyes ; then
496 # Check for openssl's libcrypto (used only for benchmarking)
497 if test x$enable_openssl = xyes ; then
498 AC_CHECK_LIB(crypto, BF_ecb_encrypt,
499 [OPENSSL_LIBFLAGS='-lcrypto'],
503 AH_TEMPLATE([WITH_OPENSSL],
504 [Define if you have openssl's libcrypto (used for benchmarking)])
506 if test x$enable_openssl = xyes ; then
507 AC_DEFINE(WITH_OPENSSL)
510 AC_SUBST(OPENSSL_LIBFLAGS)
512 # Set these flags *last*, or else the test programs won't compile
513 if test x$GCC = xyes ; then
514 # Using -ggdb3 makes (some versions of) Redhat's gcc-2.96 dump core
515 if "$CC" --version | grep '^2\.96$' 1>/dev/null 2>&1; then
518 CFLAGS="$CFLAGS -ggdb3"
520 # FIXME: It would be better to actually test if this option works and/or is needed.
521 # Or perhaps use -funsigned-char.
522 if "$CC" --version | grep 'gcc.* 4\.' 1>/dev/null 2>&1; then
523 CFLAGS="$CFLAGS -Wno-pointer-sign"
525 CFLAGS="$CFLAGS -Wall -W \
526 -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes \
527 -Wpointer-arith -Wbad-function-cast -Wnested-externs"
529 # Don't enable -Wcast-align as it results in tons of warnings in the
530 # DES code. And when using stdio.
531 # Don't enable -Waggregate-return, as that causes warnings for glibc
535 AC_CONFIG_FILES([config.make config.m4 Makefile])
536 AC_CONFIG_FILES([tools/Makefile testsuite/Makefile examples/Makefile])