Remove changes files for patches in 0.2.6.6 or earlier.
[tor.git] / configure.ac
blob610a431129c126e8b070e117575ac706a113899d
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.0-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(SYSTEMD209, [systemd >= 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 AC_PATH_PROG([SHA1SUM], [sha1sum], none)
287 AC_PATH_PROG([OPENSSL], [openssl], none)
289 TORUSER=_tor
290 AC_ARG_WITH(tor-user,
291         AS_HELP_STRING(--with-tor-user=NAME, [specify username for tor daemon]),
292         [
293            TORUSER=$withval
294         ]
296 AC_SUBST(TORUSER)
298 TORGROUP=_tor
299 AC_ARG_WITH(tor-group,
300         AS_HELP_STRING(--with-tor-group=NAME, [specify group name for tor daemon]),
301         [
302            TORGROUP=$withval
303         ]
305 AC_SUBST(TORGROUP)
308 dnl If _WIN32 is defined and non-zero, we are building for win32
309 AC_MSG_CHECKING([for win32])
310 AC_RUN_IFELSE([AC_LANG_SOURCE([
311 int main(int c, char **v) {
312 #ifdef _WIN32
313 #if _WIN32
314   return 0;
315 #else
316   return 1;
317 #endif
318 #else
319   return 2;
320 #endif
321 }])],
322 bwin32=true; AC_MSG_RESULT([yes]),
323 bwin32=false; AC_MSG_RESULT([no]),
324 bwin32=cross; AC_MSG_RESULT([cross])
327 if test "$bwin32" = cross; then
328 AC_MSG_CHECKING([for win32 (cross)])
329 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
330 #ifdef _WIN32
331 int main(int c, char **v) {return 0;}
332 #else
333 #error
334 int main(int c, char **v) {return x(y);}
335 #endif
336 ])],
337 bwin32=true; AC_MSG_RESULT([yes]),
338 bwin32=false; AC_MSG_RESULT([no]))
341 AM_CONDITIONAL(BUILD_NT_SERVICES, test x$bwin32 = xtrue)
343 dnl Enable C99 when compiling with MIPSpro
344 AC_MSG_CHECKING([for MIPSpro compiler])
345 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
346 #if (defined(__sgi) && defined(_COMPILER_VERSION))
347 #error
348   return x(y);
349 #endif
350 ])],
351 bmipspro=false; AC_MSG_RESULT(no),
352 bmipspro=true; AC_MSG_RESULT(yes))
354 if test "$bmipspro" = true; then
355   CFLAGS="$CFLAGS -c99"
358 AC_C_BIGENDIAN
360 AC_SEARCH_LIBS(socket, [socket network])
361 AC_SEARCH_LIBS(gethostbyname, [nsl])
362 AC_SEARCH_LIBS(dlopen, [dl])
363 AC_SEARCH_LIBS(inet_aton, [resolv])
364 saved_LIBS="$LIBS"
365 AC_SEARCH_LIBS([clock_gettime], [rt])
366 if test "$LIBS" != "$saved_LIBS"; then
367    # Looks like we need -lrt for clock_gettime().
368    have_rt=yes
371 AC_SEARCH_LIBS(pthread_create, [pthread])
372 AC_SEARCH_LIBS(pthread_detach, [pthread])
374 AM_CONDITIONAL(THREADS_WIN32, test "$bwin32" = "true")
375 AM_CONDITIONAL(THREADS_PTHREADS, test "$bwin32" = "false")
377 dnl -------------------------------------------------------------------
378 dnl Check for functions before libevent, since libevent-1.2 apparently
379 dnl exports strlcpy without defining it in a header.
381 AC_CHECK_FUNCS(
382         _NSGetEnviron \
383         accept4 \
384         backtrace \
385         backtrace_symbols_fd \
386         clock_gettime \
387         eventfd \
388         flock \
389         ftime \
390         getaddrinfo \
391         getifaddrs \
392         getrlimit \
393         gettimeofday \
394         gmtime_r \
395         inet_aton \
396         ioctl \
397         issetugid \
398         llround \
399         localtime_r \
400         lround \
401         memmem \
402         pipe \
403         pipe2 \
404         prctl \
405         rint \
406         sigaction \
407         socketpair \
408         strlcat \
409         strlcpy \
410         strnlen \
411         strptime \
412         strtok_r \
413         strtoull \
414         sysconf \
415         sysctl \
416         uname \
417         usleep \
418         vasprintf \
419         _vscprintf
422 if test "$bwin32" != true; then
423   AC_CHECK_HEADERS(pthread.h)
424   AC_CHECK_FUNCS(pthread_create)
427 dnl ------------------------------------------------------
428 dnl Where do you live, libevent?  And how do we call you?
430 if test "$bwin32" = true; then
431   TOR_LIB_WS32=-lws2_32
432   TOR_LIB_IPHLPAPI=-liphlpapi
433   # Some of the cargo-cults recommend -lwsock32 as well, but I don't
434   # think it's actually necessary.
435   TOR_LIB_GDI=-lgdi32
436 else
437   TOR_LIB_WS32=
438   TOR_LIB_GDI=
440 AC_SUBST(TOR_LIB_WS32)
441 AC_SUBST(TOR_LIB_GDI)
442 AC_SUBST(TOR_LIB_IPHLPAPI)
444 dnl We need to do this before we try our disgusting hack below.
445 AC_CHECK_HEADERS([sys/types.h])
447 dnl This is a disgusting hack so we safely include older libevent headers.
448 AC_CHECK_TYPE(u_int64_t, unsigned long long)
449 AC_CHECK_TYPE(u_int32_t, unsigned long)
450 AC_CHECK_TYPE(u_int16_t, unsigned short)
451 AC_CHECK_TYPE(u_int8_t, unsigned char)
453 tor_libevent_pkg_redhat="libevent"
454 tor_libevent_pkg_debian="libevent-dev"
455 tor_libevent_devpkg_redhat="libevent-devel"
456 tor_libevent_devpkg_debian="libevent-dev"
458 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
459 dnl linking for static builds.
460 STATIC_LIBEVENT_FLAGS=""
461 if test "$enable_static_libevent" = "yes"; then
462     if test "$have_rt" = yes; then
463       STATIC_LIBEVENT_FLAGS=" -lrt "
464     fi
467 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
468 #ifdef _WIN32
469 #include <winsock2.h>
470 #endif
471 #include <stdlib.h>
472 #include <sys/time.h>
473 #include <sys/types.h>
474 #include <event.h>], [
475 #ifdef _WIN32
476 #include <winsock2.h>
477 #endif
478 void exit(int); void *event_init(void);],
479     [
480 #ifdef _WIN32
481 {WSADATA d; WSAStartup(0x101,&d); }
482 #endif
483 event_init(); exit(0);
484 ], [--with-libevent-dir], [/opt/libevent])
486 dnl Now check for particular libevent functions.
487 save_LIBS="$LIBS"
488 save_LDFLAGS="$LDFLAGS"
489 save_CPPFLAGS="$CPPFLAGS"
490 LIBS="-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $LIBS"
491 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
492 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
493 AC_CHECK_FUNCS([event_get_version \
494                 event_get_version_number \
495                 event_get_method \
496                 event_set_log_callback \
497                 evutil_secure_rng_set_urandom_device_file \
498                 evutil_secure_rng_init \
499                 event_base_loopexit])
500 AC_CHECK_MEMBERS([struct event.min_heap_idx], , ,
501 [#include <event.h>
504 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
506 LIBS="$save_LIBS"
507 LDFLAGS="$save_LDFLAGS"
508 CPPFLAGS="$save_CPPFLAGS"
511 AM_CONDITIONAL(USE_EXTERNAL_EVDNS, test x$ac_cv_header_event2_dns_h = xyes)
513 if test "$enable_static_libevent" = "yes"; then
514    if test "$tor_cv_library_libevent_dir" = "(system)"; then
515      AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
516    else
517      TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
518    fi
519 else
520      TOR_LIBEVENT_LIBS="-levent"
523 dnl This isn't the best test for Libevent 2.0.3-alpha.  Once it's released,
524 dnl we can do much better.
525 if test "$enable_bufferevents" = "yes" ; then
526   if test "$ac_cv_header_event2_bufferevent_ssl_h" != "yes" ; then
527     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.])
528   else
530     CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
532     # Check for the right version.  First see if version detection works.
533     AC_MSG_CHECKING([whether we can detect the Libevent version])
534     AC_COMPILE_IFELSE([AC_LANG_SOURCE([
535 #include <event2/event.h>
536 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 10
537 #error
538 int x = y(zz);
539 #else
540 int x = 1;
541 #endif
542   ])], [event_version_number_works=yes; AC_MSG_RESULT([yes]) ],
543      [event_version_number_works=no;  AC_MSG_RESULT([no])])
544     if test "$event_version_number_works" != 'yes'; then
545       AC_MSG_WARN([Version detection on Libevent seems broken.  Your Libevent installation is probably screwed up or very old.])
546     else
547       AC_MSG_CHECKING([whether Libevent is new enough for bufferevents])
548       AC_COMPILE_IFELSE([AC_LANG_SOURCE([
549 #include <event2/event.h>
550 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000d00
551 #error
552 int x = y(zz);
553 #else
554 int x = 1;
555 #endif
556    ])], [ AC_MSG_RESULT([yes]) ],
557       [ AC_MSG_RESULT([no])
558         AC_MSG_ERROR([Libevent does not seem new enough to support bufferevents.  We require 2.0.13-stable or later]) ] )
559     fi
560   fi
563 LIBS="$save_LIBS"
564 LDFLAGS="$save_LDFLAGS"
565 CPPFLAGS="$save_CPPFLAGS"
567 AM_CONDITIONAL(USE_BUFFEREVENTS, test "$enable_bufferevents" = "yes")
568 if test "$enable_bufferevents" = "yes"; then
569   AC_DEFINE(USE_BUFFEREVENTS, 1, [Defined if we're going to use Libevent's buffered IO API])
570   if test "$enable_static_libevent" = "yes"; then
571     TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent_openssl.a $TOR_LIBEVENT_LIBS"
572   else
573     TOR_LIBEVENT_LIBS="-levent_openssl $TOR_LIBEVENT_LIBS"
574   fi
576 AC_SUBST(TOR_LIBEVENT_LIBS)
578 dnl ------------------------------------------------------
579 dnl Where do you live, libm?
581 dnl On some platforms (Haiku/BeOS) the math library is
582 dnl part of libroot. In which case don't link against lm
583 TOR_LIB_MATH=""
584 save_LIBS="$LIBS"
585 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
586 if test "$ac_cv_search_pow" != "none required"; then
587     TOR_LIB_MATH="$ac_cv_search_pow"
589 LIBS="$save_LIBS"
590 AC_SUBST(TOR_LIB_MATH)
592 dnl ------------------------------------------------------
593 dnl Where do you live, openssl?  And how do we call you?
595 tor_openssl_pkg_redhat="openssl"
596 tor_openssl_pkg_debian="libssl-dev"
597 tor_openssl_devpkg_redhat="openssl-devel"
598 tor_openssl_devpkg_debian="libssl-dev"
600 ALT_openssl_WITHVAL=""
601 AC_ARG_WITH(ssl-dir,
602   AS_HELP_STRING(--with-ssl-dir=PATH, [obsolete alias for --with-openssl-dir]),
603   [
604       if test "x$withval" != xno && test "x$withval" != "x" ; then
605          ALT_openssl_WITHVAL="$withval"
606       fi
607   ])
609 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI],
610     [#include <openssl/rand.h>],
611     [void RAND_add(const void *buf, int num, double entropy);],
612     [RAND_add((void*)0,0,0); exit(0);], [],
613     [/usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /opt/openssl])
615 dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
617 if test "$enable_static_openssl" = "yes"; then
618    if test "$tor_cv_library_openssl_dir" = "(system)"; then
619      AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
620    else
621      TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
622    fi
623 else
624      TOR_OPENSSL_LIBS="-lssl -lcrypto"
626 AC_SUBST(TOR_OPENSSL_LIBS)
628 AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , ,
629 [#include <openssl/ssl.h>
632 dnl ------------------------------------------------------
633 dnl Where do you live, zlib?  And how do we call you?
635 tor_zlib_pkg_redhat="zlib"
636 tor_zlib_pkg_debian="zlib1g"
637 tor_zlib_devpkg_redhat="zlib-devel"
638 tor_zlib_devpkg_debian="zlib1g-dev"
640 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
641     [#include <zlib.h>],
642     [const char * zlibVersion(void);],
643     [zlibVersion(); exit(0);], [--with-zlib-dir],
644     [/opt/zlib])
646 if test "$enable_static_zlib" = "yes"; then
647    if test "$tor_cv_library_zlib_dir" = "(system)"; then
648      AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
649  using --enable-static-zlib")
650    else
651      TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
652    fi
653 else
654      TOR_ZLIB_LIBS="-lz"
656 AC_SUBST(TOR_ZLIB_LIBS)
658 dnl ---------------------------------------------------------------------
659 dnl Now that we know about our major libraries, we can check for compiler
660 dnl and linker hardening options.  We need to do this with the libraries known,
661 dnl since sometimes the linker will like an option but not be willing to
662 dnl use it with a build of a library.
664 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
665 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"
667 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
668 #if !defined(__clang__)
669 #error
670 #endif])], have_clang=yes, have_clang=no)
672 if test x$enable_gcc_hardening != xno; then
673     CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
674     if test x$have_clang = xyes; then
675         TOR_CHECK_CFLAGS(-Qunused-arguments)
676     fi
677     TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
678     AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
679     AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
680 m4_ifdef([AS_VAR_IF],[
681     AS_VAR_IF(can_compile, [yes],
682         AS_VAR_IF(can_link, [yes],
683                   [],
684                   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.)]))
685         )])
686     AS_VAR_POPDEF([can_link])
687     AS_VAR_POPDEF([can_compile])
688     TOR_CHECK_CFLAGS(-Wstack-protector)
689     TOR_CHECK_CFLAGS(-fwrapv)
690     TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
691     if test "$bwin32" = "false"; then
692        TOR_CHECK_CFLAGS(-fPIE)
693        TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
694     fi
697 if test x$enable_expensive_hardening = xyes ; then
698    TOR_CHECK_CFLAGS([-fsanitize=address])
699    TOR_CHECK_CFLAGS([-fsanitize=undefined])
700    TOR_CHECK_CFLAGS([-fno-omit-frame-pointer])
703 if test x$enable_linker_hardening != xno; then
704     TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
707 # For backtrace support
708 TOR_CHECK_LDFLAGS(-rdynamic)
710 dnl ------------------------------------------------------
711 dnl Now see if we have a -fomit-frame-pointer compiler option.
713 saved_CFLAGS="$CFLAGS"
714 TOR_CHECK_CFLAGS(-fomit-frame-pointer)
715 F_OMIT_FRAME_POINTER=''
716 if test "$saved_CFLAGS" != "$CFLAGS"; then
717   if test x$enable_expensive_hardening != xyes ; then
718     F_OMIT_FRAME_POINTER='-fomit-frame-pointer'
719   fi
721 CFLAGS="$saved_CFLAGS"
722 AC_SUBST(F_OMIT_FRAME_POINTER)
724 dnl ------------------------------------------------------
725 dnl If we are adding -fomit-frame-pointer (or if the compiler's doing it
726 dnl for us, as GCC 4.6 and later do at many optimization levels), then
727 dnl we should try to add -fasynchronous-unwind-tables so that our backtrace
728 dnl code will work.
729 TOR_CHECK_CFLAGS(-fasynchronous-unwind-tables)
731 dnl ------------------------------------------------------
732 dnl Where do you live, libnatpmp?  And how do we call you?
733 dnl There are no packages for Debian or Redhat as of this patch
735 if test "$natpmp" = "true"; then
736     AC_DEFINE(NAT_PMP, 1, [Define to 1 if we are building with nat-pmp.])
737     TOR_SEARCH_LIBRARY(libnatpmp, $trylibnatpmpdir, [-lnatpmp $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
738         [#include <natpmp.h>],
739         [#ifdef _WIN32
740          #define STATICLIB
741          #endif
742          #include <natpmp.h>],
743         [   int r;
744             natpmp_t natpmp;
745             natpmpresp_t response;
746             r = initnatpmp(&natpmp, 0, 0);],
747             [printf("initnatpmp() returned %d (%s)\n", r, r?"FAILED":"SUCCESS");
748             exit(0);],
749         [--with-libnatpmp-dir],
750         [/usr/lib/])
754 dnl ------------------------------------------------------
755 dnl Where do you live, libminiupnpc?  And how do we call you?
756 dnl There are no packages for Debian or Redhat as of this patch
758 if test "$upnp" = "true"; then
759     AC_DEFINE(MINIUPNPC, 1, [Define to 1 if we are building with UPnP.])
761     dnl Before we call TOR_SEARCH_LIBRARY we'll do a quick compile test
762     dnl to see if we have miniupnpc-1.5 or -1.6
763     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <miniupnpc/miniupnpc.h>],
764         [upnpDiscover(1, 0, 0, 0);exit(0);])],[miniupnpc15="true"],[miniupnpc15="false"])
766     if test "$miniupnpc15" = "true" ; then
767         AC_DEFINE([MINIUPNPC15],[1],[libminiupnpc version 1.5 found])
768         TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
769             [#include <miniupnpc/miniwget.h>
770              #include <miniupnpc/miniupnpc.h>
771              #include <miniupnpc/upnpcommands.h>],
772             [void upnpDiscover(int delay, const char * multicastif,
773              const char * minissdpdsock, int sameport);],
774             [upnpDiscover(1, 0, 0, 0); exit(0);],
775             [--with-libminiupnpc-dir],
776             [/usr/lib/])
777     else
778         TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
779             [#include <miniupnpc/miniwget.h>
780              #include <miniupnpc/miniupnpc.h>
781              #include <miniupnpc/upnpcommands.h>],
782             [void upnpDiscover(int delay, const char * multicastif,
783              const char * minissdpdsock, int sameport, int ipv6, int * error);],
784             [upnpDiscover(1, 0, 0, 0, 0, 0); exit(0);],
785             [--with-libminiupnpc-dir],
786             [/usr/lib/])
787     fi
790 dnl ============================================================
791 dnl Check for libseccomp
793 if test "x$enable_seccomp" != "xno"; then
794   AC_CHECK_HEADERS([seccomp.h])
795   AC_SEARCH_LIBS(seccomp_init, [seccomp])
798 dnl ============================================================
799 dnl Check for libscrypt
801 if test "x$enable_libscrypt" != "xno"; then
802   AC_CHECK_HEADERS([libscrypt.h])
803   AC_SEARCH_LIBS(libscrypt_scrypt, [scrypt])
806 dnl ============================================================
807 dnl We need an implementation of curve25519.
809 dnl set these defaults.
810 build_curve25519_donna=no
811 build_curve25519_donna_c64=no
812 use_curve25519_donna=no
813 use_curve25519_nacl=no
814 CURVE25519_LIBS=
816 dnl The best choice is using curve25519-donna-c64, but that requires
817 dnl that we
818 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
819   tor_cv_can_use_curve25519_donna_c64,
820   [AC_RUN_IFELSE(
821     [AC_LANG_PROGRAM([dnl
822       #include <stdint.h>
823       typedef unsigned uint128_t __attribute__((mode(TI)));
824   int func(uint64_t a, uint64_t b) {
825            uint128_t c = ((uint128_t)a) * b;
826            int ok = ((uint64_t)(c>>96)) == 522859 &&
827              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
828                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
829                  (((uint64_t)(c))&0xffffffffL) == 0;
830            return ok;
831       }
832   ], [dnl
833     int ok = func( ((uint64_t)2000000000) * 1000000000,
834                    ((uint64_t)1234567890) << 24);
835         return !ok;
836       ])],
837   [tor_cv_can_use_curve25519_donna_c64=yes],
838       [tor_cv_can_use_curve25519_donna_c64=no],
839   [AC_LINK_IFELSE(
840         [AC_LANG_PROGRAM([dnl
841       #include <stdint.h>
842       typedef unsigned uint128_t __attribute__((mode(TI)));
843   int func(uint64_t a, uint64_t b) {
844            uint128_t c = ((uint128_t)a) * b;
845            int ok = ((uint64_t)(c>>96)) == 522859 &&
846              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
847                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
848                  (((uint64_t)(c))&0xffffffffL) == 0;
849            return ok;
850       }
851   ], [dnl
852     int ok = func( ((uint64_t)2000000000) * 1000000000,
853                  ((uint64_t)1234567890) << 24);
854         return !ok;
855       ])],
856           [tor_cv_can_use_curve25519_donna_c64=cross],
857       [tor_cv_can_use_curve25519_donna_c64=no])])])
859 AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
860                   nacl/crypto_scalarmult_curve25519.h])
862 AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
863   tor_cv_can_use_curve25519_nacl,
864   [tor_saved_LIBS="$LIBS"
865    LIBS="$LIBS -lnacl"
866    AC_LINK_IFELSE(
867      [AC_LANG_PROGRAM([dnl
868        #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
869        #include <crypto_scalarmult_curve25519.h>
870    #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
871    #include <nacl/crypto_scalarmult_curve25519.h>
872    #endif
873        #ifdef crypto_scalarmult_curve25519_ref_BYTES
874    #error Hey, this is the reference implementation! That's not fast.
875    #endif
876      ], [
877    unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
878      ])], [tor_cv_can_use_curve25519_nacl=yes],
879      [tor_cv_can_use_curve25519_nacl=no])
880    LIBS="$tor_saved_LIBS" ])
882  dnl Okay, now we need to figure out which one to actually use. Fall back
883  dnl to curve25519-donna.c
885  if test x$tor_cv_can_use_curve25519_donna_c64 != xno; then
886    build_curve25519_donna_c64=yes
887    use_curve25519_donna=yes
888  elif test x$tor_cv_can_use_curve25519_nacl = xyes; then
889    use_curve25519_nacl=yes
890    CURVE25519_LIBS=-lnacl
891  else
892    build_curve25519_donna=yes
893    use_curve25519_donna=yes
894  fi
896 if test x$use_curve25519_donna = xyes; then
897   AC_DEFINE(USE_CURVE25519_DONNA, 1,
898             [Defined if we should use an internal curve25519_donna{,_c64} implementation])
900 if test x$use_curve25519_nacl = xyes; then
901   AC_DEFINE(USE_CURVE25519_NACL, 1,
902             [Defined if we should use a curve25519 from nacl])
904 AM_CONDITIONAL(BUILD_CURVE25519_DONNA, test x$build_curve25519_donna = xyes)
905 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64, test x$build_curve25519_donna_c64 = xyes)
906 AC_SUBST(CURVE25519_LIBS)
908 dnl Make sure to enable support for large off_t if available.
909 AC_SYS_LARGEFILE
911 AC_CHECK_HEADERS(
912         assert.h \
913         errno.h \
914         fcntl.h \
915         signal.h \
916         string.h \
917         sys/fcntl.h \
918         sys/stat.h \
919         sys/time.h \
920         sys/types.h \
921         time.h \
922         unistd.h
923  , , 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.))
925 dnl These headers are not essential
927 AC_CHECK_HEADERS(
928         arpa/inet.h \
929         crt_externs.h \
930         execinfo.h \
931         grp.h \
932         ifaddrs.h \
933         inttypes.h \
934         limits.h \
935         linux/types.h \
936         machine/limits.h \
937         malloc.h \
938         malloc/malloc.h \
939         malloc_np.h \
940         netdb.h \
941         netinet/in.h \
942         netinet/in6.h \
943         pwd.h \
944         stdint.h \
945         sys/eventfd.h \
946         sys/file.h \
947         sys/ioctl.h \
948         sys/limits.h \
949         sys/mman.h \
950         sys/param.h \
951         sys/prctl.h \
952         sys/resource.h \
953         sys/select.h \
954         sys/socket.h \
955         sys/sysctl.h \
956         sys/syslimits.h \
957         sys/time.h \
958         sys/types.h \
959         sys/un.h \
960         sys/utime.h \
961         sys/wait.h \
962         syslog.h \
963         utime.h
966 AC_CHECK_HEADERS(sys/param.h)
968 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
969 [#ifdef HAVE_SYS_TYPES_H
970 #include <sys/types.h>
971 #endif
972 #ifdef HAVE_SYS_SOCKET_H
973 #include <sys/socket.h>
974 #endif])
975 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
976 [#ifdef HAVE_SYS_TYPES_H
977 #include <sys/types.h>
978 #endif
979 #ifdef HAVE_SYS_SOCKET_H
980 #include <sys/socket.h>
981 #endif
982 #ifdef HAVE_NET_IF_H
983 #include <net/if.h>
984 #endif])
986 AC_CHECK_HEADERS(linux/if.h,[],[],
988 #ifdef HAVE_SYS_SOCKET_H
989 #include <sys/socket.h>
990 #endif
993 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
994         linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
995 [#ifdef HAVE_SYS_TYPES_H
996 #include <sys/types.h>
997 #endif
998 #ifdef HAVE_SYS_SOCKET_H
999 #include <sys/socket.h>
1000 #endif
1001 #ifdef HAVE_LIMITS_H
1002 #include <limits.h>
1003 #endif
1004 #ifdef HAVE_LINUX_TYPES_H
1005 #include <linux/types.h>
1006 #endif
1007 #ifdef HAVE_NETINET_IN6_H
1008 #include <netinet/in6.h>
1009 #endif
1010 #ifdef HAVE_NETINET_IN_H
1011 #include <netinet/in.h>
1012 #endif])
1014 AC_CHECK_HEADERS(linux/netfilter_ipv6/ip6_tables.h,
1015         linux_netfilter_ipv6_ip6_tables=1, linux_netfilter_ipv6_ip6_tables=0,
1016 [#ifdef HAVE_SYS_TYPES_H
1017 #include <sys/types.h>
1018 #endif
1019 #ifdef HAVE_SYS_SOCKET_H
1020 #include <sys/socket.h>
1021 #endif
1022 #ifdef HAVE_LIMITS_H
1023 #include <limits.h>
1024 #endif
1025 #ifdef HAVE_LINUX_TYPES_H
1026 #include <linux/types.h>
1027 #endif
1028 #ifdef HAVE_NETINET_IN6_H
1029 #include <netinet/in6.h>
1030 #endif
1031 #ifdef HAVE_NETINET_IN_H
1032 #include <netinet/in.h>
1033 #endif
1034 #ifdef HAVE_LINUX_IF_H
1035 #include <linux/if.h>
1036 #endif])
1038 if test x$transparent = xtrue ; then
1039    transparent_ok=0
1040    if test x$net_if_found = x1 && test x$net_pfvar_found = x1 ; then
1041      transparent_ok=1
1042    fi
1043    if test x$linux_netfilter_ipv4 = x1 ; then
1044      transparent_ok=1
1045    fi
1046    if test x$linux_netfilter_ipv6_ip6_tables = x1 ; then
1047      transparent_ok=1
1048    fi
1049    if test x$transparent_ok = x1 ; then
1050      AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
1051      case $host in
1052        *-*-openbsd* | *-*-bitrig*)
1053          AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
1054      esac
1055    else
1056      AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
1057    fi
1060 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
1061 [#ifdef HAVE_SYS_TYPES_H
1062 #include <sys/types.h>
1063 #endif
1064 #ifdef HAVE_SYS_TIME_H
1065 #include <sys/time.h>
1066 #endif])
1068 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
1069 dnl Watch out.
1071 AC_CHECK_SIZEOF(int8_t)
1072 AC_CHECK_SIZEOF(int16_t)
1073 AC_CHECK_SIZEOF(int32_t)
1074 AC_CHECK_SIZEOF(int64_t)
1075 AC_CHECK_SIZEOF(uint8_t)
1076 AC_CHECK_SIZEOF(uint16_t)
1077 AC_CHECK_SIZEOF(uint32_t)
1078 AC_CHECK_SIZEOF(uint64_t)
1079 AC_CHECK_SIZEOF(intptr_t)
1080 AC_CHECK_SIZEOF(uintptr_t)
1082 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
1084 AC_CHECK_SIZEOF(char)
1085 AC_CHECK_SIZEOF(short)
1086 AC_CHECK_SIZEOF(int)
1087 AC_CHECK_SIZEOF(long)
1088 AC_CHECK_SIZEOF(long long)
1089 AC_CHECK_SIZEOF(__int64)
1090 AC_CHECK_SIZEOF(void *)
1091 AC_CHECK_SIZEOF(time_t)
1092 AC_CHECK_SIZEOF(size_t)
1093 AC_CHECK_SIZEOF(pid_t)
1095 AC_CHECK_TYPES([uint, u_char, ssize_t])
1097 AC_PC_FROM_UCONTEXT([/bin/true])
1099 dnl used to include sockaddr_storage, but everybody has that.
1100 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
1101 [#ifdef HAVE_SYS_TYPES_H
1102 #include <sys/types.h>
1103 #endif
1104 #ifdef HAVE_NETINET_IN_H
1105 #include <netinet/in.h>
1106 #endif
1107 #ifdef HAVE_NETINET_IN6_H
1108 #include <netinet/in6.h>
1109 #endif
1110 #ifdef HAVE_SYS_SOCKET_H
1111 #include <sys/socket.h>
1112 #endif
1113 #ifdef _WIN32
1114 #define _WIN32_WINNT 0x0501
1115 #define WIN32_LEAN_AND_MEAN
1116 #if defined(_MSC_VER) && (_MSC_VER < 1300)
1117 #include <winsock.h>
1118 #else
1119 #include <winsock2.h>
1120 #include <ws2tcpip.h>
1121 #endif
1122 #endif
1124 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
1125 [#ifdef HAVE_SYS_TYPES_H
1126 #include <sys/types.h>
1127 #endif
1128 #ifdef HAVE_NETINET_IN_H
1129 #include <netinet/in.h>
1130 #endif
1131 #ifdef HAVE_NETINET_IN6_H
1132 #include <netinet/in6.h>
1133 #endif
1134 #ifdef HAVE_SYS_SOCKET_H
1135 #include <sys/socket.h>
1136 #endif
1137 #ifdef _WIN32
1138 #define _WIN32_WINNT 0x0501
1139 #define WIN32_LEAN_AND_MEAN
1140 #if defined(_MSC_VER) && (_MSC_VER < 1300)
1141 #include <winsock.h>
1142 #else
1143 #include <winsock2.h>
1144 #include <ws2tcpip.h>
1145 #endif
1146 #endif
1149 AC_CHECK_TYPES([rlim_t], , ,
1150 [#ifdef HAVE_SYS_TYPES_H
1151 #include <sys/types.h>
1152 #endif
1153 #ifdef HAVE_SYS_TIME_H
1154 #include <sys/time.h>
1155 #endif
1156 #ifdef HAVE_SYS_RESOURCE_H
1157 #include <sys/resource.h>
1158 #endif
1161 AX_CHECK_SIGN([time_t],
1162        [ AC_DEFINE(TIME_T_IS_SIGNED, 1, [Define if time_t is signed]) ],
1163        [ : ], [
1164 #ifdef HAVE_SYS_TYPES_H
1165 #include <sys/types.h>
1166 #endif
1167 #ifdef HAVE_SYS_TIME_H
1168 #include <sys/time.h>
1169 #endif
1170 #ifdef HAVE_TIME_H
1171 #include <time.h>
1172 #endif
1175 if test "$ax_cv_decl_time_t_signed" = no; then
1176   AC_MSG_WARN([You have an unsigned time_t; some things will probably break. Please tell the Tor developers about your interesting platform.])
1179 AX_CHECK_SIGN([size_t],
1180        [ tor_cv_size_t_signed=yes ],
1181        [ tor_cv_size_t_signed=no ], [
1182 #ifdef HAVE_SYS_TYPES_H
1183 #include <sys/types.h>
1184 #endif
1187 if test "$ax_cv_decl_size_t_signed" = yes; then
1188   AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
1191 AX_CHECK_SIGN([enum always],
1192        [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
1193        [ : ], [
1194  enum always { AAA, BBB, CCC };
1197 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
1198 #ifdef HAVE_SYS_SOCKET_H
1199 #include <sys/socket.h>
1200 #endif
1203 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1205 AC_CHECK_SIZEOF(cell_t)
1207 # Now make sure that NULL can be represented as zero bytes.
1208 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1209 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1210 [[#include <stdlib.h>
1211 #include <string.h>
1212 #include <stdio.h>
1213 #ifdef HAVE_STDDEF_H
1214 #include <stddef.h>
1215 #endif
1216 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1217 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1218        [tor_cv_null_is_zero=yes],
1219        [tor_cv_null_is_zero=no],
1220        [tor_cv_null_is_zero=cross])])
1222 if test "$tor_cv_null_is_zero" = cross ; then
1223   # Cross-compiling; let's hope that the target isn't raving mad.
1224   AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
1227 if test "$tor_cv_null_is_zero" != no; then
1228   AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1229             [Define to 1 iff memset(0) sets pointers to NULL])
1232 AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
1233 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1234 [[#include <stdlib.h>
1235 #include <string.h>
1236 #include <stdio.h>
1237 #ifdef HAVE_STDDEF_H
1238 #include <stddef.h>
1239 #endif
1240 int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
1241 return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
1242        [tor_cv_dbl0_is_zero=yes],
1243        [tor_cv_dbl0_is_zero=no],
1244        [tor_cv_dbl0_is_zero=cross])])
1246 if test "$tor_cv_dbl0_is_zero" = cross ; then
1247   # Cross-compiling; let's hope that the target isn't raving mad.
1248   AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
1251 if test "$tor_cv_dbl0_is_zero" != no; then
1252   AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
1253             [Define to 1 iff memset(0) sets doubles to 0.0])
1256 # And what happens when we malloc zero?
1257 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
1258 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1259 [[#include <stdlib.h>
1260 #include <string.h>
1261 #include <stdio.h>
1262 #ifdef HAVE_STDDEF_H
1263 #include <stddef.h>
1264 #endif
1265 int main () { return malloc(0)?0:1; }]])],
1266        [tor_cv_malloc_zero_works=yes],
1267        [tor_cv_malloc_zero_works=no],
1268        [tor_cv_malloc_zero_works=cross])])
1270 if test "$tor_cv_malloc_zero_works" = cross; then
1271   # Cross-compiling; let's hope that the target isn't raving mad.
1272   AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
1275 if test "$tor_cv_malloc_zero_works" = yes; then
1276   AC_DEFINE([MALLOC_ZERO_WORKS], 1,
1277             [Define to 1 iff malloc(0) returns a pointer])
1280 # whether we seem to be in a 2s-complement world.
1281 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
1282 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1283 [[int main () { int problem = ((-99) != (~99)+1);
1284 return problem ? 1 : 0; }]])],
1285        [tor_cv_twos_complement=yes],
1286        [tor_cv_twos_complement=no],
1287        [tor_cv_twos_complement=cross])])
1289 if test "$tor_cv_twos_complement" = cross ; then
1290   # Cross-compiling; let's hope that the target isn't raving mad.
1291   AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
1294 if test "$tor_cv_twos_complement" != no ; then
1295   AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
1296             [Define to 1 iff we represent negative integers with two's complement])
1299 # What does shifting a negative value do?
1300 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
1301 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1302 [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
1303        [tor_cv_sign_extend=yes],
1304        [tor_cv_sign_extend=no],
1305        [tor_cv_sign_extend=cross])])
1307 if test "$tor_cv_sign_extend" = cross ; then
1308   # Cross-compiling; let's hope that the target isn't raving mad.
1309   AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
1312 if test "$tor_cv_sign_extend" != no ; then
1313   AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
1314             [Define to 1 iff right-shifting a negative value performs sign-extension])
1317 # Whether we should use the dmalloc memory allocation debugging library.
1318 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
1319 AC_ARG_WITH(dmalloc,
1320 AS_HELP_STRING(--with-dmalloc, [use debug memory allocation library]),
1321 [if [[ "$withval" = "yes" ]]; then
1322   dmalloc=1
1323   AC_MSG_RESULT(yes)
1324 else
1325   dmalloc=1
1326   AC_MSG_RESULT(no)
1327 fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
1330 if [[ $dmalloc -eq 1 ]]; then
1331   AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
1332   AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
1333   AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
1334   AC_CHECK_FUNCS(dmalloc_strdup dmalloc_strndup)
1337 AC_ARG_WITH(tcmalloc,
1338 AS_HELP_STRING(--with-tcmalloc, [use tcmalloc memory allocation library]),
1339 [ tcmalloc=yes ], [ tcmalloc=no ])
1341 if test x$tcmalloc = xyes ; then
1342    LDFLAGS="-ltcmalloc $LDFLAGS"
1345 using_custom_malloc=no
1346 if test x$enable_openbsd_malloc = xyes ; then
1347    using_custom_malloc=yes
1349 if test x$tcmalloc = xyes ; then
1350    using_custom_malloc=yes
1352 if test $using_custom_malloc = no ; then
1353    AC_CHECK_FUNCS(mallinfo)
1356 # By default, we're going to assume we don't have mlockall()
1357 # bionic and other platforms have various broken mlockall subsystems.
1358 # Some systems don't have a working mlockall, some aren't linkable,
1359 # and some have it but don't declare it.
1360 AC_CHECK_FUNCS(mlockall)
1361 AC_CHECK_DECLS([mlockall], , , [
1362 #ifdef HAVE_SYS_MMAN_H
1363 #include <sys/mman.h>
1364 #endif])
1366 # Allow user to specify an alternate syslog facility
1367 AC_ARG_WITH(syslog-facility,
1368 AS_HELP_STRING(--with-syslog-facility=LOG, [syslog facility to use (default=LOG_DAEMON)]),
1369 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
1370 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
1371 AC_SUBST(LOGFACILITY)
1373 # Check if we have getresuid and getresgid
1374 AC_CHECK_FUNCS(getresuid getresgid)
1376 # Check for gethostbyname_r in all its glorious incompatible versions.
1377 #   (This logic is based on that in Python's configure.in)
1378 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
1379   [Define this if you have any gethostbyname_r()])
1381 AC_CHECK_FUNC(gethostbyname_r, [
1382   AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
1383   OLD_CFLAGS=$CFLAGS
1384   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1385   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1386 #include <netdb.h>
1387   ], [[
1388     char *cp1, *cp2;
1389     struct hostent *h1, *h2;
1390     int i1, i2;
1391     (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
1392   ]])],[
1393     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1394     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
1395      [Define this if gethostbyname_r takes 6 arguments])
1396     AC_MSG_RESULT(6)
1397   ], [
1398     AC_TRY_COMPILE([
1399 #include <netdb.h>
1400     ], [
1401       char *cp1, *cp2;
1402       struct hostent *h1;
1403       int i1, i2;
1404       (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
1405     ], [
1406       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1407       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
1408         [Define this if gethostbyname_r takes 5 arguments])
1409       AC_MSG_RESULT(5)
1410    ], [
1411       AC_TRY_COMPILE([
1412 #include <netdb.h>
1413      ], [
1414        char *cp1;
1415        struct hostent *h1;
1416        struct hostent_data hd;
1417        (void) gethostbyname_r(cp1,h1,&hd);
1418      ], [
1419        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1420        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
1421          [Define this if gethostbyname_r takes 3 arguments])
1422        AC_MSG_RESULT(3)
1423      ], [
1424        AC_MSG_RESULT(0)
1425      ])
1426   ])
1427  ])
1428  CFLAGS=$OLD_CFLAGS
1431 AC_CACHE_CHECK([whether the C compiler supports __func__],
1432   tor_cv_have_func_macro,
1433   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1434 #include <stdio.h>
1435 int main(int c, char **v) { puts(__func__); }])],
1436   tor_cv_have_func_macro=yes,
1437   tor_cv_have_func_macro=no))
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 __FUNCTION__],
1448   tor_cv_have_FUNCTION_macro,
1449   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1450 #include <stdio.h>
1451 int main(int c, char **v) { puts(__FUNCTION__); }])],
1452   tor_cv_have_FUNCTION_macro=yes,
1453   tor_cv_have_FUNCTION_macro=no))
1455 AC_CACHE_CHECK([whether we have extern char **environ already declared],
1456   tor_cv_have_environ_declared,
1457   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1458 /* We define _GNU_SOURCE here because it is also defined in compat.c.
1459  * Without it environ doesn't get declared. */
1460 #define _GNU_SOURCE
1461 #ifdef HAVE_UNISTD_H
1462 #include <unistd.h>
1463 #endif
1464 #include <stdlib.h>
1465 int main(int c, char **v) { char **t = environ; }])],
1466   tor_cv_have_environ_declared=yes,
1467   tor_cv_have_environ_declared=no))
1469 if test "$tor_cv_have_func_macro" = 'yes'; then
1470   AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
1473 if test "$tor_cv_have_FUNC_macro" = 'yes'; then
1474   AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
1477 if test "$tor_cv_have_FUNCTION_macro" = 'yes'; then
1478   AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
1479            [Defined if the compiler supports __FUNCTION__])
1482 if test "$tor_cv_have_environ_declared" = 'yes'; then
1483   AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
1484            [Defined if we have extern char **environ already declared])
1487 # $prefix stores the value of the --prefix command line option, or
1488 # NONE if the option wasn't set.  In the case that it wasn't set, make
1489 # it be the default, so that we can use it to expand directories now.
1490 if test "x$prefix" = "xNONE"; then
1491   prefix=$ac_default_prefix
1494 # and similarly for $exec_prefix
1495 if test "x$exec_prefix" = "xNONE"; then
1496   exec_prefix=$prefix
1499 if test "x$BUILDDIR" = "x"; then
1500   BUILDDIR=`pwd`
1502 AC_SUBST(BUILDDIR)
1503 AH_TEMPLATE([BUILDDIR],[tor's build directory])
1504 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
1506 if test "x$CONFDIR" = "x"; then
1507   CONFDIR=`eval echo $sysconfdir/tor`
1509 AC_SUBST(CONFDIR)
1510 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
1511 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
1513 BINDIR=`eval echo $bindir`
1514 AC_SUBST(BINDIR)
1515 LOCALSTATEDIR=`eval echo $localstatedir`
1516 AC_SUBST(LOCALSTATEDIR)
1518 if test "$bwin32" = true; then
1519   # Test if the linker supports the --nxcompat and --dynamicbase options
1520   # for Windows
1521   save_LDFLAGS="$LDFLAGS"
1522   LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
1523   AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
1524   AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
1525     [AC_MSG_RESULT([yes])]
1526     [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
1527     [AC_MSG_RESULT([no])]
1528   )
1529   LDFLAGS="$save_LDFLAGS"
1532 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
1533 # than autoconf's macros like.
1534 if test "$GCC" = yes; then
1535   # Disable GCC's strict aliasing checks.  They are an hours-to-debug
1536   # accident waiting to happen.
1537   CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
1538 else
1539   # Override optimization level for non-gcc compilers
1540   CFLAGS="$CFLAGS -O"
1541   enable_gcc_warnings=no
1542   enable_gcc_warnings_advisory=no
1545 # OS X Lion started deprecating the system openssl. Let's just disable
1546 # all deprecation warnings on OS X. Also, to potentially make the binary
1547 # a little smaller, let's enable dead_strip.
1548 case "$host_os" in
1550  darwin*)
1551     CFLAGS="$CFLAGS -Wno-deprecated-declarations"
1552     LDFLAGS="$LDFLAGS -dead_strip" ;;
1553 esac
1555 # Add some more warnings which we use in development but not in the
1556 # released versions.  (Some relevant gcc versions can't handle these.)
1557 if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xyes; then
1559   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1560 #if !defined(__GNUC__) || (__GNUC__ < 4)
1561 #error
1562 #endif])], have_gcc4=yes, have_gcc4=no)
1564   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1565 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
1566 #error
1567 #endif])], have_gcc42=yes, have_gcc42=no)
1569   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1570 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
1571 #error
1572 #endif])], have_gcc43=yes, have_gcc43=no)
1574   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1575 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
1576 #error
1577 #endif])], have_gcc46=yes, have_gcc46=no)
1580   save_CFLAGS="$CFLAGS"
1581   CFLAGS="$CFLAGS -Wshorten-64-to-32"
1582   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
1583                     have_shorten64_flag=no)
1584   CFLAGS="$save_CFLAGS"
1586   case $host in
1587     *-*-openbsd* | *-*-bitrig*)
1588       # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
1589       # That's fine, except that the headers don't pass -Wredundant-decls.
1590       # Therefore, let's disable -Wsystem-headers when we're building
1591       # with maximal warnings on OpenBSD.
1592       CFLAGS="$CFLAGS -Wno-system-headers" ;;
1593   esac
1595   CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
1596   CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
1597   CFLAGS="$CFLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
1598   CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
1599   CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
1601   if test x$enable_gcc_warnings = xyes; then
1602     CFLAGS="$CFLAGS -Werror"
1603   fi
1605   # Disabled, so we can use mallinfo(): -Waggregate-return
1607   if test x$have_gcc4 = xyes ; then
1608     # These warnings break gcc 3.3.5 and work on gcc 4.0.2
1609     CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wold-style-definition"
1610   fi
1612   if test x$have_gcc42 = xyes ; then
1613     # These warnings break gcc 4.0.2 and work on gcc 4.2
1614     # XXXX020 See if any of these work with earlier versions.
1615     CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wstrict-overflow=1"
1617     # We used to use -Wstrict-overflow=5, but that breaks us heavily under 4.3.
1618   fi
1620   if test x$have_gcc42 = xyes && test x$have_clang = xno; then
1621     # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2
1622     CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init"
1623   fi
1625   if test x$have_gcc43 = xyes ; then
1626     # These warnings break gcc 4.2 and work on gcc 4.3
1627     # XXXX020 See if any of these work with earlier versions.
1628     CFLAGS="$CFLAGS -Wextra -Warray-bounds"
1629   fi
1631   if test x$have_gcc46 = xyes ; then
1632     # This warning was added in gcc 4.3, but it appears to generate
1633     # spurious warnings in gcc 4.4.  I don't know if it works in 4.5.
1634     CFLAGS="$CFLAGS -Wlogical-op"
1635   fi
1637   if test x$have_shorten64_flag = xyes ; then
1638     CFLAGS="$CFLAGS -Wshorten-64-to-32"
1639   fi
1643 ##This will break the world on some 64-bit architectures
1644 # CFLAGS="$CFLAGS -Winline"
1647 if test "$enable_coverage" = yes && test "$have_clang" = "no"; then
1648    case "$host_os" in
1649     darwin*)
1650       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.])
1651    esac
1654 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
1656 AC_CONFIG_FILES([
1657         Doxyfile
1658         Makefile
1659         contrib/dist/suse/tor.sh
1660         contrib/operator-tools/tor.logrotate
1661         contrib/dist/tor.sh
1662         contrib/dist/torctl
1663         contrib/dist/tor.service
1664         src/config/torrc.sample
1665         src/config/torrc.minimal
1666         scripts/maint/checkOptionDocs.pl
1667         scripts/maint/updateVersions.pl
1670 if test x$asciidoc = xtrue && test "$ASCIIDOC" = "none" ; then
1671   regular_mans="doc/tor doc/tor-gencert doc/tor-resolve doc/torify"
1672   for file in $regular_mans ; do
1673     if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
1674       echo "==================================";
1675       echo;
1676       echo "Building Tor has failed since manpages cannot be built.";
1677       echo;
1678       echo "You need asciidoc installed to be able to build the manpages.";
1679       echo "To build without manpages, use the --disable-asciidoc argument";
1680       echo "when calling configure.";
1681       echo;
1682       echo "==================================";
1683       exit 1;
1684     fi
1685   done
1688 AC_OUTPUT