Disable GET /tor/bytes.txt and GETINFO dir-usage
[tor.git] / configure.ac
blobd7db0dbd888ec8b3d5042c3088d85a2484e5e077
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.9.0-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")
77 AC_ARG_ENABLE(transparent,
78      AS_HELP_STRING(--disable-transparent, [disable transparent proxy support]),
79      [case "${enableval}" in
80         "yes") transparent=true ;;
81         "no")  transparent=false ;;
82         *) AC_MSG_ERROR(bad value for --enable-transparent) ;;
83       esac], [transparent=true])
85 AC_ARG_ENABLE(asciidoc,
86      AS_HELP_STRING(--disable-asciidoc, [don't use asciidoc (disables building of manpages)]),
87      [case "${enableval}" in
88         "yes") asciidoc=true ;;
89         "no")  asciidoc=false ;;
90         *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
91       esac], [asciidoc=true])
93 # systemd notify support
94 AC_ARG_ENABLE(systemd,
95       AS_HELP_STRING(--enable-systemd, [enable systemd notification support]),
96       [case "${enableval}" in
97         "yes") systemd=true ;;
98         "no")  systemd=false ;;
99         * ) AC_MSG_ERROR(bad value for --enable-systemd) ;;
100       esac], [systemd=auto])
104 # systemd support
105 if test "x$enable_systemd" = "xno"; then
106     have_systemd=no;
107 else
108     PKG_CHECK_MODULES(SYSTEMD,
109         [libsystemd-daemon],
110         have_systemd=yes,
111         have_systemd=no)
112     if test "x$have_systemd" = "xno"; then
113         AC_MSG_NOTICE([Okay, checking for systemd a different way...])
114         PKG_CHECK_MODULES(SYSTEMD,
115             [libsystemd],
116             have_systemd=yes,
117             have_systemd=no)
118     fi
121 if test "x$have_systemd" = "xyes"; then
122     AC_DEFINE(HAVE_SYSTEMD,1,[Have systemd])
123     TOR_SYSTEMD_CFLAGS="${SYSTEMD_CFLAGS}"
124     TOR_SYSTEMD_LIBS="${SYSTEMD_LIBS}"
125     PKG_CHECK_MODULES(LIBSYSTEMD209, [libsystemd >= 209],
126          [AC_DEFINE(HAVE_SYSTEMD_209,1,[Have systemd v209 or more])], [])
128 AC_SUBST(TOR_SYSTEMD_CFLAGS)
129 AC_SUBST(TOR_SYSTEMD_LIBS)
131 if test "x$enable_systemd" = "xyes" -a "x$have_systemd" != "xyes" ; then
132     AC_MSG_ERROR([Explicitly requested systemd support, but systemd not found])
135 case "$host" in
136    *-*-solaris* )
137      AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
138      ;;
139 esac
141 AC_ARG_ENABLE(gcc-warnings,
142      AS_HELP_STRING(--enable-gcc-warnings, [enable verbose warnings]))
143 AC_ARG_ENABLE(gcc-warnings-advisory,
144      AS_HELP_STRING(--enable-gcc-warnings-advisory, [enable verbose warnings, excluding -Werror]))
146 dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
147 AC_ARG_ENABLE(gcc-hardening,
148     AS_HELP_STRING(--disable-gcc-hardening, [disable compiler security checks]))
150 AC_ARG_ENABLE(expensive-hardening,
151     AS_HELP_STRING(--enable-expensive-hardening, [enable more expensive compiler hardening; makes Tor slower]))
153 dnl Linker hardening options
154 dnl Currently these options are ELF specific - you can't use this with MacOSX
155 AC_ARG_ENABLE(linker-hardening,
156     AS_HELP_STRING(--disable-linker-hardening, [disable linker security fixups]))
158 AC_ARG_ENABLE(local-appdata,
159    AS_HELP_STRING(--enable-local-appdata, [default to host local application data paths on Windows]))
160 if test "$enable_local_appdata" = "yes"; then
161   AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
162             [Defined if we default to host local appdata paths on Windows])
165 # Tor2web mode flag
166 AC_ARG_ENABLE(tor2web-mode,
167      AS_HELP_STRING(--enable-tor2web-mode, [support tor2web non-anonymous mode]),
168 [if test "x$enableval" = "xyes"; then
169     CFLAGS="$CFLAGS -D ENABLE_TOR2WEB_MODE=1"
170 fi])
172 AC_ARG_ENABLE(bufferevents,
173      AS_HELP_STRING(--enable-bufferevents, [use Libevent's buffered IO]))
175 AC_ARG_ENABLE(tool-name-check,
176      AS_HELP_STRING(--disable-tool-name-check, [check for sanely named toolchain when cross-compiling]))
178 AC_ARG_ENABLE(seccomp,
179      AS_HELP_STRING(--disable-seccomp, [do not attempt to use libseccomp]))
181 AC_ARG_ENABLE(libscrypt,
182      AS_HELP_STRING(--disable-libscrypt, [do not attempt to use libscrypt]))
184 dnl check for the correct "ar" when cross-compiling
185 AN_MAKEVAR([AR], [AC_PROG_AR])
186 AN_PROGRAM([ar], [AC_PROG_AR])
187 AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [ar])])
188 AC_PROG_AR
190 dnl Check whether the above macro has settled for a simply named tool even
191 dnl though we're cross compiling. We must do this before running AC_PROG_CC,
192 dnl because that will find any cc on the system, not only the cross-compiler,
193 dnl and then verify that a binary built with this compiler runs on the
194 dnl build system. It will then come to the false conclusion that we're not
195 dnl cross-compiling.
196 if test "x$enable_tool_name_check" != "xno"; then
197     if test "x$ac_tool_warned" = "xyes"; then
198         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.)])
199         elif test "x$ac_ct_AR" != "x" -a "x$cross_compiling" = "xmaybe"; then
200                 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.)])
201         fi
204 AC_PROG_CC
205 AC_PROG_CPP
206 AC_PROG_MAKE_SET
207 AC_PROG_RANLIB
209 AC_PATH_PROG([PERL], [perl])
211 dnl autoconf 2.59 appears not to support AC_PROG_SED
212 AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
214 dnl check for asciidoc and a2x
215 AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
216 AC_PATH_PROGS([A2X], [a2x a2x.py], none)
218 AM_CONDITIONAL(USE_ASCIIDOC, test "x$asciidoc" = "xtrue")
220 AM_CONDITIONAL(USE_FW_HELPER, test "x$natpmp" = "xtrue" || test "x$upnp" = "xtrue")
221 AM_CONDITIONAL(NAT_PMP, test "x$natpmp" = "xtrue")
222 AM_CONDITIONAL(MINIUPNPC, test "x$upnp" = "xtrue")
223 AM_PROG_CC_C_O
224 AC_PROG_CC_C99
226 AC_ARG_VAR([PYTHON], [path to Python binary])
227 AC_CHECK_PROGS(PYTHON, [python python2 python2.7 python3 python3.3])
228 if test "x$PYTHON" = "x"; then
229   AC_MSG_WARN([Python unavailable; some tests will not be run.])
231 AM_CONDITIONAL(USEPYTHON, [test "x$PYTHON" != "x"])
233 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
234 AC_C_FLEXIBLE_ARRAY_MEMBER
235 ], [
236  dnl Maybe we've got an old autoconf...
237  AC_CACHE_CHECK([for flexible array members],
238      tor_cv_c_flexarray,
239      [AC_COMPILE_IFELSE(
240        AC_LANG_PROGRAM([
241  struct abc { int a; char b[]; };
242 ], [
243  struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
244  def->b[0] = 33;
246   [tor_cv_c_flexarray=yes],
247   [tor_cv_c_flexarray=no])])
248  if test "$tor_cv_flexarray" = "yes"; then
249    AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
250  else
251    AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
252  fi
255 AC_CACHE_CHECK([for working C99 mid-block declaration syntax],
256       tor_cv_c_c99_decl,
257       [AC_COMPILE_IFELSE(
258          [AC_LANG_PROGRAM([], [int x; x = 3; int y; y = 4 + x;])],
259          [tor_cv_c_c99_decl=yes],
260          [tor_cv_c_c99_decl=no] )])
261 if test "$tor_cv_c_c99_decl" != "yes"; then
262   AC_MSG_ERROR([Your compiler doesn't support c99 mid-block declarations. This is required as of Tor 0.2.6.x])
265 AC_CACHE_CHECK([for working C99 designated initializers],
266       tor_cv_c_c99_designated_init,
267       [AC_COMPILE_IFELSE(
268          [AC_LANG_PROGRAM([struct s { int a; int b; };],
269                [[ struct s ss = { .b = 5, .a = 6 }; ]])],
270          [tor_cv_c_c99_designated_init=yes],
271          [tor_cv_c_c99_designated_init=no] )])
273 if test "$tor_cv_c_c99_designated_init" != "yes"; then
274   AC_MSG_ERROR([Your compiler doesn't support c99 designated initializers. This is required as of Tor 0.2.6.x])
277 TORUSER=_tor
278 AC_ARG_WITH(tor-user,
279         AS_HELP_STRING(--with-tor-user=NAME, [specify username for tor daemon]),
280         [
281            TORUSER=$withval
282         ]
284 AC_SUBST(TORUSER)
286 TORGROUP=_tor
287 AC_ARG_WITH(tor-group,
288         AS_HELP_STRING(--with-tor-group=NAME, [specify group name for tor daemon]),
289         [
290            TORGROUP=$withval
291         ]
293 AC_SUBST(TORGROUP)
296 dnl If _WIN32 is defined and non-zero, we are building for win32
297 AC_MSG_CHECKING([for win32])
298 AC_RUN_IFELSE([AC_LANG_SOURCE([
299 int main(int c, char **v) {
300 #ifdef _WIN32
301 #if _WIN32
302   return 0;
303 #else
304   return 1;
305 #endif
306 #else
307   return 2;
308 #endif
309 }])],
310 bwin32=true; AC_MSG_RESULT([yes]),
311 bwin32=false; AC_MSG_RESULT([no]),
312 bwin32=cross; AC_MSG_RESULT([cross])
315 if test "$bwin32" = "cross"; then
316 AC_MSG_CHECKING([for win32 (cross)])
317 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
318 #ifdef _WIN32
319 int main(int c, char **v) {return 0;}
320 #else
321 #error
322 int main(int c, char **v) {return x(y);}
323 #endif
324 ])],
325 bwin32=true; AC_MSG_RESULT([yes]),
326 bwin32=false; AC_MSG_RESULT([no]))
329 AH_BOTTOM([
330 #ifdef _WIN32
331 /* Defined to access windows functions and definitions for >=WinXP */
332 # ifndef WINVER
333 #  define WINVER 0x0501
334 # endif
336 /* Defined to access _other_ windows functions and definitions for >=WinXP */
337 # ifndef _WIN32_WINNT
338 #  define _WIN32_WINNT 0x0501
339 # endif
341 /* Defined to avoid including some windows headers as part of Windows.h */
342 # ifndef WIN32_LEAN_AND_MEAN
343 #  define WIN32_LEAN_AND_MEAN 1
344 # endif
345 #endif
349 AM_CONDITIONAL(BUILD_NT_SERVICES, test "x$bwin32" = "xtrue")
351 dnl Enable C99 when compiling with MIPSpro
352 AC_MSG_CHECKING([for MIPSpro compiler])
353 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
354 #if (defined(__sgi) && defined(_COMPILER_VERSION))
355 #error
356   return x(y);
357 #endif
358 ])],
359 bmipspro=false; AC_MSG_RESULT(no),
360 bmipspro=true; AC_MSG_RESULT(yes))
362 if test "$bmipspro" = "true"; then
363   CFLAGS="$CFLAGS -c99"
366 AC_C_BIGENDIAN
368 AC_SEARCH_LIBS(socket, [socket network])
369 AC_SEARCH_LIBS(gethostbyname, [nsl])
370 AC_SEARCH_LIBS(dlopen, [dl])
371 AC_SEARCH_LIBS(inet_aton, [resolv])
372 AC_SEARCH_LIBS(backtrace, [execinfo])
373 saved_LIBS="$LIBS"
374 AC_SEARCH_LIBS([clock_gettime], [rt])
375 if test "$LIBS" != "$saved_LIBS"; then
376    # Looks like we need -lrt for clock_gettime().
377    have_rt=yes
380 AC_SEARCH_LIBS(pthread_create, [pthread])
381 AC_SEARCH_LIBS(pthread_detach, [pthread])
383 AM_CONDITIONAL(THREADS_WIN32, test "$bwin32" = "true")
384 AM_CONDITIONAL(THREADS_PTHREADS, test "$bwin32" = "false")
386 AC_CHECK_FUNCS(
387         _NSGetEnviron \
388         RtlSecureZeroMemory \
389         SecureZeroMemory \
390         accept4 \
391         backtrace \
392         backtrace_symbols_fd \
393         clock_gettime \
394         eventfd \
395         explicit_bzero \
396         timingsafe_memcmp \
397         flock \
398         ftime \
399         getaddrinfo \
400         getentropy \
401         getifaddrs \
402         getpass \
403         getrlimit \
404         gettimeofday \
405         gmtime_r \
406         htonll \
407         inet_aton \
408         ioctl \
409         issetugid \
410         llround \
411         localtime_r \
412         lround \
413         memmem \
414         memset_s \
415         pipe \
416         pipe2 \
417         prctl \
418         readpassphrase \
419         rint \
420         sigaction \
421         socketpair \
422         statvfs \
423         strlcat \
424         strlcpy \
425         strnlen \
426         strptime \
427         strtok_r \
428         strtoull \
429         sysconf \
430         sysctl \
431         uname \
432         usleep \
433         vasprintf \
434         _vscprintf
437 if test "$bwin32" != "true"; then
438   AC_CHECK_HEADERS(pthread.h)
439   AC_CHECK_FUNCS(pthread_create)
440   AC_CHECK_FUNCS(pthread_condattr_setclock)
443 if test "$bwin32" = "true"; then
444   AC_CHECK_DECLS([SecureZeroMemory, _getwch], , , [
445 #include <windows.h>
446 #include <conio.h>
447 #include <wchar.h>
448                  ])
451 AM_CONDITIONAL(BUILD_READPASSPHRASE_C,
452   test "x$ac_cv_func_readpassphrase" = "xno" && test "$bwin32" = "false")
454 dnl ------------------------------------------------------
455 dnl Where do you live, libevent?  And how do we call you?
457 if test "$bwin32" = "true"; then
458   TOR_LIB_WS32=-lws2_32
459   TOR_LIB_IPHLPAPI=-liphlpapi
460   # Some of the cargo-cults recommend -lwsock32 as well, but I don't
461   # think it's actually necessary.
462   TOR_LIB_GDI=-lgdi32
463 else
464   TOR_LIB_WS32=
465   TOR_LIB_GDI=
467 AC_SUBST(TOR_LIB_WS32)
468 AC_SUBST(TOR_LIB_GDI)
469 AC_SUBST(TOR_LIB_IPHLPAPI)
471 tor_libevent_pkg_redhat="libevent"
472 tor_libevent_pkg_debian="libevent-dev"
473 tor_libevent_devpkg_redhat="libevent-devel"
474 tor_libevent_devpkg_debian="libevent-dev"
476 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
477 dnl linking for static builds.
478 STATIC_LIBEVENT_FLAGS=""
479 if test "$enable_static_libevent" = "yes"; then
480     if test "$have_rt" = "yes"; then
481       STATIC_LIBEVENT_FLAGS=" -lrt "
482     fi
485 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
486 #ifdef _WIN32
487 #include <winsock2.h>
488 #endif
489 #include <sys/time.h>
490 #include <sys/types.h>
491 #include <event.h>], [
492 #ifdef _WIN32
493 #include <winsock2.h>
494 #endif
495 void *event_init(void);],
496     [
497 #ifdef _WIN32
498 {WSADATA d; WSAStartup(0x101,&d); }
499 #endif
500 event_init();
501 ], [--with-libevent-dir], [/opt/libevent])
503 dnl Now check for particular libevent functions.
504 save_LIBS="$LIBS"
505 save_LDFLAGS="$LDFLAGS"
506 save_CPPFLAGS="$CPPFLAGS"
507 LIBS="-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $LIBS"
508 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
509 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
510 AC_CHECK_FUNCS([event_get_version_number \
511                 evutil_secure_rng_set_urandom_device_file \
512                 evutil_secure_rng_init \
513                ])
514 AC_CHECK_MEMBERS([struct event.min_heap_idx], , ,
515 [#include <event.h>
518 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
520 LIBS="$STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $save_LIBS"
522 AM_CONDITIONAL(USE_EXTERNAL_EVDNS,
523   test "x$ac_cv_header_event2_dns_h" = "xyes")
525 if test "$enable_static_libevent" = "yes"; then
526    if test "$tor_cv_library_libevent_dir" = "(system)"; then
527      AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
528    else
529      TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
530    fi
531 else
532      if test "x$ac_cv_header_event2_event_h" = "xyes"; then
533        AC_SEARCH_LIBS(event_new, [event event_core], , AC_MSG_ERROR("libevent2 is installed but linking it failed while searching for event_new"))
534        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"))
536        if test "$ac_cv_search_event_new" != "none required"; then
537          TOR_LIBEVENT_LIBS="$ac_cv_search_event_new"
538        fi
539        if test "$ac_cv_search_evdns_base_new" != "none required"; then
540          TOR_LIBEVENT_LIBS="$ac_cv_search_evdns_base_new $TOR_LIBEVENT_LIBS"
541        fi
542      else
543        TOR_LIBEVENT_LIBS="-levent"
544      fi
547 LIBS="$save_LIBS"
548 LDFLAGS="$save_LDFLAGS"
549 CPPFLAGS="$save_CPPFLAGS"
551 dnl This isn't the best test for Libevent 2.0.3-alpha.  Once it's released,
552 dnl we can do much better.
553 if test "$enable_bufferevents" = "yes"; then
554   if test "$ac_cv_header_event2_bufferevent_ssl_h" != "yes"; then
555     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.])
556   else
558     CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
560     # Check for the right version.  First see if version detection works.
561     AC_MSG_CHECKING([whether we can detect the Libevent version])
562     AC_COMPILE_IFELSE([AC_LANG_SOURCE([
563 #include <event2/event.h>
564 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 10
565 #error
566 int x = y(zz);
567 #else
568 int x = 1;
569 #endif
570   ])], [event_version_number_works=yes; AC_MSG_RESULT([yes]) ],
571      [event_version_number_works=no;  AC_MSG_RESULT([no])])
572     if test "$event_version_number_works" != "yes"; then
573       AC_MSG_WARN([Version detection on Libevent seems broken.  Your Libevent installation is probably screwed up or very old.])
574     else
575       AC_MSG_CHECKING([whether Libevent is new enough for bufferevents])
576       AC_COMPILE_IFELSE([AC_LANG_SOURCE([
577 #include <event2/event.h>
578 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000d00
579 #error
580 int x = y(zz);
581 #else
582 int x = 1;
583 #endif
584    ])], [ AC_MSG_RESULT([yes]) ],
585       [ AC_MSG_RESULT([no])
586         AC_MSG_ERROR([Libevent does not seem new enough to support bufferevents.  We require 2.0.13-stable or later]) ] )
587     fi
588   fi
591 LIBS="$save_LIBS"
592 LDFLAGS="$save_LDFLAGS"
593 CPPFLAGS="$save_CPPFLAGS"
595 AM_CONDITIONAL(USE_BUFFEREVENTS, test "$enable_bufferevents" = "yes")
596 if test "$enable_bufferevents" = "yes"; then
597   AC_DEFINE(USE_BUFFEREVENTS, 1, [Defined if we're going to use Libevent's buffered IO API])
598   if test "$enable_static_libevent" = "yes"; then
599     TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent_openssl.a $TOR_LIBEVENT_LIBS"
600   else
601     TOR_LIBEVENT_LIBS="-levent_openssl $TOR_LIBEVENT_LIBS"
602   fi
604 AC_SUBST(TOR_LIBEVENT_LIBS)
606 dnl ------------------------------------------------------
607 dnl Where do you live, libm?
609 dnl On some platforms (Haiku/BeOS) the math library is
610 dnl part of libroot. In which case don't link against lm
611 TOR_LIB_MATH=""
612 save_LIBS="$LIBS"
613 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
614 if test "$ac_cv_search_pow" != "none required"; then
615     TOR_LIB_MATH="$ac_cv_search_pow"
617 LIBS="$save_LIBS"
618 AC_SUBST(TOR_LIB_MATH)
620 dnl ------------------------------------------------------
621 dnl Where do you live, openssl?  And how do we call you?
623 tor_openssl_pkg_redhat="openssl"
624 tor_openssl_pkg_debian="libssl-dev"
625 tor_openssl_devpkg_redhat="openssl-devel"
626 tor_openssl_devpkg_debian="libssl-dev"
628 ALT_openssl_WITHVAL=""
629 AC_ARG_WITH(ssl-dir,
630   AS_HELP_STRING(--with-ssl-dir=PATH, [obsolete alias for --with-openssl-dir]),
631   [
632       if test "x$withval" != "xno" && test "x$withval" != "x"; then
633          ALT_openssl_WITHVAL="$withval"
634       fi
635   ])
637 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI],
638     [#include <openssl/rand.h>],
639     [void RAND_add(const void *buf, int num, double entropy);],
640     [RAND_add((void*)0,0,0);], [],
641     [/usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /opt/openssl])
643 dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
645 if test "$enable_static_openssl" = "yes"; then
646    if test "$tor_cv_library_openssl_dir" = "(system)"; then
647      AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
648    else
649      TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
650    fi
651 else
652      TOR_OPENSSL_LIBS="-lssl -lcrypto"
654 AC_SUBST(TOR_OPENSSL_LIBS)
656 dnl Now check for particular openssl functions.
657 save_LIBS="$LIBS"
658 save_LDFLAGS="$LDFLAGS"
659 save_CPPFLAGS="$CPPFLAGS"
660 LIBS="$TOR_OPENSSL_LIBS $LIBS"
661 LDFLAGS="$TOR_LDFLAGS_openssl $LDFLAGS"
662 CPPFLAGS="$TOR_CPPFLAGS_openssl $CPPFLAGS"
664 AC_TRY_COMPILE([
665 #include <openssl/opensslv.h>
666 #if OPENSSL_VERSION_NUMBER < 0x1000000fL
667 #error "too old"
668 #endif
669    ], [],
670    [ : ],
671    [ 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.]) ])
673 AC_TRY_COMPILE([
674 #include <openssl/opensslv.h>
675 #include <openssl/evp.h>
676 #if defined(OPENSSL_NO_EC) || defined(OPENSSL_NO_ECDH) || defined(OPENSSL_NO_ECDSA)
677 #error "no ECC"
678 #endif
679 #if !defined(NID_X9_62_prime256v1) || !defined(NID_secp224r1)
680 #error "curves unavailable"
681 #endif
682    ], [],
683    [ : ],
684    [ 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.]) ])
686 AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , ,
687 [#include <openssl/ssl.h>
690 AC_CHECK_FUNCS([ \
691                 SSL_SESSION_get_master_key \
692                 SSL_get_server_random \
693                 SSL_get_client_ciphers \
694                 SSL_get_client_random \
695                 SSL_CIPHER_find \
696                 TLS_method
697                ])
699 dnl Check if OpenSSL has scrypt implementation.
700 AC_CHECK_FUNCS([ EVP_PBE_scrypt ])
702 LIBS="$save_LIBS"
703 LDFLAGS="$save_LDFLAGS"
704 CPPFLAGS="$save_CPPFLAGS"
706 dnl ------------------------------------------------------
707 dnl Where do you live, zlib?  And how do we call you?
709 tor_zlib_pkg_redhat="zlib"
710 tor_zlib_pkg_debian="zlib1g"
711 tor_zlib_devpkg_redhat="zlib-devel"
712 tor_zlib_devpkg_debian="zlib1g-dev"
714 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
715     [#include <zlib.h>],
716     [const char * zlibVersion(void);],
717     [zlibVersion();], [--with-zlib-dir],
718     [/opt/zlib])
720 if test "$enable_static_zlib" = "yes"; then
721    if test "$tor_cv_library_zlib_dir" = "(system)"; then
722      AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
723  using --enable-static-zlib")
724    else
725      TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
726    fi
727 else
728      TOR_ZLIB_LIBS="-lz"
730 AC_SUBST(TOR_ZLIB_LIBS)
732 dnl ----------------------------------------------------------------------
733 dnl Check if libcap is available for capabilities.
735 tor_cap_pkg_debian="libcap2"
736 tor_cap_pkg_redhat="libcap"
737 tor_cap_devpkg_debian="libcap-dev"
738 tor_cap_devpkg_redhat="libcap-devel"
740 AC_CHECK_LIB([cap], [cap_init], [],
741   AC_MSG_NOTICE([Libcap was not found. Capabilities will not be usable.])
743 AC_CHECK_FUNCS(cap_set_proc)
745 dnl ---------------------------------------------------------------------
746 dnl Now that we know about our major libraries, we can check for compiler
747 dnl and linker hardening options.  We need to do this with the libraries known,
748 dnl since sometimes the linker will like an option but not be willing to
749 dnl use it with a build of a library.
751 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
752 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"
754 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
755 #if !defined(__clang__)
756 #error
757 #endif])], have_clang=yes, have_clang=no)
759 if test "x$enable_gcc_hardening" != "xno"; then
760     CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
761     if test "x$have_clang" = "xyes"; then
762         TOR_CHECK_CFLAGS(-Qunused-arguments)
763     fi
764     TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
765     AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
766     AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
767 m4_ifdef([AS_VAR_IF],[
768     AS_VAR_IF(can_compile, [yes],
769         AS_VAR_IF(can_link, [yes],
770                   [],
771                   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.)]))
772         )])
773     AS_VAR_POPDEF([can_link])
774     AS_VAR_POPDEF([can_compile])
775     TOR_CHECK_CFLAGS(-Wstack-protector)
776     TOR_CHECK_CFLAGS(-fwrapv)
777     TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
778     if test "$bwin32" = "false"; then
779        TOR_CHECK_CFLAGS(-fPIE)
780        TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
781     fi
784 if test "x$enable_expensive_hardening" = "xyes"; then
785    TOR_CHECK_CFLAGS([-fsanitize=address])
786    TOR_CHECK_CFLAGS([-fsanitize=undefined])
787    TOR_CHECK_CFLAGS([-fno-omit-frame-pointer])
790 if test "x$enable_linker_hardening" != "xno"; then
791     TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
794 # For backtrace support
795 TOR_CHECK_LDFLAGS(-rdynamic)
797 dnl ------------------------------------------------------
798 dnl Now see if we have a -fomit-frame-pointer compiler option.
800 saved_CFLAGS="$CFLAGS"
801 TOR_CHECK_CFLAGS(-fomit-frame-pointer)
802 F_OMIT_FRAME_POINTER=''
803 if test "$saved_CFLAGS" != "$CFLAGS"; then
804   if test "x$enable_expensive_hardening" != "xyes"; then
805     F_OMIT_FRAME_POINTER='-fomit-frame-pointer'
806   fi
808 CFLAGS="$saved_CFLAGS"
809 AC_SUBST(F_OMIT_FRAME_POINTER)
811 dnl ------------------------------------------------------
812 dnl If we are adding -fomit-frame-pointer (or if the compiler's doing it
813 dnl for us, as GCC 4.6 and later do at many optimization levels), then
814 dnl we should try to add -fasynchronous-unwind-tables so that our backtrace
815 dnl code will work.
816 TOR_CHECK_CFLAGS(-fasynchronous-unwind-tables)
818 dnl ============================================================
819 dnl Check for libseccomp
821 if test "x$enable_seccomp" != "xno"; then
822   AC_CHECK_HEADERS([seccomp.h])
823   AC_SEARCH_LIBS(seccomp_init, [seccomp])
826 dnl ============================================================
827 dnl Check for libscrypt
829 if test "x$enable_libscrypt" != "xno"; then
830   AC_CHECK_HEADERS([libscrypt.h])
831   AC_SEARCH_LIBS(libscrypt_scrypt, [scrypt])
834 dnl ============================================================
835 dnl We need an implementation of curve25519.
837 dnl set these defaults.
838 build_curve25519_donna=no
839 build_curve25519_donna_c64=no
840 use_curve25519_donna=no
841 use_curve25519_nacl=no
842 CURVE25519_LIBS=
844 dnl The best choice is using curve25519-donna-c64, but that requires
845 dnl that we
846 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
847   tor_cv_can_use_curve25519_donna_c64,
848   [AC_RUN_IFELSE(
849     [AC_LANG_PROGRAM([dnl
850       #include <stdint.h>
851       typedef unsigned uint128_t __attribute__((mode(TI)));
852   int func(uint64_t a, uint64_t b) {
853            uint128_t c = ((uint128_t)a) * b;
854            int ok = ((uint64_t)(c>>96)) == 522859 &&
855              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
856                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
857                  (((uint64_t)(c))&0xffffffffL) == 0;
858            return ok;
859       }
860   ], [dnl
861     int ok = func( ((uint64_t)2000000000) * 1000000000,
862                    ((uint64_t)1234567890) << 24);
863         return !ok;
864       ])],
865   [tor_cv_can_use_curve25519_donna_c64=yes],
866       [tor_cv_can_use_curve25519_donna_c64=no],
867   [AC_LINK_IFELSE(
868         [AC_LANG_PROGRAM([dnl
869       #include <stdint.h>
870       typedef unsigned uint128_t __attribute__((mode(TI)));
871   int func(uint64_t a, uint64_t b) {
872            uint128_t c = ((uint128_t)a) * b;
873            int ok = ((uint64_t)(c>>96)) == 522859 &&
874              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
875                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
876                  (((uint64_t)(c))&0xffffffffL) == 0;
877            return ok;
878       }
879   ], [dnl
880     int ok = func( ((uint64_t)2000000000) * 1000000000,
881                  ((uint64_t)1234567890) << 24);
882         return !ok;
883       ])],
884           [tor_cv_can_use_curve25519_donna_c64=cross],
885       [tor_cv_can_use_curve25519_donna_c64=no])])])
887 AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
888                   nacl/crypto_scalarmult_curve25519.h])
890 AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
891   tor_cv_can_use_curve25519_nacl,
892   [tor_saved_LIBS="$LIBS"
893    LIBS="$LIBS -lnacl"
894    AC_LINK_IFELSE(
895      [AC_LANG_PROGRAM([dnl
896        #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
897        #include <crypto_scalarmult_curve25519.h>
898    #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
899    #include <nacl/crypto_scalarmult_curve25519.h>
900    #endif
901        #ifdef crypto_scalarmult_curve25519_ref_BYTES
902    #error Hey, this is the reference implementation! That's not fast.
903    #endif
904      ], [
905    unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
906      ])], [tor_cv_can_use_curve25519_nacl=yes],
907      [tor_cv_can_use_curve25519_nacl=no])
908    LIBS="$tor_saved_LIBS" ])
910  dnl Okay, now we need to figure out which one to actually use. Fall back
911  dnl to curve25519-donna.c
913  if test "x$tor_cv_can_use_curve25519_donna_c64" != "xno"; then
914    build_curve25519_donna_c64=yes
915    use_curve25519_donna=yes
916  elif test "x$tor_cv_can_use_curve25519_nacl" = "xyes"; then
917    use_curve25519_nacl=yes
918    CURVE25519_LIBS=-lnacl
919  else
920    build_curve25519_donna=yes
921    use_curve25519_donna=yes
922  fi
924 if test "x$use_curve25519_donna" = "xyes"; then
925   AC_DEFINE(USE_CURVE25519_DONNA, 1,
926             [Defined if we should use an internal curve25519_donna{,_c64} implementation])
928 if test "x$use_curve25519_nacl" = "xyes"; then
929   AC_DEFINE(USE_CURVE25519_NACL, 1,
930             [Defined if we should use a curve25519 from nacl])
932 AM_CONDITIONAL(BUILD_CURVE25519_DONNA,
933   test "x$build_curve25519_donna" = "xyes")
934 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64,
935   test "x$build_curve25519_donna_c64" = "xyes")
936 AC_SUBST(CURVE25519_LIBS)
938 dnl Make sure to enable support for large off_t if available.
939 AC_SYS_LARGEFILE
941 AC_CHECK_HEADERS(
942         assert.h \
943         errno.h \
944         fcntl.h \
945         signal.h \
946         string.h \
947         sys/capability.h \
948         sys/fcntl.h \
949         sys/stat.h \
950         sys/time.h \
951         sys/types.h \
952         time.h \
953         unistd.h
954  , , 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.))
956 dnl These headers are not essential
958 AC_CHECK_HEADERS(
959         arpa/inet.h \
960         crt_externs.h \
961         execinfo.h \
962         grp.h \
963         ifaddrs.h \
964         inttypes.h \
965         limits.h \
966         linux/types.h \
967         machine/limits.h \
968         malloc.h \
969         malloc/malloc.h \
970         malloc_np.h \
971         netdb.h \
972         netinet/in.h \
973         netinet/in6.h \
974         pwd.h \
975         readpassphrase.h \
976         stdint.h \
977         sys/eventfd.h \
978         sys/file.h \
979         sys/ioctl.h \
980         sys/limits.h \
981         sys/mman.h \
982         sys/param.h \
983         sys/prctl.h \
984         sys/resource.h \
985         sys/select.h \
986         sys/socket.h \
987         sys/statvfs.h \
988         sys/syscall.h \
989         sys/sysctl.h \
990         sys/syslimits.h \
991         sys/time.h \
992         sys/types.h \
993         sys/un.h \
994         sys/utime.h \
995         sys/wait.h \
996         syslog.h \
997         utime.h
1000 AC_CHECK_HEADERS(sys/param.h)
1002 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
1003 [#ifdef HAVE_SYS_TYPES_H
1004 #include <sys/types.h>
1005 #endif
1006 #ifdef HAVE_SYS_SOCKET_H
1007 #include <sys/socket.h>
1008 #endif])
1009 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
1010 [#ifdef HAVE_SYS_TYPES_H
1011 #include <sys/types.h>
1012 #endif
1013 #ifdef HAVE_SYS_SOCKET_H
1014 #include <sys/socket.h>
1015 #endif
1016 #ifdef HAVE_NET_IF_H
1017 #include <net/if.h>
1018 #endif
1019 #ifdef HAVE_NETINET_IN_H
1020 #include <netinet/in.h>
1021 #endif])
1023 AC_CHECK_HEADERS(linux/if.h,[],[],
1025 #ifdef HAVE_SYS_SOCKET_H
1026 #include <sys/socket.h>
1027 #endif
1030 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
1031         linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
1032 [#ifdef HAVE_SYS_TYPES_H
1033 #include <sys/types.h>
1034 #endif
1035 #ifdef HAVE_SYS_SOCKET_H
1036 #include <sys/socket.h>
1037 #endif
1038 #ifdef HAVE_LIMITS_H
1039 #include <limits.h>
1040 #endif
1041 #ifdef HAVE_LINUX_TYPES_H
1042 #include <linux/types.h>
1043 #endif
1044 #ifdef HAVE_NETINET_IN6_H
1045 #include <netinet/in6.h>
1046 #endif
1047 #ifdef HAVE_NETINET_IN_H
1048 #include <netinet/in.h>
1049 #endif])
1051 AC_CHECK_HEADERS(linux/netfilter_ipv6/ip6_tables.h,
1052         linux_netfilter_ipv6_ip6_tables=1, linux_netfilter_ipv6_ip6_tables=0,
1053 [#ifdef HAVE_SYS_TYPES_H
1054 #include <sys/types.h>
1055 #endif
1056 #ifdef HAVE_SYS_SOCKET_H
1057 #include <sys/socket.h>
1058 #endif
1059 #ifdef HAVE_LIMITS_H
1060 #include <limits.h>
1061 #endif
1062 #ifdef HAVE_LINUX_TYPES_H
1063 #include <linux/types.h>
1064 #endif
1065 #ifdef HAVE_NETINET_IN6_H
1066 #include <netinet/in6.h>
1067 #endif
1068 #ifdef HAVE_NETINET_IN_H
1069 #include <netinet/in.h>
1070 #endif
1071 #ifdef HAVE_LINUX_IF_H
1072 #include <linux/if.h>
1073 #endif])
1075 if test "x$transparent" = "xtrue"; then
1076    transparent_ok=0
1077    if test "x$net_if_found" = "x1" && test "x$net_pfvar_found" = "x1"; then
1078      transparent_ok=1
1079    fi
1080    if test "x$linux_netfilter_ipv4" = "x1"; then
1081      transparent_ok=1
1082    fi
1083    if test "x$linux_netfilter_ipv6_ip6_tables" = "x1"; then
1084      transparent_ok=1
1085    fi
1086    if test "x$transparent_ok" = "x1"; then
1087      AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
1088      case "$host" in
1089        *-*-openbsd* | *-*-bitrig*)
1090          AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
1091      esac
1092    else
1093      AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
1094    fi
1097 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
1098 [#ifdef HAVE_SYS_TYPES_H
1099 #include <sys/types.h>
1100 #endif
1101 #ifdef HAVE_SYS_TIME_H
1102 #include <sys/time.h>
1103 #endif])
1105 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
1106 dnl Watch out.
1108 AC_CHECK_SIZEOF(int8_t)
1109 AC_CHECK_SIZEOF(int16_t)
1110 AC_CHECK_SIZEOF(int32_t)
1111 AC_CHECK_SIZEOF(int64_t)
1112 AC_CHECK_SIZEOF(uint8_t)
1113 AC_CHECK_SIZEOF(uint16_t)
1114 AC_CHECK_SIZEOF(uint32_t)
1115 AC_CHECK_SIZEOF(uint64_t)
1116 AC_CHECK_SIZEOF(intptr_t)
1117 AC_CHECK_SIZEOF(uintptr_t)
1119 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
1121 AC_CHECK_SIZEOF(char)
1122 AC_CHECK_SIZEOF(short)
1123 AC_CHECK_SIZEOF(int)
1124 AC_CHECK_SIZEOF(long)
1125 AC_CHECK_SIZEOF(long long)
1126 AC_CHECK_SIZEOF(__int64)
1127 AC_CHECK_SIZEOF(void *)
1128 AC_CHECK_SIZEOF(time_t)
1129 AC_CHECK_SIZEOF(size_t)
1130 AC_CHECK_SIZEOF(pid_t)
1132 AC_CHECK_TYPES([uint, u_char, ssize_t])
1134 AC_PC_FROM_UCONTEXT([:])
1136 dnl used to include sockaddr_storage, but everybody has that.
1137 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
1138 [#ifdef HAVE_SYS_TYPES_H
1139 #include <sys/types.h>
1140 #endif
1141 #ifdef HAVE_NETINET_IN_H
1142 #include <netinet/in.h>
1143 #endif
1144 #ifdef HAVE_NETINET_IN6_H
1145 #include <netinet/in6.h>
1146 #endif
1147 #ifdef HAVE_SYS_SOCKET_H
1148 #include <sys/socket.h>
1149 #endif
1150 #ifdef _WIN32
1151 #define _WIN32_WINNT 0x0501
1152 #define WIN32_LEAN_AND_MEAN
1153 #include <winsock2.h>
1154 #include <ws2tcpip.h>
1155 #endif
1157 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
1158 [#ifdef HAVE_SYS_TYPES_H
1159 #include <sys/types.h>
1160 #endif
1161 #ifdef HAVE_NETINET_IN_H
1162 #include <netinet/in.h>
1163 #endif
1164 #ifdef HAVE_NETINET_IN6_H
1165 #include <netinet/in6.h>
1166 #endif
1167 #ifdef HAVE_SYS_SOCKET_H
1168 #include <sys/socket.h>
1169 #endif
1170 #ifdef _WIN32
1171 #define _WIN32_WINNT 0x0501
1172 #define WIN32_LEAN_AND_MEAN
1173 #include <winsock2.h>
1174 #include <ws2tcpip.h>
1175 #endif
1178 AC_CHECK_TYPES([rlim_t], , ,
1179 [#ifdef HAVE_SYS_TYPES_H
1180 #include <sys/types.h>
1181 #endif
1182 #ifdef HAVE_SYS_TIME_H
1183 #include <sys/time.h>
1184 #endif
1185 #ifdef HAVE_SYS_RESOURCE_H
1186 #include <sys/resource.h>
1187 #endif
1190 AX_CHECK_SIGN([time_t],
1191        [ : ],
1192        [ : ], [
1193 #ifdef HAVE_SYS_TYPES_H
1194 #include <sys/types.h>
1195 #endif
1196 #ifdef HAVE_SYS_TIME_H
1197 #include <sys/time.h>
1198 #endif
1199 #ifdef HAVE_TIME_H
1200 #include <time.h>
1201 #endif
1204 if test "$ax_cv_decl_time_t_signed" = "no"; then
1205   AC_MSG_ERROR([You have an unsigned time_t; Tor does not support that. Please tell the Tor developers about your interesting platform.])
1208 AX_CHECK_SIGN([size_t],
1209        [ tor_cv_size_t_signed=yes ],
1210        [ tor_cv_size_t_signed=no ], [
1211 #ifdef HAVE_SYS_TYPES_H
1212 #include <sys/types.h>
1213 #endif
1216 if test "$ax_cv_decl_size_t_signed" = "yes"; then
1217   AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
1220 AX_CHECK_SIGN([enum always],
1221        [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
1222        [ : ], [
1223  enum always { AAA, BBB, CCC };
1226 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
1227 #ifdef HAVE_SYS_SOCKET_H
1228 #include <sys/socket.h>
1229 #endif
1232 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1234 AC_CHECK_SIZEOF(cell_t)
1236 # Now make sure that NULL can be represented as zero bytes.
1237 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1238 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1239 [[#include <stdlib.h>
1240 #include <string.h>
1241 #include <stdio.h>
1242 #ifdef HAVE_STDDEF_H
1243 #include <stddef.h>
1244 #endif
1245 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1246 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1247        [tor_cv_null_is_zero=yes],
1248        [tor_cv_null_is_zero=no],
1249        [tor_cv_null_is_zero=cross])])
1251 if test "$tor_cv_null_is_zero" = "cross"; then
1252   # Cross-compiling; let's hope that the target isn't raving mad.
1253   AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
1256 if test "$tor_cv_null_is_zero" != "no"; then
1257   AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1258             [Define to 1 iff memset(0) sets pointers to NULL])
1261 AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
1262 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1263 [[#include <stdlib.h>
1264 #include <string.h>
1265 #include <stdio.h>
1266 #ifdef HAVE_STDDEF_H
1267 #include <stddef.h>
1268 #endif
1269 int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
1270 return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
1271        [tor_cv_dbl0_is_zero=yes],
1272        [tor_cv_dbl0_is_zero=no],
1273        [tor_cv_dbl0_is_zero=cross])])
1275 if test "$tor_cv_dbl0_is_zero" = "cross"; then
1276   # Cross-compiling; let's hope that the target isn't raving mad.
1277   AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
1280 if test "$tor_cv_dbl0_is_zero" != "no"; then
1281   AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
1282             [Define to 1 iff memset(0) sets doubles to 0.0])
1285 # And what happens when we malloc zero?
1286 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
1287 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1288 [[#include <stdlib.h>
1289 #include <string.h>
1290 #include <stdio.h>
1291 #ifdef HAVE_STDDEF_H
1292 #include <stddef.h>
1293 #endif
1294 int main () { return malloc(0)?0:1; }]])],
1295        [tor_cv_malloc_zero_works=yes],
1296        [tor_cv_malloc_zero_works=no],
1297        [tor_cv_malloc_zero_works=cross])])
1299 if test "$tor_cv_malloc_zero_works" = "cross"; then
1300   # Cross-compiling; let's hope that the target isn't raving mad.
1301   AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
1304 if test "$tor_cv_malloc_zero_works" = "yes"; then
1305   AC_DEFINE([MALLOC_ZERO_WORKS], 1,
1306             [Define to 1 iff malloc(0) returns a pointer])
1309 # whether we seem to be in a 2s-complement world.
1310 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
1311 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1312 [[int main () { int problem = ((-99) != (~99)+1);
1313 return problem ? 1 : 0; }]])],
1314        [tor_cv_twos_complement=yes],
1315        [tor_cv_twos_complement=no],
1316        [tor_cv_twos_complement=cross])])
1318 if test "$tor_cv_twos_complement" = "cross"; then
1319   # Cross-compiling; let's hope that the target isn't raving mad.
1320   AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
1323 if test "$tor_cv_twos_complement" != "no"; then
1324   AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
1325             [Define to 1 iff we represent negative integers with
1326              two's complement])
1329 # What does shifting a negative value do?
1330 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
1331 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1332 [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
1333        [tor_cv_sign_extend=yes],
1334        [tor_cv_sign_extend=no],
1335        [tor_cv_sign_extend=cross])])
1337 if test "$tor_cv_sign_extend" = "cross"; then
1338   # Cross-compiling; let's hope that the target isn't raving mad.
1339   AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
1342 if test "$tor_cv_sign_extend" != "no"; then
1343   AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
1344             [Define to 1 iff right-shifting a negative value performs sign-extension])
1347 # Whether we should use the dmalloc memory allocation debugging library.
1348 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
1349 AC_ARG_WITH(dmalloc,
1350 AS_HELP_STRING(--with-dmalloc, [use debug memory allocation library]),
1351 [if [[ "$withval" = "yes" ]]; then
1352   dmalloc=1
1353   AC_MSG_RESULT(yes)
1354 else
1355   dmalloc=1
1356   AC_MSG_RESULT(no)
1357 fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
1360 if [[ $dmalloc -eq 1 ]]; then
1361   AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
1362   AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
1363   AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
1364   AC_CHECK_FUNCS(dmalloc_strdup dmalloc_strndup)
1367 AC_ARG_WITH(tcmalloc,
1368 AS_HELP_STRING(--with-tcmalloc, [use tcmalloc memory allocation library]),
1369 [ tcmalloc=yes ], [ tcmalloc=no ])
1371 if test "x$tcmalloc" = "xyes"; then
1372    LDFLAGS="-ltcmalloc $LDFLAGS"
1375 using_custom_malloc=no
1376 if test "x$enable_openbsd_malloc" = "xyes"; then
1377    using_custom_malloc=yes
1379 if test "x$tcmalloc" = "xyes"; then
1380    using_custom_malloc=yes
1382 if test "$using_custom_malloc" = "no"; then
1383    AC_CHECK_FUNCS(mallinfo)
1386 # By default, we're going to assume we don't have mlockall()
1387 # bionic and other platforms have various broken mlockall subsystems.
1388 # Some systems don't have a working mlockall, some aren't linkable,
1389 # and some have it but don't declare it.
1390 AC_CHECK_FUNCS(mlockall)
1391 AC_CHECK_DECLS([mlockall], , , [
1392 #ifdef HAVE_SYS_MMAN_H
1393 #include <sys/mman.h>
1394 #endif])
1396 # Allow user to specify an alternate syslog facility
1397 AC_ARG_WITH(syslog-facility,
1398 AS_HELP_STRING(--with-syslog-facility=LOG, [syslog facility to use (default=LOG_DAEMON)]),
1399 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
1400 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
1401 AC_SUBST(LOGFACILITY)
1403 # Check if we have getresuid and getresgid
1404 AC_CHECK_FUNCS(getresuid getresgid)
1406 # Check for gethostbyname_r in all its glorious incompatible versions.
1407 #   (This logic is based on that in Python's configure.in)
1408 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
1409   [Define this if you have any gethostbyname_r()])
1411 AC_CHECK_FUNC(gethostbyname_r, [
1412   AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
1413   OLD_CFLAGS=$CFLAGS
1414   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1415   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1416 #include <netdb.h>
1417   ], [[
1418     char *cp1, *cp2;
1419     struct hostent *h1, *h2;
1420     int i1, i2;
1421     (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
1422   ]])],[
1423     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1424     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
1425      [Define this if gethostbyname_r takes 6 arguments])
1426     AC_MSG_RESULT(6)
1427   ], [
1428     AC_TRY_COMPILE([
1429 #include <netdb.h>
1430     ], [
1431       char *cp1, *cp2;
1432       struct hostent *h1;
1433       int i1, i2;
1434       (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
1435     ], [
1436       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1437       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
1438         [Define this if gethostbyname_r takes 5 arguments])
1439       AC_MSG_RESULT(5)
1440    ], [
1441       AC_TRY_COMPILE([
1442 #include <netdb.h>
1443      ], [
1444        char *cp1;
1445        struct hostent *h1;
1446        struct hostent_data hd;
1447        (void) gethostbyname_r(cp1,h1,&hd);
1448      ], [
1449        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1450        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
1451          [Define this if gethostbyname_r takes 3 arguments])
1452        AC_MSG_RESULT(3)
1453      ], [
1454        AC_MSG_RESULT(0)
1455      ])
1456   ])
1457  ])
1458  CFLAGS=$OLD_CFLAGS
1461 AC_CACHE_CHECK([whether the C compiler supports __func__],
1462   tor_cv_have_func_macro,
1463   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1464 #include <stdio.h>
1465 int main(int c, char **v) { puts(__func__); }])],
1466   tor_cv_have_func_macro=yes,
1467   tor_cv_have_func_macro=no))
1469 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
1470   tor_cv_have_FUNC_macro,
1471   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1472 #include <stdio.h>
1473 int main(int c, char **v) { puts(__FUNC__); }])],
1474   tor_cv_have_FUNC_macro=yes,
1475   tor_cv_have_FUNC_macro=no))
1477 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
1478   tor_cv_have_FUNCTION_macro,
1479   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1480 #include <stdio.h>
1481 int main(int c, char **v) { puts(__FUNCTION__); }])],
1482   tor_cv_have_FUNCTION_macro=yes,
1483   tor_cv_have_FUNCTION_macro=no))
1485 AC_CACHE_CHECK([whether we have extern char **environ already declared],
1486   tor_cv_have_environ_declared,
1487   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1488 /* We define _GNU_SOURCE here because it is also defined in compat.c.
1489  * Without it environ doesn't get declared. */
1490 #define _GNU_SOURCE
1491 #ifdef HAVE_UNISTD_H
1492 #include <unistd.h>
1493 #endif
1494 #include <stdlib.h>
1495 int main(int c, char **v) { char **t = environ; }])],
1496   tor_cv_have_environ_declared=yes,
1497   tor_cv_have_environ_declared=no))
1499 if test "$tor_cv_have_func_macro" = "yes"; then
1500   AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
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_FUNCTION_macro" = "yes"; then
1508   AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
1509            [Defined if the compiler supports __FUNCTION__])
1512 if test "$tor_cv_have_environ_declared" = "yes"; then
1513   AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
1514            [Defined if we have extern char **environ already declared])
1517 # $prefix stores the value of the --prefix command line option, or
1518 # NONE if the option wasn't set.  In the case that it wasn't set, make
1519 # it be the default, so that we can use it to expand directories now.
1520 if test "x$prefix" = "xNONE"; then
1521   prefix=$ac_default_prefix
1524 # and similarly for $exec_prefix
1525 if test "x$exec_prefix" = "xNONE"; then
1526   exec_prefix=$prefix
1529 if test "x$BUILDDIR" = "x"; then
1530   BUILDDIR=`pwd`
1532 AC_SUBST(BUILDDIR)
1533 AH_TEMPLATE([BUILDDIR],[tor's build directory])
1534 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
1536 if test "x$CONFDIR" = "x"; then
1537   CONFDIR=`eval echo $sysconfdir/tor`
1539 AC_SUBST(CONFDIR)
1540 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
1541 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
1543 BINDIR=`eval echo $bindir`
1544 AC_SUBST(BINDIR)
1545 LOCALSTATEDIR=`eval echo $localstatedir`
1546 AC_SUBST(LOCALSTATEDIR)
1548 if test "$bwin32" = "true"; then
1549   # Test if the linker supports the --nxcompat and --dynamicbase options
1550   # for Windows
1551   save_LDFLAGS="$LDFLAGS"
1552   LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
1553   AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
1554   AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
1555     [AC_MSG_RESULT([yes])]
1556     [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
1557     [AC_MSG_RESULT([no])]
1558   )
1559   LDFLAGS="$save_LDFLAGS"
1562 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
1563 # than autoconf's macros like.
1564 if test "$GCC" = "yes"; then
1565   # Disable GCC's strict aliasing checks.  They are an hours-to-debug
1566   # accident waiting to happen.
1567   CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
1568 else
1569   # Override optimization level for non-gcc compilers
1570   CFLAGS="$CFLAGS -O"
1571   enable_gcc_warnings=no
1572   enable_gcc_warnings_advisory=no
1575 # OS X Lion started deprecating the system openssl. Let's just disable
1576 # all deprecation warnings on OS X. Also, to potentially make the binary
1577 # a little smaller, let's enable dead_strip.
1578 case "$host_os" in
1580  darwin*)
1581     CFLAGS="$CFLAGS -Wno-deprecated-declarations"
1582     LDFLAGS="$LDFLAGS -dead_strip" ;;
1583 esac
1585 # Add some more warnings which we use in development but not in the
1586 # released versions.  (Some relevant gcc versions can't handle these.)
1587 if test "x$enable_gcc_warnings" = "xyes" ||
1588   test "x$enable_gcc_warnings_advisory" = "xyes"; then
1590   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1591 #if !defined(__GNUC__) || (__GNUC__ < 4)
1592 #error
1593 #endif])], have_gcc4=yes, have_gcc4=no)
1595   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1596 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
1597 #error
1598 #endif])], have_gcc42=yes, have_gcc42=no)
1600   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1601 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
1602 #error
1603 #endif])], have_gcc43=yes, have_gcc43=no)
1605   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1606 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
1607 #error
1608 #endif])], have_gcc46=yes, have_gcc46=no)
1611   save_CFLAGS="$CFLAGS"
1612   CFLAGS="$CFLAGS -Wshorten-64-to-32"
1613   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
1614                     have_shorten64_flag=no)
1615   CFLAGS="$save_CFLAGS"
1617   case "$host" in
1618     *-*-openbsd* | *-*-bitrig*)
1619       # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
1620       # That's fine, except that the headers don't pass -Wredundant-decls.
1621       # Therefore, let's disable -Wsystem-headers when we're building
1622       # with maximal warnings on OpenBSD.
1623       CFLAGS="$CFLAGS -Wno-system-headers" ;;
1624   esac
1626   CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
1627   CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
1628   CFLAGS="$CFLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
1629   CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
1630   CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
1632   if test "x$enable_gcc_warnings" = "xyes"; then
1633     CFLAGS="$CFLAGS -Werror"
1634   fi
1636   # Disabled, so we can use mallinfo(): -Waggregate-return
1638   if test "x$have_gcc4" = "xyes"; then
1639     # These warnings break gcc 3.3.5 and work on gcc 4.0.2
1640     CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wold-style-definition"
1641   fi
1643   if test "x$have_gcc42" = "xyes"; then
1644     # These warnings break gcc 4.0.2 and work on gcc 4.2
1645     # XXXX020 See if any of these work with earlier versions.
1646     CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wstrict-overflow=1"
1648     # We used to use -Wstrict-overflow=5, but that breaks us heavily under 4.3.
1649   fi
1651   if test "x$have_gcc42" = "xyes" && test "x$have_clang" = "xno"; then
1652     # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2
1653     CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init"
1654   fi
1656   if test "x$have_gcc43" = "xyes"; then
1657     # These warnings break gcc 4.2 and work on gcc 4.3
1658     # XXXX020 See if any of these work with earlier versions.
1659     CFLAGS="$CFLAGS -Wextra -Warray-bounds"
1660   fi
1662   if test "x$have_gcc46" = "xyes"; then
1663     # This warning was added in gcc 4.3, but it appears to generate
1664     # spurious warnings in gcc 4.4.  I don't know if it works in 4.5.
1665     CFLAGS="$CFLAGS -Wlogical-op"
1666   fi
1668   if test "x$have_shorten64_flag" = "xyes"; then
1669     CFLAGS="$CFLAGS -Wshorten-64-to-32"
1670   fi
1674 ##This will break the world on some 64-bit architectures
1675 # CFLAGS="$CFLAGS -Winline"
1678 if test "$enable_coverage" = "yes" && test "$have_clang" = "no"; then
1679    case "$host_os" in
1680     darwin*)
1681       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.])
1682    esac
1685 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
1687 AC_CONFIG_FILES([
1688         Doxyfile
1689         Makefile
1690         contrib/dist/suse/tor.sh
1691         contrib/operator-tools/tor.logrotate
1692         contrib/dist/tor.sh
1693         contrib/dist/torctl
1694         contrib/dist/tor.service
1695         src/config/torrc.sample
1696         src/config/torrc.minimal
1697         scripts/maint/checkOptionDocs.pl
1698         scripts/maint/updateVersions.pl
1701 if test "x$asciidoc" = "xtrue" && test "$ASCIIDOC" = "none"; then
1702   regular_mans="doc/tor doc/tor-gencert doc/tor-resolve doc/torify"
1703   for file in $regular_mans ; do
1704     if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
1705       echo "==================================";
1706       echo;
1707       echo "Building Tor has failed since manpages cannot be built.";
1708       echo;
1709       echo "You need asciidoc installed to be able to build the manpages.";
1710       echo "To build without manpages, use the --disable-asciidoc argument";
1711       echo "when calling configure.";
1712       echo;
1713       echo "==================================";
1714       exit 1;
1715     fi
1716   done
1719 AC_OUTPUT