1 dnl Copyright (c) 2001-2004, Roger Dingledine
2 dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
3 dnl Copyright (c) 2007-2012, The Tor Project, Inc.
4 dnl See LICENSE for licensing information
6 AC_INIT([tor],[0.2.4.7-alpha-dev])
7 AC_CONFIG_SRCDIR([src/or/main.c])
9 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
10 AC_CONFIG_HEADERS([orconfig.h])
14 if test -f /etc/redhat-release ; then
15 if test -f /usr/kerberos/include ; then
16 CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
20 # Not a no-op; we want to make sure that CPPFLAGS is set before we use
21 # the += operator on it in src/or/Makefile.am
22 CPPFLAGS="$CPPFLAGS -I\${top_srcdir}/src/common"
24 #XXXX020 We should make these enabled or not, before 0.2.0.x-final
25 AC_ARG_ENABLE(buf-freelists,
26 AS_HELP_STRING(--disable-buf-freelists, disable freelists for buffer RAM))
27 AC_ARG_ENABLE(openbsd-malloc,
28 AS_HELP_STRING(--enable-openbsd-malloc, Use malloc code from openbsd. Linux only))
29 AC_ARG_ENABLE(instrument-downloads,
30 AS_HELP_STRING(--enable-instrument-downloads, Instrument downloads of directory resources etc.))
31 AC_ARG_ENABLE(static-openssl,
32 AS_HELP_STRING(--enable-static-openssl, Link against a static openssl library. Requires --with-openssl-dir))
33 AC_ARG_ENABLE(static-libevent,
34 AS_HELP_STRING(--enable-static-libevent, Link against a static libevent library. Requires --with-libevent-dir))
35 AC_ARG_ENABLE(static-zlib,
36 AS_HELP_STRING(--enable-static-zlib, Link against a static zlib library. Requires --with-zlib-dir))
37 AC_ARG_ENABLE(static-tor,
38 AS_HELP_STRING(--enable-static-tor, Create an entirely static Tor binary. Requires --with-openssl-dir and --with-libevent-dir and --with-zlib-dir))
39 AC_ARG_ENABLE(curve25519,
40 AS_HELP_STRING(--disable-curve25519, Build Tor with no curve25519 elliptic-curve crypto support))
42 if test "$enable_static_tor" = "yes"; then
43 enable_static_libevent="yes";
44 enable_static_openssl="yes";
45 enable_static_zlib="yes";
46 CFLAGS="$CFLAGS -static"
49 if test x$enable_buf_freelists != xno; then
50 AC_DEFINE(ENABLE_BUF_FREELISTS, 1,
51 [Defined if we try to use freelists for buffer RAM chunks])
53 AM_CONDITIONAL(USE_OPENBSD_MALLOC, test x$enable_openbsd_malloc = xyes)
54 if test x$enable_instrument_downloads = xyes; then
55 AC_DEFINE(INSTRUMENT_DOWNLOADS, 1,
56 [Defined if we want to keep track of how much of each kind of resource we download.])
59 AC_ARG_ENABLE(transparent,
60 AS_HELP_STRING(--disable-transparent, disable transparent proxy support),
61 [case "${enableval}" in
62 yes) transparent=true ;;
63 no) transparent=false ;;
64 *) AC_MSG_ERROR(bad value for --enable-transparent) ;;
65 esac], [transparent=true])
67 AC_ARG_ENABLE(asciidoc,
68 AS_HELP_STRING(--disable-asciidoc, don't use asciidoc (disables building of manpages)),
69 [case "${enableval}" in
72 *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
73 esac], [asciidoc=true])
75 # By default, we're not ready to ship a NAT-PMP aware Tor
76 AC_ARG_ENABLE(nat-pmp,
77 AS_HELP_STRING(--enable-nat-pmp, enable NAT-PMP support),
78 [case "${enableval}" in
81 * ) AC_MSG_ERROR(bad value for --enable-nat-pmp) ;;
82 esac], [natpmp=false])
84 # By default, we're not ready to ship a UPnP aware Tor
86 AS_HELP_STRING(--enable-upnp, enable UPnP support),
87 [case "${enableval}" in
90 * ) AC_MSG_ERROR(bad value for --enable-upnp) ;;
94 AC_ARG_ENABLE(threads,
95 AS_HELP_STRING(--disable-threads, disable multi-threading support))
97 if test x$enable_threads = x; then
100 # Don't try multithreading on solaris -- cpuworkers seem to lock.
101 AC_MSG_NOTICE([You are running Solaris; Sometimes threading makes
102 cpu workers lock up here, so I will disable threads.])
103 enable_threads="no";;
105 enable_threads="yes";;
109 if test "$enable_threads" = "yes"; then
110 AC_DEFINE(ENABLE_THREADS, 1, [Defined if we will try to use multithreading])
115 AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
119 AC_ARG_ENABLE(gcc-warnings,
120 AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings))
121 AC_ARG_ENABLE(gcc-warnings-advisory,
122 AS_HELP_STRING(--enable-gcc-warnings-advisory, [enable verbose warnings, excluding -Werror]))
124 dnl Adam shostack suggests the following for Windows:
125 dnl -D_FORTIFY_SOURCE=2 -fstack-protector-all
126 dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
127 dnl This requires that we use gcc and that we add -O2 to the CFLAGS.
128 AC_ARG_ENABLE(gcc-hardening,
129 AS_HELP_STRING(--disable-gcc-hardening, disable compiler security checks))
131 dnl Linker hardening options
132 dnl Currently these options are ELF specific - you can't use this with MacOSX
133 AC_ARG_ENABLE(linker-hardening,
134 AS_HELP_STRING(--disable-linker-hardening, disable linker security fixups))
136 AC_ARG_ENABLE(local-appdata,
137 AS_HELP_STRING(--enable-local-appdata, default to host local application data paths on Windows))
138 if test "$enable_local_appdata" = "yes"; then
139 AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
140 [Defined if we default to host local appdata paths on Windows])
144 AC_ARG_ENABLE(tor2web-mode,
145 AS_HELP_STRING(--enable-tor2web-mode, support tor2web non-anonymous mode),
146 [if test x$enableval = xyes; then
147 CFLAGS="$CFLAGS -D ENABLE_TOR2WEB_MODE=1"
150 AC_ARG_ENABLE(bufferevents,
151 AS_HELP_STRING(--enable-bufferevents, use Libevent's buffered IO.))
153 dnl check for the correct "ar" when cross-compiling
154 AN_MAKEVAR([AR], [AC_PROG_AR])
155 AN_PROGRAM([ar], [AC_PROG_AR])
156 AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [ar])])
164 dnl autoconf 2.59 appears not to support AC_PROG_SED
165 AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
167 dnl check for asciidoc and a2x
168 AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
169 AC_PATH_PROG([A2X], [a2x], none)
171 AM_CONDITIONAL(USE_ASCIIDOC, test x$asciidoc = xtrue)
173 AM_CONDITIONAL(USE_FW_HELPER, test x$natpmp = xtrue || test x$upnp = xtrue)
174 AM_CONDITIONAL(NAT_PMP, test x$natpmp = xtrue)
175 AM_CONDITIONAL(MINIUPNPC, test x$upnp = xtrue)
178 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
179 AC_C_FLEXIBLE_ARRAY_MEMBER
181 dnl Maybe we've got an old autoconf...
182 AC_CACHE_CHECK([for flexible array members],
186 struct abc { int a; char b[]; };
188 struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
191 [tor_cv_c_flexarray=yes],
192 [tor_cv_c_flexarray=no])])
193 if test $tor_cv_flexarray = yes ; then
194 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
196 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
200 AC_PATH_PROG([SHA1SUM], [sha1sum], none)
201 AC_PATH_PROG([OPENSSL], [openssl], none)
204 AC_ARG_WITH(tor-user,
205 [ --with-tor-user=NAME Specify username for tor daemon ],
213 AC_ARG_WITH(tor-group,
214 [ --with-tor-group=NAME Specify group name for tor daemon ],
222 dnl If _WIN32 is defined and non-zero, we are building for win32
223 AC_MSG_CHECKING([for win32])
224 AC_RUN_IFELSE([AC_LANG_SOURCE([
225 int main(int c, char **v) {
236 bwin32=true; AC_MSG_RESULT([yes]),
237 bwin32=false; AC_MSG_RESULT([no]),
238 bwin32=cross; AC_MSG_RESULT([cross])
241 if test "$bwin32" = cross; then
242 AC_MSG_CHECKING([for win32 (cross)])
243 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
245 int main(int c, char **v) {return 0;}
248 int main(int c, char **v) {return x(y);}
251 bwin32=true; AC_MSG_RESULT([yes]),
252 bwin32=false; AC_MSG_RESULT([no]))
255 AM_CONDITIONAL(BUILD_NT_SERVICES, test x$bwin32 = xtrue)
257 dnl Enable C99 when compiling with MIPSpro
258 AC_MSG_CHECKING([for MIPSpro compiler])
259 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
260 #if (defined(__sgi) && defined(_COMPILER_VERSION))
265 bmipspro=false; AC_MSG_RESULT(no),
266 bmipspro=true; AC_MSG_RESULT(yes))
268 if test "$bmipspro" = true; then
269 CFLAGS="$CFLAGS -c99"
274 AC_SEARCH_LIBS(socket, [socket network])
275 AC_SEARCH_LIBS(gethostbyname, [nsl])
276 AC_SEARCH_LIBS(dlopen, [dl])
277 AC_SEARCH_LIBS(inet_aton, [resolv])
279 AC_SEARCH_LIBS([clock_gettime], [rt])
280 if test "$LIBS" != "$saved_LIBS"; then
281 # Looks like we need -lrt for clock_gettime().
285 if test "$enable_threads" = "yes"; then
286 AC_SEARCH_LIBS(pthread_create, [pthread])
287 AC_SEARCH_LIBS(pthread_detach, [pthread])
290 dnl -------------------------------------------------------------------
291 dnl Check for functions before libevent, since libevent-1.2 apparently
292 dnl exports strlcpy without defining it in a header.
326 if test "$enable_threads" = "yes"; then
327 AC_CHECK_HEADERS(pthread.h)
328 AC_CHECK_FUNCS(pthread_create)
331 dnl ------------------------------------------------------
332 dnl Where do you live, libevent? And how do we call you?
334 if test "$bwin32" = true; then
335 TOR_LIB_WS32=-lws2_32
336 TOR_LIB_IPHLPAPI=-liphlpapi
337 # Some of the cargo-cults recommend -lwsock32 as well, but I don't
338 # think it's actually necessary.
344 AC_SUBST(TOR_LIB_WS32)
345 AC_SUBST(TOR_LIB_GDI)
346 AC_SUBST(TOR_LIB_IPHLPAPI)
348 dnl We need to do this before we try our disgusting hack below.
349 AC_CHECK_HEADERS([sys/types.h])
351 dnl This is a disgusting hack so we safely include older libevent headers.
352 AC_CHECK_TYPE(u_int64_t, unsigned long long)
353 AC_CHECK_TYPE(u_int32_t, unsigned long)
354 AC_CHECK_TYPE(u_int16_t, unsigned short)
355 AC_CHECK_TYPE(u_int8_t, unsigned char)
357 tor_libevent_pkg_redhat="libevent"
358 tor_libevent_pkg_debian="libevent-dev"
359 tor_libevent_devpkg_redhat="libevent-devel"
360 tor_libevent_devpkg_debian="libevent-dev"
362 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
363 dnl linking for static builds.
364 STATIC_LIBEVENT_FLAGS=""
365 if test "$enable_static_libevent" = "yes"; then
366 if test "$have_rt" = yes; then
367 STATIC_LIBEVENT_FLAGS=" -lrt "
371 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
373 #include <winsock2.h>
376 #include <sys/time.h>
377 #include <sys/types.h>
378 #include <event.h>], [
380 #include <winsock2.h>
382 void exit(int); void *event_init(void);],
385 {WSADATA d; WSAStartup(0x101,&d); }
387 event_init(); exit(0);
388 ], [--with-libevent-dir], [/opt/libevent])
390 dnl Now check for particular libevent functions.
392 save_LDFLAGS="$LDFLAGS"
393 save_CPPFLAGS="$CPPFLAGS"
394 LIBS="-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $LIBS"
395 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
396 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
397 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)
398 AC_CHECK_MEMBERS([struct event.min_heap_idx], , ,
402 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
405 LDFLAGS="$save_LDFLAGS"
406 CPPFLAGS="$save_CPPFLAGS"
409 AM_CONDITIONAL(USE_EXTERNAL_EVDNS, test x$ac_cv_header_event2_dns_h = xyes)
411 if test "$enable_static_libevent" = "yes"; then
412 if test "$tor_cv_library_libevent_dir" = "(system)"; then
413 AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
415 TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
418 TOR_LIBEVENT_LIBS="-levent"
421 dnl This isn't the best test for Libevent 2.0.3-alpha. Once it's released,
422 dnl we can do much better.
423 if test "$enable_bufferevents" = "yes" ; then
424 if test "$ac_cv_header_event2_bufferevent_ssl_h" != "yes" ; then
425 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.])
428 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
430 # Check for the right version. First see if version detection works.
431 AC_MSG_CHECKING([whether we can detect the Libevent version])
432 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
433 #include <event2/event.h>
434 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 10
440 ])], [event_version_number_works=yes; AC_MSG_RESULT([yes]) ],
441 [event_version_number_works=no; AC_MSG_RESULT([no])])
442 if test "$event_version_number_works" != 'yes'; then
443 AC_MSG_WARN([Version detection on Libevent seems broken. Your Libevent installation is probably screwed up or very old.])
445 AC_MSG_CHECKING([whether Libevent is new enough for bufferevents])
446 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
447 #include <event2/event.h>
448 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000d00
454 ])], [ AC_MSG_RESULT([yes]) ],
455 [ AC_MSG_RESULT([no])
456 AC_MSG_ERROR([Libevent does not seem new enough to support bufferevents. We require 2.0.13-stable or later]) ] )
462 LDFLAGS="$save_LDFLAGS"
463 CPPFLAGS="$save_CPPFLAGS"
465 AM_CONDITIONAL(USE_BUFFEREVENTS, test "$enable_bufferevents" = "yes")
466 if test "$enable_bufferevents" = "yes"; then
467 AC_DEFINE(USE_BUFFEREVENTS, 1, [Defined if we're going to use Libevent's buffered IO API])
468 if test "$enable_static_libevent" = "yes"; then
469 TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent_openssl.a $TOR_LIBEVENT_LIBS"
471 TOR_LIBEVENT_LIBS="-levent_openssl $TOR_LIBEVENT_LIBS"
474 AC_SUBST(TOR_LIBEVENT_LIBS)
476 dnl ------------------------------------------------------
477 dnl Where do you live, libm?
479 dnl On some platforms (Haiku/BeOS) the math library is
480 dnl part of libroot. In which case don't link against lm
483 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
484 if test "$ac_cv_search_pow" != "none required"; then
485 TOR_LIB_MATH="$ac_cv_search_pow"
488 AC_SUBST(TOR_LIB_MATH)
490 dnl ------------------------------------------------------
491 dnl Where do you live, openssl? And how do we call you?
493 tor_openssl_pkg_redhat="openssl"
494 tor_openssl_pkg_debian="libssl"
495 tor_openssl_devpkg_redhat="openssl-devel"
496 tor_openssl_devpkg_debian="libssl-dev"
498 ALT_openssl_WITHVAL=""
500 [ --with-ssl-dir=PATH Obsolete alias for --with-openssl-dir ],
502 if test "x$withval" != xno && test "x$withval" != "x" ; then
503 ALT_openssl_WITHVAL="$withval"
507 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI],
508 [#include <openssl/rand.h>],
509 [void RAND_add(const void *buf, int num, double entropy);],
510 [RAND_add((void*)0,0,0); exit(0);], [],
511 [/usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /opt/openssl])
513 dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
515 if test "$enable_static_openssl" = "yes"; then
516 if test "$tor_cv_library_openssl_dir" = "(system)"; then
517 AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
519 TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
522 TOR_OPENSSL_LIBS="-lssl -lcrypto"
524 AC_SUBST(TOR_OPENSSL_LIBS)
526 dnl ------------------------------------------------------
527 dnl Where do you live, zlib? And how do we call you?
529 tor_zlib_pkg_redhat="zlib"
530 tor_zlib_pkg_debian="zlib1g"
531 tor_zlib_devpkg_redhat="zlib-devel"
532 tor_zlib_devpkg_debian="zlib1g-dev"
534 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
536 [const char * zlibVersion(void);],
537 [zlibVersion(); exit(0);], [--with-zlib-dir],
540 if test "$enable_static_zlib" = "yes"; then
541 if test "$tor_cv_library_zlib_dir" = "(system)"; then
542 AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
543 using --enable-static-zlib")
545 TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
550 AC_SUBST(TOR_ZLIB_LIBS)
552 dnl ---------------------------------------------------------------------
553 dnl Now that we know about our major libraries, we can check for compiler
554 dnl and linker hardening options. We need to do this with the libraries known,
555 dnl since sometimes the linker will like an option but not be willing to
556 dnl use it with a build of a library.
558 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
559 all_libs_for_check="$TOR_ZLIB_LIBS $TOR_LIB_MATH $TOR_LIBEVENT_LIBS $TOR_OPENSSL_LIBS $TOR_LIB_WS32 $TOR_LIB_GDI"
561 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
562 #if !defined(__clang__)
564 #endif])], have_clang=yes, have_clang=no)
566 if test x$enable_gcc_hardening != xno; then
567 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
568 if test x$have_clang = xyes; then
569 TOR_CHECK_CFLAGS(-Qunused-arguments)
571 TOR_CHECK_CFLAGS(-fstack-protector-all)
572 TOR_CHECK_CFLAGS(-Wstack-protector)
573 TOR_CHECK_CFLAGS(-fwrapv)
574 TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
575 if test "$bwin32" = "false"; then
576 TOR_CHECK_CFLAGS(-fPIE)
577 TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
581 if test x$enable_linker_hardening != xno; then
582 TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
585 dnl ------------------------------------------------------
586 dnl Where do you live, libnatpmp? And how do we call you?
587 dnl There are no packages for Debian or Redhat as of this patch
589 if test "$natpmp" = "true"; then
590 AC_DEFINE(NAT_PMP, 1, [Define to 1 if we are building with nat-pmp.])
591 TOR_SEARCH_LIBRARY(libnatpmp, $trylibnatpmpdir, [-lnatpmp $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
592 [#include <natpmp.h>],
596 #include <natpmp.h>],
599 natpmpresp_t response;
600 r = initnatpmp(&natpmp, 0, 0);],
601 [printf("initnatpmp() returned %d (%s)\n", r, r?"FAILED":"SUCCESS");
603 [--with-libnatpmp-dir],
608 dnl ------------------------------------------------------
609 dnl Where do you live, libminiupnpc? And how do we call you?
610 dnl There are no packages for Debian or Redhat as of this patch
612 if test "$upnp" = "true"; then
613 AC_DEFINE(MINIUPNPC, 1, [Define to 1 if we are building with UPnP.])
615 dnl Before we call TOR_SEARCH_LIBRARY we'll do a quick compile test
616 dnl to see if we have miniupnpc-1.5 or -1.6
617 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <miniupnpc/miniupnpc.h>],
618 [upnpDiscover(1, 0, 0, 0);exit(0);])],[miniupnpc15="true"],[miniupnpc15="false"])
620 if test "$miniupnpc15" = "true" ; then
621 AC_DEFINE([MINIUPNPC15],[1],[libminiupnpc version 1.5 found])
622 TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
623 [#include <miniupnpc/miniwget.h>
624 #include <miniupnpc/miniupnpc.h>
625 #include <miniupnpc/upnpcommands.h>],
626 [void upnpDiscover(int delay, const char * multicastif,
627 const char * minissdpdsock, int sameport);],
628 [upnpDiscover(1, 0, 0, 0); exit(0);],
629 [--with-libminiupnpc-dir],
632 TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
633 [#include <miniupnpc/miniwget.h>
634 #include <miniupnpc/miniupnpc.h>
635 #include <miniupnpc/upnpcommands.h>],
636 [void upnpDiscover(int delay, const char * multicastif,
637 const char * minissdpdsock, int sameport, int ipv6, int * error);],
638 [upnpDiscover(1, 0, 0, 0, 0, 0); exit(0);],
639 [--with-libminiupnpc-dir],
644 dnl ============================================================
645 dnl We need an implementation of curve25519.
647 dnl set these defaults.
649 build_curve25519_donna=no
650 build_curve25519_donna_c64=no
651 use_curve25519_donna=no
652 use_curve25519_nacl=no
655 if test x$enable_curve25519 != xno; then
657 dnl The best choice is using curve25519-donna-c64, but that requires
659 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
660 tor_cv_can_use_curve25519_donna_c64,
662 [AC_LANG_PROGRAM([dnl
664 typedef unsigned uint128_t __attribute__((mode(TI)));
666 uint64_t a = ((uint64_t)2000000000) * 1000000000;
667 uint64_t b = ((uint64_t)1234567890) << 24;
668 uint128_t c = ((uint128_t)a) * b;
669 return ((uint64_t)(c>>96)) == 522859 &&
670 ((uint64_t)(c>>64))&0xffffffffL == 3604448702L &&
671 ((uint64_t)(c>>32))&0xffffffffL == 2351960064L &&
672 ((uint64_t)(c))&0xffffffffL == 0;
674 [tor_cv_can_use_curve25519_donna_c64=yes],
675 [tor_cv_can_use_curve25519_donna_c64=no],
677 [AC_LANG_PROGRAM([dnl
679 typedef unsigned uint128_t __attribute__((mode(TI)));
681 uint64_t a = ((uint64_t)2000000000) * 1000000000;
682 uint64_t b = ((uint64_t)1234567890) << 24;
683 uint128_t c = ((uint128_t)a) * b;
684 return ((uint64_t)(c>>96)) == 522859 &&
685 ((uint64_t)(c>>64))&0xffffffffL == 3604448702L &&
686 ((uint64_t)(c>>32))&0xffffffffL == 2351960064L &&
687 ((uint64_t)(c))&0xffffffffL == 0;
689 [tor_cv_can_use_curve25519_donna_c64=cross],
690 [tor_cv_can_use_curve25519_donna_c64=no])])])
692 AC_CACHE_CHECK([whether we can use curve25519 from nacl],
693 tor_cv_can_use_curve25519_nacl,
694 [tor_saved_LIBS="$LIBS"
697 [AC_LANG_PROGRAM([dnl
698 #include <crypto_scalarmult_curve25519.h>
699 #ifdef crypto_scalarmult_curve25519_ref_BYTES
700 #error Hey, this is the reference implementation!
703 unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
704 ])], [tor_cv_can_use_curve25519_nacl=yes],
705 [tor_cv_can_use_curve25519_nacl=no])
706 LIBS="$tor_saved_LIBS" ])
708 dnl Okay, now we need to figure out which one to actually use. Fall back
709 dnl to curve25519-donna.c
711 if test x$tor_cv_can_use_curve25519_donna_c64 != xno; then
712 build_curve25519_donna_c64=yes
713 use_curve25519_donna=yes
714 elif test x$tor_cv_can_use_curve25519_nacl = xyes; then
715 use_curve25519_nacl=yes
716 CURVE25519_LIBS=-lnacl
718 build_curve25519_donna=yes
719 use_curve25519_donna=yes
721 have_a_curve25519=yes
724 if test x$have_a_curve25519 = xyes; then
725 AC_DEFINE(CURVE25519_ENABLED, 1,
726 [Defined if we have a curve25519 implementation])
728 if test x$use_curve25519_donna = xyes; then
729 AC_DEFINE(USE_CURVE25519_DONNA, 1,
730 [Defined if we should use an internal curve25519_donna{,_c64} implementation])
732 if test x$use_curve25519_nacl = xyes; then
733 AC_DEFINE(USE_CURVE25519_NACL, 1,
734 [Defined if we should use a curve25519 from nacl])
736 AM_CONDITIONAL(BUILD_CURVE25519_DONNA, test x$build_curve25519_donna = xyes)
737 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64, test x$build_curve25519_donna_c64 = xyes)
738 AM_CONDITIONAL(CURVE25519_ENABLED, test x$have_a_curve25519 = xyes)
739 AC_SUBST(CURVE25519_LIBS)
741 dnl Make sure to enable support for large off_t if available.
756 , , 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.))
758 dnl These headers are not essential
795 AC_CHECK_HEADERS(sys/param.h)
797 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
798 [#ifdef HAVE_SYS_TYPES_H
799 #include <sys/types.h>
801 #ifdef HAVE_SYS_SOCKET_H
802 #include <sys/socket.h>
804 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
805 [#ifdef HAVE_SYS_TYPES_H
806 #include <sys/types.h>
808 #ifdef HAVE_SYS_SOCKET_H
809 #include <sys/socket.h>
814 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
815 linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
816 [#ifdef HAVE_SYS_TYPES_H
817 #include <sys/types.h>
819 #ifdef HAVE_SYS_SOCKET_H
820 #include <sys/socket.h>
825 #ifdef HAVE_LINUX_TYPES_H
826 #include <linux/types.h>
828 #ifdef HAVE_NETINET_IN6_H
829 #include <netinet/in6.h>
831 #ifdef HAVE_NETINET_IN_H
832 #include <netinet/in.h>
835 if test x$transparent = xtrue ; then
837 if test x$net_if_found = x1 && test x$net_pfvar_found = x1 ; then
840 if test x$linux_netfilter_ipv4 = x1 ; then
843 if test x$transparent_ok = x1 ; then
844 AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
846 *-*-openbsd* | *-*-bitrig*)
847 AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
850 AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
854 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
855 [#ifdef HAVE_SYS_TYPES_H
856 #include <sys/types.h>
858 #ifdef HAVE_SYS_TIME_H
859 #include <sys/time.h>
862 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
865 AC_CHECK_SIZEOF(int8_t)
866 AC_CHECK_SIZEOF(int16_t)
867 AC_CHECK_SIZEOF(int32_t)
868 AC_CHECK_SIZEOF(int64_t)
869 AC_CHECK_SIZEOF(uint8_t)
870 AC_CHECK_SIZEOF(uint16_t)
871 AC_CHECK_SIZEOF(uint32_t)
872 AC_CHECK_SIZEOF(uint64_t)
873 AC_CHECK_SIZEOF(intptr_t)
874 AC_CHECK_SIZEOF(uintptr_t)
876 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
878 AC_CHECK_SIZEOF(char)
879 AC_CHECK_SIZEOF(short)
881 AC_CHECK_SIZEOF(long)
882 AC_CHECK_SIZEOF(long long)
883 AC_CHECK_SIZEOF(__int64)
884 AC_CHECK_SIZEOF(void *)
885 AC_CHECK_SIZEOF(time_t)
886 AC_CHECK_SIZEOF(size_t)
887 AC_CHECK_SIZEOF(pid_t)
889 AC_CHECK_TYPES([uint, u_char, ssize_t])
891 dnl used to include sockaddr_storage, but everybody has that.
892 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
893 [#ifdef HAVE_SYS_TYPES_H
894 #include <sys/types.h>
896 #ifdef HAVE_NETINET_IN_H
897 #include <netinet/in.h>
899 #ifdef HAVE_NETINET_IN6_H
900 #include <netinet/in6.h>
902 #ifdef HAVE_SYS_SOCKET_H
903 #include <sys/socket.h>
906 #define _WIN32_WINNT 0x0501
907 #define WIN32_LEAN_AND_MEAN
908 #if defined(_MSC_VER) && (_MSC_VER < 1300)
911 #include <winsock2.h>
912 #include <ws2tcpip.h>
916 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
917 [#ifdef HAVE_SYS_TYPES_H
918 #include <sys/types.h>
920 #ifdef HAVE_NETINET_IN_H
921 #include <netinet/in.h>
923 #ifdef HAVE_NETINET_IN6_H
924 #include <netinet/in6.h>
926 #ifdef HAVE_SYS_SOCKET_H
927 #include <sys/socket.h>
930 #define _WIN32_WINNT 0x0501
931 #define WIN32_LEAN_AND_MEAN
932 #if defined(_MSC_VER) && (_MSC_VER < 1300)
935 #include <winsock2.h>
936 #include <ws2tcpip.h>
941 AC_CHECK_TYPES([rlim_t], , ,
942 [#ifdef HAVE_SYS_TYPES_H
943 #include <sys/types.h>
945 #ifdef HAVE_SYS_TIME_H
946 #include <sys/time.h>
948 #ifdef HAVE_SYS_RESOURCE_H
949 #include <sys/resource.h>
953 AC_CACHE_CHECK([whether time_t is signed], tor_cv_time_t_signed, [
954 AC_RUN_IFELSE([AC_LANG_SOURCE([
955 #ifdef HAVE_SYS_TYPES_H
956 #include <sys/types.h>
958 #ifdef HAVE_SYS_TIME_H
959 #include <sys/time.h>
964 int main(int c, char**v) { if (((time_t)-1)<0) return 1; else return 0; }])],
965 tor_cv_time_t_signed=no, tor_cv_time_t_signed=yes, tor_cv_time_t_signed=cross)
968 if test "$tor_cv_time_t_signed" = cross; then
969 AC_MSG_NOTICE([Cross compiling: assuming that time_t is signed.])
972 if test "$tor_cv_time_t_signed" != no; then
973 AC_DEFINE([TIME_T_IS_SIGNED], 1,
974 [Define to 1 iff time_t is signed])
977 AC_CACHE_CHECK([whether size_t is signed], tor_cv_size_t_signed, [
978 AC_RUN_IFELSE([AC_LANG_SOURCE([
979 #ifdef HAVE_SYS_TYPES_H
980 #include <sys/types.h>
982 int main(int c, char**v) { if (((size_t)-1)<0) return 1; else return 0; }])],
983 tor_cv_size_t_signed=no, tor_cv_size_t_signed=yes, tor_cv_size_t_signed=cross)
986 if test "$tor_cv_size_t_signed" = cross; then
987 AC_MSG_NOTICE([Cross compiling: assuming that size_t is not signed.])
990 if test "$tor_cv_size_t_signed" = yes; then
991 AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
994 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
995 #ifdef HAVE_SYS_SOCKET_H
996 #include <sys/socket.h>
1000 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1002 AC_CHECK_SIZEOF(cell_t)
1004 # Now make sure that NULL can be represented as zero bytes.
1005 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1006 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1007 [[#include <stdlib.h>
1010 #ifdef HAVE_STDDEF_H
1013 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1014 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1015 [tor_cv_null_is_zero=yes],
1016 [tor_cv_null_is_zero=no],
1017 [tor_cv_null_is_zero=cross])])
1019 if test "$tor_cv_null_is_zero" = cross ; then
1020 # Cross-compiling; let's hope that the target isn't raving mad.
1021 AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
1024 if test "$tor_cv_null_is_zero" != no; then
1025 AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1026 [Define to 1 iff memset(0) sets pointers to NULL])
1029 # And what happens when we malloc zero?
1030 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
1031 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1032 [[#include <stdlib.h>
1035 #ifdef HAVE_STDDEF_H
1038 int main () { return malloc(0)?0:1; }]])],
1039 [tor_cv_malloc_zero_works=yes],
1040 [tor_cv_malloc_zero_works=no],
1041 [tor_cv_malloc_zero_works=cross])])
1043 if test "$tor_cv_malloc_zero_works" = cross; then
1044 # Cross-compiling; let's hope that the target isn't raving mad.
1045 AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
1048 if test "$tor_cv_malloc_zero_works" = yes; then
1049 AC_DEFINE([MALLOC_ZERO_WORKS], 1,
1050 [Define to 1 iff malloc(0) returns a pointer])
1053 # whether we seem to be in a 2s-complement world.
1054 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
1055 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1056 [[int main () { int problem = ((-99) != (~99)+1);
1057 return problem ? 1 : 0; }]])],
1058 [tor_cv_twos_complement=yes],
1059 [tor_cv_twos_complement=no],
1060 [tor_cv_twos_complement=cross])])
1062 if test "$tor_cv_twos_complement" = cross ; then
1063 # Cross-compiling; let's hope that the target isn't raving mad.
1064 AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
1067 if test "$tor_cv_twos_complement" != no ; then
1068 AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
1069 [Define to 1 iff we represent negative integers with two's complement])
1072 # What does shifting a negative value do?
1073 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
1074 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1075 [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
1076 [tor_cv_sign_extend=yes],
1077 [tor_cv_sign_extend=no],
1078 [tor_cv_sign_extend=cross])])
1080 if test "$tor_cv_sign_extend" = cross ; then
1081 # Cross-compiling; let's hope that the target isn't raving mad.
1082 AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
1085 if test "$tor_cv_sign_extend" != no ; then
1086 AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
1087 [Define to 1 iff right-shifting a negative value performs sign-extension])
1090 # Whether we should use the dmalloc memory allocation debugging library.
1091 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
1092 AC_ARG_WITH(dmalloc,
1093 [ --with-dmalloc Use debug memory allocation library. ],
1094 [if [[ "$withval" = "yes" ]]; then
1100 fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
1103 if [[ $dmalloc -eq 1 ]]; then
1104 AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
1105 AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
1106 AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
1107 AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
1108 AC_CHECK_FUNCS(dmalloc_strdup dmalloc_strndup)
1111 AC_ARG_WITH(tcmalloc,
1112 [ --with-tcmalloc Use tcmalloc memory allocation library. ],
1113 [ tcmalloc=yes ], [ tcmalloc=no ])
1115 if test x$tcmalloc = xyes ; then
1116 LDFLAGS="-ltcmalloc $LDFLAGS"
1119 using_custom_malloc=no
1120 if test x$enable_openbsd_malloc = xyes ; then
1121 using_custom_malloc=yes
1123 if test x$tcmalloc = xyes ; then
1124 using_custom_malloc=yes
1126 if test $using_custom_malloc = no ; then
1127 AC_CHECK_FUNCS(mallinfo)
1130 # By default, we're going to assume we don't have mlockall()
1131 # bionic and other platforms have various broken mlockall subsystems.
1132 # Some systems don't have a working mlockall, some aren't linkable,
1133 # and some have it but don't declare it.
1134 AC_CHECK_FUNCS(mlockall)
1135 AC_CHECK_DECLS([mlockall], , , [
1136 #ifdef HAVE_SYS_MMAN_H
1137 #include <sys/mman.h>
1140 # Allow user to specify an alternate syslog facility
1141 AC_ARG_WITH(syslog-facility,
1142 [ --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
1143 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
1144 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
1145 AC_SUBST(LOGFACILITY)
1147 # Check if we have getresuid and getresgid
1148 AC_CHECK_FUNCS(getresuid getresgid)
1150 # Check for gethostbyname_r in all its glorious incompatible versions.
1151 # (This logic is based on that in Python's configure.in)
1152 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
1153 [Define this if you have any gethostbyname_r()])
1155 AC_CHECK_FUNC(gethostbyname_r, [
1156 AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
1158 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1159 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1163 struct hostent *h1, *h2;
1165 (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
1167 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1168 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
1169 [Define this if gethostbyname_r takes 6 arguments])
1178 (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
1180 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1181 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
1182 [Define this if gethostbyname_r takes 5 arguments])
1190 struct hostent_data hd;
1191 (void) gethostbyname_r(cp1,h1,&hd);
1193 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1194 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
1195 [Define this if gethostbyname_r takes 3 arguments])
1205 AC_CACHE_CHECK([whether the C compiler supports __func__],
1206 tor_cv_have_func_macro,
1207 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1209 int main(int c, char **v) { puts(__func__); }])],
1210 tor_cv_have_func_macro=yes,
1211 tor_cv_have_func_macro=no))
1213 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
1214 tor_cv_have_FUNC_macro,
1215 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1217 int main(int c, char **v) { puts(__FUNC__); }])],
1218 tor_cv_have_FUNC_macro=yes,
1219 tor_cv_have_FUNC_macro=no))
1221 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
1222 tor_cv_have_FUNCTION_macro,
1223 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1225 int main(int c, char **v) { puts(__FUNCTION__); }])],
1226 tor_cv_have_FUNCTION_macro=yes,
1227 tor_cv_have_FUNCTION_macro=no))
1229 AC_CACHE_CHECK([whether we have extern char **environ already declared],
1230 tor_cv_have_environ_declared,
1231 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1232 /* We define _GNU_SOURCE here because it is also defined in compat.c.
1233 * Without it environ doesn't get declared. */
1235 #ifdef HAVE_UNISTD_H
1239 int main(int c, char **v) { char **t = environ; }])],
1240 tor_cv_have_environ_declared=yes,
1241 tor_cv_have_environ_declared=no))
1243 if test "$tor_cv_have_func_macro" = 'yes'; then
1244 AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
1247 if test "$tor_cv_have_FUNC_macro" = 'yes'; then
1248 AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
1251 if test "$tor_cv_have_FUNCTION_macro" = 'yes'; then
1252 AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
1253 [Defined if the compiler supports __FUNCTION__])
1256 if test "$tor_cv_have_environ_declared" = 'yes'; then
1257 AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
1258 [Defined if we have extern char **environ already declared])
1261 # $prefix stores the value of the --prefix command line option, or
1262 # NONE if the option wasn't set. In the case that it wasn't set, make
1263 # it be the default, so that we can use it to expand directories now.
1264 if test "x$prefix" = "xNONE"; then
1265 prefix=$ac_default_prefix
1268 # and similarly for $exec_prefix
1269 if test "x$exec_prefix" = "xNONE"; then
1273 if test "x$BUILDDIR" = "x"; then
1277 AH_TEMPLATE([BUILDDIR],[tor's build directory])
1278 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
1280 if test "x$CONFDIR" = "x"; then
1281 CONFDIR=`eval echo $sysconfdir/tor`
1284 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
1285 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
1287 BINDIR=`eval echo $bindir`
1289 LOCALSTATEDIR=`eval echo $localstatedir`
1290 AC_SUBST(LOCALSTATEDIR)
1292 if test "$bwin32" = true; then
1293 # Test if the linker supports the --nxcompat and --dynamicbase options
1295 save_LDFLAGS="$LDFLAGS"
1296 LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
1297 AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
1298 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
1299 [AC_MSG_RESULT([yes])]
1300 [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
1301 [AC_MSG_RESULT([no])]
1303 LDFLAGS="$save_LDFLAGS"
1306 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
1307 # than autoconf's macros like.
1308 if test "$GCC" = yes; then
1309 # Disable GCC's strict aliasing checks. They are an hours-to-debug
1310 # accident waiting to happen.
1311 CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
1313 # Autoconf sets -g -O2 by default. Override optimization level
1314 # for non-gcc compilers
1316 enable_gcc_warnings=no
1317 enable_gcc_warnings_advisory=no
1320 # OS X Lion started deprecating the system openssl. Let's just disable
1321 # all deprecation warnings on OS X. Also, to potentially make the binary
1322 # a little smaller, let's enable dead_strip.
1326 CFLAGS="$CFLAGS -Wno-deprecated-declarations"
1327 LDFLAGS="$LDFLAGS -dead_strip" ;;
1330 # Add some more warnings which we use in development but not in the
1331 # released versions. (Some relevant gcc versions can't handle these.)
1332 if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xyes; then
1334 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1335 #if !defined(__GNUC__) || (__GNUC__ < 4)
1337 #endif])], have_gcc4=yes, have_gcc4=no)
1339 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1340 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
1342 #endif])], have_gcc42=yes, have_gcc42=no)
1344 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1345 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
1347 #endif])], have_gcc43=yes, have_gcc43=no)
1349 save_CFLAGS="$CFLAGS"
1350 CFLAGS="$CFLAGS -Wshorten-64-to-32"
1351 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
1352 have_shorten64_flag=no)
1353 CFLAGS="$save_CFLAGS"
1356 *-*-openbsd* | *-*-bitrig*)
1357 # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
1358 # That's fine, except that the headers don't pass -Wredundant-decls.
1359 # Therefore, let's disable -Wsystem-headers when we're building
1360 # with maximal warnings on OpenBSD.
1361 CFLAGS="$CFLAGS -Wno-system-headers" ;;
1364 CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
1365 CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
1366 CFLAGS="$CFLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
1367 CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
1368 CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
1370 if test x$enable_gcc_warnings = xyes; then
1371 CFLAGS="$CFLAGS -Werror"
1374 # Disabled, so we can use mallinfo(): -Waggregate-return
1376 if test x$have_gcc4 = xyes ; then
1377 # These warnings break gcc 3.3.5 and work on gcc 4.0.2
1378 CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement -Wold-style-definition"
1381 if test x$have_gcc42 = xyes ; then
1382 # These warnings break gcc 4.0.2 and work on gcc 4.2
1383 # XXXX020 See if any of these work with earlier versions.
1384 CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wstrict-overflow=1"
1386 # We used to use -Wstrict-overflow=5, but that breaks us heavily under 4.3.
1389 if test x$have_gcc42 = xyes && test x$have_clang = xno; then
1390 # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2
1391 CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init"
1394 if test x$have_gcc43 = xyes ; then
1395 # These warnings break gcc 4.2 and work on gcc 4.3
1396 # XXXX020 See if any of these work with earlier versions.
1397 CFLAGS="$CFLAGS -Wextra -Warray-bounds"
1400 if test x$have_shorten64_flag = xyes ; then
1401 CFLAGS="$CFLAGS -Wshorten-64-to-32"
1404 ##This will break the world on some 64-bit architectures
1405 # CFLAGS="$CFLAGS -Winline"
1410 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
1416 contrib/tor.logrotate
1420 src/config/torrc.sample
1425 if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
1426 ./contrib/updateVersions.pl