Merge remote-tracking branch 'arma/bug18616-v4' into maint-0.2.8
[tor.git] / configure.ac
bloba4879487455de2c75b0a3d1cc6a36b986004a64c
1 dnl Copyright (c) 2001-2004, Roger Dingledine
2 dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
3 dnl Copyright (c) 2007-2015, The Tor Project, Inc.
4 dnl See LICENSE for licensing information
6 AC_PREREQ([2.63])
7 AC_INIT([tor],[0.2.8.2-alpha-dev])
8 AC_CONFIG_SRCDIR([src/or/main.c])
9 AC_CONFIG_MACRO_DIR([m4])
11 # "foreign" means we don't follow GNU package layout standards
12 # "1.11" means we require automake version 1.11 or newer
13 # "subdir-objects" means put .o files in the same directory as the .c files
14 AM_INIT_AUTOMAKE([foreign 1.11 subdir-objects])
16 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
17 AC_CONFIG_HEADERS([orconfig.h])
19 AC_CANONICAL_HOST
21 PKG_PROG_PKG_CONFIG
23 if test -f "/etc/redhat-release"; then
24   if test -f "/usr/kerberos/include"; then
25     CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
26   fi
29 # Not a no-op; we want to make sure that CPPFLAGS is set before we use
30 # the += operator on it in src/or/Makefile.am
31 CPPFLAGS="$CPPFLAGS -I\${top_srcdir}/src/common"
33 #XXXX020 We should make these enabled or not, before 0.2.0.x-final
34 AC_ARG_ENABLE(openbsd-malloc,
35    AS_HELP_STRING(--enable-openbsd-malloc, [use malloc code from OpenBSD.  Linux only]))
36 AC_ARG_ENABLE(instrument-downloads,
37    AS_HELP_STRING(--enable-instrument-downloads, [instrument downloads of directory resources etc.]))
38 AC_ARG_ENABLE(static-openssl,
39    AS_HELP_STRING(--enable-static-openssl, [link against a static openssl library. Requires --with-openssl-dir]))
40 AC_ARG_ENABLE(static-libevent,
41    AS_HELP_STRING(--enable-static-libevent, [link against a static libevent library. Requires --with-libevent-dir]))
42 AC_ARG_ENABLE(static-zlib,
43    AS_HELP_STRING(--enable-static-zlib, [link against a static zlib library. Requires --with-zlib-dir]))
44 AC_ARG_ENABLE(static-tor,
45    AS_HELP_STRING(--enable-static-tor, [create an entirely static Tor binary. Requires --with-openssl-dir and --with-libevent-dir and --with-zlib-dir]))
46 AC_ARG_ENABLE(unittests,
47    AS_HELP_STRING(--disable-unittests, [don't build unit tests for Tor. Risky!]))
48 AC_ARG_ENABLE(coverage,
49    AS_HELP_STRING(--enable-coverage, [enable coverage support in the unit-test build]))
50 AC_ARG_ENABLE(asserts-in-tests,
51    AS_HELP_STRING(--disable-asserts-in-tests, [disable tor_assert() calls in the unit tests, for branch coverage]))
52 AC_ARG_ENABLE(system-torrc,
53    AS_HELP_STRING(--disable-system-torrc, [don't look for a system-wide torrc file]))
55 if test "x$enable_coverage" != "xyes" -a "x$enable_asserts_in_tests" = "xno" ; then
56     AC_MSG_ERROR([Can't disable assertions outside of coverage build])
59 AM_CONDITIONAL(UNITTESTS_ENABLED, test "x$enable_unittests" != "xno")
60 AM_CONDITIONAL(COVERAGE_ENABLED, test "x$enable_coverage" = "xyes")
61 AM_CONDITIONAL(DISABLE_ASSERTS_IN_UNIT_TESTS, test "x$enable_asserts_in_tests" = "xno")
63 if test "$enable_static_tor" = "yes"; then
64   enable_static_libevent="yes";
65   enable_static_openssl="yes";
66   enable_static_zlib="yes";
67   CFLAGS="$CFLAGS -static"
70 if test "$enable_system_torrc" = "no"; then
71   AC_DEFINE(DISABLE_SYSTEM_TORRC, 1,
72             [Defined if we're not going to look for a torrc in SYSCONF])
75 AM_CONDITIONAL(USE_OPENBSD_MALLOC, test "x$enable_openbsd_malloc" = "xyes")
76 if test "x$enable_instrument_downloads" = "xyes"; then
77   AC_DEFINE(INSTRUMENT_DOWNLOADS, 1,
78             [Defined if we want to keep track of how much of each kind of resource we download.])
81 AC_ARG_ENABLE(transparent,
82      AS_HELP_STRING(--disable-transparent, [disable transparent proxy support]),
83      [case "${enableval}" in
84         "yes") transparent=true ;;
85         "no")  transparent=false ;;
86         *) AC_MSG_ERROR(bad value for --enable-transparent) ;;
87       esac], [transparent=true])
89 AC_ARG_ENABLE(asciidoc,
90      AS_HELP_STRING(--disable-asciidoc, [don't use asciidoc (disables building of manpages)]),
91      [case "${enableval}" in
92         "yes") asciidoc=true ;;
93         "no")  asciidoc=false ;;
94         *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
95       esac], [asciidoc=true])
97 # systemd notify support
98 AC_ARG_ENABLE(systemd,
99       AS_HELP_STRING(--enable-systemd, [enable systemd notification support]),
100       [case "${enableval}" in
101         "yes") systemd=true ;;
102         "no")  systemd=false ;;
103         * ) AC_MSG_ERROR(bad value for --enable-systemd) ;;
104       esac], [systemd=auto])
108 # systemd support
109 if test "x$enable_systemd" = "xno"; then
110     have_systemd=no;
111 else
112     PKG_CHECK_MODULES(SYSTEMD,
113         [libsystemd-daemon],
114         have_systemd=yes,
115         have_systemd=no)
116     if test "x$have_systemd" = "xno"; then
117         AC_MSG_NOTICE([Okay, checking for systemd a different way...])
118         PKG_CHECK_MODULES(SYSTEMD,
119             [libsystemd],
120             have_systemd=yes,
121             have_systemd=no)
122     fi
125 if test "x$have_systemd" = "xyes"; then
126     AC_DEFINE(HAVE_SYSTEMD,1,[Have systemd])
127     TOR_SYSTEMD_CFLAGS="${SYSTEMD_CFLAGS}"
128     TOR_SYSTEMD_LIBS="${SYSTEMD_LIBS}"
129     PKG_CHECK_MODULES(LIBSYSTEMD209, [libsystemd >= 209],
130          [AC_DEFINE(HAVE_SYSTEMD_209,1,[Have systemd v209 or more])], [])
132 AC_SUBST(TOR_SYSTEMD_CFLAGS)
133 AC_SUBST(TOR_SYSTEMD_LIBS)
135 if test "x$enable_systemd" = "xyes" -a "x$have_systemd" != "xyes" ; then
136     AC_MSG_ERROR([Explicitly requested systemd support, but systemd not found])
139 case "$host" in
140    *-*-solaris* )
141      AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
142      ;;
143 esac
145 AC_ARG_ENABLE(gcc-warnings,
146      AS_HELP_STRING(--enable-gcc-warnings, [enable verbose warnings]))
147 AC_ARG_ENABLE(gcc-warnings-advisory,
148      AS_HELP_STRING(--enable-gcc-warnings-advisory, [enable verbose warnings, excluding -Werror]))
150 dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
151 AC_ARG_ENABLE(gcc-hardening,
152     AS_HELP_STRING(--disable-gcc-hardening, [disable compiler security checks]))
154 AC_ARG_ENABLE(expensive-hardening,
155     AS_HELP_STRING(--enable-expensive-hardening, [enable more expensive compiler hardening; makes Tor slower]))
157 dnl Linker hardening options
158 dnl Currently these options are ELF specific - you can't use this with MacOSX
159 AC_ARG_ENABLE(linker-hardening,
160     AS_HELP_STRING(--disable-linker-hardening, [disable linker security fixups]))
162 AC_ARG_ENABLE(local-appdata,
163    AS_HELP_STRING(--enable-local-appdata, [default to host local application data paths on Windows]))
164 if test "$enable_local_appdata" = "yes"; then
165   AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
166             [Defined if we default to host local appdata paths on Windows])
169 # Tor2web mode flag
170 AC_ARG_ENABLE(tor2web-mode,
171      AS_HELP_STRING(--enable-tor2web-mode, [support tor2web non-anonymous mode]),
172 [if test "x$enableval" = "xyes"; then
173     CFLAGS="$CFLAGS -D ENABLE_TOR2WEB_MODE=1"
174 fi])
176 AC_ARG_ENABLE(bufferevents,
177      AS_HELP_STRING(--enable-bufferevents, [use Libevent's buffered IO]))
179 AC_ARG_ENABLE(tool-name-check,
180      AS_HELP_STRING(--disable-tool-name-check, [check for sanely named toolchain when cross-compiling]))
182 AC_ARG_ENABLE(seccomp,
183      AS_HELP_STRING(--disable-seccomp, [do not attempt to use libseccomp]))
185 AC_ARG_ENABLE(libscrypt,
186      AS_HELP_STRING(--disable-libscrypt, [do not attempt to use libscrypt]))
188 dnl check for the correct "ar" when cross-compiling
189 AN_MAKEVAR([AR], [AC_PROG_AR])
190 AN_PROGRAM([ar], [AC_PROG_AR])
191 AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [ar])])
192 AC_PROG_AR
194 dnl Check whether the above macro has settled for a simply named tool even
195 dnl though we're cross compiling. We must do this before running AC_PROG_CC,
196 dnl because that will find any cc on the system, not only the cross-compiler,
197 dnl and then verify that a binary built with this compiler runs on the
198 dnl build system. It will then come to the false conclusion that we're not
199 dnl cross-compiling.
200 if test "x$enable_tool_name_check" != "xno"; then
201     if test "x$ac_tool_warned" = "xyes"; then
202         AC_MSG_ERROR([We are cross compiling but could not find a properly named toolchain. Do you have your cross-compiling toolchain in PATH? (You can --disable-tool-name-check to ignore this.)])
203         elif test "x$ac_ct_AR" != "x" -a "x$cross_compiling" = "xmaybe"; then
204                 AC_MSG_ERROR([We think we are cross compiling but could not find a properly named toolchain. Do you have your cross-compiling toolchain in PATH? (You can --disable-tool-name-check to ignore this.)])
205         fi
208 AC_PROG_CC
209 AC_PROG_CPP
210 AC_PROG_MAKE_SET
211 AC_PROG_RANLIB
213 AC_PATH_PROG([PERL], [perl])
215 dnl autoconf 2.59 appears not to support AC_PROG_SED
216 AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
218 dnl check for asciidoc and a2x
219 AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
220 AC_PATH_PROGS([A2X], [a2x a2x.py], none)
222 AM_CONDITIONAL(USE_ASCIIDOC, test "x$asciidoc" = "xtrue")
224 AM_CONDITIONAL(USE_FW_HELPER, test "x$natpmp" = "xtrue" || test "x$upnp" = "xtrue")
225 AM_CONDITIONAL(NAT_PMP, test "x$natpmp" = "xtrue")
226 AM_CONDITIONAL(MINIUPNPC, test "x$upnp" = "xtrue")
227 AM_PROG_CC_C_O
228 AC_PROG_CC_C99
230 AC_ARG_VAR([PYTHON], [path to Python binary])
231 AC_CHECK_PROGS(PYTHON, [python python2 python2.7 python3 python3.3])
232 if test "x$PYTHON" = "x"; then
233   AC_MSG_WARN([Python unavailable; some tests will not be run.])
235 AM_CONDITIONAL(USEPYTHON, [test "x$PYTHON" != "x"])
237 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
238 AC_C_FLEXIBLE_ARRAY_MEMBER
239 ], [
240  dnl Maybe we've got an old autoconf...
241  AC_CACHE_CHECK([for flexible array members],
242      tor_cv_c_flexarray,
243      [AC_COMPILE_IFELSE(
244        AC_LANG_PROGRAM([
245  struct abc { int a; char b[]; };
246 ], [
247  struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
248  def->b[0] = 33;
250   [tor_cv_c_flexarray=yes],
251   [tor_cv_c_flexarray=no])])
252  if test "$tor_cv_flexarray" = "yes"; then
253    AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
254  else
255    AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
256  fi
259 AC_CACHE_CHECK([for working C99 mid-block declaration syntax],
260       tor_cv_c_c99_decl,
261       [AC_COMPILE_IFELSE(
262          [AC_LANG_PROGRAM([], [int x; x = 3; int y; y = 4 + x;])],
263          [tor_cv_c_c99_decl=yes],
264          [tor_cv_c_c99_decl=no] )])
265 if test "$tor_cv_c_c99_decl" != "yes"; then
266   AC_MSG_ERROR([Your compiler doesn't support c99 mid-block declarations. This is required as of Tor 0.2.6.x])
269 AC_CACHE_CHECK([for working C99 designated initializers],
270       tor_cv_c_c99_designated_init,
271       [AC_COMPILE_IFELSE(
272          [AC_LANG_PROGRAM([struct s { int a; int b; };],
273                [[ struct s ss = { .b = 5, .a = 6 }; ]])],
274          [tor_cv_c_c99_designated_init=yes],
275          [tor_cv_c_c99_designated_init=no] )])
277 if test "$tor_cv_c_c99_designated_init" != "yes"; then
278   AC_MSG_ERROR([Your compiler doesn't support c99 designated initializers. This is required as of Tor 0.2.6.x])
281 TORUSER=_tor
282 AC_ARG_WITH(tor-user,
283         AS_HELP_STRING(--with-tor-user=NAME, [specify username for tor daemon]),
284         [
285            TORUSER=$withval
286         ]
288 AC_SUBST(TORUSER)
290 TORGROUP=_tor
291 AC_ARG_WITH(tor-group,
292         AS_HELP_STRING(--with-tor-group=NAME, [specify group name for tor daemon]),
293         [
294            TORGROUP=$withval
295         ]
297 AC_SUBST(TORGROUP)
300 dnl If _WIN32 is defined and non-zero, we are building for win32
301 AC_MSG_CHECKING([for win32])
302 AC_RUN_IFELSE([AC_LANG_SOURCE([
303 int main(int c, char **v) {
304 #ifdef _WIN32
305 #if _WIN32
306   return 0;
307 #else
308   return 1;
309 #endif
310 #else
311   return 2;
312 #endif
313 }])],
314 bwin32=true; AC_MSG_RESULT([yes]),
315 bwin32=false; AC_MSG_RESULT([no]),
316 bwin32=cross; AC_MSG_RESULT([cross])
319 if test "$bwin32" = "cross"; then
320 AC_MSG_CHECKING([for win32 (cross)])
321 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
322 #ifdef _WIN32
323 int main(int c, char **v) {return 0;}
324 #else
325 #error
326 int main(int c, char **v) {return x(y);}
327 #endif
328 ])],
329 bwin32=true; AC_MSG_RESULT([yes]),
330 bwin32=false; AC_MSG_RESULT([no]))
333 AH_BOTTOM([
334 #ifdef _WIN32
335 /* Defined to access windows functions and definitions for >=WinXP */
336 # ifndef WINVER
337 #  define WINVER 0x0501
338 # endif
340 /* Defined to access _other_ windows functions and definitions for >=WinXP */
341 # ifndef _WIN32_WINNT
342 #  define _WIN32_WINNT 0x0501
343 # endif
345 /* Defined to avoid including some windows headers as part of Windows.h */
346 # ifndef WIN32_LEAN_AND_MEAN
347 #  define WIN32_LEAN_AND_MEAN 1
348 # endif
349 #endif
353 AM_CONDITIONAL(BUILD_NT_SERVICES, test "x$bwin32" = "xtrue")
355 dnl Enable C99 when compiling with MIPSpro
356 AC_MSG_CHECKING([for MIPSpro compiler])
357 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
358 #if (defined(__sgi) && defined(_COMPILER_VERSION))
359 #error
360   return x(y);
361 #endif
362 ])],
363 bmipspro=false; AC_MSG_RESULT(no),
364 bmipspro=true; AC_MSG_RESULT(yes))
366 if test "$bmipspro" = "true"; then
367   CFLAGS="$CFLAGS -c99"
370 AC_C_BIGENDIAN
372 AC_SEARCH_LIBS(socket, [socket network])
373 AC_SEARCH_LIBS(gethostbyname, [nsl])
374 AC_SEARCH_LIBS(dlopen, [dl])
375 AC_SEARCH_LIBS(inet_aton, [resolv])
376 AC_SEARCH_LIBS(backtrace, [execinfo])
377 saved_LIBS="$LIBS"
378 AC_SEARCH_LIBS([clock_gettime], [rt])
379 if test "$LIBS" != "$saved_LIBS"; then
380    # Looks like we need -lrt for clock_gettime().
381    have_rt=yes
384 AC_SEARCH_LIBS(pthread_create, [pthread])
385 AC_SEARCH_LIBS(pthread_detach, [pthread])
387 AM_CONDITIONAL(THREADS_WIN32, test "$bwin32" = "true")
388 AM_CONDITIONAL(THREADS_PTHREADS, test "$bwin32" = "false")
390 AC_CHECK_FUNCS(
391         _NSGetEnviron \
392         RtlSecureZeroMemory \
393         SecureZeroMemory \
394         accept4 \
395         backtrace \
396         backtrace_symbols_fd \
397         clock_gettime \
398         eventfd \
399         explicit_bzero \
400         timingsafe_memcmp \
401         flock \
402         ftime \
403         getaddrinfo \
404         getentropy \
405         getifaddrs \
406         getpass \
407         getrlimit \
408         gettimeofday \
409         gmtime_r \
410         htonll \
411         inet_aton \
412         ioctl \
413         issetugid \
414         llround \
415         localtime_r \
416         lround \
417         memmem \
418         memset_s \
419         pipe \
420         pipe2 \
421         prctl \
422         readpassphrase \
423         rint \
424         sigaction \
425         socketpair \
426         statvfs \
427         strlcat \
428         strlcpy \
429         strnlen \
430         strptime \
431         strtok_r \
432         strtoull \
433         sysconf \
434         sysctl \
435         uname \
436         usleep \
437         vasprintf \
438         _vscprintf
441 if test "$bwin32" != "true"; then
442   AC_CHECK_HEADERS(pthread.h)
443   AC_CHECK_FUNCS(pthread_create)
444   AC_CHECK_FUNCS(pthread_condattr_setclock)
447 if test "$bwin32" = "true"; then
448   AC_CHECK_DECLS([SecureZeroMemory, _getwch], , , [
449 #include <windows.h>
450 #include <conio.h>
451 #include <wchar.h>
452                  ])
455 AM_CONDITIONAL(BUILD_READPASSPHRASE_C,
456   test "x$ac_cv_func_readpassphrase" = "xno" && test "$bwin32" = "false")
458 dnl ------------------------------------------------------
459 dnl Where do you live, libevent?  And how do we call you?
461 if test "$bwin32" = "true"; then
462   TOR_LIB_WS32=-lws2_32
463   TOR_LIB_IPHLPAPI=-liphlpapi
464   # Some of the cargo-cults recommend -lwsock32 as well, but I don't
465   # think it's actually necessary.
466   TOR_LIB_GDI=-lgdi32
467 else
468   TOR_LIB_WS32=
469   TOR_LIB_GDI=
471 AC_SUBST(TOR_LIB_WS32)
472 AC_SUBST(TOR_LIB_GDI)
473 AC_SUBST(TOR_LIB_IPHLPAPI)
475 tor_libevent_pkg_redhat="libevent"
476 tor_libevent_pkg_debian="libevent-dev"
477 tor_libevent_devpkg_redhat="libevent-devel"
478 tor_libevent_devpkg_debian="libevent-dev"
480 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
481 dnl linking for static builds.
482 STATIC_LIBEVENT_FLAGS=""
483 if test "$enable_static_libevent" = "yes"; then
484     if test "$have_rt" = "yes"; then
485       STATIC_LIBEVENT_FLAGS=" -lrt "
486     fi
489 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
490 #ifdef _WIN32
491 #include <winsock2.h>
492 #endif
493 #include <sys/time.h>
494 #include <sys/types.h>
495 #include <event.h>], [
496 #ifdef _WIN32
497 #include <winsock2.h>
498 #endif
499 void *event_init(void);],
500     [
501 #ifdef _WIN32
502 {WSADATA d; WSAStartup(0x101,&d); }
503 #endif
504 event_init();
505 ], [--with-libevent-dir], [/opt/libevent])
507 dnl Now check for particular libevent functions.
508 save_LIBS="$LIBS"
509 save_LDFLAGS="$LDFLAGS"
510 save_CPPFLAGS="$CPPFLAGS"
511 LIBS="-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $LIBS"
512 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
513 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
514 AC_CHECK_FUNCS([event_get_version_number \
515                 evutil_secure_rng_set_urandom_device_file \
516                 evutil_secure_rng_init \
517                ])
518 AC_CHECK_MEMBERS([struct event.min_heap_idx], , ,
519 [#include <event.h>
522 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
524 LIBS="$STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $save_LIBS"
526 AM_CONDITIONAL(USE_EXTERNAL_EVDNS,
527   test "x$ac_cv_header_event2_dns_h" = "xyes")
529 if test "$enable_static_libevent" = "yes"; then
530    if test "$tor_cv_library_libevent_dir" = "(system)"; then
531      AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
532    else
533      TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
534    fi
535 else
536      if test "x$ac_cv_header_event2_event_h" = "xyes"; then
537        AC_SEARCH_LIBS(event_new, [event event_core], , AC_MSG_ERROR("libevent2 is installed but linking it failed while searching for event_new"))
538        AC_SEARCH_LIBS(evdns_base_new, [event event_extra], , AC_MSG_ERROR("libevent2 is installed but linking it failed while searching for evdns_base_new"))
540        if test "$ac_cv_search_event_new" != "none required"; then
541          TOR_LIBEVENT_LIBS="$ac_cv_search_event_new"
542        fi
543        if test "$ac_cv_search_evdns_base_new" != "none required"; then
544          TOR_LIBEVENT_LIBS="$ac_cv_search_evdns_base_new $TOR_LIBEVENT_LIBS"
545        fi
546      else
547        TOR_LIBEVENT_LIBS="-levent"
548      fi
551 LIBS="$save_LIBS"
552 LDFLAGS="$save_LDFLAGS"
553 CPPFLAGS="$save_CPPFLAGS"
555 dnl This isn't the best test for Libevent 2.0.3-alpha.  Once it's released,
556 dnl we can do much better.
557 if test "$enable_bufferevents" = "yes"; then
558   if test "$ac_cv_header_event2_bufferevent_ssl_h" != "yes"; then
559     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.])
560   else
562     CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
564     # Check for the right version.  First see if version detection works.
565     AC_MSG_CHECKING([whether we can detect the Libevent version])
566     AC_COMPILE_IFELSE([AC_LANG_SOURCE([
567 #include <event2/event.h>
568 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 10
569 #error
570 int x = y(zz);
571 #else
572 int x = 1;
573 #endif
574   ])], [event_version_number_works=yes; AC_MSG_RESULT([yes]) ],
575      [event_version_number_works=no;  AC_MSG_RESULT([no])])
576     if test "$event_version_number_works" != "yes"; then
577       AC_MSG_WARN([Version detection on Libevent seems broken.  Your Libevent installation is probably screwed up or very old.])
578     else
579       AC_MSG_CHECKING([whether Libevent is new enough for bufferevents])
580       AC_COMPILE_IFELSE([AC_LANG_SOURCE([
581 #include <event2/event.h>
582 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000d00
583 #error
584 int x = y(zz);
585 #else
586 int x = 1;
587 #endif
588    ])], [ AC_MSG_RESULT([yes]) ],
589       [ AC_MSG_RESULT([no])
590         AC_MSG_ERROR([Libevent does not seem new enough to support bufferevents.  We require 2.0.13-stable or later]) ] )
591     fi
592   fi
595 LIBS="$save_LIBS"
596 LDFLAGS="$save_LDFLAGS"
597 CPPFLAGS="$save_CPPFLAGS"
599 AM_CONDITIONAL(USE_BUFFEREVENTS, test "$enable_bufferevents" = "yes")
600 if test "$enable_bufferevents" = "yes"; then
601   AC_DEFINE(USE_BUFFEREVENTS, 1, [Defined if we're going to use Libevent's buffered IO API])
602   if test "$enable_static_libevent" = "yes"; then
603     TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent_openssl.a $TOR_LIBEVENT_LIBS"
604   else
605     TOR_LIBEVENT_LIBS="-levent_openssl $TOR_LIBEVENT_LIBS"
606   fi
608 AC_SUBST(TOR_LIBEVENT_LIBS)
610 dnl ------------------------------------------------------
611 dnl Where do you live, libm?
613 dnl On some platforms (Haiku/BeOS) the math library is
614 dnl part of libroot. In which case don't link against lm
615 TOR_LIB_MATH=""
616 save_LIBS="$LIBS"
617 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
618 if test "$ac_cv_search_pow" != "none required"; then
619     TOR_LIB_MATH="$ac_cv_search_pow"
621 LIBS="$save_LIBS"
622 AC_SUBST(TOR_LIB_MATH)
624 dnl ------------------------------------------------------
625 dnl Where do you live, openssl?  And how do we call you?
627 tor_openssl_pkg_redhat="openssl"
628 tor_openssl_pkg_debian="libssl-dev"
629 tor_openssl_devpkg_redhat="openssl-devel"
630 tor_openssl_devpkg_debian="libssl-dev"
632 ALT_openssl_WITHVAL=""
633 AC_ARG_WITH(ssl-dir,
634   AS_HELP_STRING(--with-ssl-dir=PATH, [obsolete alias for --with-openssl-dir]),
635   [
636       if test "x$withval" != "xno" && test "x$withval" != "x"; then
637          ALT_openssl_WITHVAL="$withval"
638       fi
639   ])
641 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI],
642     [#include <openssl/rand.h>],
643     [void RAND_add(const void *buf, int num, double entropy);],
644     [RAND_add((void*)0,0,0);], [],
645     [/usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /opt/openssl])
647 dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
649 if test "$enable_static_openssl" = "yes"; then
650    if test "$tor_cv_library_openssl_dir" = "(system)"; then
651      AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
652    else
653      TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
654    fi
655 else
656      TOR_OPENSSL_LIBS="-lssl -lcrypto"
658 AC_SUBST(TOR_OPENSSL_LIBS)
660 dnl Now check for particular openssl functions.
661 save_LIBS="$LIBS"
662 save_LDFLAGS="$LDFLAGS"
663 save_CPPFLAGS="$CPPFLAGS"
664 LIBS="$TOR_OPENSSL_LIBS $LIBS"
665 LDFLAGS="$TOR_LDFLAGS_openssl $LDFLAGS"
666 CPPFLAGS="$TOR_CPPFLAGS_openssl $CPPFLAGS"
668 AC_TRY_COMPILE([
669 #include <openssl/opensslv.h>
670 #if OPENSSL_VERSION_NUMBER < 0x1000000fL
671 #error "too old"
672 #endif
673    ], [],
674    [ : ],
675    [ AC_ERROR([OpenSSL is too old. We require 1.0.0 or later. You can specify a path to a newer one with --with-openssl-dir.]) ])
677 AC_TRY_COMPILE([
678 #include <openssl/opensslv.h>
679 #include <openssl/evp.h>
680 #if defined(OPENSSL_NO_EC) || defined(OPENSSL_NO_ECDH) || defined(OPENSSL_NO_ECDSA)
681 #error "no ECC"
682 #endif
683 #if !defined(NID_X9_62_prime256v1) || !defined(NID_secp224r1)
684 #error "curves unavailable"
685 #endif
686    ], [],
687    [ : ],
688    [ AC_ERROR([OpenSSL is built without full ECC support, including curves P256 and P224. You can specify a path to one with ECC support with --with-openssl-dir.]) ])
690 AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , ,
691 [#include <openssl/ssl.h>
694 AC_CHECK_FUNCS([ \
695                 SSL_SESSION_get_master_key \
696                 SSL_get_server_random \
697                 SSL_get_client_ciphers \
698                 SSL_get_client_random \
699                 SSL_CIPHER_find \
700                 TLS_method
701                ])
703 dnl Check if OpenSSL has scrypt implementation.
704 AC_CHECK_FUNCS([ EVP_PBE_scrypt ])
706 LIBS="$save_LIBS"
707 LDFLAGS="$save_LDFLAGS"
708 CPPFLAGS="$save_CPPFLAGS"
710 dnl ------------------------------------------------------
711 dnl Where do you live, zlib?  And how do we call you?
713 tor_zlib_pkg_redhat="zlib"
714 tor_zlib_pkg_debian="zlib1g"
715 tor_zlib_devpkg_redhat="zlib-devel"
716 tor_zlib_devpkg_debian="zlib1g-dev"
718 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
719     [#include <zlib.h>],
720     [const char * zlibVersion(void);],
721     [zlibVersion();], [--with-zlib-dir],
722     [/opt/zlib])
724 if test "$enable_static_zlib" = "yes"; then
725    if test "$tor_cv_library_zlib_dir" = "(system)"; then
726      AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
727  using --enable-static-zlib")
728    else
729      TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
730    fi
731 else
732      TOR_ZLIB_LIBS="-lz"
734 AC_SUBST(TOR_ZLIB_LIBS)
736 dnl ----------------------------------------------------------------------
737 dnl Check if libcap is available for capabilities.
739 tor_cap_pkg_debian="libcap2"
740 tor_cap_pkg_redhat="libcap"
741 tor_cap_devpkg_debian="libcap-dev"
742 tor_cap_devpkg_redhat="libcap-devel"
744 AC_CHECK_LIB([cap], [cap_init], [],
745   AC_MSG_NOTICE([Libcap was not found. Capabilities will not be usable.])
747 AC_CHECK_FUNCS(cap_set_proc)
749 dnl ---------------------------------------------------------------------
750 dnl Now that we know about our major libraries, we can check for compiler
751 dnl and linker hardening options.  We need to do this with the libraries known,
752 dnl since sometimes the linker will like an option but not be willing to
753 dnl use it with a build of a library.
755 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
756 all_libs_for_check="$TOR_ZLIB_LIBS $TOR_LIB_MATH $TOR_LIBEVENT_LIBS $TOR_OPENSSL_LIBS $TOR_SYSTEMD_LIBS $TOR_LIB_WS32 $TOR_LIB_GDI $TOR_CAP_LIBS"
758 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
759 #if !defined(__clang__)
760 #error
761 #endif])], have_clang=yes, have_clang=no)
763 if test "x$enable_gcc_hardening" != "xno"; then
764     CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
765     if test "x$have_clang" = "xyes"; then
766         TOR_CHECK_CFLAGS(-Qunused-arguments)
767     fi
768     TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
769     AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
770     AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
771 m4_ifdef([AS_VAR_IF],[
772     AS_VAR_IF(can_compile, [yes],
773         AS_VAR_IF(can_link, [yes],
774                   [],
775                   AC_MSG_ERROR([We tried to build with stack protection; it looks like your compiler supports it but your libc does not provide it. Are you missing libssp? (You can --disable-gcc-hardening to ignore this error.)]))
776         )])
777     AS_VAR_POPDEF([can_link])
778     AS_VAR_POPDEF([can_compile])
779     TOR_CHECK_CFLAGS(-Wstack-protector)
780     TOR_CHECK_CFLAGS(-fwrapv)
781     TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
782     if test "$bwin32" = "false"; then
783        TOR_CHECK_CFLAGS(-fPIE)
784        TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
785     fi
788 if test "x$enable_expensive_hardening" = "xyes"; then
789    TOR_CHECK_CFLAGS([-fsanitize=address])
790    TOR_CHECK_CFLAGS([-fsanitize=undefined])
791    TOR_CHECK_CFLAGS([-fno-omit-frame-pointer])
794 if test "x$enable_linker_hardening" != "xno"; then
795     TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
798 # For backtrace support
799 TOR_CHECK_LDFLAGS(-rdynamic)
801 dnl ------------------------------------------------------
802 dnl Now see if we have a -fomit-frame-pointer compiler option.
804 saved_CFLAGS="$CFLAGS"
805 TOR_CHECK_CFLAGS(-fomit-frame-pointer)
806 F_OMIT_FRAME_POINTER=''
807 if test "$saved_CFLAGS" != "$CFLAGS"; then
808   if test "x$enable_expensive_hardening" != "xyes"; then
809     F_OMIT_FRAME_POINTER='-fomit-frame-pointer'
810   fi
812 CFLAGS="$saved_CFLAGS"
813 AC_SUBST(F_OMIT_FRAME_POINTER)
815 dnl ------------------------------------------------------
816 dnl If we are adding -fomit-frame-pointer (or if the compiler's doing it
817 dnl for us, as GCC 4.6 and later do at many optimization levels), then
818 dnl we should try to add -fasynchronous-unwind-tables so that our backtrace
819 dnl code will work.
820 TOR_CHECK_CFLAGS(-fasynchronous-unwind-tables)
822 dnl ============================================================
823 dnl Check for libseccomp
825 if test "x$enable_seccomp" != "xno"; then
826   AC_CHECK_HEADERS([seccomp.h])
827   AC_SEARCH_LIBS(seccomp_init, [seccomp])
830 dnl ============================================================
831 dnl Check for libscrypt
833 if test "x$enable_libscrypt" != "xno"; then
834   AC_CHECK_HEADERS([libscrypt.h])
835   AC_SEARCH_LIBS(libscrypt_scrypt, [scrypt])
838 dnl ============================================================
839 dnl We need an implementation of curve25519.
841 dnl set these defaults.
842 build_curve25519_donna=no
843 build_curve25519_donna_c64=no
844 use_curve25519_donna=no
845 use_curve25519_nacl=no
846 CURVE25519_LIBS=
848 dnl The best choice is using curve25519-donna-c64, but that requires
849 dnl that we
850 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
851   tor_cv_can_use_curve25519_donna_c64,
852   [AC_RUN_IFELSE(
853     [AC_LANG_PROGRAM([dnl
854       #include <stdint.h>
855       typedef unsigned uint128_t __attribute__((mode(TI)));
856   int func(uint64_t a, uint64_t b) {
857            uint128_t c = ((uint128_t)a) * b;
858            int ok = ((uint64_t)(c>>96)) == 522859 &&
859              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
860                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
861                  (((uint64_t)(c))&0xffffffffL) == 0;
862            return ok;
863       }
864   ], [dnl
865     int ok = func( ((uint64_t)2000000000) * 1000000000,
866                    ((uint64_t)1234567890) << 24);
867         return !ok;
868       ])],
869   [tor_cv_can_use_curve25519_donna_c64=yes],
870       [tor_cv_can_use_curve25519_donna_c64=no],
871   [AC_LINK_IFELSE(
872         [AC_LANG_PROGRAM([dnl
873       #include <stdint.h>
874       typedef unsigned uint128_t __attribute__((mode(TI)));
875   int func(uint64_t a, uint64_t b) {
876            uint128_t c = ((uint128_t)a) * b;
877            int ok = ((uint64_t)(c>>96)) == 522859 &&
878              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
879                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
880                  (((uint64_t)(c))&0xffffffffL) == 0;
881            return ok;
882       }
883   ], [dnl
884     int ok = func( ((uint64_t)2000000000) * 1000000000,
885                  ((uint64_t)1234567890) << 24);
886         return !ok;
887       ])],
888           [tor_cv_can_use_curve25519_donna_c64=cross],
889       [tor_cv_can_use_curve25519_donna_c64=no])])])
891 AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
892                   nacl/crypto_scalarmult_curve25519.h])
894 AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
895   tor_cv_can_use_curve25519_nacl,
896   [tor_saved_LIBS="$LIBS"
897    LIBS="$LIBS -lnacl"
898    AC_LINK_IFELSE(
899      [AC_LANG_PROGRAM([dnl
900        #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
901        #include <crypto_scalarmult_curve25519.h>
902    #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
903    #include <nacl/crypto_scalarmult_curve25519.h>
904    #endif
905        #ifdef crypto_scalarmult_curve25519_ref_BYTES
906    #error Hey, this is the reference implementation! That's not fast.
907    #endif
908      ], [
909    unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
910      ])], [tor_cv_can_use_curve25519_nacl=yes],
911      [tor_cv_can_use_curve25519_nacl=no])
912    LIBS="$tor_saved_LIBS" ])
914  dnl Okay, now we need to figure out which one to actually use. Fall back
915  dnl to curve25519-donna.c
917  if test "x$tor_cv_can_use_curve25519_donna_c64" != "xno"; then
918    build_curve25519_donna_c64=yes
919    use_curve25519_donna=yes
920  elif test "x$tor_cv_can_use_curve25519_nacl" = "xyes"; then
921    use_curve25519_nacl=yes
922    CURVE25519_LIBS=-lnacl
923  else
924    build_curve25519_donna=yes
925    use_curve25519_donna=yes
926  fi
928 if test "x$use_curve25519_donna" = "xyes"; then
929   AC_DEFINE(USE_CURVE25519_DONNA, 1,
930             [Defined if we should use an internal curve25519_donna{,_c64} implementation])
932 if test "x$use_curve25519_nacl" = "xyes"; then
933   AC_DEFINE(USE_CURVE25519_NACL, 1,
934             [Defined if we should use a curve25519 from nacl])
936 AM_CONDITIONAL(BUILD_CURVE25519_DONNA,
937   test "x$build_curve25519_donna" = "xyes")
938 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64,
939   test "x$build_curve25519_donna_c64" = "xyes")
940 AC_SUBST(CURVE25519_LIBS)
942 dnl Make sure to enable support for large off_t if available.
943 AC_SYS_LARGEFILE
945 AC_CHECK_HEADERS(
946         assert.h \
947         errno.h \
948         fcntl.h \
949         signal.h \
950         string.h \
951         sys/capability.h \
952         sys/fcntl.h \
953         sys/stat.h \
954         sys/time.h \
955         sys/types.h \
956         time.h \
957         unistd.h
958  , , 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.))
960 dnl These headers are not essential
962 AC_CHECK_HEADERS(
963         arpa/inet.h \
964         crt_externs.h \
965         execinfo.h \
966         grp.h \
967         ifaddrs.h \
968         inttypes.h \
969         limits.h \
970         linux/types.h \
971         machine/limits.h \
972         malloc.h \
973         malloc/malloc.h \
974         malloc_np.h \
975         netdb.h \
976         netinet/in.h \
977         netinet/in6.h \
978         pwd.h \
979         readpassphrase.h \
980         stdint.h \
981         sys/eventfd.h \
982         sys/file.h \
983         sys/ioctl.h \
984         sys/limits.h \
985         sys/mman.h \
986         sys/param.h \
987         sys/prctl.h \
988         sys/resource.h \
989         sys/select.h \
990         sys/socket.h \
991         sys/statvfs.h \
992         sys/syscall.h \
993         sys/sysctl.h \
994         sys/syslimits.h \
995         sys/time.h \
996         sys/types.h \
997         sys/un.h \
998         sys/utime.h \
999         sys/wait.h \
1000         syslog.h \
1001         utime.h
1004 AC_CHECK_HEADERS(sys/param.h)
1006 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
1007 [#ifdef HAVE_SYS_TYPES_H
1008 #include <sys/types.h>
1009 #endif
1010 #ifdef HAVE_SYS_SOCKET_H
1011 #include <sys/socket.h>
1012 #endif])
1013 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
1014 [#ifdef HAVE_SYS_TYPES_H
1015 #include <sys/types.h>
1016 #endif
1017 #ifdef HAVE_SYS_SOCKET_H
1018 #include <sys/socket.h>
1019 #endif
1020 #ifdef HAVE_NET_IF_H
1021 #include <net/if.h>
1022 #endif
1023 #ifdef HAVE_NETINET_IN_H
1024 #include <netinet/in.h>
1025 #endif])
1027 AC_CHECK_HEADERS(linux/if.h,[],[],
1029 #ifdef HAVE_SYS_SOCKET_H
1030 #include <sys/socket.h>
1031 #endif
1034 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
1035         linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
1036 [#ifdef HAVE_SYS_TYPES_H
1037 #include <sys/types.h>
1038 #endif
1039 #ifdef HAVE_SYS_SOCKET_H
1040 #include <sys/socket.h>
1041 #endif
1042 #ifdef HAVE_LIMITS_H
1043 #include <limits.h>
1044 #endif
1045 #ifdef HAVE_LINUX_TYPES_H
1046 #include <linux/types.h>
1047 #endif
1048 #ifdef HAVE_NETINET_IN6_H
1049 #include <netinet/in6.h>
1050 #endif
1051 #ifdef HAVE_NETINET_IN_H
1052 #include <netinet/in.h>
1053 #endif])
1055 AC_CHECK_HEADERS(linux/netfilter_ipv6/ip6_tables.h,
1056         linux_netfilter_ipv6_ip6_tables=1, linux_netfilter_ipv6_ip6_tables=0,
1057 [#ifdef HAVE_SYS_TYPES_H
1058 #include <sys/types.h>
1059 #endif
1060 #ifdef HAVE_SYS_SOCKET_H
1061 #include <sys/socket.h>
1062 #endif
1063 #ifdef HAVE_LIMITS_H
1064 #include <limits.h>
1065 #endif
1066 #ifdef HAVE_LINUX_TYPES_H
1067 #include <linux/types.h>
1068 #endif
1069 #ifdef HAVE_NETINET_IN6_H
1070 #include <netinet/in6.h>
1071 #endif
1072 #ifdef HAVE_NETINET_IN_H
1073 #include <netinet/in.h>
1074 #endif
1075 #ifdef HAVE_LINUX_IF_H
1076 #include <linux/if.h>
1077 #endif])
1079 if test "x$transparent" = "xtrue"; then
1080    transparent_ok=0
1081    if test "x$net_if_found" = "x1" && test "x$net_pfvar_found" = "x1"; then
1082      transparent_ok=1
1083    fi
1084    if test "x$linux_netfilter_ipv4" = "x1"; then
1085      transparent_ok=1
1086    fi
1087    if test "x$linux_netfilter_ipv6_ip6_tables" = "x1"; then
1088      transparent_ok=1
1089    fi
1090    if test "x$transparent_ok" = "x1"; then
1091      AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
1092      case "$host" in
1093        *-*-openbsd* | *-*-bitrig*)
1094          AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
1095      esac
1096    else
1097      AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
1098    fi
1101 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
1102 [#ifdef HAVE_SYS_TYPES_H
1103 #include <sys/types.h>
1104 #endif
1105 #ifdef HAVE_SYS_TIME_H
1106 #include <sys/time.h>
1107 #endif])
1109 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
1110 dnl Watch out.
1112 AC_CHECK_SIZEOF(int8_t)
1113 AC_CHECK_SIZEOF(int16_t)
1114 AC_CHECK_SIZEOF(int32_t)
1115 AC_CHECK_SIZEOF(int64_t)
1116 AC_CHECK_SIZEOF(uint8_t)
1117 AC_CHECK_SIZEOF(uint16_t)
1118 AC_CHECK_SIZEOF(uint32_t)
1119 AC_CHECK_SIZEOF(uint64_t)
1120 AC_CHECK_SIZEOF(intptr_t)
1121 AC_CHECK_SIZEOF(uintptr_t)
1123 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
1125 AC_CHECK_SIZEOF(char)
1126 AC_CHECK_SIZEOF(short)
1127 AC_CHECK_SIZEOF(int)
1128 AC_CHECK_SIZEOF(long)
1129 AC_CHECK_SIZEOF(long long)
1130 AC_CHECK_SIZEOF(__int64)
1131 AC_CHECK_SIZEOF(void *)
1132 AC_CHECK_SIZEOF(time_t)
1133 AC_CHECK_SIZEOF(size_t)
1134 AC_CHECK_SIZEOF(pid_t)
1136 AC_CHECK_TYPES([uint, u_char, ssize_t])
1138 AC_PC_FROM_UCONTEXT([:])
1140 dnl used to include sockaddr_storage, but everybody has that.
1141 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
1142 [#ifdef HAVE_SYS_TYPES_H
1143 #include <sys/types.h>
1144 #endif
1145 #ifdef HAVE_NETINET_IN_H
1146 #include <netinet/in.h>
1147 #endif
1148 #ifdef HAVE_NETINET_IN6_H
1149 #include <netinet/in6.h>
1150 #endif
1151 #ifdef HAVE_SYS_SOCKET_H
1152 #include <sys/socket.h>
1153 #endif
1154 #ifdef _WIN32
1155 #define _WIN32_WINNT 0x0501
1156 #define WIN32_LEAN_AND_MEAN
1157 #include <winsock2.h>
1158 #include <ws2tcpip.h>
1159 #endif
1161 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
1162 [#ifdef HAVE_SYS_TYPES_H
1163 #include <sys/types.h>
1164 #endif
1165 #ifdef HAVE_NETINET_IN_H
1166 #include <netinet/in.h>
1167 #endif
1168 #ifdef HAVE_NETINET_IN6_H
1169 #include <netinet/in6.h>
1170 #endif
1171 #ifdef HAVE_SYS_SOCKET_H
1172 #include <sys/socket.h>
1173 #endif
1174 #ifdef _WIN32
1175 #define _WIN32_WINNT 0x0501
1176 #define WIN32_LEAN_AND_MEAN
1177 #include <winsock2.h>
1178 #include <ws2tcpip.h>
1179 #endif
1182 AC_CHECK_TYPES([rlim_t], , ,
1183 [#ifdef HAVE_SYS_TYPES_H
1184 #include <sys/types.h>
1185 #endif
1186 #ifdef HAVE_SYS_TIME_H
1187 #include <sys/time.h>
1188 #endif
1189 #ifdef HAVE_SYS_RESOURCE_H
1190 #include <sys/resource.h>
1191 #endif
1194 AX_CHECK_SIGN([time_t],
1195        [ : ],
1196        [ : ], [
1197 #ifdef HAVE_SYS_TYPES_H
1198 #include <sys/types.h>
1199 #endif
1200 #ifdef HAVE_SYS_TIME_H
1201 #include <sys/time.h>
1202 #endif
1203 #ifdef HAVE_TIME_H
1204 #include <time.h>
1205 #endif
1208 if test "$ax_cv_decl_time_t_signed" = "no"; then
1209   AC_MSG_ERROR([You have an unsigned time_t; Tor does not support that. Please tell the Tor developers about your interesting platform.])
1212 AX_CHECK_SIGN([size_t],
1213        [ tor_cv_size_t_signed=yes ],
1214        [ tor_cv_size_t_signed=no ], [
1215 #ifdef HAVE_SYS_TYPES_H
1216 #include <sys/types.h>
1217 #endif
1220 if test "$ax_cv_decl_size_t_signed" = "yes"; then
1221   AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
1224 AX_CHECK_SIGN([enum always],
1225        [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
1226        [ : ], [
1227  enum always { AAA, BBB, CCC };
1230 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
1231 #ifdef HAVE_SYS_SOCKET_H
1232 #include <sys/socket.h>
1233 #endif
1236 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1238 AC_CHECK_SIZEOF(cell_t)
1240 # Now make sure that NULL can be represented as zero bytes.
1241 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1242 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1243 [[#include <stdlib.h>
1244 #include <string.h>
1245 #include <stdio.h>
1246 #ifdef HAVE_STDDEF_H
1247 #include <stddef.h>
1248 #endif
1249 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1250 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1251        [tor_cv_null_is_zero=yes],
1252        [tor_cv_null_is_zero=no],
1253        [tor_cv_null_is_zero=cross])])
1255 if test "$tor_cv_null_is_zero" = "cross"; then
1256   # Cross-compiling; let's hope that the target isn't raving mad.
1257   AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
1260 if test "$tor_cv_null_is_zero" != "no"; then
1261   AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1262             [Define to 1 iff memset(0) sets pointers to NULL])
1265 AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
1266 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1267 [[#include <stdlib.h>
1268 #include <string.h>
1269 #include <stdio.h>
1270 #ifdef HAVE_STDDEF_H
1271 #include <stddef.h>
1272 #endif
1273 int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
1274 return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
1275        [tor_cv_dbl0_is_zero=yes],
1276        [tor_cv_dbl0_is_zero=no],
1277        [tor_cv_dbl0_is_zero=cross])])
1279 if test "$tor_cv_dbl0_is_zero" = "cross"; then
1280   # Cross-compiling; let's hope that the target isn't raving mad.
1281   AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
1284 if test "$tor_cv_dbl0_is_zero" != "no"; then
1285   AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
1286             [Define to 1 iff memset(0) sets doubles to 0.0])
1289 # And what happens when we malloc zero?
1290 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
1291 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1292 [[#include <stdlib.h>
1293 #include <string.h>
1294 #include <stdio.h>
1295 #ifdef HAVE_STDDEF_H
1296 #include <stddef.h>
1297 #endif
1298 int main () { return malloc(0)?0:1; }]])],
1299        [tor_cv_malloc_zero_works=yes],
1300        [tor_cv_malloc_zero_works=no],
1301        [tor_cv_malloc_zero_works=cross])])
1303 if test "$tor_cv_malloc_zero_works" = "cross"; then
1304   # Cross-compiling; let's hope that the target isn't raving mad.
1305   AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
1308 if test "$tor_cv_malloc_zero_works" = "yes"; then
1309   AC_DEFINE([MALLOC_ZERO_WORKS], 1,
1310             [Define to 1 iff malloc(0) returns a pointer])
1313 # whether we seem to be in a 2s-complement world.
1314 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
1315 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1316 [[int main () { int problem = ((-99) != (~99)+1);
1317 return problem ? 1 : 0; }]])],
1318        [tor_cv_twos_complement=yes],
1319        [tor_cv_twos_complement=no],
1320        [tor_cv_twos_complement=cross])])
1322 if test "$tor_cv_twos_complement" = "cross"; then
1323   # Cross-compiling; let's hope that the target isn't raving mad.
1324   AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
1327 if test "$tor_cv_twos_complement" != "no"; then
1328   AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
1329             [Define to 1 iff we represent negative integers with
1330              two's complement])
1333 # What does shifting a negative value do?
1334 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
1335 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1336 [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
1337        [tor_cv_sign_extend=yes],
1338        [tor_cv_sign_extend=no],
1339        [tor_cv_sign_extend=cross])])
1341 if test "$tor_cv_sign_extend" = "cross"; then
1342   # Cross-compiling; let's hope that the target isn't raving mad.
1343   AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
1346 if test "$tor_cv_sign_extend" != "no"; then
1347   AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
1348             [Define to 1 iff right-shifting a negative value performs sign-extension])
1351 # Whether we should use the dmalloc memory allocation debugging library.
1352 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
1353 AC_ARG_WITH(dmalloc,
1354 AS_HELP_STRING(--with-dmalloc, [use debug memory allocation library]),
1355 [if [[ "$withval" = "yes" ]]; then
1356   dmalloc=1
1357   AC_MSG_RESULT(yes)
1358 else
1359   dmalloc=1
1360   AC_MSG_RESULT(no)
1361 fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
1364 if [[ $dmalloc -eq 1 ]]; then
1365   AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
1366   AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
1367   AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
1368   AC_CHECK_FUNCS(dmalloc_strdup dmalloc_strndup)
1371 AC_ARG_WITH(tcmalloc,
1372 AS_HELP_STRING(--with-tcmalloc, [use tcmalloc memory allocation library]),
1373 [ tcmalloc=yes ], [ tcmalloc=no ])
1375 if test "x$tcmalloc" = "xyes"; then
1376    LDFLAGS="-ltcmalloc $LDFLAGS"
1379 using_custom_malloc=no
1380 if test "x$enable_openbsd_malloc" = "xyes"; then
1381    using_custom_malloc=yes
1383 if test "x$tcmalloc" = "xyes"; then
1384    using_custom_malloc=yes
1386 if test "$using_custom_malloc" = "no"; then
1387    AC_CHECK_FUNCS(mallinfo)
1390 # By default, we're going to assume we don't have mlockall()
1391 # bionic and other platforms have various broken mlockall subsystems.
1392 # Some systems don't have a working mlockall, some aren't linkable,
1393 # and some have it but don't declare it.
1394 AC_CHECK_FUNCS(mlockall)
1395 AC_CHECK_DECLS([mlockall], , , [
1396 #ifdef HAVE_SYS_MMAN_H
1397 #include <sys/mman.h>
1398 #endif])
1400 # Allow user to specify an alternate syslog facility
1401 AC_ARG_WITH(syslog-facility,
1402 AS_HELP_STRING(--with-syslog-facility=LOG, [syslog facility to use (default=LOG_DAEMON)]),
1403 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
1404 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
1405 AC_SUBST(LOGFACILITY)
1407 # Check if we have getresuid and getresgid
1408 AC_CHECK_FUNCS(getresuid getresgid)
1410 # Check for gethostbyname_r in all its glorious incompatible versions.
1411 #   (This logic is based on that in Python's configure.in)
1412 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
1413   [Define this if you have any gethostbyname_r()])
1415 AC_CHECK_FUNC(gethostbyname_r, [
1416   AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
1417   OLD_CFLAGS=$CFLAGS
1418   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1419   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1420 #include <netdb.h>
1421   ], [[
1422     char *cp1, *cp2;
1423     struct hostent *h1, *h2;
1424     int i1, i2;
1425     (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
1426   ]])],[
1427     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1428     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
1429      [Define this if gethostbyname_r takes 6 arguments])
1430     AC_MSG_RESULT(6)
1431   ], [
1432     AC_TRY_COMPILE([
1433 #include <netdb.h>
1434     ], [
1435       char *cp1, *cp2;
1436       struct hostent *h1;
1437       int i1, i2;
1438       (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
1439     ], [
1440       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1441       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
1442         [Define this if gethostbyname_r takes 5 arguments])
1443       AC_MSG_RESULT(5)
1444    ], [
1445       AC_TRY_COMPILE([
1446 #include <netdb.h>
1447      ], [
1448        char *cp1;
1449        struct hostent *h1;
1450        struct hostent_data hd;
1451        (void) gethostbyname_r(cp1,h1,&hd);
1452      ], [
1453        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1454        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
1455          [Define this if gethostbyname_r takes 3 arguments])
1456        AC_MSG_RESULT(3)
1457      ], [
1458        AC_MSG_RESULT(0)
1459      ])
1460   ])
1461  ])
1462  CFLAGS=$OLD_CFLAGS
1465 AC_CACHE_CHECK([whether the C compiler supports __func__],
1466   tor_cv_have_func_macro,
1467   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1468 #include <stdio.h>
1469 int main(int c, char **v) { puts(__func__); }])],
1470   tor_cv_have_func_macro=yes,
1471   tor_cv_have_func_macro=no))
1473 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
1474   tor_cv_have_FUNC_macro,
1475   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1476 #include <stdio.h>
1477 int main(int c, char **v) { puts(__FUNC__); }])],
1478   tor_cv_have_FUNC_macro=yes,
1479   tor_cv_have_FUNC_macro=no))
1481 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
1482   tor_cv_have_FUNCTION_macro,
1483   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1484 #include <stdio.h>
1485 int main(int c, char **v) { puts(__FUNCTION__); }])],
1486   tor_cv_have_FUNCTION_macro=yes,
1487   tor_cv_have_FUNCTION_macro=no))
1489 AC_CACHE_CHECK([whether we have extern char **environ already declared],
1490   tor_cv_have_environ_declared,
1491   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1492 /* We define _GNU_SOURCE here because it is also defined in compat.c.
1493  * Without it environ doesn't get declared. */
1494 #define _GNU_SOURCE
1495 #ifdef HAVE_UNISTD_H
1496 #include <unistd.h>
1497 #endif
1498 #include <stdlib.h>
1499 int main(int c, char **v) { char **t = environ; }])],
1500   tor_cv_have_environ_declared=yes,
1501   tor_cv_have_environ_declared=no))
1503 if test "$tor_cv_have_func_macro" = "yes"; then
1504   AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
1507 if test "$tor_cv_have_FUNC_macro" = "yes"; then
1508   AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
1511 if test "$tor_cv_have_FUNCTION_macro" = "yes"; then
1512   AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
1513            [Defined if the compiler supports __FUNCTION__])
1516 if test "$tor_cv_have_environ_declared" = "yes"; then
1517   AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
1518            [Defined if we have extern char **environ already declared])
1521 # $prefix stores the value of the --prefix command line option, or
1522 # NONE if the option wasn't set.  In the case that it wasn't set, make
1523 # it be the default, so that we can use it to expand directories now.
1524 if test "x$prefix" = "xNONE"; then
1525   prefix=$ac_default_prefix
1528 # and similarly for $exec_prefix
1529 if test "x$exec_prefix" = "xNONE"; then
1530   exec_prefix=$prefix
1533 if test "x$BUILDDIR" = "x"; then
1534   BUILDDIR=`pwd`
1536 AC_SUBST(BUILDDIR)
1537 AH_TEMPLATE([BUILDDIR],[tor's build directory])
1538 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
1540 if test "x$CONFDIR" = "x"; then
1541   CONFDIR=`eval echo $sysconfdir/tor`
1543 AC_SUBST(CONFDIR)
1544 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
1545 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
1547 BINDIR=`eval echo $bindir`
1548 AC_SUBST(BINDIR)
1549 LOCALSTATEDIR=`eval echo $localstatedir`
1550 AC_SUBST(LOCALSTATEDIR)
1552 if test "$bwin32" = "true"; then
1553   # Test if the linker supports the --nxcompat and --dynamicbase options
1554   # for Windows
1555   save_LDFLAGS="$LDFLAGS"
1556   LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
1557   AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
1558   AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
1559     [AC_MSG_RESULT([yes])]
1560     [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
1561     [AC_MSG_RESULT([no])]
1562   )
1563   LDFLAGS="$save_LDFLAGS"
1566 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
1567 # than autoconf's macros like.
1568 if test "$GCC" = "yes"; then
1569   # Disable GCC's strict aliasing checks.  They are an hours-to-debug
1570   # accident waiting to happen.
1571   CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
1572 else
1573   # Override optimization level for non-gcc compilers
1574   CFLAGS="$CFLAGS -O"
1575   enable_gcc_warnings=no
1576   enable_gcc_warnings_advisory=no
1579 # OS X Lion started deprecating the system openssl. Let's just disable
1580 # all deprecation warnings on OS X. Also, to potentially make the binary
1581 # a little smaller, let's enable dead_strip.
1582 case "$host_os" in
1584  darwin*)
1585     CFLAGS="$CFLAGS -Wno-deprecated-declarations"
1586     LDFLAGS="$LDFLAGS -dead_strip" ;;
1587 esac
1589 # Add some more warnings which we use in development but not in the
1590 # released versions.  (Some relevant gcc versions can't handle these.)
1591 if test "x$enable_gcc_warnings" = "xyes" ||
1592   test "x$enable_gcc_warnings_advisory" = "xyes"; then
1594   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1595 #if !defined(__GNUC__) || (__GNUC__ < 4)
1596 #error
1597 #endif])], have_gcc4=yes, have_gcc4=no)
1599   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1600 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
1601 #error
1602 #endif])], have_gcc42=yes, have_gcc42=no)
1604   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1605 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
1606 #error
1607 #endif])], have_gcc43=yes, have_gcc43=no)
1609   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1610 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
1611 #error
1612 #endif])], have_gcc46=yes, have_gcc46=no)
1615   save_CFLAGS="$CFLAGS"
1616   CFLAGS="$CFLAGS -Wshorten-64-to-32"
1617   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
1618                     have_shorten64_flag=no)
1619   CFLAGS="$save_CFLAGS"
1621   case "$host" in
1622     *-*-openbsd* | *-*-bitrig*)
1623       # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
1624       # That's fine, except that the headers don't pass -Wredundant-decls.
1625       # Therefore, let's disable -Wsystem-headers when we're building
1626       # with maximal warnings on OpenBSD.
1627       CFLAGS="$CFLAGS -Wno-system-headers" ;;
1628   esac
1630   CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
1631   CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
1632   CFLAGS="$CFLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
1633   CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
1634   CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
1636   if test "x$enable_gcc_warnings" = "xyes"; then
1637     CFLAGS="$CFLAGS -Werror"
1638   fi
1640   # Disabled, so we can use mallinfo(): -Waggregate-return
1642   if test "x$have_gcc4" = "xyes"; then
1643     # These warnings break gcc 3.3.5 and work on gcc 4.0.2
1644     CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wold-style-definition"
1645   fi
1647   if test "x$have_gcc42" = "xyes"; then
1648     # These warnings break gcc 4.0.2 and work on gcc 4.2
1649     # XXXX020 See if any of these work with earlier versions.
1650     CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wstrict-overflow=1"
1652     # We used to use -Wstrict-overflow=5, but that breaks us heavily under 4.3.
1653   fi
1655   if test "x$have_gcc42" = "xyes" && test "x$have_clang" = "xno"; then
1656     # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2
1657     CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init"
1658   fi
1660   if test "x$have_gcc43" = "xyes"; then
1661     # These warnings break gcc 4.2 and work on gcc 4.3
1662     # XXXX020 See if any of these work with earlier versions.
1663     CFLAGS="$CFLAGS -Wextra -Warray-bounds"
1664   fi
1666   if test "x$have_gcc46" = "xyes"; then
1667     # This warning was added in gcc 4.3, but it appears to generate
1668     # spurious warnings in gcc 4.4.  I don't know if it works in 4.5.
1669     CFLAGS="$CFLAGS -Wlogical-op"
1670   fi
1672   if test "x$have_shorten64_flag" = "xyes"; then
1673     CFLAGS="$CFLAGS -Wshorten-64-to-32"
1674   fi
1678 ##This will break the world on some 64-bit architectures
1679 # CFLAGS="$CFLAGS -Winline"
1682 if test "$enable_coverage" = "yes" && test "$have_clang" = "no"; then
1683    case "$host_os" in
1684     darwin*)
1685       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.])
1686    esac
1689 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
1691 AC_CONFIG_FILES([
1692         Doxyfile
1693         Makefile
1694         contrib/dist/suse/tor.sh
1695         contrib/operator-tools/tor.logrotate
1696         contrib/dist/tor.sh
1697         contrib/dist/torctl
1698         contrib/dist/tor.service
1699         src/config/torrc.sample
1700         src/config/torrc.minimal
1701         scripts/maint/checkOptionDocs.pl
1702         scripts/maint/updateVersions.pl
1705 if test "x$asciidoc" = "xtrue" && test "$ASCIIDOC" = "none"; then
1706   regular_mans="doc/tor doc/tor-gencert doc/tor-resolve doc/torify"
1707   for file in $regular_mans ; do
1708     if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
1709       echo "==================================";
1710       echo;
1711       echo "Building Tor has failed since manpages cannot be built.";
1712       echo;
1713       echo "You need asciidoc installed to be able to build the manpages.";
1714       echo "To build without manpages, use the --disable-asciidoc argument";
1715       echo "when calling configure.";
1716       echo;
1717       echo "==================================";
1718       exit 1;
1719     fi
1720   done
1723 AC_OUTPUT