aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac170
1 files changed, 147 insertions, 23 deletions
diff --git a/configure.ac b/configure.ac
index 105528e142..864477b8fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,10 +1,11 @@
dnl Copyright (c) 2001-2004, Roger Dingledine
dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
-dnl Copyright (c) 2007-2012, The Tor Project, Inc.
+dnl Copyright (c) 2007-2013, The Tor Project, Inc.
dnl See LICENSE for licensing information
-AC_INIT([tor],[0.2.4.5-alpha-dev])
+AC_INIT([tor],[0.2.4.10-alpha-dev])
AC_CONFIG_SRCDIR([src/or/main.c])
+AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CONFIG_HEADERS([orconfig.h])
@@ -36,6 +37,8 @@ AC_ARG_ENABLE(static-zlib,
AS_HELP_STRING(--enable-static-zlib, Link against a static zlib library. Requires --with-zlib-dir))
AC_ARG_ENABLE(static-tor,
AS_HELP_STRING(--enable-static-tor, Create an entirely static Tor binary. Requires --with-openssl-dir and --with-libevent-dir and --with-zlib-dir))
+AC_ARG_ENABLE(curve25519,
+ AS_HELP_STRING(--disable-curve25519, Build Tor with no curve25519 elliptic-curve crypto support))
if test "$enable_static_tor" = "yes"; then
enable_static_libevent="yes";
@@ -318,6 +321,7 @@ AC_CHECK_FUNCS(
sysconf \
uname \
vasprintf \
+ _vscprintf
)
if test "$enable_threads" = "yes"; then
@@ -638,6 +642,110 @@ if test "$upnp" = "true"; then
fi
fi
+dnl ============================================================
+dnl We need an implementation of curve25519.
+
+dnl set these defaults.
+have_a_curve25519=no
+build_curve25519_donna=no
+build_curve25519_donna_c64=no
+use_curve25519_donna=no
+use_curve25519_nacl=no
+CURVE25519_LIBS=
+
+if test x$enable_curve25519 != xno; then
+
+ dnl The best choice is using curve25519-donna-c64, but that requires
+ dnl that we
+ AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
+ tor_cv_can_use_curve25519_donna_c64,
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([dnl
+ #include <stdint.h>
+ typedef unsigned uint128_t __attribute__((mode(TI)));
+ ], [dnl
+ uint64_t a = ((uint64_t)2000000000) * 1000000000;
+ uint64_t b = ((uint64_t)1234567890) << 24;
+ uint128_t c = ((uint128_t)a) * b;
+ return ((uint64_t)(c>>96)) == 522859 &&
+ ((uint64_t)(c>>64))&0xffffffffL == 3604448702L &&
+ ((uint64_t)(c>>32))&0xffffffffL == 2351960064L &&
+ ((uint64_t)(c))&0xffffffffL == 0;
+ ])],
+ [tor_cv_can_use_curve25519_donna_c64=yes],
+ [tor_cv_can_use_curve25519_donna_c64=no],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([dnl
+ #include <stdint.h>
+ typedef unsigned uint128_t __attribute__((mode(TI)));
+ ], [dnl
+ uint64_t a = ((uint64_t)2000000000) * 1000000000;
+ uint64_t b = ((uint64_t)1234567890) << 24;
+ uint128_t c = ((uint128_t)a) * b;
+ return ((uint64_t)(c>>96)) == 522859 &&
+ ((uint64_t)(c>>64))&0xffffffffL == 3604448702L &&
+ ((uint64_t)(c>>32))&0xffffffffL == 2351960064L &&
+ ((uint64_t)(c))&0xffffffffL == 0;
+ ])],
+ [tor_cv_can_use_curve25519_donna_c64=cross],
+ [tor_cv_can_use_curve25519_donna_c64=no])])])
+
+ AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
+ nacl/crypto_scalarmult_curve25519.h])
+
+ AC_CACHE_CHECK([whether we can use curve25519 from nacl],
+ tor_cv_can_use_curve25519_nacl,
+ [tor_saved_LIBS="$LIBS"
+ LIBS="$LIBS -lnacl"
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([dnl
+ #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
+ #include <crypto_scalarmult_curve25519.h>
+ #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
+ #include <nacl/crypto_scalarmult_curve25519.h>
+ #endif
+ #ifdef crypto_scalarmult_curve25519_ref_BYTES
+ #error Hey, this is the reference implementation!
+ #endif
+ ], [
+ unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
+ ])], [tor_cv_can_use_curve25519_nacl=yes],
+ [tor_cv_can_use_curve25519_nacl=no])
+ LIBS="$tor_saved_LIBS" ])
+
+ dnl Okay, now we need to figure out which one to actually use. Fall back
+ dnl to curve25519-donna.c
+
+ if test x$tor_cv_can_use_curve25519_donna_c64 != xno; then
+ build_curve25519_donna_c64=yes
+ use_curve25519_donna=yes
+ elif test x$tor_cv_can_use_curve25519_nacl = xyes; then
+ use_curve25519_nacl=yes
+ CURVE25519_LIBS=-lnacl
+ else
+ build_curve25519_donna=yes
+ use_curve25519_donna=yes
+ fi
+ have_a_curve25519=yes
+fi
+
+if test x$have_a_curve25519 = xyes; then
+ AC_DEFINE(CURVE25519_ENABLED, 1,
+ [Defined if we have a curve25519 implementation])
+fi
+if test x$use_curve25519_donna = xyes; then
+ AC_DEFINE(USE_CURVE25519_DONNA, 1,
+ [Defined if we should use an internal curve25519_donna{,_c64} implementation])
+fi
+if test x$use_curve25519_nacl = xyes; then
+ AC_DEFINE(USE_CURVE25519_NACL, 1,
+ [Defined if we should use a curve25519 from nacl])
+fi
+AM_CONDITIONAL(BUILD_CURVE25519_DONNA, test x$build_curve25519_donna = xyes)
+AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64, test x$build_curve25519_donna_c64 = xyes)
+AM_CONDITIONAL(CURVE25519_ENABLED, test x$have_a_curve25519 = xyes)
+AC_SUBST(CURVE25519_LIBS)
+
dnl Make sure to enable support for large off_t if available.
AC_SYS_LARGEFILE
@@ -784,6 +892,7 @@ AC_CHECK_SIZEOF(__int64)
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(time_t)
AC_CHECK_SIZEOF(size_t)
+AC_CHECK_SIZEOF(pid_t)
AC_CHECK_TYPES([uint, u_char, ssize_t])
@@ -849,8 +958,9 @@ AC_CHECK_TYPES([rlim_t], , ,
#endif
])
-AC_CACHE_CHECK([whether time_t is signed], tor_cv_time_t_signed, [
-AC_RUN_IFELSE([AC_LANG_SOURCE([
+AX_CHECK_SIGN([time_t],
+ [ AC_DEFINE(TIME_T_IS_SIGNED, 1, [Define if time_t is signed]) ],
+ [ : ], [
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -860,36 +970,26 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([
#ifdef HAVE_TIME_H
#include <time.h>
#endif
-int main(int c, char**v) { if (((time_t)-1)<0) return 1; else return 0; }])],
- tor_cv_time_t_signed=no, tor_cv_time_t_signed=yes, tor_cv_time_t_signed=cross)
])
-if test "$tor_cv_time_t_signed" = cross; then
- AC_MSG_NOTICE([Cross compiling: assuming that time_t is signed.])
-fi
-
-if test "$tor_cv_time_t_signed" != no; then
- AC_DEFINE([TIME_T_IS_SIGNED], 1,
- [Define to 1 iff time_t is signed])
-fi
-
-AC_CACHE_CHECK([whether size_t is signed], tor_cv_size_t_signed, [
-AC_RUN_IFELSE([AC_LANG_SOURCE([
+AX_CHECK_SIGN([size_t],
+ [ tor_cv_size_t_signed=yes ],
+ [ tor_cv_size_t_signed=no ], [
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
-int main(int c, char**v) { if (((size_t)-1)<0) return 1; else return 0; }])],
- tor_cv_size_t_signed=no, tor_cv_size_t_signed=yes, tor_cv_size_t_signed=cross)
])
-if test "$tor_cv_size_t_signed" = cross; then
- AC_MSG_NOTICE([Cross compiling: assuming that size_t is not signed.])
-fi
-
if test "$tor_cv_size_t_signed" = yes; then
AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
fi
+AX_CHECK_SIGN([enum always],
+ [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
+ [ : ], [
+ enum always { AAA, BBB, CCC };
+])
+
AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
@@ -925,6 +1025,30 @@ if test "$tor_cv_null_is_zero" != no; then
[Define to 1 iff memset(0) sets pointers to NULL])
fi
+AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
+[AC_RUN_IFELSE([AC_LANG_SOURCE(
+[[#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#ifdef HAVE_STDDEF_H
+#include <stddef.h>
+#endif
+int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
+return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
+ [tor_cv_dbl0_is_zero=yes],
+ [tor_cv_dbl0_is_zero=no],
+ [tor_cv_dbl0_is_zero=cross])])
+
+if test "$tor_cv_dbl0_is_zero" = cross ; then
+ # Cross-compiling; let's hope that the target isn't raving mad.
+ AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
+fi
+
+if test "$tor_cv_dbl0_is_zero" != no; then
+ AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
+ [Define to 1 iff memset(0) sets doubles to 0.0])
+fi
+
# And what happens when we malloc zero?
AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
[AC_RUN_IFELSE([AC_LANG_SOURCE(