Add chutney performance testing support to src/test/test-network.sh
[tor.git] / configure.ac
blob0f93e461f4cfc7242cbb38c6688a7cbe5bb74faa
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_INIT([tor],[0.2.7.1-alpha-dev])
7 AC_CONFIG_SRCDIR([src/or/main.c])
8 AC_CONFIG_MACRO_DIR([m4])
9 AM_INIT_AUTOMAKE
10 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
11 AC_CONFIG_HEADERS([orconfig.h])
13 AC_CANONICAL_HOST
15 PKG_PROG_PKG_CONFIG
17 if test -f /etc/redhat-release ; then
18   if test -f /usr/kerberos/include ; then
19     CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
20   fi
23 # Not a no-op; we want to make sure that CPPFLAGS is set before we use
24 # the += operator on it in src/or/Makefile.am
25 CPPFLAGS="$CPPFLAGS -I\${top_srcdir}/src/common"
27 #XXXX020 We should make these enabled or not, before 0.2.0.x-final
28 AC_ARG_ENABLE(openbsd-malloc,
29    AS_HELP_STRING(--enable-openbsd-malloc, [use malloc code from OpenBSD.  Linux only]))
30 AC_ARG_ENABLE(instrument-downloads,
31    AS_HELP_STRING(--enable-instrument-downloads, [instrument downloads of directory resources etc.]))
32 AC_ARG_ENABLE(static-openssl,
33    AS_HELP_STRING(--enable-static-openssl, [link against a static openssl library. Requires --with-openssl-dir]))
34 AC_ARG_ENABLE(static-libevent,
35    AS_HELP_STRING(--enable-static-libevent, [link against a static libevent library. Requires --with-libevent-dir]))
36 AC_ARG_ENABLE(static-zlib,
37    AS_HELP_STRING(--enable-static-zlib, [link against a static zlib library. Requires --with-zlib-dir]))
38 AC_ARG_ENABLE(static-tor,
39    AS_HELP_STRING(--enable-static-tor, [create an entirely static Tor binary. Requires --with-openssl-dir and --with-libevent-dir and --with-zlib-dir]))
40 AC_ARG_ENABLE(unittests,
41    AS_HELP_STRING(--disable-unittests, [don't build unit tests for Tor. Risky!]))
42 AC_ARG_ENABLE(coverage,
43    AS_HELP_STRING(--enable-coverage, [enable coverage support in the unit-test build]))
44 AC_ARG_ENABLE(system-torrc,
45    AS_HELP_STRING(--disable-system-torrc, [don't look for a system-wide torrc file]))
47 AM_CONDITIONAL(UNITTESTS_ENABLED, test x$enable_unittests != xno)
48 AM_CONDITIONAL(COVERAGE_ENABLED, test x$enable_coverage = xyes)
50 if test "$enable_static_tor" = "yes"; then
51   enable_static_libevent="yes";
52   enable_static_openssl="yes";
53   enable_static_zlib="yes";
54   CFLAGS="$CFLAGS -static"
57 if test "$enable_system_torrc" = "no"; then
58   AC_DEFINE(DISABLE_SYSTEM_TORRC, 1,
59             [Defined if we're not going to look for a torrc in SYSCONF])
62 AM_CONDITIONAL(USE_OPENBSD_MALLOC, test x$enable_openbsd_malloc = xyes)
63 if test x$enable_instrument_downloads = xyes; then
64   AC_DEFINE(INSTRUMENT_DOWNLOADS, 1,
65             [Defined if we want to keep track of how much of each kind of resource we download.])
68 AC_ARG_ENABLE(transparent,
69      AS_HELP_STRING(--disable-transparent, [disable transparent proxy support]),
70      [case "${enableval}" in
71         yes) transparent=true ;;
72         no)  transparent=false ;;
73         *) AC_MSG_ERROR(bad value for --enable-transparent) ;;
74       esac], [transparent=true])
76 AC_ARG_ENABLE(asciidoc,
77      AS_HELP_STRING(--disable-asciidoc, [don't use asciidoc (disables building of manpages)]),
78      [case "${enableval}" in
79         yes) asciidoc=true ;;
80         no)  asciidoc=false ;;
81         *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
82       esac], [asciidoc=true])
84 # By default, we're not ready to ship a NAT-PMP aware Tor
85 AC_ARG_ENABLE(nat-pmp,
86      AS_HELP_STRING(--enable-nat-pmp, [enable NAT-PMP support]),
87      [case "${enableval}" in
88         yes) natpmp=true ;;
89         no)  natpmp=false ;;
90         * ) AC_MSG_ERROR(bad value for --enable-nat-pmp) ;;
91       esac], [natpmp=false])
93 # By default, we're not ready to ship a UPnP aware Tor
94 AC_ARG_ENABLE(upnp,
95      AS_HELP_STRING(--enable-upnp, [enable UPnP support]),
96      [case "${enableval}" in
97         yes) upnp=true ;;
98         no)  upnp=false ;;
99         * ) AC_MSG_ERROR(bad value for --enable-upnp) ;;
100       esac], [upnp=false])
102 # systemd notify support
103 AC_ARG_ENABLE(systemd,
104       AS_HELP_STRING(--enable-systemd, [enable systemd notification support]),
105       [case "${enableval}" in
106         yes) systemd=true ;;
107         no)  systemd=false ;;
108         * ) AC_MSG_ERROR(bad value for --enable-systemd) ;;
109       esac], [systemd=auto])
113 # systemd support
114 if test x$enable_systemd = xno ; then
115     have_systemd=no;
116 else
117     PKG_CHECK_MODULES(SYSTEMD,
118         [libsystemd-daemon],
119         have_systemd=yes,
120         have_systemd=no)
121     if test x$have_systemd=xno; then
122         AC_MSG_NOTICE([Okay, checking for systemd a different way...])
123         PKG_CHECK_MODULES(SYSTEMD,
124             [libsystemd],
125             have_systemd=yes,
126             have_systemd=no)
127     fi
130 if test x$have_systemd = xyes; then
131     AC_DEFINE(HAVE_SYSTEMD,1,[Have systemd])
132     TOR_SYSTEMD_CFLAGS="${SYSTEMD_CFLAGS}"
133     TOR_SYSTEMD_LIBS="${SYSTEMD_LIBS}"
134     PKG_CHECK_MODULES(LIBSYSTEMD209, [libsystemd >= 209],
135          [AC_DEFINE(HAVE_SYSTEMD_209,1,[Have systemd v209 or more])], [])
137 AC_SUBST(TOR_SYSTEMD_CFLAGS)
138 AC_SUBST(TOR_SYSTEMD_LIBS)
140 if test x$enable_systemd = xyes -a x$have_systemd != xyes ; then
141     AC_MSG_ERROR([Explicitly requested systemd support, but systemd not found])
144 case $host in
145    *-*-solaris* )
146      AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
147      ;;
148 esac
150 AC_ARG_ENABLE(gcc-warnings,
151      AS_HELP_STRING(--enable-gcc-warnings, [enable verbose warnings]))
152 AC_ARG_ENABLE(gcc-warnings-advisory,
153      AS_HELP_STRING(--enable-gcc-warnings-advisory, [enable verbose warnings, excluding -Werror]))
155 dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
156 AC_ARG_ENABLE(gcc-hardening,
157     AS_HELP_STRING(--disable-gcc-hardening, [disable compiler security checks]))
159 AC_ARG_ENABLE(expensive-hardening,
160     AS_HELP_STRING(--enable-expensive-hardening, [enable more expensive compiler hardening; makes Tor slower]))
162 dnl Linker hardening options
163 dnl Currently these options are ELF specific - you can't use this with MacOSX
164 AC_ARG_ENABLE(linker-hardening,
165     AS_HELP_STRING(--disable-linker-hardening, [disable linker security fixups]))
167 AC_ARG_ENABLE(local-appdata,
168    AS_HELP_STRING(--enable-local-appdata, [default to host local application data paths on Windows]))
169 if test "$enable_local_appdata" = "yes"; then
170   AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
171             [Defined if we default to host local appdata paths on Windows])
174 # Tor2web mode flag
175 AC_ARG_ENABLE(tor2web-mode,
176      AS_HELP_STRING(--enable-tor2web-mode, [support tor2web non-anonymous mode]),
177 [if test x$enableval = xyes; then
178     CFLAGS="$CFLAGS -D ENABLE_TOR2WEB_MODE=1"
179 fi])
181 AC_ARG_ENABLE(bufferevents,
182      AS_HELP_STRING(--enable-bufferevents, [use Libevent's buffered IO]))
184 AC_ARG_ENABLE(tool-name-check,
185      AS_HELP_STRING(--disable-tool-name-check, [check for sanely named toolchain when cross-compiling]))
187 AC_ARG_ENABLE(seccomp,
188      AS_HELP_STRING(--disable-seccomp, [do not attempt to use libseccomp]))
190 AC_ARG_ENABLE(libscrypt,
191      AS_HELP_STRING(--disable-libscrypt, [do not attempt to use libscrypt]))
193 dnl check for the correct "ar" when cross-compiling
194 AN_MAKEVAR([AR], [AC_PROG_AR])
195 AN_PROGRAM([ar], [AC_PROG_AR])
196 AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [ar])])
197 AC_PROG_AR
199 dnl Check whether the above macro has settled for a simply named tool even
200 dnl though we're cross compiling. We must do this before running AC_PROG_CC,
201 dnl because that will find any cc on the system, not only the cross-compiler,
202 dnl and then verify that a binary built with this compiler runs on the
203 dnl build system. It will then come to the false conclusion that we're not
204 dnl cross-compiling.
205 if test x$enable_tool_name_check != xno; then
206     if test x$ac_tool_warned = xyes; then
207         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.)])
208         elif test "x$ac_ct_AR" != x -a x$cross_compiling = xmaybe; then
209                 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.)])
210         fi
213 AC_PROG_CC
214 AC_PROG_CPP
215 AC_PROG_MAKE_SET
216 AC_PROG_RANLIB
218 AC_PATH_PROG([PERL], [perl])
220 dnl autoconf 2.59 appears not to support AC_PROG_SED
221 AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
223 dnl check for asciidoc and a2x
224 AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
225 AC_PATH_PROGS([A2X], [a2x a2x.py], none)
227 AM_CONDITIONAL(USE_ASCIIDOC, test x$asciidoc = xtrue)
229 AM_CONDITIONAL(USE_FW_HELPER, test x$natpmp = xtrue || test x$upnp = xtrue)
230 AM_CONDITIONAL(NAT_PMP, test x$natpmp = xtrue)
231 AM_CONDITIONAL(MINIUPNPC, test x$upnp = xtrue)
232 AM_PROG_CC_C_O
233 AC_PROG_CC_C99
235 AC_ARG_VAR([PYTHON], [path to Python binary])
236 AC_CHECK_PROGS(PYTHON, [python python2 python2.7 python3 python3.3])
237 if test "x$PYTHON" = "x"; then
238   AC_MSG_WARN([Python unavailable; some tests will not be run.])
240 AM_CONDITIONAL(USEPYTHON, [test "x$PYTHON" != "x"])
242 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
243 AC_C_FLEXIBLE_ARRAY_MEMBER
244 ], [
245  dnl Maybe we've got an old autoconf...
246  AC_CACHE_CHECK([for flexible array members],
247      tor_cv_c_flexarray,
248      [AC_COMPILE_IFELSE(
249        AC_LANG_PROGRAM([
250  struct abc { int a; char b[]; };
251 ], [
252  struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
253  def->b[0] = 33;
255   [tor_cv_c_flexarray=yes],
256   [tor_cv_c_flexarray=no])])
257  if test $tor_cv_flexarray = yes ; then
258    AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
259  else
260    AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
261  fi
264 AC_CACHE_CHECK([for working C99 mid-block declaration syntax],
265       tor_cv_c_c99_decl,
266       [AC_COMPILE_IFELSE(
267          [AC_LANG_PROGRAM([], [int x; x = 3; int y; y = 4 + x;])],
268          [tor_cv_c_c99_decl=yes],
269          [tor_cv_c_c99_decl=no] )])
270 if test "$tor_cv_c_c99_decl" != "yes"; then
271   AC_MSG_ERROR([Your compiler doesn't support c99 mid-block declarations. This is required as of Tor 0.2.6.x])
274 AC_CACHE_CHECK([for working C99 designated initializers],
275       tor_cv_c_c99_designated_init,
276       [AC_COMPILE_IFELSE(
277          [AC_LANG_PROGRAM([struct s { int a; int b; };],
278                [[ struct s ss = { .b = 5, .a = 6 }; ]])],
279          [tor_cv_c_c99_designated_init=yes],
280          [tor_cv_c_c99_designated_init=no] )])
282 if test "$tor_cv_c_c99_designated_init" != "yes"; then
283   AC_MSG_ERROR([Your compiler doesn't support c99 designated initializers. This is required as of Tor 0.2.6.x])
286 TORUSER=_tor
287 AC_ARG_WITH(tor-user,
288         AS_HELP_STRING(--with-tor-user=NAME, [specify username for tor daemon]),
289         [
290            TORUSER=$withval
291         ]
293 AC_SUBST(TORUSER)
295 TORGROUP=_tor
296 AC_ARG_WITH(tor-group,
297         AS_HELP_STRING(--with-tor-group=NAME, [specify group name for tor daemon]),
298         [
299            TORGROUP=$withval
300         ]
302 AC_SUBST(TORGROUP)
305 dnl If _WIN32 is defined and non-zero, we are building for win32
306 AC_MSG_CHECKING([for win32])
307 AC_RUN_IFELSE([AC_LANG_SOURCE([
308 int main(int c, char **v) {
309 #ifdef _WIN32
310 #if _WIN32
311   return 0;
312 #else
313   return 1;
314 #endif
315 #else
316   return 2;
317 #endif
318 }])],
319 bwin32=true; AC_MSG_RESULT([yes]),
320 bwin32=false; AC_MSG_RESULT([no]),
321 bwin32=cross; AC_MSG_RESULT([cross])
324 if test "$bwin32" = cross; then
325 AC_MSG_CHECKING([for win32 (cross)])
326 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
327 #ifdef _WIN32
328 int main(int c, char **v) {return 0;}
329 #else
330 #error
331 int main(int c, char **v) {return x(y);}
332 #endif
333 ])],
334 bwin32=true; AC_MSG_RESULT([yes]),
335 bwin32=false; AC_MSG_RESULT([no]))
338 if test "$bwin32" = yes; then
339   AC_DEFINE(WIN32_LEAN_AND_MEAN, 1, [Defined to avoid including some windows headers])
340   AC_DEFINE(WINVER, 0x0501, [Defined to access windows functions and definitions for >=WinXP])
341   AC_DEFINE(_WIN32_WINNT, 0x0501, [Defined to access windows functions and definitions for >=WinXP])
344 AM_CONDITIONAL(BUILD_NT_SERVICES, test x$bwin32 = xtrue)
346 dnl Enable C99 when compiling with MIPSpro
347 AC_MSG_CHECKING([for MIPSpro compiler])
348 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
349 #if (defined(__sgi) && defined(_COMPILER_VERSION))
350 #error
351   return x(y);
352 #endif
353 ])],
354 bmipspro=false; AC_MSG_RESULT(no),
355 bmipspro=true; AC_MSG_RESULT(yes))
357 if test "$bmipspro" = true; then
358   CFLAGS="$CFLAGS -c99"
361 AC_C_BIGENDIAN
363 AC_SEARCH_LIBS(socket, [socket network])
364 AC_SEARCH_LIBS(gethostbyname, [nsl])
365 AC_SEARCH_LIBS(dlopen, [dl])
366 AC_SEARCH_LIBS(inet_aton, [resolv])
367 saved_LIBS="$LIBS"
368 AC_SEARCH_LIBS([clock_gettime], [rt])
369 if test "$LIBS" != "$saved_LIBS"; then
370    # Looks like we need -lrt for clock_gettime().
371    have_rt=yes
374 AC_SEARCH_LIBS(pthread_create, [pthread])
375 AC_SEARCH_LIBS(pthread_detach, [pthread])
377 AM_CONDITIONAL(THREADS_WIN32, test "$bwin32" = "true")
378 AM_CONDITIONAL(THREADS_PTHREADS, test "$bwin32" = "false")
380 dnl -------------------------------------------------------------------
381 dnl Check for functions before libevent, since libevent-1.2 apparently
382 dnl exports strlcpy without defining it in a header.
384 AC_CHECK_FUNCS(
385         _NSGetEnviron \
386         accept4 \
387         backtrace \
388         backtrace_symbols_fd \
389         clock_gettime \
390         eventfd \
391         flock \
392         ftime \
393         getaddrinfo \
394         getifaddrs \
395         getpass \
396         getrlimit \
397         gettimeofday \
398         gmtime_r \
399         inet_aton \
400         ioctl \
401         issetugid \
402         llround \
403         localtime_r \
404         lround \
405         memmem \
406         pipe \
407         pipe2 \
408         prctl \
409         readpassphrase \
410         rint \
411         sigaction \
412         socketpair \
413         strlcat \
414         strlcpy \
415         strnlen \
416         strptime \
417         strtok_r \
418         strtoull \
419         sysconf \
420         sysctl \
421         uname \
422         usleep \
423         vasprintf \
424         _vscprintf
427 if test "$bwin32" != true; then
428   AC_CHECK_HEADERS(pthread.h)
429   AC_CHECK_FUNCS(pthread_create)
432 AM_CONDITIONAL(BUILD_READPASSPHRASE_C, test x$ac_cv_func_readpassphrase = xno && test $bwin32 = false)
434 dnl ------------------------------------------------------
435 dnl Where do you live, libevent?  And how do we call you?
437 if test "$bwin32" = true; then
438   TOR_LIB_WS32=-lws2_32
439   TOR_LIB_IPHLPAPI=-liphlpapi
440   # Some of the cargo-cults recommend -lwsock32 as well, but I don't
441   # think it's actually necessary.
442   TOR_LIB_GDI=-lgdi32
443 else
444   TOR_LIB_WS32=
445   TOR_LIB_GDI=
447 AC_SUBST(TOR_LIB_WS32)
448 AC_SUBST(TOR_LIB_GDI)
449 AC_SUBST(TOR_LIB_IPHLPAPI)
451 tor_libevent_pkg_redhat="libevent"
452 tor_libevent_pkg_debian="libevent-dev"
453 tor_libevent_devpkg_redhat="libevent-devel"
454 tor_libevent_devpkg_debian="libevent-dev"
456 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
457 dnl linking for static builds.
458 STATIC_LIBEVENT_FLAGS=""
459 if test "$enable_static_libevent" = "yes"; then
460     if test "$have_rt" = yes; then
461       STATIC_LIBEVENT_FLAGS=" -lrt "
462     fi
465 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
466 #ifdef _WIN32
467 #include <winsock2.h>
468 #endif
469 #include <stdlib.h>
470 #include <sys/time.h>
471 #include <sys/types.h>
472 #include <event.h>], [
473 #ifdef _WIN32
474 #include <winsock2.h>
475 #endif
476 void exit(int); void *event_init(void);],
477     [
478 #ifdef _WIN32
479 {WSADATA d; WSAStartup(0x101,&d); }
480 #endif
481 event_init(); exit(0);
482 ], [--with-libevent-dir], [/opt/libevent])
484 dnl Now check for particular libevent functions.
485 save_LIBS="$LIBS"
486 save_LDFLAGS="$LDFLAGS"
487 save_CPPFLAGS="$CPPFLAGS"
488 LIBS="-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $LIBS"
489 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
490 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
491 AC_CHECK_FUNCS([event_get_version_number \
492                 evutil_secure_rng_set_urandom_device_file \
493                 evutil_secure_rng_init \
494                ])
495 AC_CHECK_MEMBERS([struct event.min_heap_idx], , ,
496 [#include <event.h>
499 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
501 LIBS="$save_LIBS"
502 LDFLAGS="$save_LDFLAGS"
503 CPPFLAGS="$save_CPPFLAGS"
506 AM_CONDITIONAL(USE_EXTERNAL_EVDNS, test x$ac_cv_header_event2_dns_h = xyes)
508 if test "$enable_static_libevent" = "yes"; then
509    if test "$tor_cv_library_libevent_dir" = "(system)"; then
510      AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
511    else
512      TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
513    fi
514 else
515      TOR_LIBEVENT_LIBS="-levent"
518 dnl This isn't the best test for Libevent 2.0.3-alpha.  Once it's released,
519 dnl we can do much better.
520 if test "$enable_bufferevents" = "yes" ; then
521   if test "$ac_cv_header_event2_bufferevent_ssl_h" != "yes" ; then
522     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.])
523   else
525     CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
527     # Check for the right version.  First see if version detection works.
528     AC_MSG_CHECKING([whether we can detect the Libevent version])
529     AC_COMPILE_IFELSE([AC_LANG_SOURCE([
530 #include <event2/event.h>
531 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 10
532 #error
533 int x = y(zz);
534 #else
535 int x = 1;
536 #endif
537   ])], [event_version_number_works=yes; AC_MSG_RESULT([yes]) ],
538      [event_version_number_works=no;  AC_MSG_RESULT([no])])
539     if test "$event_version_number_works" != 'yes'; then
540       AC_MSG_WARN([Version detection on Libevent seems broken.  Your Libevent installation is probably screwed up or very old.])
541     else
542       AC_MSG_CHECKING([whether Libevent is new enough for bufferevents])
543       AC_COMPILE_IFELSE([AC_LANG_SOURCE([
544 #include <event2/event.h>
545 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000d00
546 #error
547 int x = y(zz);
548 #else
549 int x = 1;
550 #endif
551    ])], [ AC_MSG_RESULT([yes]) ],
552       [ AC_MSG_RESULT([no])
553         AC_MSG_ERROR([Libevent does not seem new enough to support bufferevents.  We require 2.0.13-stable or later]) ] )
554     fi
555   fi
558 LIBS="$save_LIBS"
559 LDFLAGS="$save_LDFLAGS"
560 CPPFLAGS="$save_CPPFLAGS"
562 AM_CONDITIONAL(USE_BUFFEREVENTS, test "$enable_bufferevents" = "yes")
563 if test "$enable_bufferevents" = "yes"; then
564   AC_DEFINE(USE_BUFFEREVENTS, 1, [Defined if we're going to use Libevent's buffered IO API])
565   if test "$enable_static_libevent" = "yes"; then
566     TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent_openssl.a $TOR_LIBEVENT_LIBS"
567   else
568     TOR_LIBEVENT_LIBS="-levent_openssl $TOR_LIBEVENT_LIBS"
569   fi
571 AC_SUBST(TOR_LIBEVENT_LIBS)
573 dnl ------------------------------------------------------
574 dnl Where do you live, libm?
576 dnl On some platforms (Haiku/BeOS) the math library is
577 dnl part of libroot. In which case don't link against lm
578 TOR_LIB_MATH=""
579 save_LIBS="$LIBS"
580 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
581 if test "$ac_cv_search_pow" != "none required"; then
582     TOR_LIB_MATH="$ac_cv_search_pow"
584 LIBS="$save_LIBS"
585 AC_SUBST(TOR_LIB_MATH)
587 dnl ------------------------------------------------------
588 dnl Where do you live, openssl?  And how do we call you?
590 tor_openssl_pkg_redhat="openssl"
591 tor_openssl_pkg_debian="libssl-dev"
592 tor_openssl_devpkg_redhat="openssl-devel"
593 tor_openssl_devpkg_debian="libssl-dev"
595 ALT_openssl_WITHVAL=""
596 AC_ARG_WITH(ssl-dir,
597   AS_HELP_STRING(--with-ssl-dir=PATH, [obsolete alias for --with-openssl-dir]),
598   [
599       if test "x$withval" != xno && test "x$withval" != "x" ; then
600          ALT_openssl_WITHVAL="$withval"
601       fi
602   ])
604 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI],
605     [#include <openssl/rand.h>],
606     [void RAND_add(const void *buf, int num, double entropy);],
607     [RAND_add((void*)0,0,0); exit(0);], [],
608     [/usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /opt/openssl])
610 dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
612 if test "$enable_static_openssl" = "yes"; then
613    if test "$tor_cv_library_openssl_dir" = "(system)"; then
614      AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
615    else
616      TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
617    fi
618 else
619      TOR_OPENSSL_LIBS="-lssl -lcrypto"
621 AC_SUBST(TOR_OPENSSL_LIBS)
623 dnl Now check for particular openssl functions.
624 save_LIBS="$LIBS"
625 save_LDFLAGS="$LDFLAGS"
626 save_CPPFLAGS="$CPPFLAGS"
627 LIBS="$TOR_OPENSSL_LIBS $LIBS"
628 LDFLAGS="$TOR_LDFLAGS_openssl $LDFLAGS"
629 CPPFLAGS="$TOR_CPPFLAGS_openssl $CPPFLAGS"
630 AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , ,
631 [#include <openssl/ssl.h>
634 AC_CHECK_FUNCS([ \
635                 SSL_SESSION_get_master_key \
636                 SSL_get_server_random \
637                 SSL_get_client_ciphers \
638                 SSL_get_client_random \
639                 SSL_CIPHER_find \
640                 TLS_method
641                ])
642 LIBS="$save_LIBS"
643 LDFLAGS="$save_LDFLAGS"
644 CPPFLAGS="$save_CPPFLAGS"
646 dnl ------------------------------------------------------
647 dnl Where do you live, zlib?  And how do we call you?
649 tor_zlib_pkg_redhat="zlib"
650 tor_zlib_pkg_debian="zlib1g"
651 tor_zlib_devpkg_redhat="zlib-devel"
652 tor_zlib_devpkg_debian="zlib1g-dev"
654 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
655     [#include <zlib.h>],
656     [const char * zlibVersion(void);],
657     [zlibVersion(); exit(0);], [--with-zlib-dir],
658     [/opt/zlib])
660 if test "$enable_static_zlib" = "yes"; then
661    if test "$tor_cv_library_zlib_dir" = "(system)"; then
662      AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
663  using --enable-static-zlib")
664    else
665      TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
666    fi
667 else
668      TOR_ZLIB_LIBS="-lz"
670 AC_SUBST(TOR_ZLIB_LIBS)
672 dnl ---------------------------------------------------------------------
673 dnl Now that we know about our major libraries, we can check for compiler
674 dnl and linker hardening options.  We need to do this with the libraries known,
675 dnl since sometimes the linker will like an option but not be willing to
676 dnl use it with a build of a library.
678 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
679 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"
681 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
682 #if !defined(__clang__)
683 #error
684 #endif])], have_clang=yes, have_clang=no)
686 if test x$enable_gcc_hardening != xno; then
687     CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
688     if test x$have_clang = xyes; then
689         TOR_CHECK_CFLAGS(-Qunused-arguments)
690     fi
691     TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
692     AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
693     AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
694 m4_ifdef([AS_VAR_IF],[
695     AS_VAR_IF(can_compile, [yes],
696         AS_VAR_IF(can_link, [yes],
697                   [],
698                   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.)]))
699         )])
700     AS_VAR_POPDEF([can_link])
701     AS_VAR_POPDEF([can_compile])
702     TOR_CHECK_CFLAGS(-Wstack-protector)
703     TOR_CHECK_CFLAGS(-fwrapv)
704     TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
705     if test "$bwin32" = "false"; then
706        TOR_CHECK_CFLAGS(-fPIE)
707        TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
708     fi
711 if test x$enable_expensive_hardening = xyes ; then
712    TOR_CHECK_CFLAGS([-fsanitize=address])
713    TOR_CHECK_CFLAGS([-fsanitize=undefined])
714    TOR_CHECK_CFLAGS([-fno-omit-frame-pointer])
717 if test x$enable_linker_hardening != xno; then
718     TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
721 # For backtrace support
722 TOR_CHECK_LDFLAGS(-rdynamic)
724 dnl ------------------------------------------------------
725 dnl Now see if we have a -fomit-frame-pointer compiler option.
727 saved_CFLAGS="$CFLAGS"
728 TOR_CHECK_CFLAGS(-fomit-frame-pointer)
729 F_OMIT_FRAME_POINTER=''
730 if test "$saved_CFLAGS" != "$CFLAGS"; then
731   if test x$enable_expensive_hardening != xyes ; then
732     F_OMIT_FRAME_POINTER='-fomit-frame-pointer'
733   fi
735 CFLAGS="$saved_CFLAGS"
736 AC_SUBST(F_OMIT_FRAME_POINTER)
738 dnl ------------------------------------------------------
739 dnl If we are adding -fomit-frame-pointer (or if the compiler's doing it
740 dnl for us, as GCC 4.6 and later do at many optimization levels), then
741 dnl we should try to add -fasynchronous-unwind-tables so that our backtrace
742 dnl code will work.
743 TOR_CHECK_CFLAGS(-fasynchronous-unwind-tables)
745 dnl ------------------------------------------------------
746 dnl Where do you live, libnatpmp?  And how do we call you?
747 dnl There are no packages for Debian or Redhat as of this patch
749 if test "$natpmp" = "true"; then
750     AC_DEFINE(NAT_PMP, 1, [Define to 1 if we are building with nat-pmp.])
751     TOR_SEARCH_LIBRARY(libnatpmp, $trylibnatpmpdir, [-lnatpmp $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
752         [#include <natpmp.h>],
753         [#ifdef _WIN32
754          #define STATICLIB
755          #endif
756          #include <natpmp.h>],
757         [   int r;
758             natpmp_t natpmp;
759             natpmpresp_t response;
760             r = initnatpmp(&natpmp, 0, 0);],
761             [printf("initnatpmp() returned %d (%s)\n", r, r?"FAILED":"SUCCESS");
762             exit(0);],
763         [--with-libnatpmp-dir],
764         [/usr/lib/])
768 dnl ------------------------------------------------------
769 dnl Where do you live, libminiupnpc?  And how do we call you?
770 dnl There are no packages for Debian or Redhat as of this patch
772 if test "$upnp" = "true"; then
773     AC_DEFINE(MINIUPNPC, 1, [Define to 1 if we are building with UPnP.])
775     dnl Before we call TOR_SEARCH_LIBRARY we'll do a quick compile test
776     dnl to see if we have miniupnpc-1.5 or -1.6
777     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <miniupnpc/miniupnpc.h>],
778         [upnpDiscover(1, 0, 0, 0);exit(0);])],[miniupnpc15="true"],[miniupnpc15="false"])
780     if test "$miniupnpc15" = "true" ; then
781         AC_DEFINE([MINIUPNPC15],[1],[libminiupnpc version 1.5 found])
782         TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
783             [#include <miniupnpc/miniwget.h>
784              #include <miniupnpc/miniupnpc.h>
785              #include <miniupnpc/upnpcommands.h>],
786             [void upnpDiscover(int delay, const char * multicastif,
787              const char * minissdpdsock, int sameport);],
788             [upnpDiscover(1, 0, 0, 0); exit(0);],
789             [--with-libminiupnpc-dir],
790             [/usr/lib/])
791     else
792         TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
793             [#include <miniupnpc/miniwget.h>
794              #include <miniupnpc/miniupnpc.h>
795              #include <miniupnpc/upnpcommands.h>],
796             [void upnpDiscover(int delay, const char * multicastif,
797              const char * minissdpdsock, int sameport, int ipv6, int * error);],
798             [upnpDiscover(1, 0, 0, 0, 0, 0); exit(0);],
799             [--with-libminiupnpc-dir],
800             [/usr/lib/])
801     fi
804 dnl ============================================================
805 dnl Check for libseccomp
807 if test "x$enable_seccomp" != "xno"; then
808   AC_CHECK_HEADERS([seccomp.h])
809   AC_SEARCH_LIBS(seccomp_init, [seccomp])
812 dnl ============================================================
813 dnl Check for libscrypt
815 if test "x$enable_libscrypt" != "xno"; then
816   AC_CHECK_HEADERS([libscrypt.h])
817   AC_SEARCH_LIBS(libscrypt_scrypt, [scrypt])
820 dnl ============================================================
821 dnl We need an implementation of curve25519.
823 dnl set these defaults.
824 build_curve25519_donna=no
825 build_curve25519_donna_c64=no
826 use_curve25519_donna=no
827 use_curve25519_nacl=no
828 CURVE25519_LIBS=
830 dnl The best choice is using curve25519-donna-c64, but that requires
831 dnl that we
832 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
833   tor_cv_can_use_curve25519_donna_c64,
834   [AC_RUN_IFELSE(
835     [AC_LANG_PROGRAM([dnl
836       #include <stdint.h>
837       typedef unsigned uint128_t __attribute__((mode(TI)));
838   int func(uint64_t a, uint64_t b) {
839            uint128_t c = ((uint128_t)a) * b;
840            int ok = ((uint64_t)(c>>96)) == 522859 &&
841              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
842                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
843                  (((uint64_t)(c))&0xffffffffL) == 0;
844            return ok;
845       }
846   ], [dnl
847     int ok = func( ((uint64_t)2000000000) * 1000000000,
848                    ((uint64_t)1234567890) << 24);
849         return !ok;
850       ])],
851   [tor_cv_can_use_curve25519_donna_c64=yes],
852       [tor_cv_can_use_curve25519_donna_c64=no],
853   [AC_LINK_IFELSE(
854         [AC_LANG_PROGRAM([dnl
855       #include <stdint.h>
856       typedef unsigned uint128_t __attribute__((mode(TI)));
857   int func(uint64_t a, uint64_t b) {
858            uint128_t c = ((uint128_t)a) * b;
859            int ok = ((uint64_t)(c>>96)) == 522859 &&
860              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
861                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
862                  (((uint64_t)(c))&0xffffffffL) == 0;
863            return ok;
864       }
865   ], [dnl
866     int ok = func( ((uint64_t)2000000000) * 1000000000,
867                  ((uint64_t)1234567890) << 24);
868         return !ok;
869       ])],
870           [tor_cv_can_use_curve25519_donna_c64=cross],
871       [tor_cv_can_use_curve25519_donna_c64=no])])])
873 AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
874                   nacl/crypto_scalarmult_curve25519.h])
876 AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
877   tor_cv_can_use_curve25519_nacl,
878   [tor_saved_LIBS="$LIBS"
879    LIBS="$LIBS -lnacl"
880    AC_LINK_IFELSE(
881      [AC_LANG_PROGRAM([dnl
882        #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
883        #include <crypto_scalarmult_curve25519.h>
884    #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
885    #include <nacl/crypto_scalarmult_curve25519.h>
886    #endif
887        #ifdef crypto_scalarmult_curve25519_ref_BYTES
888    #error Hey, this is the reference implementation! That's not fast.
889    #endif
890      ], [
891    unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
892      ])], [tor_cv_can_use_curve25519_nacl=yes],
893      [tor_cv_can_use_curve25519_nacl=no])
894    LIBS="$tor_saved_LIBS" ])
896  dnl Okay, now we need to figure out which one to actually use. Fall back
897  dnl to curve25519-donna.c
899  if test x$tor_cv_can_use_curve25519_donna_c64 != xno; then
900    build_curve25519_donna_c64=yes
901    use_curve25519_donna=yes
902  elif test x$tor_cv_can_use_curve25519_nacl = xyes; then
903    use_curve25519_nacl=yes
904    CURVE25519_LIBS=-lnacl
905  else
906    build_curve25519_donna=yes
907    use_curve25519_donna=yes
908  fi
910 if test x$use_curve25519_donna = xyes; then
911   AC_DEFINE(USE_CURVE25519_DONNA, 1,
912             [Defined if we should use an internal curve25519_donna{,_c64} implementation])
914 if test x$use_curve25519_nacl = xyes; then
915   AC_DEFINE(USE_CURVE25519_NACL, 1,
916             [Defined if we should use a curve25519 from nacl])
918 AM_CONDITIONAL(BUILD_CURVE25519_DONNA, test x$build_curve25519_donna = xyes)
919 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64, test x$build_curve25519_donna_c64 = xyes)
920 AC_SUBST(CURVE25519_LIBS)
922 dnl Make sure to enable support for large off_t if available.
923 AC_SYS_LARGEFILE
925 AC_CHECK_HEADERS(
926         assert.h \
927         errno.h \
928         fcntl.h \
929         signal.h \
930         string.h \
931         sys/fcntl.h \
932         sys/stat.h \
933         sys/time.h \
934         sys/types.h \
935         time.h \
936         unistd.h
937  , , 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.))
939 dnl These headers are not essential
941 AC_CHECK_HEADERS(
942         arpa/inet.h \
943         crt_externs.h \
944         execinfo.h \
945         grp.h \
946         ifaddrs.h \
947         inttypes.h \
948         limits.h \
949         linux/types.h \
950         machine/limits.h \
951         malloc.h \
952         malloc/malloc.h \
953         malloc_np.h \
954         netdb.h \
955         netinet/in.h \
956         netinet/in6.h \
957         pwd.h \
958         readpassphrase.h \
959         stdint.h \
960         sys/eventfd.h \
961         sys/file.h \
962         sys/ioctl.h \
963         sys/limits.h \
964         sys/mman.h \
965         sys/param.h \
966         sys/prctl.h \
967         sys/resource.h \
968         sys/select.h \
969         sys/socket.h \
970         sys/sysctl.h \
971         sys/syslimits.h \
972         sys/time.h \
973         sys/types.h \
974         sys/un.h \
975         sys/utime.h \
976         sys/wait.h \
977         syslog.h \
978         utime.h
981 AC_CHECK_HEADERS(sys/param.h)
983 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
984 [#ifdef HAVE_SYS_TYPES_H
985 #include <sys/types.h>
986 #endif
987 #ifdef HAVE_SYS_SOCKET_H
988 #include <sys/socket.h>
989 #endif])
990 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
991 [#ifdef HAVE_SYS_TYPES_H
992 #include <sys/types.h>
993 #endif
994 #ifdef HAVE_SYS_SOCKET_H
995 #include <sys/socket.h>
996 #endif
997 #ifdef HAVE_NET_IF_H
998 #include <net/if.h>
999 #endif])
1001 AC_CHECK_HEADERS(linux/if.h,[],[],
1003 #ifdef HAVE_SYS_SOCKET_H
1004 #include <sys/socket.h>
1005 #endif
1008 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
1009         linux_netfilter_ipv4=1, linux_netfilter_ipv4=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_LIMITS_H
1017 #include <limits.h>
1018 #endif
1019 #ifdef HAVE_LINUX_TYPES_H
1020 #include <linux/types.h>
1021 #endif
1022 #ifdef HAVE_NETINET_IN6_H
1023 #include <netinet/in6.h>
1024 #endif
1025 #ifdef HAVE_NETINET_IN_H
1026 #include <netinet/in.h>
1027 #endif])
1029 AC_CHECK_HEADERS(linux/netfilter_ipv6/ip6_tables.h,
1030         linux_netfilter_ipv6_ip6_tables=1, linux_netfilter_ipv6_ip6_tables=0,
1031 [#ifdef HAVE_SYS_TYPES_H
1032 #include <sys/types.h>
1033 #endif
1034 #ifdef HAVE_SYS_SOCKET_H
1035 #include <sys/socket.h>
1036 #endif
1037 #ifdef HAVE_LIMITS_H
1038 #include <limits.h>
1039 #endif
1040 #ifdef HAVE_LINUX_TYPES_H
1041 #include <linux/types.h>
1042 #endif
1043 #ifdef HAVE_NETINET_IN6_H
1044 #include <netinet/in6.h>
1045 #endif
1046 #ifdef HAVE_NETINET_IN_H
1047 #include <netinet/in.h>
1048 #endif
1049 #ifdef HAVE_LINUX_IF_H
1050 #include <linux/if.h>
1051 #endif])
1053 if test x$transparent = xtrue ; then
1054    transparent_ok=0
1055    if test x$net_if_found = x1 && test x$net_pfvar_found = x1 ; then
1056      transparent_ok=1
1057    fi
1058    if test x$linux_netfilter_ipv4 = x1 ; then
1059      transparent_ok=1
1060    fi
1061    if test x$linux_netfilter_ipv6_ip6_tables = x1 ; then
1062      transparent_ok=1
1063    fi
1064    if test x$transparent_ok = x1 ; then
1065      AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
1066      case $host in
1067        *-*-openbsd* | *-*-bitrig*)
1068          AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
1069      esac
1070    else
1071      AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
1072    fi
1075 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
1076 [#ifdef HAVE_SYS_TYPES_H
1077 #include <sys/types.h>
1078 #endif
1079 #ifdef HAVE_SYS_TIME_H
1080 #include <sys/time.h>
1081 #endif])
1083 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
1084 dnl Watch out.
1086 AC_CHECK_SIZEOF(int8_t)
1087 AC_CHECK_SIZEOF(int16_t)
1088 AC_CHECK_SIZEOF(int32_t)
1089 AC_CHECK_SIZEOF(int64_t)
1090 AC_CHECK_SIZEOF(uint8_t)
1091 AC_CHECK_SIZEOF(uint16_t)
1092 AC_CHECK_SIZEOF(uint32_t)
1093 AC_CHECK_SIZEOF(uint64_t)
1094 AC_CHECK_SIZEOF(intptr_t)
1095 AC_CHECK_SIZEOF(uintptr_t)
1097 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
1099 AC_CHECK_SIZEOF(char)
1100 AC_CHECK_SIZEOF(short)
1101 AC_CHECK_SIZEOF(int)
1102 AC_CHECK_SIZEOF(long)
1103 AC_CHECK_SIZEOF(long long)
1104 AC_CHECK_SIZEOF(__int64)
1105 AC_CHECK_SIZEOF(void *)
1106 AC_CHECK_SIZEOF(time_t)
1107 AC_CHECK_SIZEOF(size_t)
1108 AC_CHECK_SIZEOF(pid_t)
1110 AC_CHECK_TYPES([uint, u_char, ssize_t])
1112 AC_PC_FROM_UCONTEXT([/bin/true])
1114 dnl used to include sockaddr_storage, but everybody has that.
1115 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
1116 [#ifdef HAVE_SYS_TYPES_H
1117 #include <sys/types.h>
1118 #endif
1119 #ifdef HAVE_NETINET_IN_H
1120 #include <netinet/in.h>
1121 #endif
1122 #ifdef HAVE_NETINET_IN6_H
1123 #include <netinet/in6.h>
1124 #endif
1125 #ifdef HAVE_SYS_SOCKET_H
1126 #include <sys/socket.h>
1127 #endif
1128 #ifdef _WIN32
1129 #define _WIN32_WINNT 0x0501
1130 #define WIN32_LEAN_AND_MEAN
1131 #include <winsock2.h>
1132 #include <ws2tcpip.h>
1133 #endif
1135 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
1136 [#ifdef HAVE_SYS_TYPES_H
1137 #include <sys/types.h>
1138 #endif
1139 #ifdef HAVE_NETINET_IN_H
1140 #include <netinet/in.h>
1141 #endif
1142 #ifdef HAVE_NETINET_IN6_H
1143 #include <netinet/in6.h>
1144 #endif
1145 #ifdef HAVE_SYS_SOCKET_H
1146 #include <sys/socket.h>
1147 #endif
1148 #ifdef _WIN32
1149 #define _WIN32_WINNT 0x0501
1150 #define WIN32_LEAN_AND_MEAN
1151 #include <winsock2.h>
1152 #include <ws2tcpip.h>
1153 #endif
1154 #endif
1157 AC_CHECK_TYPES([rlim_t], , ,
1158 [#ifdef HAVE_SYS_TYPES_H
1159 #include <sys/types.h>
1160 #endif
1161 #ifdef HAVE_SYS_TIME_H
1162 #include <sys/time.h>
1163 #endif
1164 #ifdef HAVE_SYS_RESOURCE_H
1165 #include <sys/resource.h>
1166 #endif
1169 AX_CHECK_SIGN([time_t],
1170        [ AC_DEFINE(TIME_T_IS_SIGNED, 1, [Define if time_t is signed]) ],
1171        [ : ], [
1172 #ifdef HAVE_SYS_TYPES_H
1173 #include <sys/types.h>
1174 #endif
1175 #ifdef HAVE_SYS_TIME_H
1176 #include <sys/time.h>
1177 #endif
1178 #ifdef HAVE_TIME_H
1179 #include <time.h>
1180 #endif
1183 if test "$ax_cv_decl_time_t_signed" = no; then
1184   AC_MSG_WARN([You have an unsigned time_t; some things will probably break. Please tell the Tor developers about your interesting platform.])
1187 AX_CHECK_SIGN([size_t],
1188        [ tor_cv_size_t_signed=yes ],
1189        [ tor_cv_size_t_signed=no ], [
1190 #ifdef HAVE_SYS_TYPES_H
1191 #include <sys/types.h>
1192 #endif
1195 if test "$ax_cv_decl_size_t_signed" = yes; then
1196   AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
1199 AX_CHECK_SIGN([enum always],
1200        [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
1201        [ : ], [
1202  enum always { AAA, BBB, CCC };
1205 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
1206 #ifdef HAVE_SYS_SOCKET_H
1207 #include <sys/socket.h>
1208 #endif
1211 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1213 AC_CHECK_SIZEOF(cell_t)
1215 # Now make sure that NULL can be represented as zero bytes.
1216 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1217 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1218 [[#include <stdlib.h>
1219 #include <string.h>
1220 #include <stdio.h>
1221 #ifdef HAVE_STDDEF_H
1222 #include <stddef.h>
1223 #endif
1224 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1225 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1226        [tor_cv_null_is_zero=yes],
1227        [tor_cv_null_is_zero=no],
1228        [tor_cv_null_is_zero=cross])])
1230 if test "$tor_cv_null_is_zero" = cross ; then
1231   # Cross-compiling; let's hope that the target isn't raving mad.
1232   AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
1235 if test "$tor_cv_null_is_zero" != no; then
1236   AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1237             [Define to 1 iff memset(0) sets pointers to NULL])
1240 AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
1241 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1242 [[#include <stdlib.h>
1243 #include <string.h>
1244 #include <stdio.h>
1245 #ifdef HAVE_STDDEF_H
1246 #include <stddef.h>
1247 #endif
1248 int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
1249 return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
1250        [tor_cv_dbl0_is_zero=yes],
1251        [tor_cv_dbl0_is_zero=no],
1252        [tor_cv_dbl0_is_zero=cross])])
1254 if test "$tor_cv_dbl0_is_zero" = cross ; then
1255   # Cross-compiling; let's hope that the target isn't raving mad.
1256   AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
1259 if test "$tor_cv_dbl0_is_zero" != no; then
1260   AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
1261             [Define to 1 iff memset(0) sets doubles to 0.0])
1264 # And what happens when we malloc zero?
1265 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
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 () { return malloc(0)?0:1; }]])],
1274        [tor_cv_malloc_zero_works=yes],
1275        [tor_cv_malloc_zero_works=no],
1276        [tor_cv_malloc_zero_works=cross])])
1278 if test "$tor_cv_malloc_zero_works" = cross; then
1279   # Cross-compiling; let's hope that the target isn't raving mad.
1280   AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
1283 if test "$tor_cv_malloc_zero_works" = yes; then
1284   AC_DEFINE([MALLOC_ZERO_WORKS], 1,
1285             [Define to 1 iff malloc(0) returns a pointer])
1288 # whether we seem to be in a 2s-complement world.
1289 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
1290 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1291 [[int main () { int problem = ((-99) != (~99)+1);
1292 return problem ? 1 : 0; }]])],
1293        [tor_cv_twos_complement=yes],
1294        [tor_cv_twos_complement=no],
1295        [tor_cv_twos_complement=cross])])
1297 if test "$tor_cv_twos_complement" = cross ; then
1298   # Cross-compiling; let's hope that the target isn't raving mad.
1299   AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
1302 if test "$tor_cv_twos_complement" != no ; then
1303   AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
1304             [Define to 1 iff we represent negative integers with two's complement])
1307 # What does shifting a negative value do?
1308 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
1309 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1310 [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
1311        [tor_cv_sign_extend=yes],
1312        [tor_cv_sign_extend=no],
1313        [tor_cv_sign_extend=cross])])
1315 if test "$tor_cv_sign_extend" = cross ; then
1316   # Cross-compiling; let's hope that the target isn't raving mad.
1317   AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
1320 if test "$tor_cv_sign_extend" != no ; then
1321   AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
1322             [Define to 1 iff right-shifting a negative value performs sign-extension])
1325 # Whether we should use the dmalloc memory allocation debugging library.
1326 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
1327 AC_ARG_WITH(dmalloc,
1328 AS_HELP_STRING(--with-dmalloc, [use debug memory allocation library]),
1329 [if [[ "$withval" = "yes" ]]; then
1330   dmalloc=1
1331   AC_MSG_RESULT(yes)
1332 else
1333   dmalloc=1
1334   AC_MSG_RESULT(no)
1335 fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
1338 if [[ $dmalloc -eq 1 ]]; then
1339   AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
1340   AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
1341   AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
1342   AC_CHECK_FUNCS(dmalloc_strdup dmalloc_strndup)
1345 AC_ARG_WITH(tcmalloc,
1346 AS_HELP_STRING(--with-tcmalloc, [use tcmalloc memory allocation library]),
1347 [ tcmalloc=yes ], [ tcmalloc=no ])
1349 if test x$tcmalloc = xyes ; then
1350    LDFLAGS="-ltcmalloc $LDFLAGS"
1353 using_custom_malloc=no
1354 if test x$enable_openbsd_malloc = xyes ; then
1355    using_custom_malloc=yes
1357 if test x$tcmalloc = xyes ; then
1358    using_custom_malloc=yes
1360 if test $using_custom_malloc = no ; then
1361    AC_CHECK_FUNCS(mallinfo)
1364 # By default, we're going to assume we don't have mlockall()
1365 # bionic and other platforms have various broken mlockall subsystems.
1366 # Some systems don't have a working mlockall, some aren't linkable,
1367 # and some have it but don't declare it.
1368 AC_CHECK_FUNCS(mlockall)
1369 AC_CHECK_DECLS([mlockall], , , [
1370 #ifdef HAVE_SYS_MMAN_H
1371 #include <sys/mman.h>
1372 #endif])
1374 # Allow user to specify an alternate syslog facility
1375 AC_ARG_WITH(syslog-facility,
1376 AS_HELP_STRING(--with-syslog-facility=LOG, [syslog facility to use (default=LOG_DAEMON)]),
1377 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
1378 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
1379 AC_SUBST(LOGFACILITY)
1381 # Check if we have getresuid and getresgid
1382 AC_CHECK_FUNCS(getresuid getresgid)
1384 # Check for gethostbyname_r in all its glorious incompatible versions.
1385 #   (This logic is based on that in Python's configure.in)
1386 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
1387   [Define this if you have any gethostbyname_r()])
1389 AC_CHECK_FUNC(gethostbyname_r, [
1390   AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
1391   OLD_CFLAGS=$CFLAGS
1392   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1393   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1394 #include <netdb.h>
1395   ], [[
1396     char *cp1, *cp2;
1397     struct hostent *h1, *h2;
1398     int i1, i2;
1399     (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
1400   ]])],[
1401     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1402     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
1403      [Define this if gethostbyname_r takes 6 arguments])
1404     AC_MSG_RESULT(6)
1405   ], [
1406     AC_TRY_COMPILE([
1407 #include <netdb.h>
1408     ], [
1409       char *cp1, *cp2;
1410       struct hostent *h1;
1411       int i1, i2;
1412       (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
1413     ], [
1414       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1415       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
1416         [Define this if gethostbyname_r takes 5 arguments])
1417       AC_MSG_RESULT(5)
1418    ], [
1419       AC_TRY_COMPILE([
1420 #include <netdb.h>
1421      ], [
1422        char *cp1;
1423        struct hostent *h1;
1424        struct hostent_data hd;
1425        (void) gethostbyname_r(cp1,h1,&hd);
1426      ], [
1427        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1428        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
1429          [Define this if gethostbyname_r takes 3 arguments])
1430        AC_MSG_RESULT(3)
1431      ], [
1432        AC_MSG_RESULT(0)
1433      ])
1434   ])
1435  ])
1436  CFLAGS=$OLD_CFLAGS
1439 AC_CACHE_CHECK([whether the C compiler supports __func__],
1440   tor_cv_have_func_macro,
1441   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1442 #include <stdio.h>
1443 int main(int c, char **v) { puts(__func__); }])],
1444   tor_cv_have_func_macro=yes,
1445   tor_cv_have_func_macro=no))
1447 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
1448   tor_cv_have_FUNC_macro,
1449   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1450 #include <stdio.h>
1451 int main(int c, char **v) { puts(__FUNC__); }])],
1452   tor_cv_have_FUNC_macro=yes,
1453   tor_cv_have_FUNC_macro=no))
1455 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
1456   tor_cv_have_FUNCTION_macro,
1457   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1458 #include <stdio.h>
1459 int main(int c, char **v) { puts(__FUNCTION__); }])],
1460   tor_cv_have_FUNCTION_macro=yes,
1461   tor_cv_have_FUNCTION_macro=no))
1463 AC_CACHE_CHECK([whether we have extern char **environ already declared],
1464   tor_cv_have_environ_declared,
1465   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1466 /* We define _GNU_SOURCE here because it is also defined in compat.c.
1467  * Without it environ doesn't get declared. */
1468 #define _GNU_SOURCE
1469 #ifdef HAVE_UNISTD_H
1470 #include <unistd.h>
1471 #endif
1472 #include <stdlib.h>
1473 int main(int c, char **v) { char **t = environ; }])],
1474   tor_cv_have_environ_declared=yes,
1475   tor_cv_have_environ_declared=no))
1477 if test "$tor_cv_have_func_macro" = 'yes'; then
1478   AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
1481 if test "$tor_cv_have_FUNC_macro" = 'yes'; then
1482   AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
1485 if test "$tor_cv_have_FUNCTION_macro" = 'yes'; then
1486   AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
1487            [Defined if the compiler supports __FUNCTION__])
1490 if test "$tor_cv_have_environ_declared" = 'yes'; then
1491   AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
1492            [Defined if we have extern char **environ already declared])
1495 # $prefix stores the value of the --prefix command line option, or
1496 # NONE if the option wasn't set.  In the case that it wasn't set, make
1497 # it be the default, so that we can use it to expand directories now.
1498 if test "x$prefix" = "xNONE"; then
1499   prefix=$ac_default_prefix
1502 # and similarly for $exec_prefix
1503 if test "x$exec_prefix" = "xNONE"; then
1504   exec_prefix=$prefix
1507 if test "x$BUILDDIR" = "x"; then
1508   BUILDDIR=`pwd`
1510 AC_SUBST(BUILDDIR)
1511 AH_TEMPLATE([BUILDDIR],[tor's build directory])
1512 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
1514 if test "x$CONFDIR" = "x"; then
1515   CONFDIR=`eval echo $sysconfdir/tor`
1517 AC_SUBST(CONFDIR)
1518 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
1519 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
1521 BINDIR=`eval echo $bindir`
1522 AC_SUBST(BINDIR)
1523 LOCALSTATEDIR=`eval echo $localstatedir`
1524 AC_SUBST(LOCALSTATEDIR)
1526 if test "$bwin32" = true; then
1527   # Test if the linker supports the --nxcompat and --dynamicbase options
1528   # for Windows
1529   save_LDFLAGS="$LDFLAGS"
1530   LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
1531   AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
1532   AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
1533     [AC_MSG_RESULT([yes])]
1534     [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
1535     [AC_MSG_RESULT([no])]
1536   )
1537   LDFLAGS="$save_LDFLAGS"
1540 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
1541 # than autoconf's macros like.
1542 if test "$GCC" = yes; then
1543   # Disable GCC's strict aliasing checks.  They are an hours-to-debug
1544   # accident waiting to happen.
1545   CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
1546 else
1547   # Override optimization level for non-gcc compilers
1548   CFLAGS="$CFLAGS -O"
1549   enable_gcc_warnings=no
1550   enable_gcc_warnings_advisory=no
1553 # OS X Lion started deprecating the system openssl. Let's just disable
1554 # all deprecation warnings on OS X. Also, to potentially make the binary
1555 # a little smaller, let's enable dead_strip.
1556 case "$host_os" in
1558  darwin*)
1559     CFLAGS="$CFLAGS -Wno-deprecated-declarations"
1560     LDFLAGS="$LDFLAGS -dead_strip" ;;
1561 esac
1563 # Add some more warnings which we use in development but not in the
1564 # released versions.  (Some relevant gcc versions can't handle these.)
1565 if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xyes; then
1567   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1568 #if !defined(__GNUC__) || (__GNUC__ < 4)
1569 #error
1570 #endif])], have_gcc4=yes, have_gcc4=no)
1572   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1573 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
1574 #error
1575 #endif])], have_gcc42=yes, have_gcc42=no)
1577   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1578 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
1579 #error
1580 #endif])], have_gcc43=yes, have_gcc43=no)
1582   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1583 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
1584 #error
1585 #endif])], have_gcc46=yes, have_gcc46=no)
1588   save_CFLAGS="$CFLAGS"
1589   CFLAGS="$CFLAGS -Wshorten-64-to-32"
1590   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
1591                     have_shorten64_flag=no)
1592   CFLAGS="$save_CFLAGS"
1594   case $host in
1595     *-*-openbsd* | *-*-bitrig*)
1596       # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
1597       # That's fine, except that the headers don't pass -Wredundant-decls.
1598       # Therefore, let's disable -Wsystem-headers when we're building
1599       # with maximal warnings on OpenBSD.
1600       CFLAGS="$CFLAGS -Wno-system-headers" ;;
1601   esac
1603   CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
1604   CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
1605   CFLAGS="$CFLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
1606   CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
1607   CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
1609   if test x$enable_gcc_warnings = xyes; then
1610     CFLAGS="$CFLAGS -Werror"
1611   fi
1613   # Disabled, so we can use mallinfo(): -Waggregate-return
1615   if test x$have_gcc4 = xyes ; then
1616     # These warnings break gcc 3.3.5 and work on gcc 4.0.2
1617     CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wold-style-definition"
1618   fi
1620   if test x$have_gcc42 = xyes ; then
1621     # These warnings break gcc 4.0.2 and work on gcc 4.2
1622     # XXXX020 See if any of these work with earlier versions.
1623     CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wstrict-overflow=1"
1625     # We used to use -Wstrict-overflow=5, but that breaks us heavily under 4.3.
1626   fi
1628   if test x$have_gcc42 = xyes && test x$have_clang = xno; then
1629     # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2
1630     CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init"
1631   fi
1633   if test x$have_gcc43 = xyes ; then
1634     # These warnings break gcc 4.2 and work on gcc 4.3
1635     # XXXX020 See if any of these work with earlier versions.
1636     CFLAGS="$CFLAGS -Wextra -Warray-bounds"
1637   fi
1639   if test x$have_gcc46 = xyes ; then
1640     # This warning was added in gcc 4.3, but it appears to generate
1641     # spurious warnings in gcc 4.4.  I don't know if it works in 4.5.
1642     CFLAGS="$CFLAGS -Wlogical-op"
1643   fi
1645   if test x$have_shorten64_flag = xyes ; then
1646     CFLAGS="$CFLAGS -Wshorten-64-to-32"
1647   fi
1651 ##This will break the world on some 64-bit architectures
1652 # CFLAGS="$CFLAGS -Winline"
1655 if test "$enable_coverage" = yes && test "$have_clang" = "no"; then
1656    case "$host_os" in
1657     darwin*)
1658       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.])
1659    esac
1662 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
1664 AC_CONFIG_FILES([
1665         Doxyfile
1666         Makefile
1667         contrib/dist/suse/tor.sh
1668         contrib/operator-tools/tor.logrotate
1669         contrib/dist/tor.sh
1670         contrib/dist/torctl
1671         contrib/dist/tor.service
1672         src/config/torrc.sample
1673         src/config/torrc.minimal
1674         scripts/maint/checkOptionDocs.pl
1675         scripts/maint/updateVersions.pl
1676         src/test/test_zero_length_keys.sh
1677         src/test/test_ntor.sh
1678         src/test/test_bt.sh
1681 if test x$asciidoc = xtrue && test "$ASCIIDOC" = "none" ; then
1682   regular_mans="doc/tor doc/tor-gencert doc/tor-resolve doc/torify"
1683   for file in $regular_mans ; do
1684     if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
1685       echo "==================================";
1686       echo;
1687       echo "Building Tor has failed since manpages cannot be built.";
1688       echo;
1689       echo "You need asciidoc installed to be able to build the manpages.";
1690       echo "To build without manpages, use the --disable-asciidoc argument";
1691       echo "when calling configure.";
1692       echo;
1693       echo "==================================";
1694       exit 1;
1695     fi
1696   done
1699 AC_OUTPUT