Implement status/fresh-relay-descs command
[tor.git] / configure.ac
blobaf16edfe491a576b9372e9c7ebfb6e41d6a28502
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.6.2-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(buf-freelists,
29    AS_HELP_STRING(--enable-buf-freelists, enable freelists for buffer RAM))
30 AC_ARG_ENABLE(mempools,
31    AS_HELP_STRING(--enable-mempools, enable mempools for relay cells))
32 AC_ARG_ENABLE(openbsd-malloc,
33    AS_HELP_STRING(--enable-openbsd-malloc, Use malloc code from openbsd.  Linux only))
34 AC_ARG_ENABLE(instrument-downloads,
35    AS_HELP_STRING(--enable-instrument-downloads, Instrument downloads of directory resources etc.))
36 AC_ARG_ENABLE(static-openssl,
37    AS_HELP_STRING(--enable-static-openssl, Link against a static openssl library. Requires --with-openssl-dir))
38 AC_ARG_ENABLE(static-libevent,
39    AS_HELP_STRING(--enable-static-libevent, Link against a static libevent library. Requires --with-libevent-dir))
40 AC_ARG_ENABLE(static-zlib,
41    AS_HELP_STRING(--enable-static-zlib, Link against a static zlib library. Requires --with-zlib-dir))
42 AC_ARG_ENABLE(static-tor,
43    AS_HELP_STRING(--enable-static-tor, Create an entirely static Tor binary. Requires --with-openssl-dir and --with-libevent-dir and --with-zlib-dir))
44 AC_ARG_ENABLE(unittests,
45    AS_HELP_STRING(--disable-unittests, [Don't build unit tests for Tor. Risky!]))
46 AC_ARG_ENABLE(coverage,
47    AS_HELP_STRING(--enable-coverage, [Enable coverage support in the unit-test build]))
48 AC_ARG_ENABLE(system-torrc,
49    AS_HELP_STRING(--disable-system-torrc, [Don't look for a system-wide torrc file]))
51 AM_CONDITIONAL(UNITTESTS_ENABLED, test x$enable_unittests != xno)
52 AM_CONDITIONAL(COVERAGE_ENABLED, test x$enable_coverage = xyes)
54 if test "$enable_static_tor" = "yes"; then
55   enable_static_libevent="yes";
56   enable_static_openssl="yes";
57   enable_static_zlib="yes";
58   CFLAGS="$CFLAGS -static"
61 if test "$enable_system_torrc" = "no"; then
62   AC_DEFINE(DISABLE_SYSTEM_TORRC, 1,
63             [Defined if we're not going to look for a torrc in SYSCONF])
66 if test x$enable_buf_freelists = xyes; then
67   AC_DEFINE(ENABLE_BUF_FREELISTS, 1,
68             [Defined if we try to use freelists for buffer RAM chunks])
71 AM_CONDITIONAL(USE_MEMPOOLS, test x$enable_mempools = xyes)
72 if test x$enable_mempools = xyes; then
73   AC_DEFINE(ENABLE_MEMPOOLS, 1,
74             [Defined if we try to use mempools for cells being relayed])
77 AM_CONDITIONAL(USE_OPENBSD_MALLOC, test x$enable_openbsd_malloc = xyes)
78 if test x$enable_instrument_downloads = xyes; then
79   AC_DEFINE(INSTRUMENT_DOWNLOADS, 1,
80             [Defined if we want to keep track of how much of each kind of resource we download.])
83 AC_ARG_ENABLE(transparent,
84      AS_HELP_STRING(--disable-transparent, disable transparent proxy support),
85      [case "${enableval}" in
86         yes) transparent=true ;;
87         no)  transparent=false ;;
88         *) AC_MSG_ERROR(bad value for --enable-transparent) ;;
89       esac], [transparent=true])
91 AC_ARG_ENABLE(asciidoc,
92      AS_HELP_STRING(--disable-asciidoc, don't use asciidoc (disables building of manpages)),
93      [case "${enableval}" in
94         yes) asciidoc=true ;;
95         no)  asciidoc=false ;;
96         *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
97       esac], [asciidoc=true])
99 # By default, we're not ready to ship a NAT-PMP aware Tor
100 AC_ARG_ENABLE(nat-pmp,
101      AS_HELP_STRING(--enable-nat-pmp, enable NAT-PMP support),
102      [case "${enableval}" in
103         yes) natpmp=true ;;
104         no)  natpmp=false ;;
105         * ) AC_MSG_ERROR(bad value for --enable-nat-pmp) ;;
106       esac], [natpmp=false])
108 # By default, we're not ready to ship a UPnP aware Tor
109 AC_ARG_ENABLE(upnp,
110      AS_HELP_STRING(--enable-upnp, enable UPnP support),
111      [case "${enableval}" in
112         yes) upnp=true ;;
113         no)  upnp=false ;;
114         * ) AC_MSG_ERROR(bad value for --enable-upnp) ;;
115       esac], [upnp=false])
117 # systemd notify support
118 AC_ARG_ENABLE(systemd,
119       AS_HELP_STRING(--enable-systemd, enable systemd notification support),
120       [case "${enableval}" in
121         yes) systemd=true ;;
122         no)  systemd=false ;;
123         * ) AC_MSG_ERROR(bad value for --enable-systemd) ;;
124       esac], [systemd=auto])
128 # systemd support
129 if test x$enable_systemd = xno ; then
130     have_systemd=no;
131 else
132     PKG_CHECK_MODULES(SYSTEMD,
133         [libsystemd-daemon],
134         have_systemd=yes,
135         have_systemd=no)
136     if test x$have_systemd=xno; then
137         AC_MSG_NOTICE([Okay, checking for systemd a different way...])
138         PKG_CHECK_MODULES(SYSTEMD,
139             [libsystemd],
140             have_systemd=yes,
141             have_systemd=no)
142     fi
145 if test x$have_systemd = xyes; then
146     AC_DEFINE(HAVE_SYSTEMD,1,[Have systemd])
147     TOR_SYSTEMD_CFLAGS="${SYSTEMD_CFLAGS}"
148     TOR_SYSTEMD_LIBS="${SYSTEMD_LIBS}"
149     PKG_CHECK_MODULES(SYSTEMD209, [systemd >= 209],
150          [AC_DEFINE(HAVE_SYSTEMD_209,1,[Have systemd v209 or more])], [])
152 AC_SUBST(TOR_SYSTEMD_CFLAGS)
153 AC_SUBST(TOR_SYSTEMD_LIBS)
155 if test x$enable_systemd = xyes -a x$have_systemd != xyes ; then
156     AC_MSG_ERROR([Explicitly requested systemd support, but systemd not found])
159 AC_ARG_ENABLE(threads,
160      AS_HELP_STRING(--disable-threads, disable multi-threading support))
162 if test x$enable_threads = x; then
163    case $host in
164     *-*-solaris* )
165      # Don't try multithreading on solaris -- cpuworkers seem to lock.
166      AC_MSG_NOTICE([You are running Solaris; Sometimes threading makes
167 cpu workers lock up here, so I will disable threads.])
168      enable_threads="no";;
169     *)
170      enable_threads="yes";;
171    esac
175 case $host in
176    *-*-solaris* )
177      AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
178      ;;
179 esac
181 AC_ARG_ENABLE(gcc-warnings,
182      AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings))
183 AC_ARG_ENABLE(gcc-warnings-advisory,
184      AS_HELP_STRING(--enable-gcc-warnings-advisory, [enable verbose warnings, excluding -Werror]))
186 dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
187 AC_ARG_ENABLE(gcc-hardening,
188     AS_HELP_STRING(--disable-gcc-hardening, disable compiler security checks))
190 AC_ARG_ENABLE(expensive-hardening,
191     AS_HELP_STRING(--enable-expensive-hardening, enable more expensive compiler hardening; makes Tor slower))
193 dnl Linker hardening options
194 dnl Currently these options are ELF specific - you can't use this with MacOSX
195 AC_ARG_ENABLE(linker-hardening,
196     AS_HELP_STRING(--disable-linker-hardening, disable linker security fixups))
198 AC_ARG_ENABLE(local-appdata,
199    AS_HELP_STRING(--enable-local-appdata, default to host local application data paths on Windows))
200 if test "$enable_local_appdata" = "yes"; then
201   AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
202             [Defined if we default to host local appdata paths on Windows])
205 # Tor2web mode flag
206 AC_ARG_ENABLE(tor2web-mode,
207      AS_HELP_STRING(--enable-tor2web-mode, support tor2web non-anonymous mode),
208 [if test x$enableval = xyes; then
209     CFLAGS="$CFLAGS -D ENABLE_TOR2WEB_MODE=1"
210 fi])
212 AC_ARG_ENABLE(bufferevents,
213      AS_HELP_STRING(--enable-bufferevents, use Libevent's buffered IO.))
215 AC_ARG_ENABLE(tool-name-check,
216      AS_HELP_STRING(--disable-tool-name-check, check for sanely named toolchain when cross-compiling))
218 AC_ARG_ENABLE(seccomp,
219      AS_HELP_STRING(--disable-seccomp, do not attempt to use libseccomp))
221 AC_ARG_ENABLE(libscrypt,
222      AS_HELP_STRING(--disable-libscrypt, do not attempt to use libscrypt))
224 dnl check for the correct "ar" when cross-compiling
225 AN_MAKEVAR([AR], [AC_PROG_AR])
226 AN_PROGRAM([ar], [AC_PROG_AR])
227 AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [ar])])
228 AC_PROG_AR
230 dnl Check whether the above macro has settled for a simply named tool even
231 dnl though we're cross compiling. We must do this before running AC_PROG_CC,
232 dnl because that will find any cc on the system, not only the cross-compiler,
233 dnl and then verify that a binary built with this compiler runs on the
234 dnl build system. It will then come to the false conclusion that we're not
235 dnl cross-compiling.
236 if test x$enable_tool_name_check != xno; then
237     if test x$ac_tool_warned = xyes; then
238         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.)])
239         elif test "x$ac_ct_AR" != x -a x$cross_compiling = xmaybe; then
240                 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.)])
241         fi
244 AC_PROG_CC
245 AC_PROG_CPP
246 AC_PROG_MAKE_SET
247 AC_PROG_RANLIB
249 dnl autoconf 2.59 appears not to support AC_PROG_SED
250 AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
252 dnl check for asciidoc and a2x
253 AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
254 AC_PATH_PROGS([A2X], [a2x a2x.py], none)
256 AM_CONDITIONAL(USE_ASCIIDOC, test x$asciidoc = xtrue)
258 AM_CONDITIONAL(USE_FW_HELPER, test x$natpmp = xtrue || test x$upnp = xtrue)
259 AM_CONDITIONAL(NAT_PMP, test x$natpmp = xtrue)
260 AM_CONDITIONAL(MINIUPNPC, test x$upnp = xtrue)
261 AM_PROG_CC_C_O
262 AC_PROG_CC_C99
264 AC_ARG_VAR(PYTHON)
265 AC_CHECK_PROGS(PYTHON, [python python2 python2.7 python3 python3.3])
266 if test "x$PYTHON" = "x"; then
267   AC_MSG_WARN([Python unavailable; some tests will not be run.])
269 AM_CONDITIONAL(USEPYTHON, [test "x$PYTHON" != "x"])
271 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
272 AC_C_FLEXIBLE_ARRAY_MEMBER
273 ], [
274  dnl Maybe we've got an old autoconf...
275  AC_CACHE_CHECK([for flexible array members],
276      tor_cv_c_flexarray,
277      [AC_COMPILE_IFELSE(
278        AC_LANG_PROGRAM([
279  struct abc { int a; char b[]; };
280 ], [
281  struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
282  def->b[0] = 33;
284   [tor_cv_c_flexarray=yes],
285   [tor_cv_c_flexarray=no])])
286  if test $tor_cv_flexarray = yes ; then
287    AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
288  else
289    AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
290  fi
293 AC_CACHE_CHECK([for working C99 mid-block declaration syntax],
294       tor_cv_c_c99_decl,
295       [AC_COMPILE_IFELSE(
296          [AC_LANG_PROGRAM([], [int x; x = 3; int y; y = 4 + x;])],
297          [tor_cv_c_c99_decl=yes],
298          [tor_cv_c_c99_decl=no] )])
299 if test "$tor_cv_c_c99_decl" != "yes"; then
300   AC_MSG_ERROR([Your compiler doesn't support c99 mid-block declarations. This is required as of Tor 0.2.6.x])
303 AC_CACHE_CHECK([for working C99 designated initializers],
304       tor_cv_c_c99_designated_init,
305       [AC_COMPILE_IFELSE(
306          [AC_LANG_PROGRAM([struct s { int a; int b; };],
307                [[ struct s ss = { .b = 5, .a = 6 }; ]])],
308          [tor_cv_c_c99_designated_init=yes],
309          [tor_cv_c_c99_designated_init=no] )])
311 if test "$tor_cv_c_c99_designated_init" != "yes"; then
312   AC_MSG_ERROR([Your compiler doesn't support c99 designated initializers. This is required as of Tor 0.2.6.x])
315 AC_PATH_PROG([SHA1SUM], [sha1sum], none)
316 AC_PATH_PROG([OPENSSL], [openssl], none)
318 TORUSER=_tor
319 AC_ARG_WITH(tor-user,
320         [  --with-tor-user=NAME    Specify username for tor daemon ],
321         [
322            TORUSER=$withval
323         ]
325 AC_SUBST(TORUSER)
327 TORGROUP=_tor
328 AC_ARG_WITH(tor-group,
329         [  --with-tor-group=NAME   Specify group name for tor daemon ],
330         [
331            TORGROUP=$withval
332         ]
334 AC_SUBST(TORGROUP)
337 dnl If _WIN32 is defined and non-zero, we are building for win32
338 AC_MSG_CHECKING([for win32])
339 AC_RUN_IFELSE([AC_LANG_SOURCE([
340 int main(int c, char **v) {
341 #ifdef _WIN32
342 #if _WIN32
343   return 0;
344 #else
345   return 1;
346 #endif
347 #else
348   return 2;
349 #endif
350 }])],
351 bwin32=true; AC_MSG_RESULT([yes]),
352 bwin32=false; AC_MSG_RESULT([no]),
353 bwin32=cross; AC_MSG_RESULT([cross])
356 if test "$bwin32" = cross; then
357 AC_MSG_CHECKING([for win32 (cross)])
358 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
359 #ifdef _WIN32
360 int main(int c, char **v) {return 0;}
361 #else
362 #error
363 int main(int c, char **v) {return x(y);}
364 #endif
365 ])],
366 bwin32=true; AC_MSG_RESULT([yes]),
367 bwin32=false; AC_MSG_RESULT([no]))
370 AM_CONDITIONAL(BUILD_NT_SERVICES, test x$bwin32 = xtrue)
372 dnl Enable C99 when compiling with MIPSpro
373 AC_MSG_CHECKING([for MIPSpro compiler])
374 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
375 #if (defined(__sgi) && defined(_COMPILER_VERSION))
376 #error
377   return x(y);
378 #endif
379 ])],
380 bmipspro=false; AC_MSG_RESULT(no),
381 bmipspro=true; AC_MSG_RESULT(yes))
383 if test "$bmipspro" = true; then
384   CFLAGS="$CFLAGS -c99"
387 AC_C_BIGENDIAN
389 AC_SEARCH_LIBS(socket, [socket network])
390 AC_SEARCH_LIBS(gethostbyname, [nsl])
391 AC_SEARCH_LIBS(dlopen, [dl])
392 AC_SEARCH_LIBS(inet_aton, [resolv])
393 saved_LIBS="$LIBS"
394 AC_SEARCH_LIBS([clock_gettime], [rt])
395 if test "$LIBS" != "$saved_LIBS"; then
396    # Looks like we need -lrt for clock_gettime().
397    have_rt=yes
400 AC_SEARCH_LIBS(pthread_create, [pthread])
401 AC_SEARCH_LIBS(pthread_detach, [pthread])
403 AM_CONDITIONAL(THREADS_WIN32, test "$enable_threads" = "yes" && test "$bwin32" = "true")
404 AM_CONDITIONAL(THREADS_PTHREADS, test "$enable_threads" = "yes" && test "$bwin32" = "false")
405 AM_CONDITIONAL(THREADS_NONE, test "$enable_threads" != "yes")
407 dnl -------------------------------------------------------------------
408 dnl Check for functions before libevent, since libevent-1.2 apparently
409 dnl exports strlcpy without defining it in a header.
411 AC_CHECK_FUNCS(
412         _NSGetEnviron \
413         accept4 \
414         backtrace \
415         backtrace_symbols_fd \
416         clock_gettime \
417         eventfd \
418         flock \
419         ftime \
420         getaddrinfo \
421         getifaddrs \
422         getrlimit \
423         gettimeofday \
424         gmtime_r \
425         inet_aton \
426         ioctl \
427         issetugid \
428         llround \
429         localtime_r \
430         lround \
431         memmem \
432         pipe \
433         pipe2 \
434         prctl \
435         rint \
436         sigaction \
437         socketpair \
438         strlcat \
439         strlcpy \
440         strnlen \
441         strptime \
442         strtok_r \
443         strtoull \
444         sysconf \
445         sysctl \
446         uname \
447         usleep \
448         vasprintf \
449         _vscprintf
452 if test "$bwin32" != true; then
453   AC_CHECK_HEADERS(pthread.h)
454   AC_CHECK_FUNCS(pthread_create)
457 dnl ------------------------------------------------------
458 dnl Where do you live, libevent?  And how do we call you?
460 if test "$bwin32" = true; then
461   TOR_LIB_WS32=-lws2_32
462   TOR_LIB_IPHLPAPI=-liphlpapi
463   # Some of the cargo-cults recommend -lwsock32 as well, but I don't
464   # think it's actually necessary.
465   TOR_LIB_GDI=-lgdi32
466 else
467   TOR_LIB_WS32=
468   TOR_LIB_GDI=
470 AC_SUBST(TOR_LIB_WS32)
471 AC_SUBST(TOR_LIB_GDI)
472 AC_SUBST(TOR_LIB_IPHLPAPI)
474 dnl We need to do this before we try our disgusting hack below.
475 AC_CHECK_HEADERS([sys/types.h])
477 dnl This is a disgusting hack so we safely include older libevent headers.
478 AC_CHECK_TYPE(u_int64_t, unsigned long long)
479 AC_CHECK_TYPE(u_int32_t, unsigned long)
480 AC_CHECK_TYPE(u_int16_t, unsigned short)
481 AC_CHECK_TYPE(u_int8_t, unsigned char)
483 tor_libevent_pkg_redhat="libevent"
484 tor_libevent_pkg_debian="libevent-dev"
485 tor_libevent_devpkg_redhat="libevent-devel"
486 tor_libevent_devpkg_debian="libevent-dev"
488 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
489 dnl linking for static builds.
490 STATIC_LIBEVENT_FLAGS=""
491 if test "$enable_static_libevent" = "yes"; then
492     if test "$have_rt" = yes; then
493       STATIC_LIBEVENT_FLAGS=" -lrt "
494     fi
497 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
498 #ifdef _WIN32
499 #include <winsock2.h>
500 #endif
501 #include <stdlib.h>
502 #include <sys/time.h>
503 #include <sys/types.h>
504 #include <event.h>], [
505 #ifdef _WIN32
506 #include <winsock2.h>
507 #endif
508 void exit(int); void *event_init(void);],
509     [
510 #ifdef _WIN32
511 {WSADATA d; WSAStartup(0x101,&d); }
512 #endif
513 event_init(); exit(0);
514 ], [--with-libevent-dir], [/opt/libevent])
516 dnl Now check for particular libevent functions.
517 save_LIBS="$LIBS"
518 save_LDFLAGS="$LDFLAGS"
519 save_CPPFLAGS="$CPPFLAGS"
520 LIBS="-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $LIBS"
521 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
522 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
523 AC_CHECK_FUNCS([event_get_version \
524                 event_get_version_number \
525                 event_get_method \
526                 event_set_log_callback \
527                 evutil_secure_rng_set_urandom_device_file \
528                 evutil_secure_rng_init \
529                 event_base_loopexit])
530 AC_CHECK_MEMBERS([struct event.min_heap_idx], , ,
531 [#include <event.h>
534 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
536 LIBS="$save_LIBS"
537 LDFLAGS="$save_LDFLAGS"
538 CPPFLAGS="$save_CPPFLAGS"
541 AM_CONDITIONAL(USE_EXTERNAL_EVDNS, test x$ac_cv_header_event2_dns_h = xyes)
543 if test "$enable_static_libevent" = "yes"; then
544    if test "$tor_cv_library_libevent_dir" = "(system)"; then
545      AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
546    else
547      TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
548    fi
549 else
550      TOR_LIBEVENT_LIBS="-levent"
553 dnl This isn't the best test for Libevent 2.0.3-alpha.  Once it's released,
554 dnl we can do much better.
555 if test "$enable_bufferevents" = "yes" ; then
556   if test "$ac_cv_header_event2_bufferevent_ssl_h" != "yes" ; then
557     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.])
558   else
560     CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
562     # Check for the right version.  First see if version detection works.
563     AC_MSG_CHECKING([whether we can detect the Libevent version])
564     AC_COMPILE_IFELSE([AC_LANG_SOURCE([
565 #include <event2/event.h>
566 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 10
567 #error
568 int x = y(zz);
569 #else
570 int x = 1;
571 #endif
572   ])], [event_version_number_works=yes; AC_MSG_RESULT([yes]) ],
573      [event_version_number_works=no;  AC_MSG_RESULT([no])])
574     if test "$event_version_number_works" != 'yes'; then
575       AC_MSG_WARN([Version detection on Libevent seems broken.  Your Libevent installation is probably screwed up or very old.])
576     else
577       AC_MSG_CHECKING([whether Libevent is new enough for bufferevents])
578       AC_COMPILE_IFELSE([AC_LANG_SOURCE([
579 #include <event2/event.h>
580 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000d00
581 #error
582 int x = y(zz);
583 #else
584 int x = 1;
585 #endif
586    ])], [ AC_MSG_RESULT([yes]) ],
587       [ AC_MSG_RESULT([no])
588         AC_MSG_ERROR([Libevent does not seem new enough to support bufferevents.  We require 2.0.13-stable or later]) ] )
589     fi
590   fi
593 LIBS="$save_LIBS"
594 LDFLAGS="$save_LDFLAGS"
595 CPPFLAGS="$save_CPPFLAGS"
597 AM_CONDITIONAL(USE_BUFFEREVENTS, test "$enable_bufferevents" = "yes")
598 if test "$enable_bufferevents" = "yes"; then
599   AC_DEFINE(USE_BUFFEREVENTS, 1, [Defined if we're going to use Libevent's buffered IO API])
600   if test "$enable_static_libevent" = "yes"; then
601     TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent_openssl.a $TOR_LIBEVENT_LIBS"
602   else
603     TOR_LIBEVENT_LIBS="-levent_openssl $TOR_LIBEVENT_LIBS"
604   fi
606 AC_SUBST(TOR_LIBEVENT_LIBS)
608 dnl ------------------------------------------------------
609 dnl Where do you live, libm?
611 dnl On some platforms (Haiku/BeOS) the math library is
612 dnl part of libroot. In which case don't link against lm
613 TOR_LIB_MATH=""
614 save_LIBS="$LIBS"
615 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
616 if test "$ac_cv_search_pow" != "none required"; then
617     TOR_LIB_MATH="$ac_cv_search_pow"
619 LIBS="$save_LIBS"
620 AC_SUBST(TOR_LIB_MATH)
622 dnl ------------------------------------------------------
623 dnl Where do you live, openssl?  And how do we call you?
625 tor_openssl_pkg_redhat="openssl"
626 tor_openssl_pkg_debian="libssl-dev"
627 tor_openssl_devpkg_redhat="openssl-devel"
628 tor_openssl_devpkg_debian="libssl-dev"
630 ALT_openssl_WITHVAL=""
631 AC_ARG_WITH(ssl-dir,
632   [  --with-ssl-dir=PATH    Obsolete alias for --with-openssl-dir ],
633   [
634       if test "x$withval" != xno && test "x$withval" != "x" ; then
635          ALT_openssl_WITHVAL="$withval"
636       fi
637   ])
639 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI],
640     [#include <openssl/rand.h>],
641     [void RAND_add(const void *buf, int num, double entropy);],
642     [RAND_add((void*)0,0,0); exit(0);], [],
643     [/usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /opt/openssl])
645 dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
647 if test "$enable_static_openssl" = "yes"; then
648    if test "$tor_cv_library_openssl_dir" = "(system)"; then
649      AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
650    else
651      TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
652    fi
653 else
654      TOR_OPENSSL_LIBS="-lssl -lcrypto"
656 AC_SUBST(TOR_OPENSSL_LIBS)
658 AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , ,
659 [#include <openssl/ssl.h>
662 dnl ------------------------------------------------------
663 dnl Where do you live, zlib?  And how do we call you?
665 tor_zlib_pkg_redhat="zlib"
666 tor_zlib_pkg_debian="zlib1g"
667 tor_zlib_devpkg_redhat="zlib-devel"
668 tor_zlib_devpkg_debian="zlib1g-dev"
670 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
671     [#include <zlib.h>],
672     [const char * zlibVersion(void);],
673     [zlibVersion(); exit(0);], [--with-zlib-dir],
674     [/opt/zlib])
676 if test "$enable_static_zlib" = "yes"; then
677    if test "$tor_cv_library_zlib_dir" = "(system)"; then
678      AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
679  using --enable-static-zlib")
680    else
681      TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
682    fi
683 else
684      TOR_ZLIB_LIBS="-lz"
686 AC_SUBST(TOR_ZLIB_LIBS)
688 dnl ---------------------------------------------------------------------
689 dnl Now that we know about our major libraries, we can check for compiler
690 dnl and linker hardening options.  We need to do this with the libraries known,
691 dnl since sometimes the linker will like an option but not be willing to
692 dnl use it with a build of a library.
694 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
695 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"
697 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
698 #if !defined(__clang__)
699 #error
700 #endif])], have_clang=yes, have_clang=no)
702 if test x$enable_gcc_hardening != xno; then
703     CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
704     if test x$have_clang = xyes; then
705         TOR_CHECK_CFLAGS(-Qunused-arguments)
706     fi
707     TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
708     AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
709     AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
710 m4_ifdef([AS_VAR_IF],[
711     AS_VAR_IF(can_compile, [yes],
712         AS_VAR_IF(can_link, [yes],
713                   [],
714                   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.)]))
715         )])
716     AS_VAR_POPDEF([can_link])
717     AS_VAR_POPDEF([can_compile])
718     TOR_CHECK_CFLAGS(-Wstack-protector)
719     TOR_CHECK_CFLAGS(-fwrapv)
720     TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
721     if test "$bwin32" = "false"; then
722        TOR_CHECK_CFLAGS(-fPIE)
723        TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
724     fi
727 if test x$enable_expensive_hardening = xyes ; then
728    TOR_CHECK_CFLAGS([-fsanitize=address])
729    TOR_CHECK_CFLAGS([-fsanitize=undefined])
730    TOR_CHECK_CFLAGS([-fno-omit-frame-pointer])
733 if test x$enable_linker_hardening != xno; then
734     TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
737 # For backtrace support
738 TOR_CHECK_LDFLAGS(-rdynamic)
740 dnl ------------------------------------------------------
741 dnl Now see if we have a -fomit-frame-pointer compiler option.
743 saved_CFLAGS="$CFLAGS"
744 TOR_CHECK_CFLAGS(-fomit-frame-pointer)
745 F_OMIT_FRAME_POINTER=''
746 if test "$saved_CFLAGS" != "$CFLAGS"; then
747   if test x$enable_expensive_hardening != xyes ; then
748     F_OMIT_FRAME_POINTER='-fomit-frame-pointer'
749   fi
751 CFLAGS="$saved_CFLAGS"
752 AC_SUBST(F_OMIT_FRAME_POINTER)
754 dnl ------------------------------------------------------
755 dnl If we are adding -fomit-frame-pointer (or if the compiler's doing it
756 dnl for us, as GCC 4.6 and later do at many optimization levels), then
757 dnl we should try to add -fasynchronous-unwind-tables so that our backtrace
758 dnl code will work.
759 TOR_CHECK_CFLAGS(-fasynchronous-unwind-tables)
761 dnl ------------------------------------------------------
762 dnl Where do you live, libnatpmp?  And how do we call you?
763 dnl There are no packages for Debian or Redhat as of this patch
765 if test "$natpmp" = "true"; then
766     AC_DEFINE(NAT_PMP, 1, [Define to 1 if we are building with nat-pmp.])
767     TOR_SEARCH_LIBRARY(libnatpmp, $trylibnatpmpdir, [-lnatpmp $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
768         [#include <natpmp.h>],
769         [#ifdef _WIN32
770          #define STATICLIB
771          #endif
772          #include <natpmp.h>],
773         [   int r;
774             natpmp_t natpmp;
775             natpmpresp_t response;
776             r = initnatpmp(&natpmp, 0, 0);],
777             [printf("initnatpmp() returned %d (%s)\n", r, r?"FAILED":"SUCCESS");
778             exit(0);],
779         [--with-libnatpmp-dir],
780         [/usr/lib/])
784 dnl ------------------------------------------------------
785 dnl Where do you live, libminiupnpc?  And how do we call you?
786 dnl There are no packages for Debian or Redhat as of this patch
788 if test "$upnp" = "true"; then
789     AC_DEFINE(MINIUPNPC, 1, [Define to 1 if we are building with UPnP.])
791     dnl Before we call TOR_SEARCH_LIBRARY we'll do a quick compile test
792     dnl to see if we have miniupnpc-1.5 or -1.6
793     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <miniupnpc/miniupnpc.h>],
794         [upnpDiscover(1, 0, 0, 0);exit(0);])],[miniupnpc15="true"],[miniupnpc15="false"])
796     if test "$miniupnpc15" = "true" ; then
797         AC_DEFINE([MINIUPNPC15],[1],[libminiupnpc version 1.5 found])
798         TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
799             [#include <miniupnpc/miniwget.h>
800              #include <miniupnpc/miniupnpc.h>
801              #include <miniupnpc/upnpcommands.h>],
802             [void upnpDiscover(int delay, const char * multicastif,
803              const char * minissdpdsock, int sameport);],
804             [upnpDiscover(1, 0, 0, 0); exit(0);],
805             [--with-libminiupnpc-dir],
806             [/usr/lib/])
807     else
808         TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
809             [#include <miniupnpc/miniwget.h>
810              #include <miniupnpc/miniupnpc.h>
811              #include <miniupnpc/upnpcommands.h>],
812             [void upnpDiscover(int delay, const char * multicastif,
813              const char * minissdpdsock, int sameport, int ipv6, int * error);],
814             [upnpDiscover(1, 0, 0, 0, 0, 0); exit(0);],
815             [--with-libminiupnpc-dir],
816             [/usr/lib/])
817     fi
820 dnl ============================================================
821 dnl Check for libseccomp
823 if test "x$enable_seccomp" != "xno"; then
824   AC_CHECK_HEADERS([seccomp.h])
825   AC_SEARCH_LIBS(seccomp_init, [seccomp])
828 dnl ============================================================
829 dnl Check for libscrypt
831 if test "x$enable_libscrypt" != "xno"; then
832   AC_CHECK_HEADERS([libscrypt.h])
833   AC_SEARCH_LIBS(libscrypt_scrypt, [scrypt])
836 dnl ============================================================
837 dnl We need an implementation of curve25519.
839 dnl set these defaults.
840 build_curve25519_donna=no
841 build_curve25519_donna_c64=no
842 use_curve25519_donna=no
843 use_curve25519_nacl=no
844 CURVE25519_LIBS=
846 dnl The best choice is using curve25519-donna-c64, but that requires
847 dnl that we
848 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
849   tor_cv_can_use_curve25519_donna_c64,
850   [AC_RUN_IFELSE(
851     [AC_LANG_PROGRAM([dnl
852       #include <stdint.h>
853       typedef unsigned uint128_t __attribute__((mode(TI)));
854   int func(uint64_t a, uint64_t b) {
855            uint128_t c = ((uint128_t)a) * b;
856            int ok = ((uint64_t)(c>>96)) == 522859 &&
857              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
858                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
859                  (((uint64_t)(c))&0xffffffffL) == 0;
860            return ok;
861       }
862   ], [dnl
863     int ok = func( ((uint64_t)2000000000) * 1000000000,
864                    ((uint64_t)1234567890) << 24);
865         return !ok;
866       ])],
867   [tor_cv_can_use_curve25519_donna_c64=yes],
868       [tor_cv_can_use_curve25519_donna_c64=no],
869   [AC_LINK_IFELSE(
870         [AC_LANG_PROGRAM([dnl
871       #include <stdint.h>
872       typedef unsigned uint128_t __attribute__((mode(TI)));
873   int func(uint64_t a, uint64_t b) {
874            uint128_t c = ((uint128_t)a) * b;
875            int ok = ((uint64_t)(c>>96)) == 522859 &&
876              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
877                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
878                  (((uint64_t)(c))&0xffffffffL) == 0;
879            return ok;
880       }
881   ], [dnl
882     int ok = func( ((uint64_t)2000000000) * 1000000000,
883                  ((uint64_t)1234567890) << 24);
884         return !ok;
885       ])],
886           [tor_cv_can_use_curve25519_donna_c64=cross],
887       [tor_cv_can_use_curve25519_donna_c64=no])])])
889 AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
890                   nacl/crypto_scalarmult_curve25519.h])
892 AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
893   tor_cv_can_use_curve25519_nacl,
894   [tor_saved_LIBS="$LIBS"
895    LIBS="$LIBS -lnacl"
896    AC_LINK_IFELSE(
897      [AC_LANG_PROGRAM([dnl
898        #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
899        #include <crypto_scalarmult_curve25519.h>
900    #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
901    #include <nacl/crypto_scalarmult_curve25519.h>
902    #endif
903        #ifdef crypto_scalarmult_curve25519_ref_BYTES
904    #error Hey, this is the reference implementation! That's not fast.
905    #endif
906      ], [
907    unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
908      ])], [tor_cv_can_use_curve25519_nacl=yes],
909      [tor_cv_can_use_curve25519_nacl=no])
910    LIBS="$tor_saved_LIBS" ])
912  dnl Okay, now we need to figure out which one to actually use. Fall back
913  dnl to curve25519-donna.c
915  if test x$tor_cv_can_use_curve25519_donna_c64 != xno; then
916    build_curve25519_donna_c64=yes
917    use_curve25519_donna=yes
918  elif test x$tor_cv_can_use_curve25519_nacl = xyes; then
919    use_curve25519_nacl=yes
920    CURVE25519_LIBS=-lnacl
921  else
922    build_curve25519_donna=yes
923    use_curve25519_donna=yes
924  fi
926 if test x$use_curve25519_donna = xyes; then
927   AC_DEFINE(USE_CURVE25519_DONNA, 1,
928             [Defined if we should use an internal curve25519_donna{,_c64} implementation])
930 if test x$use_curve25519_nacl = xyes; then
931   AC_DEFINE(USE_CURVE25519_NACL, 1,
932             [Defined if we should use a curve25519 from nacl])
934 AM_CONDITIONAL(BUILD_CURVE25519_DONNA, test x$build_curve25519_donna = xyes)
935 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64, test x$build_curve25519_donna_c64 = xyes)
936 AC_SUBST(CURVE25519_LIBS)
938 dnl Make sure to enable support for large off_t if available.
939 AC_SYS_LARGEFILE
941 AC_CHECK_HEADERS(
942         assert.h \
943         errno.h \
944         fcntl.h \
945         signal.h \
946         string.h \
947         sys/fcntl.h \
948         sys/stat.h \
949         sys/time.h \
950         sys/types.h \
951         time.h \
952         unistd.h
953  , , 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.))
955 dnl These headers are not essential
957 AC_CHECK_HEADERS(
958         arpa/inet.h \
959         crt_externs.h \
960         execinfo.h \
961         grp.h \
962         ifaddrs.h \
963         inttypes.h \
964         limits.h \
965         linux/types.h \
966         machine/limits.h \
967         malloc.h \
968         malloc/malloc.h \
969         malloc_np.h \
970         netdb.h \
971         netinet/in.h \
972         netinet/in6.h \
973         pwd.h \
974         stdint.h \
975         sys/eventfd.h \
976         sys/file.h \
977         sys/ioctl.h \
978         sys/limits.h \
979         sys/mman.h \
980         sys/param.h \
981         sys/prctl.h \
982         sys/resource.h \
983         sys/select.h \
984         sys/socket.h \
985         sys/sysctl.h \
986         sys/syslimits.h \
987         sys/time.h \
988         sys/types.h \
989         sys/un.h \
990         sys/utime.h \
991         sys/wait.h \
992         syslog.h \
993         utime.h
996 AC_CHECK_HEADERS(sys/param.h)
998 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
999 [#ifdef HAVE_SYS_TYPES_H
1000 #include <sys/types.h>
1001 #endif
1002 #ifdef HAVE_SYS_SOCKET_H
1003 #include <sys/socket.h>
1004 #endif])
1005 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
1006 [#ifdef HAVE_SYS_TYPES_H
1007 #include <sys/types.h>
1008 #endif
1009 #ifdef HAVE_SYS_SOCKET_H
1010 #include <sys/socket.h>
1011 #endif
1012 #ifdef HAVE_NET_IF_H
1013 #include <net/if.h>
1014 #endif])
1016 AC_CHECK_HEADERS(linux/if.h,[],[],
1018 #ifdef HAVE_SYS_SOCKET_H
1019 #include <sys/socket.h>
1020 #endif
1023 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
1024         linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
1025 [#ifdef HAVE_SYS_TYPES_H
1026 #include <sys/types.h>
1027 #endif
1028 #ifdef HAVE_SYS_SOCKET_H
1029 #include <sys/socket.h>
1030 #endif
1031 #ifdef HAVE_LIMITS_H
1032 #include <limits.h>
1033 #endif
1034 #ifdef HAVE_LINUX_TYPES_H
1035 #include <linux/types.h>
1036 #endif
1037 #ifdef HAVE_NETINET_IN6_H
1038 #include <netinet/in6.h>
1039 #endif
1040 #ifdef HAVE_NETINET_IN_H
1041 #include <netinet/in.h>
1042 #endif])
1044 AC_CHECK_HEADERS(linux/netfilter_ipv6/ip6_tables.h,
1045         linux_netfilter_ipv6_ip6_tables=1, linux_netfilter_ipv6_ip6_tables=0,
1046 [#ifdef HAVE_SYS_TYPES_H
1047 #include <sys/types.h>
1048 #endif
1049 #ifdef HAVE_SYS_SOCKET_H
1050 #include <sys/socket.h>
1051 #endif
1052 #ifdef HAVE_LIMITS_H
1053 #include <limits.h>
1054 #endif
1055 #ifdef HAVE_LINUX_TYPES_H
1056 #include <linux/types.h>
1057 #endif
1058 #ifdef HAVE_NETINET_IN6_H
1059 #include <netinet/in6.h>
1060 #endif
1061 #ifdef HAVE_NETINET_IN_H
1062 #include <netinet/in.h>
1063 #endif
1064 #ifdef HAVE_LINUX_IF_H
1065 #include <linux/if.h>
1066 #endif])
1068 if test x$transparent = xtrue ; then
1069    transparent_ok=0
1070    if test x$net_if_found = x1 && test x$net_pfvar_found = x1 ; then
1071      transparent_ok=1
1072    fi
1073    if test x$linux_netfilter_ipv4 = x1 ; then
1074      transparent_ok=1
1075    fi
1076    if test x$linux_netfilter_ipv6_ip6_tables = x1 ; then
1077      transparent_ok=1
1078    fi
1079    if test x$transparent_ok = x1 ; then
1080      AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
1081      case $host in
1082        *-*-openbsd* | *-*-bitrig*)
1083          AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
1084      esac
1085    else
1086      AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
1087    fi
1090 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
1091 [#ifdef HAVE_SYS_TYPES_H
1092 #include <sys/types.h>
1093 #endif
1094 #ifdef HAVE_SYS_TIME_H
1095 #include <sys/time.h>
1096 #endif])
1098 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
1099 dnl Watch out.
1101 AC_CHECK_SIZEOF(int8_t)
1102 AC_CHECK_SIZEOF(int16_t)
1103 AC_CHECK_SIZEOF(int32_t)
1104 AC_CHECK_SIZEOF(int64_t)
1105 AC_CHECK_SIZEOF(uint8_t)
1106 AC_CHECK_SIZEOF(uint16_t)
1107 AC_CHECK_SIZEOF(uint32_t)
1108 AC_CHECK_SIZEOF(uint64_t)
1109 AC_CHECK_SIZEOF(intptr_t)
1110 AC_CHECK_SIZEOF(uintptr_t)
1112 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
1114 AC_CHECK_SIZEOF(char)
1115 AC_CHECK_SIZEOF(short)
1116 AC_CHECK_SIZEOF(int)
1117 AC_CHECK_SIZEOF(long)
1118 AC_CHECK_SIZEOF(long long)
1119 AC_CHECK_SIZEOF(__int64)
1120 AC_CHECK_SIZEOF(void *)
1121 AC_CHECK_SIZEOF(time_t)
1122 AC_CHECK_SIZEOF(size_t)
1123 AC_CHECK_SIZEOF(pid_t)
1125 AC_CHECK_TYPES([uint, u_char, ssize_t])
1127 AC_PC_FROM_UCONTEXT([/bin/true])
1129 dnl used to include sockaddr_storage, but everybody has that.
1130 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
1131 [#ifdef HAVE_SYS_TYPES_H
1132 #include <sys/types.h>
1133 #endif
1134 #ifdef HAVE_NETINET_IN_H
1135 #include <netinet/in.h>
1136 #endif
1137 #ifdef HAVE_NETINET_IN6_H
1138 #include <netinet/in6.h>
1139 #endif
1140 #ifdef HAVE_SYS_SOCKET_H
1141 #include <sys/socket.h>
1142 #endif
1143 #ifdef _WIN32
1144 #define _WIN32_WINNT 0x0501
1145 #define WIN32_LEAN_AND_MEAN
1146 #if defined(_MSC_VER) && (_MSC_VER < 1300)
1147 #include <winsock.h>
1148 #else
1149 #include <winsock2.h>
1150 #include <ws2tcpip.h>
1151 #endif
1152 #endif
1154 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
1155 [#ifdef HAVE_SYS_TYPES_H
1156 #include <sys/types.h>
1157 #endif
1158 #ifdef HAVE_NETINET_IN_H
1159 #include <netinet/in.h>
1160 #endif
1161 #ifdef HAVE_NETINET_IN6_H
1162 #include <netinet/in6.h>
1163 #endif
1164 #ifdef HAVE_SYS_SOCKET_H
1165 #include <sys/socket.h>
1166 #endif
1167 #ifdef _WIN32
1168 #define _WIN32_WINNT 0x0501
1169 #define WIN32_LEAN_AND_MEAN
1170 #if defined(_MSC_VER) && (_MSC_VER < 1300)
1171 #include <winsock.h>
1172 #else
1173 #include <winsock2.h>
1174 #include <ws2tcpip.h>
1175 #endif
1176 #endif
1179 AC_CHECK_TYPES([rlim_t], , ,
1180 [#ifdef HAVE_SYS_TYPES_H
1181 #include <sys/types.h>
1182 #endif
1183 #ifdef HAVE_SYS_TIME_H
1184 #include <sys/time.h>
1185 #endif
1186 #ifdef HAVE_SYS_RESOURCE_H
1187 #include <sys/resource.h>
1188 #endif
1191 AX_CHECK_SIGN([time_t],
1192        [ AC_DEFINE(TIME_T_IS_SIGNED, 1, [Define if time_t is signed]) ],
1193        [ : ], [
1194 #ifdef HAVE_SYS_TYPES_H
1195 #include <sys/types.h>
1196 #endif
1197 #ifdef HAVE_SYS_TIME_H
1198 #include <sys/time.h>
1199 #endif
1200 #ifdef HAVE_TIME_H
1201 #include <time.h>
1202 #endif
1205 if test "$ax_cv_decl_time_t_signed" = no; then
1206   AC_MSG_WARN([You have an unsigned time_t; some things will probably break. Please tell the Tor developers about your interesting platform.])
1209 AX_CHECK_SIGN([size_t],
1210        [ tor_cv_size_t_signed=yes ],
1211        [ tor_cv_size_t_signed=no ], [
1212 #ifdef HAVE_SYS_TYPES_H
1213 #include <sys/types.h>
1214 #endif
1217 if test "$ax_cv_decl_size_t_signed" = yes; then
1218   AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
1221 AX_CHECK_SIGN([enum always],
1222        [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
1223        [ : ], [
1224  enum always { AAA, BBB, CCC };
1227 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
1228 #ifdef HAVE_SYS_SOCKET_H
1229 #include <sys/socket.h>
1230 #endif
1233 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1235 AC_CHECK_SIZEOF(cell_t)
1237 # Now make sure that NULL can be represented as zero bytes.
1238 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1239 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1240 [[#include <stdlib.h>
1241 #include <string.h>
1242 #include <stdio.h>
1243 #ifdef HAVE_STDDEF_H
1244 #include <stddef.h>
1245 #endif
1246 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1247 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1248        [tor_cv_null_is_zero=yes],
1249        [tor_cv_null_is_zero=no],
1250        [tor_cv_null_is_zero=cross])])
1252 if test "$tor_cv_null_is_zero" = cross ; then
1253   # Cross-compiling; let's hope that the target isn't raving mad.
1254   AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
1257 if test "$tor_cv_null_is_zero" != no; then
1258   AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1259             [Define to 1 iff memset(0) sets pointers to NULL])
1262 AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
1263 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1264 [[#include <stdlib.h>
1265 #include <string.h>
1266 #include <stdio.h>
1267 #ifdef HAVE_STDDEF_H
1268 #include <stddef.h>
1269 #endif
1270 int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
1271 return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
1272        [tor_cv_dbl0_is_zero=yes],
1273        [tor_cv_dbl0_is_zero=no],
1274        [tor_cv_dbl0_is_zero=cross])])
1276 if test "$tor_cv_dbl0_is_zero" = cross ; then
1277   # Cross-compiling; let's hope that the target isn't raving mad.
1278   AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
1281 if test "$tor_cv_dbl0_is_zero" != no; then
1282   AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
1283             [Define to 1 iff memset(0) sets doubles to 0.0])
1286 # And what happens when we malloc zero?
1287 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
1288 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1289 [[#include <stdlib.h>
1290 #include <string.h>
1291 #include <stdio.h>
1292 #ifdef HAVE_STDDEF_H
1293 #include <stddef.h>
1294 #endif
1295 int main () { return malloc(0)?0:1; }]])],
1296        [tor_cv_malloc_zero_works=yes],
1297        [tor_cv_malloc_zero_works=no],
1298        [tor_cv_malloc_zero_works=cross])])
1300 if test "$tor_cv_malloc_zero_works" = cross; then
1301   # Cross-compiling; let's hope that the target isn't raving mad.
1302   AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
1305 if test "$tor_cv_malloc_zero_works" = yes; then
1306   AC_DEFINE([MALLOC_ZERO_WORKS], 1,
1307             [Define to 1 iff malloc(0) returns a pointer])
1310 # whether we seem to be in a 2s-complement world.
1311 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
1312 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1313 [[int main () { int problem = ((-99) != (~99)+1);
1314 return problem ? 1 : 0; }]])],
1315        [tor_cv_twos_complement=yes],
1316        [tor_cv_twos_complement=no],
1317        [tor_cv_twos_complement=cross])])
1319 if test "$tor_cv_twos_complement" = cross ; then
1320   # Cross-compiling; let's hope that the target isn't raving mad.
1321   AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
1324 if test "$tor_cv_twos_complement" != no ; then
1325   AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
1326             [Define to 1 iff we represent negative integers with two's complement])
1329 # What does shifting a negative value do?
1330 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
1331 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1332 [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
1333        [tor_cv_sign_extend=yes],
1334        [tor_cv_sign_extend=no],
1335        [tor_cv_sign_extend=cross])])
1337 if test "$tor_cv_sign_extend" = cross ; then
1338   # Cross-compiling; let's hope that the target isn't raving mad.
1339   AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
1342 if test "$tor_cv_sign_extend" != no ; then
1343   AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
1344             [Define to 1 iff right-shifting a negative value performs sign-extension])
1347 # Whether we should use the dmalloc memory allocation debugging library.
1348 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
1349 AC_ARG_WITH(dmalloc,
1350 [  --with-dmalloc          Use debug memory allocation library. ],
1351 [if [[ "$withval" = "yes" ]]; then
1352   dmalloc=1
1353   AC_MSG_RESULT(yes)
1354 else
1355   dmalloc=1
1356   AC_MSG_RESULT(no)
1357 fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
1360 if [[ $dmalloc -eq 1 ]]; then
1361   AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
1362   AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
1363   AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
1364   AC_CHECK_FUNCS(dmalloc_strdup dmalloc_strndup)
1367 AC_ARG_WITH(tcmalloc,
1368 [  --with-tcmalloc         Use tcmalloc memory allocation library. ],
1369 [ tcmalloc=yes ], [ tcmalloc=no ])
1371 if test x$tcmalloc = xyes ; then
1372    LDFLAGS="-ltcmalloc $LDFLAGS"
1375 using_custom_malloc=no
1376 if test x$enable_openbsd_malloc = xyes ; then
1377    using_custom_malloc=yes
1379 if test x$tcmalloc = xyes ; then
1380    using_custom_malloc=yes
1382 if test $using_custom_malloc = no ; then
1383    AC_CHECK_FUNCS(mallinfo)
1386 # By default, we're going to assume we don't have mlockall()
1387 # bionic and other platforms have various broken mlockall subsystems.
1388 # Some systems don't have a working mlockall, some aren't linkable,
1389 # and some have it but don't declare it.
1390 AC_CHECK_FUNCS(mlockall)
1391 AC_CHECK_DECLS([mlockall], , , [
1392 #ifdef HAVE_SYS_MMAN_H
1393 #include <sys/mman.h>
1394 #endif])
1396 # Allow user to specify an alternate syslog facility
1397 AC_ARG_WITH(syslog-facility,
1398 [  --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
1399 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
1400 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
1401 AC_SUBST(LOGFACILITY)
1403 # Check if we have getresuid and getresgid
1404 AC_CHECK_FUNCS(getresuid getresgid)
1406 # Check for gethostbyname_r in all its glorious incompatible versions.
1407 #   (This logic is based on that in Python's configure.in)
1408 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
1409   [Define this if you have any gethostbyname_r()])
1411 AC_CHECK_FUNC(gethostbyname_r, [
1412   AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
1413   OLD_CFLAGS=$CFLAGS
1414   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1415   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1416 #include <netdb.h>
1417   ], [[
1418     char *cp1, *cp2;
1419     struct hostent *h1, *h2;
1420     int i1, i2;
1421     (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
1422   ]])],[
1423     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1424     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
1425      [Define this if gethostbyname_r takes 6 arguments])
1426     AC_MSG_RESULT(6)
1427   ], [
1428     AC_TRY_COMPILE([
1429 #include <netdb.h>
1430     ], [
1431       char *cp1, *cp2;
1432       struct hostent *h1;
1433       int i1, i2;
1434       (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
1435     ], [
1436       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1437       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
1438         [Define this if gethostbyname_r takes 5 arguments])
1439       AC_MSG_RESULT(5)
1440    ], [
1441       AC_TRY_COMPILE([
1442 #include <netdb.h>
1443      ], [
1444        char *cp1;
1445        struct hostent *h1;
1446        struct hostent_data hd;
1447        (void) gethostbyname_r(cp1,h1,&hd);
1448      ], [
1449        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1450        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
1451          [Define this if gethostbyname_r takes 3 arguments])
1452        AC_MSG_RESULT(3)
1453      ], [
1454        AC_MSG_RESULT(0)
1455      ])
1456   ])
1457  ])
1458  CFLAGS=$OLD_CFLAGS
1461 AC_CACHE_CHECK([whether the C compiler supports __func__],
1462   tor_cv_have_func_macro,
1463   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1464 #include <stdio.h>
1465 int main(int c, char **v) { puts(__func__); }])],
1466   tor_cv_have_func_macro=yes,
1467   tor_cv_have_func_macro=no))
1469 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
1470   tor_cv_have_FUNC_macro,
1471   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1472 #include <stdio.h>
1473 int main(int c, char **v) { puts(__FUNC__); }])],
1474   tor_cv_have_FUNC_macro=yes,
1475   tor_cv_have_FUNC_macro=no))
1477 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
1478   tor_cv_have_FUNCTION_macro,
1479   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1480 #include <stdio.h>
1481 int main(int c, char **v) { puts(__FUNCTION__); }])],
1482   tor_cv_have_FUNCTION_macro=yes,
1483   tor_cv_have_FUNCTION_macro=no))
1485 AC_CACHE_CHECK([whether we have extern char **environ already declared],
1486   tor_cv_have_environ_declared,
1487   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1488 /* We define _GNU_SOURCE here because it is also defined in compat.c.
1489  * Without it environ doesn't get declared. */
1490 #define _GNU_SOURCE
1491 #ifdef HAVE_UNISTD_H
1492 #include <unistd.h>
1493 #endif
1494 #include <stdlib.h>
1495 int main(int c, char **v) { char **t = environ; }])],
1496   tor_cv_have_environ_declared=yes,
1497   tor_cv_have_environ_declared=no))
1499 if test "$tor_cv_have_func_macro" = 'yes'; then
1500   AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
1503 if test "$tor_cv_have_FUNC_macro" = 'yes'; then
1504   AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
1507 if test "$tor_cv_have_FUNCTION_macro" = 'yes'; then
1508   AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
1509            [Defined if the compiler supports __FUNCTION__])
1512 if test "$tor_cv_have_environ_declared" = 'yes'; then
1513   AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
1514            [Defined if we have extern char **environ already declared])
1517 # $prefix stores the value of the --prefix command line option, or
1518 # NONE if the option wasn't set.  In the case that it wasn't set, make
1519 # it be the default, so that we can use it to expand directories now.
1520 if test "x$prefix" = "xNONE"; then
1521   prefix=$ac_default_prefix
1524 # and similarly for $exec_prefix
1525 if test "x$exec_prefix" = "xNONE"; then
1526   exec_prefix=$prefix
1529 if test "x$BUILDDIR" = "x"; then
1530   BUILDDIR=`pwd`
1532 AC_SUBST(BUILDDIR)
1533 AH_TEMPLATE([BUILDDIR],[tor's build directory])
1534 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
1536 if test "x$CONFDIR" = "x"; then
1537   CONFDIR=`eval echo $sysconfdir/tor`
1539 AC_SUBST(CONFDIR)
1540 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
1541 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
1543 BINDIR=`eval echo $bindir`
1544 AC_SUBST(BINDIR)
1545 LOCALSTATEDIR=`eval echo $localstatedir`
1546 AC_SUBST(LOCALSTATEDIR)
1548 if test "$bwin32" = true; then
1549   # Test if the linker supports the --nxcompat and --dynamicbase options
1550   # for Windows
1551   save_LDFLAGS="$LDFLAGS"
1552   LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
1553   AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
1554   AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
1555     [AC_MSG_RESULT([yes])]
1556     [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
1557     [AC_MSG_RESULT([no])]
1558   )
1559   LDFLAGS="$save_LDFLAGS"
1562 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
1563 # than autoconf's macros like.
1564 if test "$GCC" = yes; then
1565   # Disable GCC's strict aliasing checks.  They are an hours-to-debug
1566   # accident waiting to happen.
1567   CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
1568 else
1569   # Override optimization level for non-gcc compilers
1570   CFLAGS="$CFLAGS -O"
1571   enable_gcc_warnings=no
1572   enable_gcc_warnings_advisory=no
1575 # OS X Lion started deprecating the system openssl. Let's just disable
1576 # all deprecation warnings on OS X. Also, to potentially make the binary
1577 # a little smaller, let's enable dead_strip.
1578 case "$host_os" in
1580  darwin*)
1581     CFLAGS="$CFLAGS -Wno-deprecated-declarations"
1582     LDFLAGS="$LDFLAGS -dead_strip" ;;
1583 esac
1585 # Add some more warnings which we use in development but not in the
1586 # released versions.  (Some relevant gcc versions can't handle these.)
1587 if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xyes; then
1589   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1590 #if !defined(__GNUC__) || (__GNUC__ < 4)
1591 #error
1592 #endif])], have_gcc4=yes, have_gcc4=no)
1594   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1595 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
1596 #error
1597 #endif])], have_gcc42=yes, have_gcc42=no)
1599   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1600 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
1601 #error
1602 #endif])], have_gcc43=yes, have_gcc43=no)
1604   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1605 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
1606 #error
1607 #endif])], have_gcc46=yes, have_gcc46=no)
1610   save_CFLAGS="$CFLAGS"
1611   CFLAGS="$CFLAGS -Wshorten-64-to-32"
1612   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
1613                     have_shorten64_flag=no)
1614   CFLAGS="$save_CFLAGS"
1616   case $host in
1617     *-*-openbsd* | *-*-bitrig*)
1618       # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
1619       # That's fine, except that the headers don't pass -Wredundant-decls.
1620       # Therefore, let's disable -Wsystem-headers when we're building
1621       # with maximal warnings on OpenBSD.
1622       CFLAGS="$CFLAGS -Wno-system-headers" ;;
1623   esac
1625   CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
1626   CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
1627   CFLAGS="$CFLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
1628   CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
1629   CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
1631   if test x$enable_gcc_warnings = xyes; then
1632     CFLAGS="$CFLAGS -Werror"
1633   fi
1635   # Disabled, so we can use mallinfo(): -Waggregate-return
1637   if test x$have_gcc4 = xyes ; then
1638     # These warnings break gcc 3.3.5 and work on gcc 4.0.2
1639     CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wold-style-definition"
1640   fi
1642   if test x$have_gcc42 = xyes ; then
1643     # These warnings break gcc 4.0.2 and work on gcc 4.2
1644     # XXXX020 See if any of these work with earlier versions.
1645     CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wstrict-overflow=1"
1647     # We used to use -Wstrict-overflow=5, but that breaks us heavily under 4.3.
1648   fi
1650   if test x$have_gcc42 = xyes && test x$have_clang = xno; then
1651     # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2
1652     CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init"
1653   fi
1655   if test x$have_gcc43 = xyes ; then
1656     # These warnings break gcc 4.2 and work on gcc 4.3
1657     # XXXX020 See if any of these work with earlier versions.
1658     CFLAGS="$CFLAGS -Wextra -Warray-bounds"
1659   fi
1661   if test x$have_gcc46 = xyes ; then
1662     # This warning was added in gcc 4.3, but it appears to generate
1663     # spurious warnings in gcc 4.4.  I don't know if it works in 4.5.
1664     CFLAGS="$CFLAGS -Wlogical-op"
1665   fi
1667   if test x$have_shorten64_flag = xyes ; then
1668     CFLAGS="$CFLAGS -Wshorten-64-to-32"
1669   fi
1673 ##This will break the world on some 64-bit architectures
1674 # CFLAGS="$CFLAGS -Winline"
1677 if test "$enable_coverage" = yes && test "$have_clang" = "no"; then
1678    case "$host_os" in
1679     darwin*)
1680       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.])
1681    esac
1684 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
1686 AC_CONFIG_FILES([
1687         Doxyfile
1688         Makefile
1689         contrib/dist/suse/tor.sh
1690         contrib/operator-tools/tor.logrotate
1691         contrib/dist/tor.sh
1692         contrib/dist/torctl
1693         contrib/dist/tor.service
1694         src/config/torrc.sample
1695         src/config/torrc.minimal
1698 if test x$asciidoc = xtrue && test "$ASCIIDOC" = "none" ; then
1699   regular_mans="doc/tor doc/tor-gencert doc/tor-resolve doc/torify"
1700   for file in $regular_mans ; do
1701     if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
1702       echo "==================================";
1703       echo;
1704       echo "Building Tor has failed since manpages cannot be built.";
1705       echo;
1706       echo "You need asciidoc installed to be able to build the manpages.";
1707       echo "To build without manpages, use the --disable-asciidoc argument";
1708       echo "when calling configure.";
1709       echo;
1710       echo "==================================";
1711       exit 1;
1712     fi
1713   done
1716 AC_OUTPUT
1718 if test -x /usr/bin/perl && test -x ./scripts/maint/updateVersions.pl ; then
1719   ./scripts/maint/updateVersions.pl