1 dnl Copyright (c) 2001-2004, Roger Dingledine
2 dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
3 dnl Copyright (c) 2007-2013, The Tor Project, Inc.
4 dnl See LICENSE for licensing information
6 AC_INIT([tor],[0.2.4.23])
7 AC_CONFIG_SRCDIR([src/or/main.c])
8 AC_CONFIG_MACRO_DIR([m4])
10 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
11 AC_CONFIG_HEADERS([orconfig.h])
15 if test -f /etc/redhat-release ; then
16 if test -f /usr/kerberos/include ; then
17 CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
21 # Not a no-op; we want to make sure that CPPFLAGS is set before we use
22 # the += operator on it in src/or/Makefile.am
23 CPPFLAGS="$CPPFLAGS -I\${top_srcdir}/src/common"
25 #XXXX020 We should make these enabled or not, before 0.2.0.x-final
26 AC_ARG_ENABLE(buf-freelists,
27 AS_HELP_STRING(--disable-buf-freelists, disable freelists for buffer RAM))
28 AC_ARG_ENABLE(openbsd-malloc,
29 AS_HELP_STRING(--enable-openbsd-malloc, Use malloc code from openbsd. Linux only))
30 AC_ARG_ENABLE(instrument-downloads,
31 AS_HELP_STRING(--enable-instrument-downloads, Instrument downloads of directory resources etc.))
32 AC_ARG_ENABLE(static-openssl,
33 AS_HELP_STRING(--enable-static-openssl, Link against a static openssl library. Requires --with-openssl-dir))
34 AC_ARG_ENABLE(static-libevent,
35 AS_HELP_STRING(--enable-static-libevent, Link against a static libevent library. Requires --with-libevent-dir))
36 AC_ARG_ENABLE(static-zlib,
37 AS_HELP_STRING(--enable-static-zlib, Link against a static zlib library. Requires --with-zlib-dir))
38 AC_ARG_ENABLE(static-tor,
39 AS_HELP_STRING(--enable-static-tor, Create an entirely static Tor binary. Requires --with-openssl-dir and --with-libevent-dir and --with-zlib-dir))
40 AC_ARG_ENABLE(curve25519,
41 AS_HELP_STRING(--disable-curve25519, Build Tor with no curve25519 elliptic-curve crypto support))
43 if test "$enable_static_tor" = "yes"; then
44 enable_static_libevent="yes";
45 enable_static_openssl="yes";
46 enable_static_zlib="yes";
47 CFLAGS="$CFLAGS -static"
50 if test x$enable_buf_freelists != xno; then
51 AC_DEFINE(ENABLE_BUF_FREELISTS, 1,
52 [Defined if we try to use freelists for buffer RAM chunks])
54 AM_CONDITIONAL(USE_OPENBSD_MALLOC, test x$enable_openbsd_malloc = xyes)
55 if test x$enable_instrument_downloads = xyes; then
56 AC_DEFINE(INSTRUMENT_DOWNLOADS, 1,
57 [Defined if we want to keep track of how much of each kind of resource we download.])
60 AC_ARG_ENABLE(transparent,
61 AS_HELP_STRING(--disable-transparent, disable transparent proxy support),
62 [case "${enableval}" in
63 yes) transparent=true ;;
64 no) transparent=false ;;
65 *) AC_MSG_ERROR(bad value for --enable-transparent) ;;
66 esac], [transparent=true])
68 AC_ARG_ENABLE(asciidoc,
69 AS_HELP_STRING(--disable-asciidoc, don't use asciidoc (disables building of manpages)),
70 [case "${enableval}" in
73 *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
74 esac], [asciidoc=true])
76 # By default, we're not ready to ship a NAT-PMP aware Tor
77 AC_ARG_ENABLE(nat-pmp,
78 AS_HELP_STRING(--enable-nat-pmp, enable NAT-PMP support),
79 [case "${enableval}" in
82 * ) AC_MSG_ERROR(bad value for --enable-nat-pmp) ;;
83 esac], [natpmp=false])
85 # By default, we're not ready to ship a UPnP aware Tor
87 AS_HELP_STRING(--enable-upnp, enable UPnP support),
88 [case "${enableval}" in
91 * ) AC_MSG_ERROR(bad value for --enable-upnp) ;;
95 AC_ARG_ENABLE(threads,
96 AS_HELP_STRING(--disable-threads, disable multi-threading support))
98 if test x$enable_threads = x; then
101 # Don't try multithreading on solaris -- cpuworkers seem to lock.
102 AC_MSG_NOTICE([You are running Solaris; Sometimes threading makes
103 cpu workers lock up here, so I will disable threads.])
104 enable_threads="no";;
106 enable_threads="yes";;
110 if test "$enable_threads" = "yes"; then
111 AC_DEFINE(ENABLE_THREADS, 1, [Defined if we will try to use multithreading])
116 AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
120 AC_ARG_ENABLE(gcc-warnings,
121 AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings))
122 AC_ARG_ENABLE(gcc-warnings-advisory,
123 AS_HELP_STRING(--enable-gcc-warnings-advisory, [enable verbose warnings, excluding -Werror]))
125 dnl Adam shostack suggests the following for Windows:
126 dnl -D_FORTIFY_SOURCE=2 -fstack-protector-all
127 dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
128 dnl This requires that we use gcc and that we add -O2 to the CFLAGS.
129 AC_ARG_ENABLE(gcc-hardening,
130 AS_HELP_STRING(--disable-gcc-hardening, disable compiler security checks))
132 dnl Linker hardening options
133 dnl Currently these options are ELF specific - you can't use this with MacOSX
134 AC_ARG_ENABLE(linker-hardening,
135 AS_HELP_STRING(--disable-linker-hardening, disable linker security fixups))
137 AC_ARG_ENABLE(local-appdata,
138 AS_HELP_STRING(--enable-local-appdata, default to host local application data paths on Windows))
139 if test "$enable_local_appdata" = "yes"; then
140 AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
141 [Defined if we default to host local appdata paths on Windows])
145 AC_ARG_ENABLE(tor2web-mode,
146 AS_HELP_STRING(--enable-tor2web-mode, support tor2web non-anonymous mode),
147 [if test x$enableval = xyes; then
148 CFLAGS="$CFLAGS -D ENABLE_TOR2WEB_MODE=1"
151 AC_ARG_ENABLE(bufferevents,
152 AS_HELP_STRING(--enable-bufferevents, use Libevent's buffered IO.))
154 dnl check for the correct "ar" when cross-compiling
155 AN_MAKEVAR([AR], [AC_PROG_AR])
156 AN_PROGRAM([ar], [AC_PROG_AR])
157 AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [ar])])
165 dnl autoconf 2.59 appears not to support AC_PROG_SED
166 AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
168 dnl check for asciidoc and a2x
169 AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
170 AC_PATH_PROGS([A2X], [a2x a2x.py], none)
172 AM_CONDITIONAL(USE_ASCIIDOC, test x$asciidoc = xtrue)
174 AM_CONDITIONAL(USE_FW_HELPER, test x$natpmp = xtrue || test x$upnp = xtrue)
175 AM_CONDITIONAL(NAT_PMP, test x$natpmp = xtrue)
176 AM_CONDITIONAL(MINIUPNPC, test x$upnp = xtrue)
179 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
180 AC_C_FLEXIBLE_ARRAY_MEMBER
182 dnl Maybe we've got an old autoconf...
183 AC_CACHE_CHECK([for flexible array members],
187 struct abc { int a; char b[]; };
189 struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
192 [tor_cv_c_flexarray=yes],
193 [tor_cv_c_flexarray=no])])
194 if test $tor_cv_flexarray = yes ; then
195 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
197 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
201 AC_PATH_PROG([SHA1SUM], [sha1sum], none)
202 AC_PATH_PROG([OPENSSL], [openssl], none)
205 AC_ARG_WITH(tor-user,
206 [ --with-tor-user=NAME Specify username for tor daemon ],
214 AC_ARG_WITH(tor-group,
215 [ --with-tor-group=NAME Specify group name for tor daemon ],
223 dnl If _WIN32 is defined and non-zero, we are building for win32
224 AC_MSG_CHECKING([for win32])
225 AC_RUN_IFELSE([AC_LANG_SOURCE([
226 int main(int c, char **v) {
237 bwin32=true; AC_MSG_RESULT([yes]),
238 bwin32=false; AC_MSG_RESULT([no]),
239 bwin32=cross; AC_MSG_RESULT([cross])
242 if test "$bwin32" = cross; then
243 AC_MSG_CHECKING([for win32 (cross)])
244 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
246 int main(int c, char **v) {return 0;}
249 int main(int c, char **v) {return x(y);}
252 bwin32=true; AC_MSG_RESULT([yes]),
253 bwin32=false; AC_MSG_RESULT([no]))
256 AM_CONDITIONAL(BUILD_NT_SERVICES, test x$bwin32 = xtrue)
258 dnl Enable C99 when compiling with MIPSpro
259 AC_MSG_CHECKING([for MIPSpro compiler])
260 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
261 #if (defined(__sgi) && defined(_COMPILER_VERSION))
266 bmipspro=false; AC_MSG_RESULT(no),
267 bmipspro=true; AC_MSG_RESULT(yes))
269 if test "$bmipspro" = true; then
270 CFLAGS="$CFLAGS -c99"
275 AC_SEARCH_LIBS(socket, [socket network])
276 AC_SEARCH_LIBS(gethostbyname, [nsl])
277 AC_SEARCH_LIBS(dlopen, [dl])
278 AC_SEARCH_LIBS(inet_aton, [resolv])
280 AC_SEARCH_LIBS([clock_gettime], [rt])
281 if test "$LIBS" != "$saved_LIBS"; then
282 # Looks like we need -lrt for clock_gettime().
286 if test "$enable_threads" = "yes"; then
287 AC_SEARCH_LIBS(pthread_create, [pthread])
288 AC_SEARCH_LIBS(pthread_detach, [pthread])
291 dnl -------------------------------------------------------------------
292 dnl Check for functions before libevent, since libevent-1.2 apparently
293 dnl exports strlcpy without defining it in a header.
327 if test "$enable_threads" = "yes"; then
328 AC_CHECK_HEADERS(pthread.h)
329 AC_CHECK_FUNCS(pthread_create)
332 dnl ------------------------------------------------------
333 dnl Where do you live, libevent? And how do we call you?
335 if test "$bwin32" = true; then
336 TOR_LIB_WS32=-lws2_32
337 TOR_LIB_IPHLPAPI=-liphlpapi
338 # Some of the cargo-cults recommend -lwsock32 as well, but I don't
339 # think it's actually necessary.
345 AC_SUBST(TOR_LIB_WS32)
346 AC_SUBST(TOR_LIB_GDI)
347 AC_SUBST(TOR_LIB_IPHLPAPI)
349 dnl We need to do this before we try our disgusting hack below.
350 AC_CHECK_HEADERS([sys/types.h])
352 dnl This is a disgusting hack so we safely include older libevent headers.
353 AC_CHECK_TYPE(u_int64_t, unsigned long long)
354 AC_CHECK_TYPE(u_int32_t, unsigned long)
355 AC_CHECK_TYPE(u_int16_t, unsigned short)
356 AC_CHECK_TYPE(u_int8_t, unsigned char)
358 tor_libevent_pkg_redhat="libevent"
359 tor_libevent_pkg_debian="libevent-dev"
360 tor_libevent_devpkg_redhat="libevent-devel"
361 tor_libevent_devpkg_debian="libevent-dev"
363 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
364 dnl linking for static builds.
365 STATIC_LIBEVENT_FLAGS=""
366 if test "$enable_static_libevent" = "yes"; then
367 if test "$have_rt" = yes; then
368 STATIC_LIBEVENT_FLAGS=" -lrt "
372 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
374 #include <winsock2.h>
377 #include <sys/time.h>
378 #include <sys/types.h>
379 #include <event.h>], [
381 #include <winsock2.h>
383 void exit(int); void *event_init(void);],
386 {WSADATA d; WSAStartup(0x101,&d); }
388 event_init(); exit(0);
389 ], [--with-libevent-dir], [/opt/libevent])
391 dnl Now check for particular libevent functions.
393 save_LDFLAGS="$LDFLAGS"
394 save_CPPFLAGS="$CPPFLAGS"
395 LIBS="-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $LIBS"
396 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
397 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
398 AC_CHECK_FUNCS(event_get_version event_get_version_number event_get_method event_set_log_callback evdns_set_outgoing_bind_address event_base_loopexit)
399 AC_CHECK_MEMBERS([struct event.min_heap_idx], , ,
403 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
406 LDFLAGS="$save_LDFLAGS"
407 CPPFLAGS="$save_CPPFLAGS"
410 AM_CONDITIONAL(USE_EXTERNAL_EVDNS, test x$ac_cv_header_event2_dns_h = xyes)
412 if test "$enable_static_libevent" = "yes"; then
413 if test "$tor_cv_library_libevent_dir" = "(system)"; then
414 AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
416 TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
419 TOR_LIBEVENT_LIBS="-levent"
422 dnl This isn't the best test for Libevent 2.0.3-alpha. Once it's released,
423 dnl we can do much better.
424 if test "$enable_bufferevents" = "yes" ; then
425 if test "$ac_cv_header_event2_bufferevent_ssl_h" != "yes" ; then
426 AC_MSG_ERROR([You've asked for bufferevent support, but you're using a version of Libevent without SSL support. This won't work. We need Libevent 2.0.8-rc or later, and you don't seem to even have Libevent 2.0.3-alpha.])
429 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
431 # Check for the right version. First see if version detection works.
432 AC_MSG_CHECKING([whether we can detect the Libevent version])
433 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
434 #include <event2/event.h>
435 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 10
441 ])], [event_version_number_works=yes; AC_MSG_RESULT([yes]) ],
442 [event_version_number_works=no; AC_MSG_RESULT([no])])
443 if test "$event_version_number_works" != 'yes'; then
444 AC_MSG_WARN([Version detection on Libevent seems broken. Your Libevent installation is probably screwed up or very old.])
446 AC_MSG_CHECKING([whether Libevent is new enough for bufferevents])
447 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
448 #include <event2/event.h>
449 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000d00
455 ])], [ AC_MSG_RESULT([yes]) ],
456 [ AC_MSG_RESULT([no])
457 AC_MSG_ERROR([Libevent does not seem new enough to support bufferevents. We require 2.0.13-stable or later]) ] )
463 LDFLAGS="$save_LDFLAGS"
464 CPPFLAGS="$save_CPPFLAGS"
466 AM_CONDITIONAL(USE_BUFFEREVENTS, test "$enable_bufferevents" = "yes")
467 if test "$enable_bufferevents" = "yes"; then
468 AC_DEFINE(USE_BUFFEREVENTS, 1, [Defined if we're going to use Libevent's buffered IO API])
469 if test "$enable_static_libevent" = "yes"; then
470 TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent_openssl.a $TOR_LIBEVENT_LIBS"
472 TOR_LIBEVENT_LIBS="-levent_openssl $TOR_LIBEVENT_LIBS"
475 AC_SUBST(TOR_LIBEVENT_LIBS)
477 dnl ------------------------------------------------------
478 dnl Where do you live, libm?
480 dnl On some platforms (Haiku/BeOS) the math library is
481 dnl part of libroot. In which case don't link against lm
484 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
485 if test "$ac_cv_search_pow" != "none required"; then
486 TOR_LIB_MATH="$ac_cv_search_pow"
489 AC_SUBST(TOR_LIB_MATH)
491 dnl ------------------------------------------------------
492 dnl Where do you live, openssl? And how do we call you?
494 tor_openssl_pkg_redhat="openssl"
495 tor_openssl_pkg_debian="libssl"
496 tor_openssl_devpkg_redhat="openssl-devel"
497 tor_openssl_devpkg_debian="libssl-dev"
499 ALT_openssl_WITHVAL=""
501 [ --with-ssl-dir=PATH Obsolete alias for --with-openssl-dir ],
503 if test "x$withval" != xno && test "x$withval" != "x" ; then
504 ALT_openssl_WITHVAL="$withval"
508 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI],
509 [#include <openssl/rand.h>],
510 [void RAND_add(const void *buf, int num, double entropy);],
511 [RAND_add((void*)0,0,0); exit(0);], [],
512 [/usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /opt/openssl])
514 dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
516 if test "$enable_static_openssl" = "yes"; then
517 if test "$tor_cv_library_openssl_dir" = "(system)"; then
518 AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
520 TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
523 TOR_OPENSSL_LIBS="-lssl -lcrypto"
525 AC_SUBST(TOR_OPENSSL_LIBS)
527 AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , ,
528 [#include <openssl/ssl.h>
531 dnl ------------------------------------------------------
532 dnl Where do you live, zlib? And how do we call you?
534 tor_zlib_pkg_redhat="zlib"
535 tor_zlib_pkg_debian="zlib1g"
536 tor_zlib_devpkg_redhat="zlib-devel"
537 tor_zlib_devpkg_debian="zlib1g-dev"
539 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
541 [const char * zlibVersion(void);],
542 [zlibVersion(); exit(0);], [--with-zlib-dir],
545 if test "$enable_static_zlib" = "yes"; then
546 if test "$tor_cv_library_zlib_dir" = "(system)"; then
547 AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
548 using --enable-static-zlib")
550 TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
555 AC_SUBST(TOR_ZLIB_LIBS)
557 dnl ---------------------------------------------------------------------
558 dnl Now that we know about our major libraries, we can check for compiler
559 dnl and linker hardening options. We need to do this with the libraries known,
560 dnl since sometimes the linker will like an option but not be willing to
561 dnl use it with a build of a library.
563 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
564 all_libs_for_check="$TOR_ZLIB_LIBS $TOR_LIB_MATH $TOR_LIBEVENT_LIBS $TOR_OPENSSL_LIBS $TOR_LIB_WS32 $TOR_LIB_GDI"
566 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
567 #if !defined(__clang__)
569 #endif])], have_clang=yes, have_clang=no)
571 if test x$enable_gcc_hardening != xno; then
572 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
573 if test x$have_clang = xyes; then
574 TOR_CHECK_CFLAGS(-Qunused-arguments)
576 TOR_CHECK_CFLAGS(-fstack-protector-all)
577 TOR_CHECK_CFLAGS(-Wstack-protector)
578 TOR_CHECK_CFLAGS(-fwrapv)
579 TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
580 if test "$bwin32" = "false"; then
581 TOR_CHECK_CFLAGS(-fPIE)
582 TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
586 if test x$enable_linker_hardening != xno; then
587 TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
590 dnl ------------------------------------------------------
591 dnl Where do you live, libnatpmp? And how do we call you?
592 dnl There are no packages for Debian or Redhat as of this patch
594 if test "$natpmp" = "true"; then
595 AC_DEFINE(NAT_PMP, 1, [Define to 1 if we are building with nat-pmp.])
596 TOR_SEARCH_LIBRARY(libnatpmp, $trylibnatpmpdir, [-lnatpmp $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
597 [#include <natpmp.h>],
601 #include <natpmp.h>],
604 natpmpresp_t response;
605 r = initnatpmp(&natpmp, 0, 0);],
606 [printf("initnatpmp() returned %d (%s)\n", r, r?"FAILED":"SUCCESS");
608 [--with-libnatpmp-dir],
613 dnl ------------------------------------------------------
614 dnl Where do you live, libminiupnpc? And how do we call you?
615 dnl There are no packages for Debian or Redhat as of this patch
617 if test "$upnp" = "true"; then
618 AC_DEFINE(MINIUPNPC, 1, [Define to 1 if we are building with UPnP.])
620 dnl Before we call TOR_SEARCH_LIBRARY we'll do a quick compile test
621 dnl to see if we have miniupnpc-1.5 or -1.6
622 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <miniupnpc/miniupnpc.h>],
623 [upnpDiscover(1, 0, 0, 0);exit(0);])],[miniupnpc15="true"],[miniupnpc15="false"])
625 if test "$miniupnpc15" = "true" ; then
626 AC_DEFINE([MINIUPNPC15],[1],[libminiupnpc version 1.5 found])
627 TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
628 [#include <miniupnpc/miniwget.h>
629 #include <miniupnpc/miniupnpc.h>
630 #include <miniupnpc/upnpcommands.h>],
631 [void upnpDiscover(int delay, const char * multicastif,
632 const char * minissdpdsock, int sameport);],
633 [upnpDiscover(1, 0, 0, 0); exit(0);],
634 [--with-libminiupnpc-dir],
637 TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
638 [#include <miniupnpc/miniwget.h>
639 #include <miniupnpc/miniupnpc.h>
640 #include <miniupnpc/upnpcommands.h>],
641 [void upnpDiscover(int delay, const char * multicastif,
642 const char * minissdpdsock, int sameport, int ipv6, int * error);],
643 [upnpDiscover(1, 0, 0, 0, 0, 0); exit(0);],
644 [--with-libminiupnpc-dir],
649 dnl ============================================================
650 dnl We need an implementation of curve25519.
652 dnl set these defaults.
654 build_curve25519_donna=no
655 build_curve25519_donna_c64=no
656 use_curve25519_donna=no
657 use_curve25519_nacl=no
660 if test x$enable_curve25519 != xno; then
662 dnl The best choice is using curve25519-donna-c64, but that requires
664 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
665 tor_cv_can_use_curve25519_donna_c64,
667 [AC_LANG_PROGRAM([dnl
669 typedef unsigned uint128_t __attribute__((mode(TI)));
670 int func(uint64_t a, uint64_t b) {
671 uint128_t c = ((uint128_t)a) * b;
672 int ok = ((uint64_t)(c>>96)) == 522859 &&
673 (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
674 (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
675 (((uint64_t)(c))&0xffffffffL) == 0;
679 int ok = func( ((uint64_t)2000000000) * 1000000000,
680 ((uint64_t)1234567890) << 24);
683 [tor_cv_can_use_curve25519_donna_c64=yes],
684 [tor_cv_can_use_curve25519_donna_c64=no],
686 [AC_LANG_PROGRAM([dnl
688 typedef unsigned uint128_t __attribute__((mode(TI)));
689 int func(uint64_t a, uint64_t b) {
690 uint128_t c = ((uint128_t)a) * b;
691 int ok = ((uint64_t)(c>>96)) == 522859 &&
692 (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
693 (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
694 (((uint64_t)(c))&0xffffffffL) == 0;
698 int ok = func( ((uint64_t)2000000000) * 1000000000,
699 ((uint64_t)1234567890) << 24);
702 [tor_cv_can_use_curve25519_donna_c64=cross],
703 [tor_cv_can_use_curve25519_donna_c64=no])])])
705 AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
706 nacl/crypto_scalarmult_curve25519.h])
708 AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
709 tor_cv_can_use_curve25519_nacl,
710 [tor_saved_LIBS="$LIBS"
713 [AC_LANG_PROGRAM([dnl
714 #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
715 #include <crypto_scalarmult_curve25519.h>
716 #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
717 #include <nacl/crypto_scalarmult_curve25519.h>
719 #ifdef crypto_scalarmult_curve25519_ref_BYTES
720 #error Hey, this is the reference implementation! That's not fast.
723 unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
724 ])], [tor_cv_can_use_curve25519_nacl=yes],
725 [tor_cv_can_use_curve25519_nacl=no])
726 LIBS="$tor_saved_LIBS" ])
728 dnl Okay, now we need to figure out which one to actually use. Fall back
729 dnl to curve25519-donna.c
731 if test x$tor_cv_can_use_curve25519_donna_c64 != xno; then
732 build_curve25519_donna_c64=yes
733 use_curve25519_donna=yes
734 elif test x$tor_cv_can_use_curve25519_nacl = xyes; then
735 use_curve25519_nacl=yes
736 CURVE25519_LIBS=-lnacl
738 build_curve25519_donna=yes
739 use_curve25519_donna=yes
741 have_a_curve25519=yes
744 if test x$have_a_curve25519 = xyes; then
745 AC_DEFINE(CURVE25519_ENABLED, 1,
746 [Defined if we have a curve25519 implementation])
748 if test x$use_curve25519_donna = xyes; then
749 AC_DEFINE(USE_CURVE25519_DONNA, 1,
750 [Defined if we should use an internal curve25519_donna{,_c64} implementation])
752 if test x$use_curve25519_nacl = xyes; then
753 AC_DEFINE(USE_CURVE25519_NACL, 1,
754 [Defined if we should use a curve25519 from nacl])
756 AM_CONDITIONAL(BUILD_CURVE25519_DONNA, test x$build_curve25519_donna = xyes)
757 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64, test x$build_curve25519_donna_c64 = xyes)
758 AM_CONDITIONAL(CURVE25519_ENABLED, test x$have_a_curve25519 = xyes)
759 AC_SUBST(CURVE25519_LIBS)
761 dnl Make sure to enable support for large off_t if available.
776 , , AC_MSG_WARN(Some headers were not found, compilation may fail. If compilation succeeds, please send your orconfig.h to the developers so we can fix this warning.))
778 dnl These headers are not essential
815 AC_CHECK_HEADERS(sys/param.h)
817 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
818 [#ifdef HAVE_SYS_TYPES_H
819 #include <sys/types.h>
821 #ifdef HAVE_SYS_SOCKET_H
822 #include <sys/socket.h>
824 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
825 [#ifdef HAVE_SYS_TYPES_H
826 #include <sys/types.h>
828 #ifdef HAVE_SYS_SOCKET_H
829 #include <sys/socket.h>
834 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
835 linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
836 [#ifdef HAVE_SYS_TYPES_H
837 #include <sys/types.h>
839 #ifdef HAVE_SYS_SOCKET_H
840 #include <sys/socket.h>
845 #ifdef HAVE_LINUX_TYPES_H
846 #include <linux/types.h>
848 #ifdef HAVE_NETINET_IN6_H
849 #include <netinet/in6.h>
851 #ifdef HAVE_NETINET_IN_H
852 #include <netinet/in.h>
855 if test x$transparent = xtrue ; then
857 if test x$net_if_found = x1 && test x$net_pfvar_found = x1 ; then
860 if test x$linux_netfilter_ipv4 = x1 ; then
863 if test x$transparent_ok = x1 ; then
864 AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
866 *-*-openbsd* | *-*-bitrig*)
867 AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
870 AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
874 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
875 [#ifdef HAVE_SYS_TYPES_H
876 #include <sys/types.h>
878 #ifdef HAVE_SYS_TIME_H
879 #include <sys/time.h>
882 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
885 AC_CHECK_SIZEOF(int8_t)
886 AC_CHECK_SIZEOF(int16_t)
887 AC_CHECK_SIZEOF(int32_t)
888 AC_CHECK_SIZEOF(int64_t)
889 AC_CHECK_SIZEOF(uint8_t)
890 AC_CHECK_SIZEOF(uint16_t)
891 AC_CHECK_SIZEOF(uint32_t)
892 AC_CHECK_SIZEOF(uint64_t)
893 AC_CHECK_SIZEOF(intptr_t)
894 AC_CHECK_SIZEOF(uintptr_t)
896 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
898 AC_CHECK_SIZEOF(char)
899 AC_CHECK_SIZEOF(short)
901 AC_CHECK_SIZEOF(long)
902 AC_CHECK_SIZEOF(long long)
903 AC_CHECK_SIZEOF(__int64)
904 AC_CHECK_SIZEOF(void *)
905 AC_CHECK_SIZEOF(time_t)
906 AC_CHECK_SIZEOF(size_t)
907 AC_CHECK_SIZEOF(pid_t)
909 AC_CHECK_TYPES([uint, u_char, ssize_t])
911 dnl used to include sockaddr_storage, but everybody has that.
912 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
913 [#ifdef HAVE_SYS_TYPES_H
914 #include <sys/types.h>
916 #ifdef HAVE_NETINET_IN_H
917 #include <netinet/in.h>
919 #ifdef HAVE_NETINET_IN6_H
920 #include <netinet/in6.h>
922 #ifdef HAVE_SYS_SOCKET_H
923 #include <sys/socket.h>
926 #define _WIN32_WINNT 0x0501
927 #define WIN32_LEAN_AND_MEAN
928 #if defined(_MSC_VER) && (_MSC_VER < 1300)
931 #include <winsock2.h>
932 #include <ws2tcpip.h>
936 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
937 [#ifdef HAVE_SYS_TYPES_H
938 #include <sys/types.h>
940 #ifdef HAVE_NETINET_IN_H
941 #include <netinet/in.h>
943 #ifdef HAVE_NETINET_IN6_H
944 #include <netinet/in6.h>
946 #ifdef HAVE_SYS_SOCKET_H
947 #include <sys/socket.h>
950 #define _WIN32_WINNT 0x0501
951 #define WIN32_LEAN_AND_MEAN
952 #if defined(_MSC_VER) && (_MSC_VER < 1300)
955 #include <winsock2.h>
956 #include <ws2tcpip.h>
961 AC_CHECK_TYPES([rlim_t], , ,
962 [#ifdef HAVE_SYS_TYPES_H
963 #include <sys/types.h>
965 #ifdef HAVE_SYS_TIME_H
966 #include <sys/time.h>
968 #ifdef HAVE_SYS_RESOURCE_H
969 #include <sys/resource.h>
973 AX_CHECK_SIGN([time_t],
974 [ AC_DEFINE(TIME_T_IS_SIGNED, 1, [Define if time_t is signed]) ],
976 #ifdef HAVE_SYS_TYPES_H
977 #include <sys/types.h>
979 #ifdef HAVE_SYS_TIME_H
980 #include <sys/time.h>
987 if test "$ax_cv_decl_time_t_signed" = no; then
988 AC_MSG_WARN([You have an unsigned time_t; some things will probably break. Please tell the Tor developers about your interesting platform.])
991 AX_CHECK_SIGN([size_t],
992 [ tor_cv_size_t_signed=yes ],
993 [ tor_cv_size_t_signed=no ], [
994 #ifdef HAVE_SYS_TYPES_H
995 #include <sys/types.h>
999 if test "$ax_cv_decl_size_t_signed" = yes; then
1000 AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
1003 AX_CHECK_SIGN([enum always],
1004 [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
1006 enum always { AAA, BBB, CCC };
1009 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
1010 #ifdef HAVE_SYS_SOCKET_H
1011 #include <sys/socket.h>
1015 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1017 AC_CHECK_SIZEOF(cell_t)
1019 # Now make sure that NULL can be represented as zero bytes.
1020 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1021 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1022 [[#include <stdlib.h>
1025 #ifdef HAVE_STDDEF_H
1028 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1029 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1030 [tor_cv_null_is_zero=yes],
1031 [tor_cv_null_is_zero=no],
1032 [tor_cv_null_is_zero=cross])])
1034 if test "$tor_cv_null_is_zero" = cross ; then
1035 # Cross-compiling; let's hope that the target isn't raving mad.
1036 AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
1039 if test "$tor_cv_null_is_zero" != no; then
1040 AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1041 [Define to 1 iff memset(0) sets pointers to NULL])
1044 AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
1045 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1046 [[#include <stdlib.h>
1049 #ifdef HAVE_STDDEF_H
1052 int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
1053 return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
1054 [tor_cv_dbl0_is_zero=yes],
1055 [tor_cv_dbl0_is_zero=no],
1056 [tor_cv_dbl0_is_zero=cross])])
1058 if test "$tor_cv_dbl0_is_zero" = cross ; then
1059 # Cross-compiling; let's hope that the target isn't raving mad.
1060 AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
1063 if test "$tor_cv_dbl0_is_zero" != no; then
1064 AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
1065 [Define to 1 iff memset(0) sets doubles to 0.0])
1068 # And what happens when we malloc zero?
1069 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
1070 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1071 [[#include <stdlib.h>
1074 #ifdef HAVE_STDDEF_H
1077 int main () { return malloc(0)?0:1; }]])],
1078 [tor_cv_malloc_zero_works=yes],
1079 [tor_cv_malloc_zero_works=no],
1080 [tor_cv_malloc_zero_works=cross])])
1082 if test "$tor_cv_malloc_zero_works" = cross; then
1083 # Cross-compiling; let's hope that the target isn't raving mad.
1084 AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
1087 if test "$tor_cv_malloc_zero_works" = yes; then
1088 AC_DEFINE([MALLOC_ZERO_WORKS], 1,
1089 [Define to 1 iff malloc(0) returns a pointer])
1092 # whether we seem to be in a 2s-complement world.
1093 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
1094 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1095 [[int main () { int problem = ((-99) != (~99)+1);
1096 return problem ? 1 : 0; }]])],
1097 [tor_cv_twos_complement=yes],
1098 [tor_cv_twos_complement=no],
1099 [tor_cv_twos_complement=cross])])
1101 if test "$tor_cv_twos_complement" = cross ; then
1102 # Cross-compiling; let's hope that the target isn't raving mad.
1103 AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
1106 if test "$tor_cv_twos_complement" != no ; then
1107 AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
1108 [Define to 1 iff we represent negative integers with two's complement])
1111 # What does shifting a negative value do?
1112 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
1113 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1114 [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
1115 [tor_cv_sign_extend=yes],
1116 [tor_cv_sign_extend=no],
1117 [tor_cv_sign_extend=cross])])
1119 if test "$tor_cv_sign_extend" = cross ; then
1120 # Cross-compiling; let's hope that the target isn't raving mad.
1121 AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
1124 if test "$tor_cv_sign_extend" != no ; then
1125 AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
1126 [Define to 1 iff right-shifting a negative value performs sign-extension])
1129 # Whether we should use the dmalloc memory allocation debugging library.
1130 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
1131 AC_ARG_WITH(dmalloc,
1132 [ --with-dmalloc Use debug memory allocation library. ],
1133 [if [[ "$withval" = "yes" ]]; then
1139 fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
1142 if [[ $dmalloc -eq 1 ]]; then
1143 AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
1144 AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
1145 AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
1146 AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
1147 AC_CHECK_FUNCS(dmalloc_strdup dmalloc_strndup)
1150 AC_ARG_WITH(tcmalloc,
1151 [ --with-tcmalloc Use tcmalloc memory allocation library. ],
1152 [ tcmalloc=yes ], [ tcmalloc=no ])
1154 if test x$tcmalloc = xyes ; then
1155 LDFLAGS="-ltcmalloc $LDFLAGS"
1158 using_custom_malloc=no
1159 if test x$enable_openbsd_malloc = xyes ; then
1160 using_custom_malloc=yes
1162 if test x$tcmalloc = xyes ; then
1163 using_custom_malloc=yes
1165 if test $using_custom_malloc = no ; then
1166 AC_CHECK_FUNCS(mallinfo)
1169 # By default, we're going to assume we don't have mlockall()
1170 # bionic and other platforms have various broken mlockall subsystems.
1171 # Some systems don't have a working mlockall, some aren't linkable,
1172 # and some have it but don't declare it.
1173 AC_CHECK_FUNCS(mlockall)
1174 AC_CHECK_DECLS([mlockall], , , [
1175 #ifdef HAVE_SYS_MMAN_H
1176 #include <sys/mman.h>
1179 # Allow user to specify an alternate syslog facility
1180 AC_ARG_WITH(syslog-facility,
1181 [ --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
1182 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
1183 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
1184 AC_SUBST(LOGFACILITY)
1186 # Check if we have getresuid and getresgid
1187 AC_CHECK_FUNCS(getresuid getresgid)
1189 # Check for gethostbyname_r in all its glorious incompatible versions.
1190 # (This logic is based on that in Python's configure.in)
1191 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
1192 [Define this if you have any gethostbyname_r()])
1194 AC_CHECK_FUNC(gethostbyname_r, [
1195 AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
1197 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1198 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1202 struct hostent *h1, *h2;
1204 (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
1206 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1207 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
1208 [Define this if gethostbyname_r takes 6 arguments])
1217 (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
1219 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1220 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
1221 [Define this if gethostbyname_r takes 5 arguments])
1229 struct hostent_data hd;
1230 (void) gethostbyname_r(cp1,h1,&hd);
1232 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1233 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
1234 [Define this if gethostbyname_r takes 3 arguments])
1244 AC_CACHE_CHECK([whether the C compiler supports __func__],
1245 tor_cv_have_func_macro,
1246 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1248 int main(int c, char **v) { puts(__func__); }])],
1249 tor_cv_have_func_macro=yes,
1250 tor_cv_have_func_macro=no))
1252 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
1253 tor_cv_have_FUNC_macro,
1254 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1256 int main(int c, char **v) { puts(__FUNC__); }])],
1257 tor_cv_have_FUNC_macro=yes,
1258 tor_cv_have_FUNC_macro=no))
1260 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
1261 tor_cv_have_FUNCTION_macro,
1262 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1264 int main(int c, char **v) { puts(__FUNCTION__); }])],
1265 tor_cv_have_FUNCTION_macro=yes,
1266 tor_cv_have_FUNCTION_macro=no))
1268 AC_CACHE_CHECK([whether we have extern char **environ already declared],
1269 tor_cv_have_environ_declared,
1270 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1271 /* We define _GNU_SOURCE here because it is also defined in compat.c.
1272 * Without it environ doesn't get declared. */
1274 #ifdef HAVE_UNISTD_H
1278 int main(int c, char **v) { char **t = environ; }])],
1279 tor_cv_have_environ_declared=yes,
1280 tor_cv_have_environ_declared=no))
1282 if test "$tor_cv_have_func_macro" = 'yes'; then
1283 AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
1286 if test "$tor_cv_have_FUNC_macro" = 'yes'; then
1287 AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
1290 if test "$tor_cv_have_FUNCTION_macro" = 'yes'; then
1291 AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
1292 [Defined if the compiler supports __FUNCTION__])
1295 if test "$tor_cv_have_environ_declared" = 'yes'; then
1296 AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
1297 [Defined if we have extern char **environ already declared])
1300 # $prefix stores the value of the --prefix command line option, or
1301 # NONE if the option wasn't set. In the case that it wasn't set, make
1302 # it be the default, so that we can use it to expand directories now.
1303 if test "x$prefix" = "xNONE"; then
1304 prefix=$ac_default_prefix
1307 # and similarly for $exec_prefix
1308 if test "x$exec_prefix" = "xNONE"; then
1312 if test "x$BUILDDIR" = "x"; then
1316 AH_TEMPLATE([BUILDDIR],[tor's build directory])
1317 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
1319 if test "x$CONFDIR" = "x"; then
1320 CONFDIR=`eval echo $sysconfdir/tor`
1323 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
1324 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
1326 BINDIR=`eval echo $bindir`
1328 LOCALSTATEDIR=`eval echo $localstatedir`
1329 AC_SUBST(LOCALSTATEDIR)
1331 if test "$bwin32" = true; then
1332 # Test if the linker supports the --nxcompat and --dynamicbase options
1334 save_LDFLAGS="$LDFLAGS"
1335 LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
1336 AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
1337 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
1338 [AC_MSG_RESULT([yes])]
1339 [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
1340 [AC_MSG_RESULT([no])]
1342 LDFLAGS="$save_LDFLAGS"
1345 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
1346 # than autoconf's macros like.
1347 if test "$GCC" = yes; then
1348 # Disable GCC's strict aliasing checks. They are an hours-to-debug
1349 # accident waiting to happen.
1350 CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
1352 # Autoconf sets -g -O2 by default. Override optimization level
1353 # for non-gcc compilers
1355 enable_gcc_warnings=no
1356 enable_gcc_warnings_advisory=no
1359 # OS X Lion started deprecating the system openssl. Let's just disable
1360 # all deprecation warnings on OS X. Also, to potentially make the binary
1361 # a little smaller, let's enable dead_strip.
1365 CFLAGS="$CFLAGS -Wno-deprecated-declarations"
1366 LDFLAGS="$LDFLAGS -dead_strip" ;;
1369 # Add some more warnings which we use in development but not in the
1370 # released versions. (Some relevant gcc versions can't handle these.)
1371 if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xyes; then
1373 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1374 #if !defined(__GNUC__) || (__GNUC__ < 4)
1376 #endif])], have_gcc4=yes, have_gcc4=no)
1378 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1379 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
1381 #endif])], have_gcc42=yes, have_gcc42=no)
1383 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1384 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
1386 #endif])], have_gcc43=yes, have_gcc43=no)
1388 save_CFLAGS="$CFLAGS"
1389 CFLAGS="$CFLAGS -Wshorten-64-to-32"
1390 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
1391 have_shorten64_flag=no)
1392 CFLAGS="$save_CFLAGS"
1395 *-*-openbsd* | *-*-bitrig*)
1396 # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
1397 # That's fine, except that the headers don't pass -Wredundant-decls.
1398 # Therefore, let's disable -Wsystem-headers when we're building
1399 # with maximal warnings on OpenBSD.
1400 CFLAGS="$CFLAGS -Wno-system-headers" ;;
1403 CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
1404 CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
1405 CFLAGS="$CFLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
1406 CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
1407 CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
1409 if test x$enable_gcc_warnings = xyes; then
1410 CFLAGS="$CFLAGS -Werror"
1413 # Disabled, so we can use mallinfo(): -Waggregate-return
1415 if test x$have_gcc4 = xyes ; then
1416 # These warnings break gcc 3.3.5 and work on gcc 4.0.2
1417 CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement -Wold-style-definition"
1420 if test x$have_gcc42 = xyes ; then
1421 # These warnings break gcc 4.0.2 and work on gcc 4.2
1422 # XXXX020 See if any of these work with earlier versions.
1423 CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wstrict-overflow=1"
1425 # We used to use -Wstrict-overflow=5, but that breaks us heavily under 4.3.
1428 if test x$have_gcc42 = xyes && test x$have_clang = xno; then
1429 # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2
1430 CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init"
1433 if test x$have_gcc43 = xyes ; then
1434 # These warnings break gcc 4.2 and work on gcc 4.3
1435 # XXXX020 See if any of these work with earlier versions.
1436 CFLAGS="$CFLAGS -Wextra -Warray-bounds"
1439 if test x$have_shorten64_flag = xyes ; then
1440 CFLAGS="$CFLAGS -Wshorten-64-to-32"
1443 ##This will break the world on some 64-bit architectures
1444 # CFLAGS="$CFLAGS -Winline"
1449 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
1455 contrib/tor.logrotate
1459 src/config/torrc.sample
1464 if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
1465 ./contrib/updateVersions.pl