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.5.0-alpha-dev])
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))
42 AC_ARG_ENABLE(unittests,
43 AS_HELP_STRING(--disable-unittests, [Don't build unit tests for Tor. Risky!]))
44 AC_ARG_ENABLE(coverage,
45 AS_HELP_STRING(--enable-coverage, [Enable coverage support in the unit-test build]))
47 AM_CONDITIONAL(UNITTESTS_ENABLED, test x$enable_unittests != xno)
48 AM_CONDITIONAL(COVERAGE_ENABLED, test x$enable_coverage = xyes)
50 echo "COVERAGE: $enable_coverage"
52 if test "$enable_static_tor" = "yes"; then
53 enable_static_libevent="yes";
54 enable_static_openssl="yes";
55 enable_static_zlib="yes";
56 CFLAGS="$CFLAGS -static"
59 if test x$enable_buf_freelists != xno; then
60 AC_DEFINE(ENABLE_BUF_FREELISTS, 1,
61 [Defined if we try to use freelists for buffer RAM chunks])
63 AM_CONDITIONAL(USE_OPENBSD_MALLOC, test x$enable_openbsd_malloc = xyes)
64 if test x$enable_instrument_downloads = xyes; then
65 AC_DEFINE(INSTRUMENT_DOWNLOADS, 1,
66 [Defined if we want to keep track of how much of each kind of resource we download.])
69 AC_ARG_ENABLE(transparent,
70 AS_HELP_STRING(--disable-transparent, disable transparent proxy support),
71 [case "${enableval}" in
72 yes) transparent=true ;;
73 no) transparent=false ;;
74 *) AC_MSG_ERROR(bad value for --enable-transparent) ;;
75 esac], [transparent=true])
77 AC_ARG_ENABLE(asciidoc,
78 AS_HELP_STRING(--disable-asciidoc, don't use asciidoc (disables building of manpages)),
79 [case "${enableval}" in
82 *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
83 esac], [asciidoc=true])
85 # By default, we're not ready to ship a NAT-PMP aware Tor
86 AC_ARG_ENABLE(nat-pmp,
87 AS_HELP_STRING(--enable-nat-pmp, enable NAT-PMP support),
88 [case "${enableval}" in
91 * ) AC_MSG_ERROR(bad value for --enable-nat-pmp) ;;
92 esac], [natpmp=false])
94 # By default, we're not ready to ship a UPnP aware Tor
96 AS_HELP_STRING(--enable-upnp, enable UPnP support),
97 [case "${enableval}" in
100 * ) AC_MSG_ERROR(bad value for --enable-upnp) ;;
104 AC_ARG_ENABLE(threads,
105 AS_HELP_STRING(--disable-threads, disable multi-threading support))
107 if test x$enable_threads = x; then
110 # Don't try multithreading on solaris -- cpuworkers seem to lock.
111 AC_MSG_NOTICE([You are running Solaris; Sometimes threading makes
112 cpu workers lock up here, so I will disable threads.])
113 enable_threads="no";;
115 enable_threads="yes";;
119 if test "$enable_threads" = "yes"; then
120 AC_DEFINE(ENABLE_THREADS, 1, [Defined if we will try to use multithreading])
125 AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
129 AC_ARG_ENABLE(gcc-warnings,
130 AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings))
131 AC_ARG_ENABLE(gcc-warnings-advisory,
132 AS_HELP_STRING(--enable-gcc-warnings-advisory, [enable verbose warnings, excluding -Werror]))
134 dnl Adam shostack suggests the following for Windows:
135 dnl -D_FORTIFY_SOURCE=2 -fstack-protector-all
136 dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
137 dnl This requires that we use gcc and that we add -O2 to the CFLAGS.
138 AC_ARG_ENABLE(gcc-hardening,
139 AS_HELP_STRING(--disable-gcc-hardening, disable compiler security checks))
141 dnl Linker hardening options
142 dnl Currently these options are ELF specific - you can't use this with MacOSX
143 AC_ARG_ENABLE(linker-hardening,
144 AS_HELP_STRING(--disable-linker-hardening, disable linker security fixups))
146 AC_ARG_ENABLE(local-appdata,
147 AS_HELP_STRING(--enable-local-appdata, default to host local application data paths on Windows))
148 if test "$enable_local_appdata" = "yes"; then
149 AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
150 [Defined if we default to host local appdata paths on Windows])
154 AC_ARG_ENABLE(tor2web-mode,
155 AS_HELP_STRING(--enable-tor2web-mode, support tor2web non-anonymous mode),
156 [if test x$enableval = xyes; then
157 CFLAGS="$CFLAGS -D ENABLE_TOR2WEB_MODE=1"
160 AC_ARG_ENABLE(bufferevents,
161 AS_HELP_STRING(--enable-bufferevents, use Libevent's buffered IO.))
163 dnl check for the correct "ar" when cross-compiling
164 AN_MAKEVAR([AR], [AC_PROG_AR])
165 AN_PROGRAM([ar], [AC_PROG_AR])
166 AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [ar])])
174 dnl autoconf 2.59 appears not to support AC_PROG_SED
175 AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
177 dnl check for asciidoc and a2x
178 AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
179 AC_PATH_PROG([A2X], [a2x], none)
181 AM_CONDITIONAL(USE_ASCIIDOC, test x$asciidoc = xtrue)
183 AM_CONDITIONAL(USE_FW_HELPER, test x$natpmp = xtrue || test x$upnp = xtrue)
184 AM_CONDITIONAL(NAT_PMP, test x$natpmp = xtrue)
185 AM_CONDITIONAL(MINIUPNPC, test x$upnp = xtrue)
188 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
189 AC_C_FLEXIBLE_ARRAY_MEMBER
191 dnl Maybe we've got an old autoconf...
192 AC_CACHE_CHECK([for flexible array members],
196 struct abc { int a; char b[]; };
198 struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
201 [tor_cv_c_flexarray=yes],
202 [tor_cv_c_flexarray=no])])
203 if test $tor_cv_flexarray = yes ; then
204 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
206 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
210 AC_PATH_PROG([SHA1SUM], [sha1sum], none)
211 AC_PATH_PROG([OPENSSL], [openssl], none)
214 AC_ARG_WITH(tor-user,
215 [ --with-tor-user=NAME Specify username for tor daemon ],
223 AC_ARG_WITH(tor-group,
224 [ --with-tor-group=NAME Specify group name for tor daemon ],
232 dnl If _WIN32 is defined and non-zero, we are building for win32
233 AC_MSG_CHECKING([for win32])
234 AC_RUN_IFELSE([AC_LANG_SOURCE([
235 int main(int c, char **v) {
246 bwin32=true; AC_MSG_RESULT([yes]),
247 bwin32=false; AC_MSG_RESULT([no]),
248 bwin32=cross; AC_MSG_RESULT([cross])
251 if test "$bwin32" = cross; then
252 AC_MSG_CHECKING([for win32 (cross)])
253 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
255 int main(int c, char **v) {return 0;}
258 int main(int c, char **v) {return x(y);}
261 bwin32=true; AC_MSG_RESULT([yes]),
262 bwin32=false; AC_MSG_RESULT([no]))
265 AM_CONDITIONAL(BUILD_NT_SERVICES, test x$bwin32 = xtrue)
267 dnl Enable C99 when compiling with MIPSpro
268 AC_MSG_CHECKING([for MIPSpro compiler])
269 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
270 #if (defined(__sgi) && defined(_COMPILER_VERSION))
275 bmipspro=false; AC_MSG_RESULT(no),
276 bmipspro=true; AC_MSG_RESULT(yes))
278 if test "$bmipspro" = true; then
279 CFLAGS="$CFLAGS -c99"
284 AC_SEARCH_LIBS(socket, [socket network])
285 AC_SEARCH_LIBS(gethostbyname, [nsl])
286 AC_SEARCH_LIBS(dlopen, [dl])
287 AC_SEARCH_LIBS(inet_aton, [resolv])
289 AC_SEARCH_LIBS([clock_gettime], [rt])
290 if test "$LIBS" != "$saved_LIBS"; then
291 # Looks like we need -lrt for clock_gettime().
295 if test "$enable_threads" = "yes"; then
296 AC_SEARCH_LIBS(pthread_create, [pthread])
297 AC_SEARCH_LIBS(pthread_detach, [pthread])
300 dnl -------------------------------------------------------------------
301 dnl Check for functions before libevent, since libevent-1.2 apparently
302 dnl exports strlcpy without defining it in a header.
336 if test "$enable_threads" = "yes"; then
337 AC_CHECK_HEADERS(pthread.h)
338 AC_CHECK_FUNCS(pthread_create)
341 dnl ------------------------------------------------------
342 dnl Where do you live, libevent? And how do we call you?
344 if test "$bwin32" = true; then
345 TOR_LIB_WS32=-lws2_32
346 TOR_LIB_IPHLPAPI=-liphlpapi
347 # Some of the cargo-cults recommend -lwsock32 as well, but I don't
348 # think it's actually necessary.
354 AC_SUBST(TOR_LIB_WS32)
355 AC_SUBST(TOR_LIB_GDI)
356 AC_SUBST(TOR_LIB_IPHLPAPI)
358 dnl We need to do this before we try our disgusting hack below.
359 AC_CHECK_HEADERS([sys/types.h])
361 dnl This is a disgusting hack so we safely include older libevent headers.
362 AC_CHECK_TYPE(u_int64_t, unsigned long long)
363 AC_CHECK_TYPE(u_int32_t, unsigned long)
364 AC_CHECK_TYPE(u_int16_t, unsigned short)
365 AC_CHECK_TYPE(u_int8_t, unsigned char)
367 tor_libevent_pkg_redhat="libevent"
368 tor_libevent_pkg_debian="libevent-dev"
369 tor_libevent_devpkg_redhat="libevent-devel"
370 tor_libevent_devpkg_debian="libevent-dev"
372 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
373 dnl linking for static builds.
374 STATIC_LIBEVENT_FLAGS=""
375 if test "$enable_static_libevent" = "yes"; then
376 if test "$have_rt" = yes; then
377 STATIC_LIBEVENT_FLAGS=" -lrt "
381 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
383 #include <winsock2.h>
386 #include <sys/time.h>
387 #include <sys/types.h>
388 #include <event.h>], [
390 #include <winsock2.h>
392 void exit(int); void *event_init(void);],
395 {WSADATA d; WSAStartup(0x101,&d); }
397 event_init(); exit(0);
398 ], [--with-libevent-dir], [/opt/libevent])
400 dnl Now check for particular libevent functions.
402 save_LDFLAGS="$LDFLAGS"
403 save_CPPFLAGS="$CPPFLAGS"
404 LIBS="-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $LIBS"
405 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
406 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
407 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)
408 AC_CHECK_MEMBERS([struct event.min_heap_idx], , ,
412 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
415 LDFLAGS="$save_LDFLAGS"
416 CPPFLAGS="$save_CPPFLAGS"
419 AM_CONDITIONAL(USE_EXTERNAL_EVDNS, test x$ac_cv_header_event2_dns_h = xyes)
421 if test "$enable_static_libevent" = "yes"; then
422 if test "$tor_cv_library_libevent_dir" = "(system)"; then
423 AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
425 TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
428 TOR_LIBEVENT_LIBS="-levent"
431 dnl This isn't the best test for Libevent 2.0.3-alpha. Once it's released,
432 dnl we can do much better.
433 if test "$enable_bufferevents" = "yes" ; then
434 if test "$ac_cv_header_event2_bufferevent_ssl_h" != "yes" ; then
435 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.])
438 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
440 # Check for the right version. First see if version detection works.
441 AC_MSG_CHECKING([whether we can detect the Libevent version])
442 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
443 #include <event2/event.h>
444 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 10
450 ])], [event_version_number_works=yes; AC_MSG_RESULT([yes]) ],
451 [event_version_number_works=no; AC_MSG_RESULT([no])])
452 if test "$event_version_number_works" != 'yes'; then
453 AC_MSG_WARN([Version detection on Libevent seems broken. Your Libevent installation is probably screwed up or very old.])
455 AC_MSG_CHECKING([whether Libevent is new enough for bufferevents])
456 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
457 #include <event2/event.h>
458 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000d00
464 ])], [ AC_MSG_RESULT([yes]) ],
465 [ AC_MSG_RESULT([no])
466 AC_MSG_ERROR([Libevent does not seem new enough to support bufferevents. We require 2.0.13-stable or later]) ] )
472 LDFLAGS="$save_LDFLAGS"
473 CPPFLAGS="$save_CPPFLAGS"
475 AM_CONDITIONAL(USE_BUFFEREVENTS, test "$enable_bufferevents" = "yes")
476 if test "$enable_bufferevents" = "yes"; then
477 AC_DEFINE(USE_BUFFEREVENTS, 1, [Defined if we're going to use Libevent's buffered IO API])
478 if test "$enable_static_libevent" = "yes"; then
479 TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent_openssl.a $TOR_LIBEVENT_LIBS"
481 TOR_LIBEVENT_LIBS="-levent_openssl $TOR_LIBEVENT_LIBS"
484 AC_SUBST(TOR_LIBEVENT_LIBS)
486 dnl ------------------------------------------------------
487 dnl Where do you live, libm?
489 dnl On some platforms (Haiku/BeOS) the math library is
490 dnl part of libroot. In which case don't link against lm
493 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
494 if test "$ac_cv_search_pow" != "none required"; then
495 TOR_LIB_MATH="$ac_cv_search_pow"
498 AC_SUBST(TOR_LIB_MATH)
500 dnl ------------------------------------------------------
501 dnl Where do you live, openssl? And how do we call you?
503 tor_openssl_pkg_redhat="openssl"
504 tor_openssl_pkg_debian="libssl"
505 tor_openssl_devpkg_redhat="openssl-devel"
506 tor_openssl_devpkg_debian="libssl-dev"
508 ALT_openssl_WITHVAL=""
510 [ --with-ssl-dir=PATH Obsolete alias for --with-openssl-dir ],
512 if test "x$withval" != xno && test "x$withval" != "x" ; then
513 ALT_openssl_WITHVAL="$withval"
517 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI],
518 [#include <openssl/rand.h>],
519 [void RAND_add(const void *buf, int num, double entropy);],
520 [RAND_add((void*)0,0,0); exit(0);], [],
521 [/usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /opt/openssl])
523 dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
525 if test "$enable_static_openssl" = "yes"; then
526 if test "$tor_cv_library_openssl_dir" = "(system)"; then
527 AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
529 TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
532 TOR_OPENSSL_LIBS="-lssl -lcrypto"
534 AC_SUBST(TOR_OPENSSL_LIBS)
536 dnl ------------------------------------------------------
537 dnl Where do you live, zlib? And how do we call you?
539 tor_zlib_pkg_redhat="zlib"
540 tor_zlib_pkg_debian="zlib1g"
541 tor_zlib_devpkg_redhat="zlib-devel"
542 tor_zlib_devpkg_debian="zlib1g-dev"
544 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
546 [const char * zlibVersion(void);],
547 [zlibVersion(); exit(0);], [--with-zlib-dir],
550 if test "$enable_static_zlib" = "yes"; then
551 if test "$tor_cv_library_zlib_dir" = "(system)"; then
552 AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
553 using --enable-static-zlib")
555 TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
560 AC_SUBST(TOR_ZLIB_LIBS)
562 dnl ---------------------------------------------------------------------
563 dnl Now that we know about our major libraries, we can check for compiler
564 dnl and linker hardening options. We need to do this with the libraries known,
565 dnl since sometimes the linker will like an option but not be willing to
566 dnl use it with a build of a library.
568 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
569 all_libs_for_check="$TOR_ZLIB_LIBS $TOR_LIB_MATH $TOR_LIBEVENT_LIBS $TOR_OPENSSL_LIBS $TOR_LIB_WS32 $TOR_LIB_GDI"
571 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
572 #if !defined(__clang__)
574 #endif])], have_clang=yes, have_clang=no)
576 if test x$enable_gcc_hardening != xno; then
577 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
578 if test x$have_clang = xyes; then
579 TOR_CHECK_CFLAGS(-Qunused-arguments)
581 TOR_CHECK_CFLAGS(-fstack-protector-all)
582 TOR_CHECK_CFLAGS(-Wstack-protector)
583 TOR_CHECK_CFLAGS(-fwrapv)
584 TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
585 if test "$bwin32" = "false"; then
586 TOR_CHECK_CFLAGS(-fPIE)
587 TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
591 if test x$enable_linker_hardening != xno; then
592 TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
595 dnl ------------------------------------------------------
596 dnl Now see if we have a -fomit-frame-pointer compiler option.
598 saved_CFLAGS="$CFLAGS"
599 TOR_CHECK_CFLAGS(-fomit-frame-pointer)
600 if test "$saved_CFLAGS" != "$CFLAGS"; then
601 F_OMIT_FRAME_POINTER='-fomit-frame-pointer'
603 F_OMIT_FRAME_POINTER=''
605 CFLAGS="$saved_CFLAGS"
606 AC_SUBST(F_OMIT_FRAME_POINTER)
608 dnl ------------------------------------------------------
609 dnl Where do you live, libnatpmp? And how do we call you?
610 dnl There are no packages for Debian or Redhat as of this patch
612 if test "$natpmp" = "true"; then
613 AC_DEFINE(NAT_PMP, 1, [Define to 1 if we are building with nat-pmp.])
614 TOR_SEARCH_LIBRARY(libnatpmp, $trylibnatpmpdir, [-lnatpmp $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
615 [#include <natpmp.h>],
619 #include <natpmp.h>],
622 natpmpresp_t response;
623 r = initnatpmp(&natpmp, 0, 0);],
624 [printf("initnatpmp() returned %d (%s)\n", r, r?"FAILED":"SUCCESS");
626 [--with-libnatpmp-dir],
631 dnl ------------------------------------------------------
632 dnl Where do you live, libminiupnpc? And how do we call you?
633 dnl There are no packages for Debian or Redhat as of this patch
635 if test "$upnp" = "true"; then
636 AC_DEFINE(MINIUPNPC, 1, [Define to 1 if we are building with UPnP.])
638 dnl Before we call TOR_SEARCH_LIBRARY we'll do a quick compile test
639 dnl to see if we have miniupnpc-1.5 or -1.6
640 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <miniupnpc/miniupnpc.h>],
641 [upnpDiscover(1, 0, 0, 0);exit(0);])],[miniupnpc15="true"],[miniupnpc15="false"])
643 if test "$miniupnpc15" = "true" ; then
644 AC_DEFINE([MINIUPNPC15],[1],[libminiupnpc version 1.5 found])
645 TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
646 [#include <miniupnpc/miniwget.h>
647 #include <miniupnpc/miniupnpc.h>
648 #include <miniupnpc/upnpcommands.h>],
649 [void upnpDiscover(int delay, const char * multicastif,
650 const char * minissdpdsock, int sameport);],
651 [upnpDiscover(1, 0, 0, 0); exit(0);],
652 [--with-libminiupnpc-dir],
655 TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
656 [#include <miniupnpc/miniwget.h>
657 #include <miniupnpc/miniupnpc.h>
658 #include <miniupnpc/upnpcommands.h>],
659 [void upnpDiscover(int delay, const char * multicastif,
660 const char * minissdpdsock, int sameport, int ipv6, int * error);],
661 [upnpDiscover(1, 0, 0, 0, 0, 0); exit(0);],
662 [--with-libminiupnpc-dir],
667 dnl ============================================================
668 dnl Check for libseccomp
670 AC_CHECK_HEADERS([seccomp.h])
671 AC_SEARCH_LIBS(seccomp_init, [seccomp])
673 dnl ============================================================
674 dnl We need an implementation of curve25519.
676 dnl set these defaults.
678 build_curve25519_donna=no
679 build_curve25519_donna_c64=no
680 use_curve25519_donna=no
681 use_curve25519_nacl=no
684 if test x$enable_curve25519 != xno; then
686 dnl The best choice is using curve25519-donna-c64, but that requires
688 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
689 tor_cv_can_use_curve25519_donna_c64,
691 [AC_LANG_PROGRAM([dnl
693 typedef unsigned uint128_t __attribute__((mode(TI)));
694 int func(uint64_t a, uint64_t b) {
695 uint128_t c = ((uint128_t)a) * b;
696 int ok = ((uint64_t)(c>>96)) == 522859 &&
697 (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
698 (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
699 (((uint64_t)(c))&0xffffffffL) == 0;
703 int ok = func( ((uint64_t)2000000000) * 1000000000,
704 ((uint64_t)1234567890) << 24);
707 [tor_cv_can_use_curve25519_donna_c64=yes],
708 [tor_cv_can_use_curve25519_donna_c64=no],
710 [AC_LANG_PROGRAM([dnl
712 typedef unsigned uint128_t __attribute__((mode(TI)));
713 int func(uint64_t a, uint64_t b) {
714 uint128_t c = ((uint128_t)a) * b;
715 int ok = ((uint64_t)(c>>96)) == 522859 &&
716 (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
717 (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
718 (((uint64_t)(c))&0xffffffffL) == 0;
722 int ok = func( ((uint64_t)2000000000) * 1000000000,
723 ((uint64_t)1234567890) << 24);
726 [tor_cv_can_use_curve25519_donna_c64=cross],
727 [tor_cv_can_use_curve25519_donna_c64=no])])])
729 AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
730 nacl/crypto_scalarmult_curve25519.h])
732 AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
733 tor_cv_can_use_curve25519_nacl,
734 [tor_saved_LIBS="$LIBS"
737 [AC_LANG_PROGRAM([dnl
738 #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
739 #include <crypto_scalarmult_curve25519.h>
740 #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
741 #include <nacl/crypto_scalarmult_curve25519.h>
743 #ifdef crypto_scalarmult_curve25519_ref_BYTES
744 #error Hey, this is the reference implementation! That's not fast.
747 unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
748 ])], [tor_cv_can_use_curve25519_nacl=yes],
749 [tor_cv_can_use_curve25519_nacl=no])
750 LIBS="$tor_saved_LIBS" ])
752 dnl Okay, now we need to figure out which one to actually use. Fall back
753 dnl to curve25519-donna.c
755 if test x$tor_cv_can_use_curve25519_donna_c64 != xno; then
756 build_curve25519_donna_c64=yes
757 use_curve25519_donna=yes
758 elif test x$tor_cv_can_use_curve25519_nacl = xyes; then
759 use_curve25519_nacl=yes
760 CURVE25519_LIBS=-lnacl
762 build_curve25519_donna=yes
763 use_curve25519_donna=yes
765 have_a_curve25519=yes
768 if test x$have_a_curve25519 = xyes; then
769 AC_DEFINE(CURVE25519_ENABLED, 1,
770 [Defined if we have a curve25519 implementation])
772 if test x$use_curve25519_donna = xyes; then
773 AC_DEFINE(USE_CURVE25519_DONNA, 1,
774 [Defined if we should use an internal curve25519_donna{,_c64} implementation])
776 if test x$use_curve25519_nacl = xyes; then
777 AC_DEFINE(USE_CURVE25519_NACL, 1,
778 [Defined if we should use a curve25519 from nacl])
780 AM_CONDITIONAL(BUILD_CURVE25519_DONNA, test x$build_curve25519_donna = xyes)
781 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64, test x$build_curve25519_donna_c64 = xyes)
782 AM_CONDITIONAL(CURVE25519_ENABLED, test x$have_a_curve25519 = xyes)
783 AC_SUBST(CURVE25519_LIBS)
785 dnl Make sure to enable support for large off_t if available.
800 , , 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.))
802 dnl These headers are not essential
839 AC_CHECK_HEADERS(sys/param.h)
841 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
842 [#ifdef HAVE_SYS_TYPES_H
843 #include <sys/types.h>
845 #ifdef HAVE_SYS_SOCKET_H
846 #include <sys/socket.h>
848 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
849 [#ifdef HAVE_SYS_TYPES_H
850 #include <sys/types.h>
852 #ifdef HAVE_SYS_SOCKET_H
853 #include <sys/socket.h>
858 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
859 linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
860 [#ifdef HAVE_SYS_TYPES_H
861 #include <sys/types.h>
863 #ifdef HAVE_SYS_SOCKET_H
864 #include <sys/socket.h>
869 #ifdef HAVE_LINUX_TYPES_H
870 #include <linux/types.h>
872 #ifdef HAVE_NETINET_IN6_H
873 #include <netinet/in6.h>
875 #ifdef HAVE_NETINET_IN_H
876 #include <netinet/in.h>
879 if test x$transparent = xtrue ; then
881 if test x$net_if_found = x1 && test x$net_pfvar_found = x1 ; then
884 if test x$linux_netfilter_ipv4 = x1 ; then
887 if test x$transparent_ok = x1 ; then
888 AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
890 *-*-openbsd* | *-*-bitrig*)
891 AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
894 AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
898 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
899 [#ifdef HAVE_SYS_TYPES_H
900 #include <sys/types.h>
902 #ifdef HAVE_SYS_TIME_H
903 #include <sys/time.h>
906 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
909 AC_CHECK_SIZEOF(int8_t)
910 AC_CHECK_SIZEOF(int16_t)
911 AC_CHECK_SIZEOF(int32_t)
912 AC_CHECK_SIZEOF(int64_t)
913 AC_CHECK_SIZEOF(uint8_t)
914 AC_CHECK_SIZEOF(uint16_t)
915 AC_CHECK_SIZEOF(uint32_t)
916 AC_CHECK_SIZEOF(uint64_t)
917 AC_CHECK_SIZEOF(intptr_t)
918 AC_CHECK_SIZEOF(uintptr_t)
920 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
922 AC_CHECK_SIZEOF(char)
923 AC_CHECK_SIZEOF(short)
925 AC_CHECK_SIZEOF(long)
926 AC_CHECK_SIZEOF(long long)
927 AC_CHECK_SIZEOF(__int64)
928 AC_CHECK_SIZEOF(void *)
929 AC_CHECK_SIZEOF(time_t)
930 AC_CHECK_SIZEOF(size_t)
931 AC_CHECK_SIZEOF(pid_t)
933 AC_CHECK_TYPES([uint, u_char, ssize_t])
935 dnl used to include sockaddr_storage, but everybody has that.
936 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
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>
960 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
961 [#ifdef HAVE_SYS_TYPES_H
962 #include <sys/types.h>
964 #ifdef HAVE_NETINET_IN_H
965 #include <netinet/in.h>
967 #ifdef HAVE_NETINET_IN6_H
968 #include <netinet/in6.h>
970 #ifdef HAVE_SYS_SOCKET_H
971 #include <sys/socket.h>
974 #define _WIN32_WINNT 0x0501
975 #define WIN32_LEAN_AND_MEAN
976 #if defined(_MSC_VER) && (_MSC_VER < 1300)
979 #include <winsock2.h>
980 #include <ws2tcpip.h>
985 AC_CHECK_TYPES([rlim_t], , ,
986 [#ifdef HAVE_SYS_TYPES_H
987 #include <sys/types.h>
989 #ifdef HAVE_SYS_TIME_H
990 #include <sys/time.h>
992 #ifdef HAVE_SYS_RESOURCE_H
993 #include <sys/resource.h>
997 AX_CHECK_SIGN([time_t],
998 [ AC_DEFINE(TIME_T_IS_SIGNED, 1, [Define if time_t is signed]) ],
1000 #ifdef HAVE_SYS_TYPES_H
1001 #include <sys/types.h>
1003 #ifdef HAVE_SYS_TIME_H
1004 #include <sys/time.h>
1011 if test "$ax_cv_decl_time_t_signed" = no; then
1012 AC_MSG_WARN([You have an unsigned time_t; some things will probably break. Please tell the Tor developers about your interesting platform.])
1015 AX_CHECK_SIGN([size_t],
1016 [ tor_cv_size_t_signed=yes ],
1017 [ tor_cv_size_t_signed=no ], [
1018 #ifdef HAVE_SYS_TYPES_H
1019 #include <sys/types.h>
1023 if test "$ax_cv_decl_size_t_signed" = yes; then
1024 AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
1027 AX_CHECK_SIGN([enum always],
1028 [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
1030 enum always { AAA, BBB, CCC };
1033 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
1034 #ifdef HAVE_SYS_SOCKET_H
1035 #include <sys/socket.h>
1039 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1041 AC_CHECK_SIZEOF(cell_t)
1043 # Now make sure that NULL can be represented as zero bytes.
1044 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1045 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1046 [[#include <stdlib.h>
1049 #ifdef HAVE_STDDEF_H
1052 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1053 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1054 [tor_cv_null_is_zero=yes],
1055 [tor_cv_null_is_zero=no],
1056 [tor_cv_null_is_zero=cross])])
1058 if test "$tor_cv_null_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 NULL is represented as a sequence of 0-valued bytes.])
1063 if test "$tor_cv_null_is_zero" != no; then
1064 AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1065 [Define to 1 iff memset(0) sets pointers to NULL])
1068 AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
1069 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1070 [[#include <stdlib.h>
1073 #ifdef HAVE_STDDEF_H
1076 int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
1077 return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
1078 [tor_cv_dbl0_is_zero=yes],
1079 [tor_cv_dbl0_is_zero=no],
1080 [tor_cv_dbl0_is_zero=cross])])
1082 if test "$tor_cv_dbl0_is_zero" = 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 0.0 can be represented as a sequence of 0-valued bytes.])
1087 if test "$tor_cv_dbl0_is_zero" != no; then
1088 AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
1089 [Define to 1 iff memset(0) sets doubles to 0.0])
1092 # And what happens when we malloc zero?
1093 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
1094 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1095 [[#include <stdlib.h>
1098 #ifdef HAVE_STDDEF_H
1101 int main () { return malloc(0)?0:1; }]])],
1102 [tor_cv_malloc_zero_works=yes],
1103 [tor_cv_malloc_zero_works=no],
1104 [tor_cv_malloc_zero_works=cross])])
1106 if test "$tor_cv_malloc_zero_works" = cross; then
1107 # Cross-compiling; let's hope that the target isn't raving mad.
1108 AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
1111 if test "$tor_cv_malloc_zero_works" = yes; then
1112 AC_DEFINE([MALLOC_ZERO_WORKS], 1,
1113 [Define to 1 iff malloc(0) returns a pointer])
1116 # whether we seem to be in a 2s-complement world.
1117 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
1118 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1119 [[int main () { int problem = ((-99) != (~99)+1);
1120 return problem ? 1 : 0; }]])],
1121 [tor_cv_twos_complement=yes],
1122 [tor_cv_twos_complement=no],
1123 [tor_cv_twos_complement=cross])])
1125 if test "$tor_cv_twos_complement" = cross ; then
1126 # Cross-compiling; let's hope that the target isn't raving mad.
1127 AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
1130 if test "$tor_cv_twos_complement" != no ; then
1131 AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
1132 [Define to 1 iff we represent negative integers with two's complement])
1135 # What does shifting a negative value do?
1136 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
1137 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1138 [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
1139 [tor_cv_sign_extend=yes],
1140 [tor_cv_sign_extend=no],
1141 [tor_cv_sign_extend=cross])])
1143 if test "$tor_cv_sign_extend" = cross ; then
1144 # Cross-compiling; let's hope that the target isn't raving mad.
1145 AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
1148 if test "$tor_cv_sign_extend" != no ; then
1149 AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
1150 [Define to 1 iff right-shifting a negative value performs sign-extension])
1153 # Whether we should use the dmalloc memory allocation debugging library.
1154 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
1155 AC_ARG_WITH(dmalloc,
1156 [ --with-dmalloc Use debug memory allocation library. ],
1157 [if [[ "$withval" = "yes" ]]; then
1163 fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
1166 if [[ $dmalloc -eq 1 ]]; then
1167 AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
1168 AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
1169 AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
1170 AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
1171 AC_CHECK_FUNCS(dmalloc_strdup dmalloc_strndup)
1174 AC_ARG_WITH(tcmalloc,
1175 [ --with-tcmalloc Use tcmalloc memory allocation library. ],
1176 [ tcmalloc=yes ], [ tcmalloc=no ])
1178 if test x$tcmalloc = xyes ; then
1179 LDFLAGS="-ltcmalloc $LDFLAGS"
1182 using_custom_malloc=no
1183 if test x$enable_openbsd_malloc = xyes ; then
1184 using_custom_malloc=yes
1186 if test x$tcmalloc = xyes ; then
1187 using_custom_malloc=yes
1189 if test $using_custom_malloc = no ; then
1190 AC_CHECK_FUNCS(mallinfo)
1193 # By default, we're going to assume we don't have mlockall()
1194 # bionic and other platforms have various broken mlockall subsystems.
1195 # Some systems don't have a working mlockall, some aren't linkable,
1196 # and some have it but don't declare it.
1197 AC_CHECK_FUNCS(mlockall)
1198 AC_CHECK_DECLS([mlockall], , , [
1199 #ifdef HAVE_SYS_MMAN_H
1200 #include <sys/mman.h>
1203 # Allow user to specify an alternate syslog facility
1204 AC_ARG_WITH(syslog-facility,
1205 [ --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
1206 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
1207 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
1208 AC_SUBST(LOGFACILITY)
1210 # Check if we have getresuid and getresgid
1211 AC_CHECK_FUNCS(getresuid getresgid)
1213 # Check for gethostbyname_r in all its glorious incompatible versions.
1214 # (This logic is based on that in Python's configure.in)
1215 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
1216 [Define this if you have any gethostbyname_r()])
1218 AC_CHECK_FUNC(gethostbyname_r, [
1219 AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
1221 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1222 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1226 struct hostent *h1, *h2;
1228 (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
1230 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1231 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
1232 [Define this if gethostbyname_r takes 6 arguments])
1241 (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
1243 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1244 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
1245 [Define this if gethostbyname_r takes 5 arguments])
1253 struct hostent_data hd;
1254 (void) gethostbyname_r(cp1,h1,&hd);
1256 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1257 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
1258 [Define this if gethostbyname_r takes 3 arguments])
1268 AC_CACHE_CHECK([whether the C compiler supports __func__],
1269 tor_cv_have_func_macro,
1270 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1272 int main(int c, char **v) { puts(__func__); }])],
1273 tor_cv_have_func_macro=yes,
1274 tor_cv_have_func_macro=no))
1276 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
1277 tor_cv_have_FUNC_macro,
1278 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1280 int main(int c, char **v) { puts(__FUNC__); }])],
1281 tor_cv_have_FUNC_macro=yes,
1282 tor_cv_have_FUNC_macro=no))
1284 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
1285 tor_cv_have_FUNCTION_macro,
1286 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1288 int main(int c, char **v) { puts(__FUNCTION__); }])],
1289 tor_cv_have_FUNCTION_macro=yes,
1290 tor_cv_have_FUNCTION_macro=no))
1292 AC_CACHE_CHECK([whether we have extern char **environ already declared],
1293 tor_cv_have_environ_declared,
1294 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1295 /* We define _GNU_SOURCE here because it is also defined in compat.c.
1296 * Without it environ doesn't get declared. */
1298 #ifdef HAVE_UNISTD_H
1302 int main(int c, char **v) { char **t = environ; }])],
1303 tor_cv_have_environ_declared=yes,
1304 tor_cv_have_environ_declared=no))
1306 if test "$tor_cv_have_func_macro" = 'yes'; then
1307 AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
1310 if test "$tor_cv_have_FUNC_macro" = 'yes'; then
1311 AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
1314 if test "$tor_cv_have_FUNCTION_macro" = 'yes'; then
1315 AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
1316 [Defined if the compiler supports __FUNCTION__])
1319 if test "$tor_cv_have_environ_declared" = 'yes'; then
1320 AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
1321 [Defined if we have extern char **environ already declared])
1324 # $prefix stores the value of the --prefix command line option, or
1325 # NONE if the option wasn't set. In the case that it wasn't set, make
1326 # it be the default, so that we can use it to expand directories now.
1327 if test "x$prefix" = "xNONE"; then
1328 prefix=$ac_default_prefix
1331 # and similarly for $exec_prefix
1332 if test "x$exec_prefix" = "xNONE"; then
1336 if test "x$BUILDDIR" = "x"; then
1340 AH_TEMPLATE([BUILDDIR],[tor's build directory])
1341 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
1343 if test "x$CONFDIR" = "x"; then
1344 CONFDIR=`eval echo $sysconfdir/tor`
1347 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
1348 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
1350 BINDIR=`eval echo $bindir`
1352 LOCALSTATEDIR=`eval echo $localstatedir`
1353 AC_SUBST(LOCALSTATEDIR)
1355 if test "$bwin32" = true; then
1356 # Test if the linker supports the --nxcompat and --dynamicbase options
1358 save_LDFLAGS="$LDFLAGS"
1359 LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
1360 AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
1361 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
1362 [AC_MSG_RESULT([yes])]
1363 [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
1364 [AC_MSG_RESULT([no])]
1366 LDFLAGS="$save_LDFLAGS"
1369 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
1370 # than autoconf's macros like.
1371 if test "$GCC" = yes; then
1372 # Disable GCC's strict aliasing checks. They are an hours-to-debug
1373 # accident waiting to happen.
1374 CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
1376 # Autoconf sets -g -O2 by default. Override optimization level
1377 # for non-gcc compilers
1379 enable_gcc_warnings=no
1380 enable_gcc_warnings_advisory=no
1383 # OS X Lion started deprecating the system openssl. Let's just disable
1384 # all deprecation warnings on OS X. Also, to potentially make the binary
1385 # a little smaller, let's enable dead_strip.
1389 CFLAGS="$CFLAGS -Wno-deprecated-declarations"
1390 LDFLAGS="$LDFLAGS -dead_strip" ;;
1393 # Add some more warnings which we use in development but not in the
1394 # released versions. (Some relevant gcc versions can't handle these.)
1395 if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xyes; then
1397 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1398 #if !defined(__GNUC__) || (__GNUC__ < 4)
1400 #endif])], have_gcc4=yes, have_gcc4=no)
1402 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1403 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
1405 #endif])], have_gcc42=yes, have_gcc42=no)
1407 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1408 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
1410 #endif])], have_gcc43=yes, have_gcc43=no)
1412 save_CFLAGS="$CFLAGS"
1413 CFLAGS="$CFLAGS -Wshorten-64-to-32"
1414 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
1415 have_shorten64_flag=no)
1416 CFLAGS="$save_CFLAGS"
1419 *-*-openbsd* | *-*-bitrig*)
1420 # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
1421 # That's fine, except that the headers don't pass -Wredundant-decls.
1422 # Therefore, let's disable -Wsystem-headers when we're building
1423 # with maximal warnings on OpenBSD.
1424 CFLAGS="$CFLAGS -Wno-system-headers" ;;
1427 CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
1428 CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
1429 CFLAGS="$CFLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
1430 CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
1431 CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
1433 if test x$enable_gcc_warnings = xyes; then
1434 CFLAGS="$CFLAGS -Werror"
1437 # Disabled, so we can use mallinfo(): -Waggregate-return
1439 if test x$have_gcc4 = xyes ; then
1440 # These warnings break gcc 3.3.5 and work on gcc 4.0.2
1441 CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement -Wold-style-definition"
1444 if test x$have_gcc42 = xyes ; then
1445 # These warnings break gcc 4.0.2 and work on gcc 4.2
1446 # XXXX020 See if any of these work with earlier versions.
1447 CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wstrict-overflow=1"
1449 # We used to use -Wstrict-overflow=5, but that breaks us heavily under 4.3.
1452 if test x$have_gcc42 = xyes && test x$have_clang = xno; then
1453 # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2
1454 CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init"
1457 if test x$have_gcc43 = xyes ; then
1458 # These warnings break gcc 4.2 and work on gcc 4.3
1459 # XXXX020 See if any of these work with earlier versions.
1460 CFLAGS="$CFLAGS -Wextra -Warray-bounds"
1463 if test x$have_shorten64_flag = xyes ; then
1464 CFLAGS="$CFLAGS -Wshorten-64-to-32"
1467 ##This will break the world on some 64-bit architectures
1468 # CFLAGS="$CFLAGS -Winline"
1471 if test "$enable_coverage" = yes && test "$have_clang" = "no"; then
1474 AC_MSG_WARN([Tried to enable coverage on OSX without using the clang compiler. This might not work! If coverage fails, use CC=clang when configuring with --enable-profiling.])
1478 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
1484 contrib/tor.logrotate
1488 src/config/torrc.sample
1491 if test x$asciidoc = xtrue && test "$ASCIIDOC" = "none" ; then
1492 regular_mans="doc/tor doc/tor-gencert doc/tor-resolve doc/torify"
1493 for file in $regular_mans ; do
1494 if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
1495 echo "==================================";
1497 echo "You need asciidoc installed to be able to build the manpage.";
1498 echo "To build without manpages, use the --disable-asciidoc argument";
1499 echo "when calling configure.";
1501 echo "==================================";
1509 if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
1510 ./contrib/updateVersions.pl