1 dnl Copyright (c) 2001-2004, Roger Dingledine
2 dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
3 dnl Copyright (c) 2007-2019, The Tor Project, Inc.
4 dnl See LICENSE for licensing information
7 AC_INIT([tor],[0.4.5.1-alpha-dev])
8 AC_CONFIG_SRCDIR([src/app/main/tor_main.c])
9 AC_CONFIG_MACRO_DIR([m4])
13 # DO NOT EDIT THIS DEFINITION BY HAND UNLESS YOU KNOW WHAT YOU'RE DOING.
15 # The update_versions.py script updates this definition when the
16 # version number changes. Tor uses it to make sure that it
17 # only shuts down for missing "required protocols" when those protocols
18 # are listed as required by a consensus after this date.
19 AC_DEFINE(APPROX_RELEASE_DATE, ["2020-11-01"], # for 0.4.5.1-alpha-dev
20 [Approximate date when this software was released. (Updated when the version changes.)])
22 # "foreign" means we don't follow GNU package layout standards
23 # "1.11" means we require automake version 1.11 or newer
24 # "subdir-objects" means put .o files in the same directory as the .c files
25 AM_INIT_AUTOMAKE([foreign 1.11 subdir-objects -Wall -Werror])
28 tor_incr_n_warnings() {
29 tor_ac_n_warnings=`expr $tor_ac_n_warnings + 1`
32 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
33 AC_CONFIG_HEADERS([orconfig.h])
35 AC_USE_SYSTEM_EXTENSIONS
39 if test "x$PKG_CONFIG" = "x" ; then
40 pkg_config_user_action="install pkg-config, and check the PKG_CONFIG_PATH environment variable"
41 AC_MSG_NOTICE([Some libraries need pkg-config, including systemd, nss, lzma, zstd, and custom mallocs.])
42 AC_MSG_NOTICE([To use those libraries, $pkg_config_user_action.])
44 pkg_config_user_action="check the PKG_CONFIG_PATH environment variable"
47 if test "x$PKG_CONFIG_PATH" = "x" && test "x$prefix" != "xNONE" && test "$host" != "$build"; then
48 export PKG_CONFIG_PATH=$prefix/lib/pkgconfig
49 AC_MSG_NOTICE([set PKG_CONFIG_PATH=$PKG_CONFIG_PATH to support cross-compiling])
52 AC_ARG_ENABLE(openbsd-malloc,
53 AS_HELP_STRING(--enable-openbsd-malloc, [use malloc code from OpenBSD. Linux only. Deprecated: see --with-malloc]))
54 AC_ARG_ENABLE(static-openssl,
55 AS_HELP_STRING(--enable-static-openssl, [link against a static openssl library. Requires --with-openssl-dir]))
56 AC_ARG_ENABLE(static-libevent,
57 AS_HELP_STRING(--enable-static-libevent, [link against a static libevent library. Requires --with-libevent-dir]))
58 AC_ARG_ENABLE(static-zlib,
59 AS_HELP_STRING(--enable-static-zlib, [link against a static zlib library. Requires --with-zlib-dir]))
60 AC_ARG_ENABLE(static-tor,
61 AS_HELP_STRING(--enable-static-tor, [create an entirely static Tor binary. Requires --with-openssl-dir and --with-libevent-dir and --with-zlib-dir]))
62 AC_ARG_ENABLE(unittests,
63 AS_HELP_STRING(--disable-unittests, [don't build unit tests for Tor. Risky!]))
64 AC_ARG_ENABLE(coverage,
65 AS_HELP_STRING(--enable-coverage, [enable coverage support in the unit-test build]))
66 AC_ARG_ENABLE(asserts-in-tests,
67 AS_HELP_STRING(--disable-asserts-in-tests, [disable tor_assert() calls in the unit tests, for branch coverage]))
68 AC_ARG_ENABLE(system-torrc,
69 AS_HELP_STRING(--disable-system-torrc, [don't look for a system-wide torrc file]))
70 AC_ARG_ENABLE(libfuzzer,
71 AS_HELP_STRING(--enable-libfuzzer, [build extra fuzzers based on 'libfuzzer']))
72 AC_ARG_ENABLE(oss-fuzz,
73 AS_HELP_STRING(--enable-oss-fuzz, [build extra fuzzers based on 'oss-fuzz' environment]))
74 AC_ARG_ENABLE(memory-sentinels,
75 AS_HELP_STRING(--disable-memory-sentinels, [disable code that tries to prevent some kinds of memory access bugs. For fuzzing only.]))
77 AS_HELP_STRING(--enable-rust, [enable rust integration]))
78 AC_ARG_ENABLE(cargo-online-mode,
79 AS_HELP_STRING(--enable-cargo-online-mode, [Allow cargo to make network requests to fetch crates. For builds with rust only.]))
80 AC_ARG_ENABLE(restart-debugging,
81 AS_HELP_STRING(--enable-restart-debugging, [Build Tor with support for debugging in-process restart. Developers only.]))
82 AC_ARG_ENABLE(zstd-advanced-apis,
83 AS_HELP_STRING(--disable-zstd-advanced-apis, [Build without support for zstd's "static-only" APIs.]))
85 AS_HELP_STRING(--enable-nss, [Use Mozilla's NSS TLS library. (EXPERIMENTAL)]))
87 AS_HELP_STRING(--enable-pic, [Build Tor's binaries as position-independent code, suitable to link as a library.]))
89 AC_ARG_ENABLE(missing-doc-warnings,
90 AS_HELP_STRING(--enable-missing-doc-warnings, [Tell doxygen to warn about missing documentation. Makes doxygen warnings nonfatal.]))
92 if test "$enable_missing_doc_warnings" = "yes"; then
93 DOXYGEN_FATAL_WARNINGS=NO
94 DOXYGEN_WARN_ON_MISSING=YES
95 elif test "$enable_fatal_warnings" = "yes"; then
96 # Fatal warnings from doxygen are nice, but not if we're warning about
97 # missing documentation.
98 DOXYGEN_FATAL_WARNINGS=YES
99 DOXYGEN_WARN_ON_MISSING=NO
101 DOXYGEN_FATAL_WARNINGS=NO
102 DOXYGEN_WARN_ON_MISSING=NO
104 AC_SUBST(DOXYGEN_FATAL_WARNINGS)
105 AC_SUBST(DOXYGEN_WARN_ON_MISSING)
107 if test "x$enable_coverage" != "xyes" -a "x$enable_asserts_in_tests" = "xno" ; then
108 AC_MSG_ERROR([Can't disable assertions outside of coverage build])
111 AM_CONDITIONAL(UNITTESTS_ENABLED, test "x$enable_unittests" != "xno")
112 AM_CONDITIONAL(COVERAGE_ENABLED, test "x$enable_coverage" = "xyes")
113 AM_CONDITIONAL(DISABLE_ASSERTS_IN_UNIT_TESTS, test "x$enable_asserts_in_tests" = "xno")
114 AM_CONDITIONAL(LIBFUZZER_ENABLED, test "x$enable_libfuzzer" = "xyes")
115 AM_CONDITIONAL(OSS_FUZZ_ENABLED, test "x$enable_oss_fuzz" = "xyes")
116 AM_CONDITIONAL(USE_RUST, test "x$enable_rust" = "xyes")
117 AM_CONDITIONAL(USE_NSS, test "x$enable_nss" = "xyes")
118 AM_CONDITIONAL(USE_OPENSSL, test "x$enable_nss" != "xyes")
120 if test "x$enable_nss" = "xyes"; then
121 AC_DEFINE(ENABLE_NSS, 1,
122 [Defined if we're building with NSS.])
124 AC_DEFINE(ENABLE_OPENSSL, 1,
125 [Defined if we're building with OpenSSL or LibreSSL])
128 if test "$enable_static_tor" = "yes"; then
129 enable_static_libevent="yes";
130 enable_static_openssl="yes";
131 enable_static_zlib="yes";
132 CFLAGS="$CFLAGS -static"
135 if test "$enable_system_torrc" = "no"; then
136 AC_DEFINE(DISABLE_SYSTEM_TORRC, 1,
137 [Defined if we're not going to look for a torrc in SYSCONF])
140 if test "$enable_memory_sentinels" = "no"; then
141 AC_DEFINE(DISABLE_MEMORY_SENTINELS, 1,
142 [Defined if we're turning off memory safety code to look for bugs])
145 AC_ARG_ENABLE(manpage,
146 AS_HELP_STRING(--disable-manpage, [Disable manpage generation.]))
148 AC_ARG_ENABLE(html-manual,
149 AS_HELP_STRING(--disable-html-manual, [Disable HTML documentation.]))
151 AC_ARG_ENABLE(asciidoc,
152 AS_HELP_STRING(--disable-asciidoc, [don't use asciidoc (disables building of manpages)]),
153 [case "${enableval}" in
154 "yes") asciidoc=true ;;
155 "no") asciidoc=false ;;
156 *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
157 esac], [asciidoc=true])
159 # systemd notify support
160 AC_ARG_ENABLE(systemd,
161 AS_HELP_STRING(--enable-systemd, [enable systemd notification support]),
162 [case "${enableval}" in
163 "yes") systemd=true ;;
164 "no") systemd=false ;;
165 * ) AC_MSG_ERROR(bad value for --enable-systemd) ;;
166 esac], [systemd=auto])
168 if test "$enable_restart_debugging" = "yes"; then
169 AC_DEFINE(ENABLE_RESTART_DEBUGGING, 1,
170 [Defined if we're building with support for in-process restart debugging.])
173 if test "$enable_zstd_advanced_apis" != "no"; then
174 AC_DEFINE(ENABLE_ZSTD_ADVANCED_APIS, 1,
175 [Defined if we're going to try to use zstd's "static-only" APIs.])
179 if test "x$enable_systemd" = "xno"; then
182 PKG_CHECK_MODULES(SYSTEMD,
186 if test "x$have_systemd" = "xno"; then
187 AC_MSG_NOTICE([Okay, checking for systemd a different way...])
188 PKG_CHECK_MODULES(SYSTEMD,
195 if test "x$have_systemd" = "xyes"; then
196 AC_DEFINE(HAVE_SYSTEMD,1,[Have systemd])
197 TOR_SYSTEMD_CFLAGS="${SYSTEMD_CFLAGS}"
198 TOR_SYSTEMD_LIBS="${SYSTEMD_LIBS}"
199 PKG_CHECK_MODULES(LIBSYSTEMD209, [libsystemd >= 209],
200 [AC_DEFINE(HAVE_SYSTEMD_209,1,[Have systemd v209 or greater])], [])
202 AC_SUBST(TOR_SYSTEMD_CFLAGS)
203 AC_SUBST(TOR_SYSTEMD_LIBS)
205 if test "x$enable_systemd" = "xyes" -a "x$have_systemd" != "xyes" ; then
206 AC_MSG_ERROR([Explicitly requested systemd support, but systemd not found, $pkg_config_user_action, or set SYSTEMD_CFLAGS and SYSTEMD_LIBS.])
211 AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
215 AC_ARG_ENABLE(gcc-warnings,
216 AS_HELP_STRING(--enable-gcc-warnings, [deprecated alias for enable-fatal-warnings]))
217 AC_ARG_ENABLE(fatal-warnings,
218 AS_HELP_STRING(--enable-fatal-warnings, [tell the compiler to treat all warnings as errors.]))
219 AC_ARG_ENABLE(gcc-warnings-advisory,
220 AS_HELP_STRING(--disable-gcc-warnings-advisory, [disable the regular verbose warnings]))
222 dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
223 AC_ARG_ENABLE(gcc-hardening,
224 AS_HELP_STRING(--disable-gcc-hardening, [disable compiler security checks]))
226 dnl Deprecated --enable-expensive-hardening but keep it for now for backward compat.
227 AC_ARG_ENABLE(expensive-hardening,
228 AS_HELP_STRING(--enable-expensive-hardening, [enable more fragile and expensive compiler hardening; makes Tor slower]))
229 AC_ARG_ENABLE(fragile-hardening,
230 AS_HELP_STRING(--enable-fragile-hardening, [enable more fragile and expensive compiler hardening; makes Tor slower]))
231 if test "x$enable_expensive_hardening" = "xyes" || test "x$enable_fragile_hardening" = "xyes"; then
232 fragile_hardening="yes"
233 AC_DEFINE(DEBUG_SMARTLIST, 1, [Enable smartlist debugging])
236 AC_ARG_ENABLE(all-bugs-are-fatal,
237 AS_HELP_STRING(--enable-all-bugs-are-fatal, [force all soft asserts in Tor codebase (tor_assert_nonfatal(), BUG(), etc.) to act as hard asserts (tor_assert() and equivalents); makes Tor fragile; only recommended for dev builds]))
239 if test "x$enable_all_bugs_are_fatal" = "xyes"; then
240 AC_DEFINE(ALL_BUGS_ARE_FATAL, 1, [All assert failures are fatal])
243 dnl Linker hardening options
244 dnl Currently these options are ELF specific - you can't use this with MacOSX
245 AC_ARG_ENABLE(linker-hardening,
246 AS_HELP_STRING(--disable-linker-hardening, [disable linker security fixups]))
248 AC_ARG_ENABLE(local-appdata,
249 AS_HELP_STRING(--enable-local-appdata, [default to host local application data paths on Windows]))
250 if test "$enable_local_appdata" = "yes"; then
251 AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
252 [Defined if we default to host local appdata paths on Windows])
255 AC_ARG_ENABLE(tool-name-check,
256 AS_HELP_STRING(--disable-tool-name-check, [check for sanely named toolchain when cross-compiling]))
258 AC_ARG_ENABLE(seccomp,
259 AS_HELP_STRING(--disable-seccomp, [do not attempt to use libseccomp]))
261 AC_ARG_ENABLE(libscrypt,
262 AS_HELP_STRING(--disable-libscrypt, [do not attempt to use libscrypt]))
264 dnl --- Tracing Options. ---
268 dnl LTTng instrumentation option.
269 AC_ARG_ENABLE(tracing-instrumentation-lttng,
270 AS_HELP_STRING([--enable-tracing-instrumentation-lttng],
271 [build with LTTng-UST instrumentation]))
272 AM_CONDITIONAL([USE_TRACING_INSTRUMENTATION_LTTNG],
273 [test "x$enable_tracing_instrumentation_lttng" = "xyes"])
275 if test "x$enable_tracing_instrumentation_lttng" = "xyes"; then
276 AC_CHECK_HEADERS([lttng/tracepoint.h], [],
277 [AC_MSG_ERROR([LTTng instrumentation headers not found.
278 On Debian, apt install liblttng-ust-dev"])], [])
279 AC_DEFINE([USE_TRACING_INSTRUMENTATION_LTTNG], [1], [Using LTTng instrumentation])
280 TOR_TRACE_LIBS="-llttng-ust -ldl"
284 dnl USDT instrumentation option.
285 AC_ARG_ENABLE(tracing-instrumentation-usdt,
286 AS_HELP_STRING([--enable-tracing-instrumentation-usdt],
287 [build with tracing USDT instrumentation]))
288 AM_CONDITIONAL([USE_TRACING_INSTRUMENTATION_USDT],
289 [test "x$enable_tracing_instrumentation_usdt" = "xyes"])
291 if test "x$enable_tracing_instrumentation_usdt" = "xyes"; then
292 AC_CHECK_HEADERS([sys/sdt.h], [],
293 [AC_MSG_ERROR([USDT instrumentation requires sys/sdt.h header.
294 On Debian, apt install systemtap-sdt-dev])], [])
295 AC_MSG_CHECKING([STAP_PROBEV()])
296 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
297 #define SDT_USE_VARIADIC
301 STAP_PROBEV(p, n, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
305 dnl LTTng generates USDT probes if the UST library was built with
306 dnl --with-sdt. There is unfortunately no way to check that so we always
307 dnl build the USDT probes even though LTTng instrumentation was requested.
308 AC_DEFINE([USE_TRACING_INSTRUMENTATION_USDT], [1], [Using USDT instrumentation])
312 AC_MSG_ERROR([USDT tracing support requires STAP_PROBEV()])
316 dnl Tracepoints event to debug logs.
317 AC_ARG_ENABLE(tracing-instrumentation-log-debug,
318 AS_HELP_STRING([--enable-tracing-instrumentation-log-debug],
319 [build with tracing event to debug log]),
320 AC_DEFINE([USE_TRACING_INSTRUMENTATION_LOG_DEBUG], [1],
321 [Tracepoints to log debug]), [])
322 AM_CONDITIONAL([USE_TRACING_INSTRUMENTATION_LOG_DEBUG],
323 [test "x$enable_tracing_instrumentation_log_debug" = "xyes"])
324 if test "x$enable_tracing_instrumentation_log_debug" = "xyes"; then
328 dnl Define that tracing is supported if any instrumentation is used.
329 AM_COND_IF([USE_TRACING_INSTRUMENTATION_LOG_DEBUG],
330 AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
331 AM_COND_IF([USE_TRACING_INSTRUMENTATION_USDT],
332 AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
333 AM_COND_IF([USE_TRACING_INSTRUMENTATION_LTTNG],
334 AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
335 AM_CONDITIONAL([USE_TRACING], [test "x$have_tracing" = x1 ])
337 dnl Finally, define the trace libs.
338 AC_SUBST([TOR_TRACE_LIBS])
340 dnl -- End Tracing Options. --
342 dnl Enable Android only features.
343 AC_ARG_ENABLE(android,
344 AS_HELP_STRING(--enable-android, [build with Android features enabled]))
345 AM_CONDITIONAL([USE_ANDROID], [test "x$enable_android" = "xyes"])
347 if test "x$enable_android" = "xyes"; then
348 AC_DEFINE([USE_ANDROID], [1], [Compile with Android specific features enabled])
353 dnl Tor modules options. These options are namespaced with --disable-module-XXX
357 m4_define(MODULES, relay dirauth dircache)
360 AC_ARG_ENABLE([module-relay],
361 AS_HELP_STRING([--disable-module-relay],
362 [Build tor without the Relay modules: tor can not run as a relay, bridge, or authority. Implies --disable-module-dirauth]))
363 AM_CONDITIONAL(BUILD_MODULE_RELAY, [test "x$enable_module_relay" != "xno"])
364 AM_COND_IF(BUILD_MODULE_RELAY,
365 AC_DEFINE([HAVE_MODULE_RELAY], [1],
366 [Compile with Relay feature support]))
368 dnl Dircache module. (This cannot be enabled or disabled independently of
369 dnl the relay module. It is not listed by --list-modules for this reason.)
370 AM_CONDITIONAL(BUILD_MODULE_DIRCACHE,
371 [test "x$enable_module_relay" != "xno"])
372 AM_COND_IF(BUILD_MODULE_DIRCACHE,
373 AC_DEFINE([HAVE_MODULE_DIRCACHE], [1],
374 [Compile with directory cache support]))
376 dnl Directory Authority module.
377 AC_ARG_ENABLE([module-dirauth],
378 AS_HELP_STRING([--disable-module-dirauth],
379 [Build tor without the Directory Authority module: tor can not run as a directory authority or bridge authority]))
380 AM_CONDITIONAL(BUILD_MODULE_DIRAUTH,[test "x$enable_module_dirauth" != "xno" && test "x$enable_module_relay" != "xno"])
381 AM_COND_IF(BUILD_MODULE_DIRAUTH,
382 AC_DEFINE([HAVE_MODULE_DIRAUTH], [1],
383 [Compile with Directory Authority feature support]))
385 dnl Helper variables.
386 TOR_MODULES_ALL_ENABLED=
387 AC_DEFUN([ADD_MODULE], [
388 MODULE=m4_toupper($1)
389 TOR_MODULES_ALL_ENABLED="${TOR_MODULES_ALL_ENABLED} -DHAVE_MODULE_${MODULE}=1"
391 m4_foreach_w([module], MODULES, [ADD_MODULE([module])])
392 AC_SUBST(TOR_MODULES_ALL_ENABLED)
394 dnl check for the correct "ar" when cross-compiling.
395 dnl (AM_PROG_AR was new in automake 1.11.2, which we do not yet require,
396 dnl so kludge up a replacement for the case where it isn't there yet.)
397 m4_ifdef([AM_PROG_AR],
399 [AN_MAKEVAR([AR], [AC_PROG_AR])
400 AN_PROGRAM([ar], [AC_PROG_AR])
401 AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [:])])
404 dnl Check whether the above macro has settled for a simply named tool even
405 dnl though we're cross compiling. We must do this before running AC_PROG_CC,
406 dnl because that will find any cc on the system, not only the cross-compiler,
407 dnl and then verify that a binary built with this compiler runs on the
408 dnl build system. It will then come to the false conclusion that we're not
410 if test "x$enable_tool_name_check" != "xno"; then
411 if test "x$ac_tool_warned" = "xyes"; then
412 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.)])
413 elif test "x$ac_ct_AR" != "x" -a "x$cross_compiling" = "xmaybe"; then
414 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.)])
424 AC_ARG_VAR([PERL], [path to Perl binary])
425 AC_CHECK_PROGS([PERL], [perl])
426 AM_CONDITIONAL(USE_PERL, [test "x$ac_cv_prog_PERL" != "x"])
428 dnl check for asciidoc and a2x
429 AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
430 AC_PATH_PROGS([A2X], [a2x a2x.py], none)
432 AM_CONDITIONAL(USE_ASCIIDOC, test "x$asciidoc" = "xtrue")
433 AM_CONDITIONAL(BUILD_MANPAGE, [test "x$enable_manpage" != "xno"])
434 AM_CONDITIONAL(BUILD_HTML_DOCS, [test "x$enable_html_manual" != "xno"])
439 AC_CACHE_CHECK([for Python 3], [tor_cv_PYTHON],
440 [AC_PATH_PROGS_FEATURE_CHECK([PYTHON], [ \
442 python3.8 python3.7 python3.6 python3.5 python3.4 \
444 [["$ac_path_PYTHON" -c 'import sys; sys.exit(sys.version_info[0]<3)' && tor_cv_PYTHON="$ac_path_PYTHON" ac_path_PYTHON_found=:]] )])
445 AC_SUBST([PYTHON], [$tor_cv_PYTHON])
447 PYTHON="$tor_cv_PYTHON"
449 if test "x$PYTHON" = "x"; then
451 AC_MSG_WARN([Python 3 unavailable; some tests will not be run.])
454 AM_CONDITIONAL(USEPYTHON, [test "x$PYTHON" != "x"])
456 dnl List all external rust crates we depend on here. Include the version
461 AC_SUBST(rust_crates)
463 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
464 AC_C_FLEXIBLE_ARRAY_MEMBER
466 dnl Maybe we've got an old autoconf...
467 AC_CACHE_CHECK([for flexible array members],
471 struct abc { int a; char b[]; };
473 struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
476 [tor_cv_c_flexarray=yes],
477 [tor_cv_c_flexarray=no])])
478 if test "$tor_cv_flexarray" = "yes"; then
479 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
481 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
485 AC_CACHE_CHECK([for working C99 mid-block declaration syntax],
488 [AC_LANG_PROGRAM([], [int x; x = 3; int y; y = 4 + x;])],
489 [tor_cv_c_c99_decl=yes],
490 [tor_cv_c_c99_decl=no] )])
491 if test "$tor_cv_c_c99_decl" != "yes"; then
492 AC_MSG_ERROR([Your compiler doesn't support c99 mid-block declarations. This is required as of Tor 0.2.6.x])
495 AC_CACHE_CHECK([for working C99 designated initializers],
496 tor_cv_c_c99_designated_init,
498 [AC_LANG_PROGRAM([struct s { int a; int b; };],
499 [[ struct s ss = { .b = 5, .a = 6 }; ]])],
500 [tor_cv_c_c99_designated_init=yes],
501 [tor_cv_c_c99_designated_init=no] )])
503 if test "$tor_cv_c_c99_designated_init" != "yes"; then
504 AC_MSG_ERROR([Your compiler doesn't support c99 designated initializers. This is required as of Tor 0.2.6.x])
507 saved_CFLAGS="$CFLAGS"
508 CFLAGS="$CFLAGS -Werror"
509 AC_CACHE_CHECK([for __attribute__((fallthrough))],
510 tor_cv_c_attr_fallthrough,
512 [AC_LANG_PROGRAM([extern int x; void fn(void) ;],
513 [[ switch (x) { case 1: fn(); __attribute__((fallthrough));
514 case 2: fn(); break; } ]])],
515 [tor_cv_c_attr_fallthrough=yes],
516 [tor_cv_c_attr_fallthrough=no] )])
517 CFLAGS="$saved_CFLAGS"
519 if test "$tor_cv_c_attr_fallthrough" = "yes"; then
520 AC_DEFINE(HAVE_ATTR_FALLTHROUGH, [1], [defined if we have the fallthrough attribute.])
524 AC_ARG_WITH(tor-user,
525 AS_HELP_STRING(--with-tor-user=NAME, [specify username for tor daemon]),
533 AC_ARG_WITH(tor-group,
534 AS_HELP_STRING(--with-tor-group=NAME, [specify group name for tor daemon]),
542 dnl If _WIN32 is defined and non-zero, we are building for win32
543 AC_MSG_CHECKING([for win32])
544 AC_RUN_IFELSE([AC_LANG_SOURCE([
545 int main(int c, char **v) {
556 bwin32=true; AC_MSG_RESULT([yes]),
557 bwin32=false; AC_MSG_RESULT([no]),
558 bwin32=cross; AC_MSG_RESULT([cross])
561 if test "$bwin32" = "cross"; then
562 AC_MSG_CHECKING([for win32 (cross)])
563 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
565 int main(int c, char **v) {return 0;}
568 int main(int c, char **v) {return x(y);}
571 bwin32=true; AC_MSG_RESULT([yes]),
572 bwin32=false; AC_MSG_RESULT([no]))
577 /* Defined to access windows functions and definitions for >=WinVista */
579 # define WINVER 0x0600
582 /* Defined to access _other_ windows functions and definitions for >=WinVista */
583 # ifndef _WIN32_WINNT
584 # define _WIN32_WINNT 0x0600
587 /* Defined to avoid including some windows headers as part of Windows.h */
588 # ifndef WIN32_LEAN_AND_MEAN
589 # define WIN32_LEAN_AND_MEAN 1
594 AM_CONDITIONAL(WIN32, test "x$bwin32" = "xtrue")
595 AM_CONDITIONAL(BUILD_NT_SERVICES, test "x$bwin32" = "xtrue")
596 AM_CONDITIONAL(BUILD_LIBTORRUNNER, test "x$bwin32" != "xtrue")
598 dnl Enable C99 when compiling with MIPSpro
599 AC_MSG_CHECKING([for MIPSpro compiler])
600 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
601 #if (defined(__sgi) && defined(_COMPILER_VERSION))
606 bmipspro=false; AC_MSG_RESULT(no),
607 bmipspro=true; AC_MSG_RESULT(yes))
609 if test "$bmipspro" = "true"; then
610 CFLAGS="$CFLAGS -c99"
615 AC_ARG_VAR([TOR_RUST_TARGET], [Rust target, must be specified when cross-compiling (HOST != BUILD). example: i686-pc-windows-gnu])
617 if test "x$enable_rust" = "xyes"; then
618 AC_ARG_VAR([RUSTC], [path to the rustc binary])
619 AC_CHECK_PROG([RUSTC], [rustc], [rustc],[no])
620 if test "x$RUSTC" = "xno"; then
621 AC_MSG_ERROR([rustc unavailable but rust integration requested.])
624 AC_ARG_VAR([CARGO], [path to the cargo binary])
625 AC_CHECK_PROG([CARGO], [cargo], [cargo],[no])
626 if test "x$CARGO" = "xno"; then
627 AC_MSG_ERROR([cargo unavailable but rust integration requested.])
630 AC_DEFINE([HAVE_RUST], 1, [have Rust])
631 if test "x$enable_fatal_warnings" = "xyes"; then
636 if test "x$enable_cargo_online_mode" = "xyes"; then
640 CARGO_ONLINE=--frozen
643 dnl When we're not allowed to touch the network, we need crate dependencies
644 dnl locally available.
645 AC_MSG_CHECKING([rust crate dependencies])
646 AC_ARG_VAR([TOR_RUST_DEPENDENCIES], [path to directory with local crate mirror])
647 if test "x$TOR_RUST_DEPENDENCIES" = "x"; then
648 TOR_RUST_DEPENDENCIES="${srcdir}/src/ext/rust/crates"
650 dnl Check whether the path exists before we try to cd into it.
651 if test ! -d "$TOR_RUST_DEPENDENCIES"; then
652 AC_MSG_ERROR([Rust dependency directory $TOR_RUST_DEPENDENCIES does not exist. Specify a dependency directory using the TOR_RUST_DEPENDENCIES variable or allow cargo to fetch crates using --enable-cargo-online-mode.])
655 dnl Make the path absolute, since we'll be using it from within a
657 TOR_RUST_DEPENDENCIES=$(cd "$TOR_RUST_DEPENDENCIES" ; pwd)
659 for dep in $rust_crates; do
660 if test ! -d "$TOR_RUST_DEPENDENCIES"/"$dep"; then
661 AC_MSG_ERROR([Failure to find rust dependency $TOR_RUST_DEPENDENCIES/$dep. Specify a dependency directory using the TOR_RUST_DEPENDENCIES variable or allow cargo to fetch crates using --enable-cargo-online-mode.])
665 if test "x$ERRORED" = "x"; then
670 dnl For now both MSVC and MinGW rust libraries will output static libs with
671 dnl the MSVC naming convention.
672 if test "$bwin32" = "true"; then
673 tor_rust_static_name=tor_rust.lib
675 tor_rust_static_name=libtor_rust.a
680 if test -n "$TOR_RUST_TARGET"; then
681 if test "$host" = "$build"; then
682 AC_MSG_ERROR([HOST = BUILD is invalid if TOR_RUST_TARGET is specified, see configure --help for more information.])
684 RUST_TARGET_PROP="target = '$TOR_RUST_TARGET'"
685 TOR_RUST_LIB_PATH="src/rust/target/$TOR_RUST_TARGET/release/$tor_rust_static_name"
687 if test "$host" != "$build"; then
688 AC_MSG_ERROR([TOR_RUST_TARGET must be specified when cross-compiling with Rust enabled.])
691 TOR_RUST_LIB_PATH="src/rust/target/release/$tor_rust_static_name"
694 AC_SUBST(RUST_TARGET_PROP)
695 AC_SUBST(TOR_RUST_LIB_PATH)
696 AC_SUBST(CARGO_ONLINE)
700 dnl Let's check the rustc version, too
701 AC_MSG_CHECKING([rust version])
702 RUSTC_VERSION=`$RUSTC --version`
703 RUSTC_VERSION_MAJOR=`$RUSTC --version | cut -d ' ' -f 2 | cut -d '.' -f 1`
704 RUSTC_VERSION_MINOR=`$RUSTC --version | cut -d ' ' -f 2 | cut -d '.' -f 2`
705 if test "x$RUSTC_VERSION_MAJOR" = "x" -o "x$RUSTC_VERSION_MINOR" = "x"; then
706 AC_MSG_ERROR([rustc version couldn't be identified])
708 if test "$RUSTC_VERSION_MAJOR" -lt 2 -a "$RUSTC_VERSION_MINOR" -lt 31; then
709 AC_MSG_ERROR([rustc must be at least version 1.31.0])
711 AC_MSG_RESULT([$RUSTC_VERSION])
714 AC_SEARCH_LIBS(socket, [socket network])
715 AC_SEARCH_LIBS(gethostbyname, [nsl])
716 AC_SEARCH_LIBS(dlopen, [dl])
717 AC_SEARCH_LIBS(inet_aton, [resolv])
718 AC_SEARCH_LIBS(backtrace, [execinfo])
720 AC_SEARCH_LIBS([clock_gettime], [rt])
721 if test "$LIBS" != "$saved_LIBS"; then
722 # Looks like we need -lrt for clock_gettime().
726 if test "$bwin32" = "false"; then
727 AC_SEARCH_LIBS(pthread_create, [pthread])
728 AC_SEARCH_LIBS(pthread_detach, [pthread])
731 AM_CONDITIONAL(THREADS_WIN32, test "$bwin32" = "true")
732 AM_CONDITIONAL(THREADS_PTHREADS, test "$bwin32" = "false")
736 RtlSecureZeroMemory \
740 backtrace_symbols_fd \
747 get_current_dir_name \
755 gnu_get_libc_version \
792 # Apple messed up when they added some functions: they
793 # forgot to decorate them with appropriate AVAILABLE_MAC_OS_VERSION
796 # We should only probe for these functions if we are sure that we
797 # are not targeting OS X 10.9 or earlier.
798 AC_MSG_CHECKING([for a pre-Yosemite OS X build target])
799 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
801 # include <AvailabilityMacros.h>
802 # ifndef MAC_OS_X_VERSION_10_10
803 # define MAC_OS_X_VERSION_10_10 101000
805 # if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
806 # if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
807 # error "Running on Mac OS X 10.9 or earlier"
812 [on_macos_pre_10_10=no ; AC_MSG_RESULT([no])],
813 [on_macos_pre_10_10=yes; AC_MSG_RESULT([yes])])
815 if test "$on_macos_pre_10_10" = "no"; then
817 mach_approximate_time \
821 # We should only probe for these functions if we are sure that we
822 # are not targeting OSX 10.11 or earlier.
823 AC_MSG_CHECKING([for a pre-Sierra OSX build target])
824 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
826 # include <AvailabilityMacros.h>
827 # ifndef MAC_OS_X_VERSION_10_12
828 # define MAC_OS_X_VERSION_10_12 101200
830 # if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
831 # if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
832 # error "Running on Mac OSX 10.11 or earlier"
837 [on_macos_pre_10_12=no ; AC_MSG_RESULT([no])],
838 [on_macos_pre_10_12=yes; AC_MSG_RESULT([yes])])
840 if test "$on_macos_pre_10_12" = "no"; then
847 if test "$bwin32" != "true"; then
848 AC_CHECK_HEADERS(pthread.h)
849 AC_CHECK_FUNCS(pthread_create)
850 AC_CHECK_FUNCS(pthread_condattr_setclock)
853 if test "$bwin32" = "true"; then
854 AC_CHECK_DECLS([SecureZeroMemory, _getwch], , , [
861 AM_CONDITIONAL(BUILD_READPASSPHRASE_C,
862 test "x$ac_cv_func_readpassphrase" = "xno" && test "$bwin32" = "false")
866 AC_MSG_CHECKING([whether free(NULL) works])
867 AC_RUN_IFELSE([AC_LANG_PROGRAM([
873 [free_null_ok=true; AC_MSG_RESULT(yes)],
874 [free_null_ok=false; AC_MSG_RESULT(no)],
875 [free_null_ok=cross; AC_MSG_RESULT(cross)])
877 if test "$free_null_ok" = "false"; then
878 AC_MSG_ERROR([Your libc implementation doesn't allow free(NULL), as required by C99.])
881 dnl ------------------------------------------------------
882 dnl Where do you live, libevent? And how do we call you?
884 if test "$bwin32" = "true"; then
885 TOR_LIB_WS32=-lws2_32
886 TOR_LIB_IPHLPAPI=-liphlpapi
887 TOR_LIB_SHLWAPI=-lshlwapi
888 # Some of the cargo-cults recommend -lwsock32 as well, but I don't
889 # think it's actually necessary.
891 TOR_LIB_USERENV=-luserenv
897 AC_SUBST(TOR_LIB_WS32)
898 AC_SUBST(TOR_LIB_GDI)
899 AC_SUBST(TOR_LIB_IPHLPAPI)
900 AC_SUBST(TOR_LIB_SHLWAPI)
901 AC_SUBST(TOR_LIB_USERENV)
903 tor_libevent_pkg_redhat="libevent"
904 tor_libevent_pkg_debian="libevent-dev"
905 tor_libevent_devpkg_redhat="libevent-devel"
906 tor_libevent_devpkg_debian="libevent-dev"
908 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
909 dnl linking for static builds.
910 STATIC_LIBEVENT_FLAGS=""
911 if test "$enable_static_libevent" = "yes"; then
912 if test "$have_rt" = "yes"; then
913 STATIC_LIBEVENT_FLAGS=" -lrt "
917 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
919 #include <winsock2.h>
921 #include <sys/time.h>
922 #include <sys/types.h>
923 #include <event2/event.h>], [
925 #include <winsock2.h>
928 struct event_base *event_base_new(void);
929 void event_base_free(struct event_base *);],
932 {WSADATA d; WSAStartup(0x101,&d); }
934 event_base_free(event_base_new());
935 ], [--with-libevent-dir], [/opt/libevent])
937 dnl Determine the incantation needed to link libevent.
939 save_LDFLAGS="$LDFLAGS"
940 save_CPPFLAGS="$CPPFLAGS"
942 LIBS="$STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $save_LIBS"
943 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
944 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
946 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
948 if test "$enable_static_libevent" = "yes"; then
949 if test "$tor_cv_library_libevent_dir" = "(system)"; then
950 AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
952 TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
955 if test "x$ac_cv_header_event2_event_h" = "xyes"; then
956 AC_SEARCH_LIBS(event_new, [event event_core], , AC_MSG_ERROR("libevent2 is installed but linking it failed while searching for event_new"))
957 AC_SEARCH_LIBS(evdns_base_new, [event event_extra], , AC_MSG_ERROR("libevent2 is installed but linking it failed while searching for evdns_base_new"))
959 if test "$ac_cv_search_event_new" != "none required"; then
960 TOR_LIBEVENT_LIBS="$ac_cv_search_event_new"
962 if test "$ac_cv_search_evdns_base_new" != "none required"; then
963 TOR_LIBEVENT_LIBS="$ac_cv_search_evdns_base_new $TOR_LIBEVENT_LIBS"
966 AC_MSG_ERROR("libevent2 is required but the headers could not be found")
970 dnl Now check for particular libevent functions.
971 AC_CHECK_FUNCS([evutil_secure_rng_set_urandom_device_file \
972 evutil_secure_rng_add_bytes \
973 evdns_base_get_nameserver_addr \
978 LDFLAGS="$save_LDFLAGS"
979 CPPFLAGS="$save_CPPFLAGS"
981 dnl Check that libevent is at least at version 2.0.10, the first stable
982 dnl release of its series
983 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
984 AC_MSG_CHECKING([whether Libevent is new enough])
985 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
986 #include <event2/event.h>
987 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000a00
993 ])], [ AC_MSG_RESULT([yes]) ],
994 [ AC_MSG_RESULT([no])
995 AC_MSG_ERROR([Libevent is not new enough. We require 2.0.10-stable or later]) ] )
998 LDFLAGS="$save_LDFLAGS"
999 CPPFLAGS="$save_CPPFLAGS"
1001 AC_SUBST(TOR_LIBEVENT_LIBS)
1003 dnl ------------------------------------------------------
1004 dnl Where do you live, libm?
1006 dnl On some platforms (Haiku/BeOS) the math library is
1007 dnl part of libroot. In which case don't link against lm
1010 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
1011 if test "$ac_cv_search_pow" != "none required"; then
1012 TOR_LIB_MATH="$ac_cv_search_pow"
1015 AC_SUBST(TOR_LIB_MATH)
1017 dnl ------------------------------------------------------
1018 dnl Hello, NSS. You're new around here.
1019 if test "x$enable_nss" = "xyes"; then
1020 PKG_CHECK_MODULES(NSS,
1023 [have_nss=no; AC_MSG_ERROR([You asked for NSS but I can't find it, $pkg_config_user_action, or set NSS_CFLAGS and NSS_LIBS.])])
1024 AC_SUBST(NSS_CFLAGS)
1028 dnl ------------------------------------------------------
1029 dnl Where do you live, openssl? And how do we call you?
1031 if test "x$enable_nss" != "xyes"; then
1033 tor_openssl_pkg_redhat="openssl"
1034 tor_openssl_pkg_debian="libssl-dev"
1035 tor_openssl_devpkg_redhat="openssl-devel"
1036 tor_openssl_devpkg_debian="libssl-dev"
1038 ALT_openssl_WITHVAL=""
1039 AC_ARG_WITH(ssl-dir,
1040 AS_HELP_STRING(--with-ssl-dir=PATH, [obsolete alias for --with-openssl-dir]),
1042 if test "x$withval" != "xno" && test "x$withval" != "x"; then
1043 ALT_openssl_WITHVAL="$withval"
1047 AC_MSG_NOTICE([Now, we'll look for OpenSSL >= 1.0.1])
1048 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI $TOR_LIB_WS32],
1049 [#include <openssl/ssl.h>
1050 char *getenv(const char *);],
1051 [struct ssl_cipher_st;
1052 unsigned SSL_CIPHER_get_id(const struct ssl_cipher_st *);
1053 char *getenv(const char *);],
1054 dnl This funny-looking test program calls getenv, so that the compiler
1055 dnl will neither make code that call SSL_CIPHER_get_id(NULL) [producing
1056 dnl a crash], nor optimize out the call to SSL_CIPHER_get_id().
1057 dnl We look for SSL_cipher_get_id() because it is present in
1058 dnl OpenSSL >=1.0.1, because it is not deprecated, and because Tor
1060 [if (getenv("THIS_SHOULDNT_BE_SET_X201803")) SSL_CIPHER_get_id((void *)0);], [],
1061 [/usr/local/opt/openssl /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /opt/openssl])
1063 if test "$enable_static_openssl" = "yes"; then
1064 if test "$tor_cv_library_openssl_dir" = "(system)"; then
1065 AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
1067 TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
1070 TOR_OPENSSL_LIBS="-lssl -lcrypto"
1072 AC_SUBST(TOR_OPENSSL_LIBS)
1074 dnl Now validate openssl, and check for particular openssl functions.
1076 save_LDFLAGS="$LDFLAGS"
1077 save_CPPFLAGS="$CPPFLAGS"
1078 LIBS="$TOR_OPENSSL_LIBS $LIBS"
1079 LDFLAGS="$TOR_LDFLAGS_openssl $LDFLAGS"
1080 CPPFLAGS="$TOR_CPPFLAGS_openssl $CPPFLAGS"
1082 dnl Tor currently uses a number of APIs that are deprecated in OpenSSL 3.0.0
1083 dnl and later. We want to migrate away from them, but that will be a lot of
1084 dnl work. (See ticket tor#40166.) For now, we disable the deprecation
1087 AC_MSG_CHECKING([for OpenSSL >= 3.0.0])
1088 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1089 #include <openssl/opensslv.h>
1090 #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER <= 0x30000000L
1091 #error "you_have_version_3"
1094 [ AC_MSG_RESULT([no]) ],
1095 [ AC_MSG_RESULT([yes]);
1096 AC_DEFINE(OPENSSL_SUPPRESS_DEPRECATED, 1, [disable openssl deprecated-function warnings]) ])
1098 AC_MSG_CHECKING([for OpenSSL < 1.0.1])
1099 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1100 #include <openssl/opensslv.h>
1101 #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1000100fL
1105 [ AC_MSG_RESULT([no]) ],
1106 [ AC_MSG_ERROR([OpenSSL is too old. We require 1.0.1 or later. You can specify a path to a newer one with --with-openssl-dir.]) ])
1108 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1109 #include <openssl/opensslv.h>
1110 #include <openssl/evp.h>
1111 #if defined(OPENSSL_NO_EC) || defined(OPENSSL_NO_ECDH) || defined(OPENSSL_NO_ECDSA)
1114 #if !defined(NID_X9_62_prime256v1) || !defined(NID_secp224r1)
1115 #error "curves unavailable"
1119 [ AC_MSG_ERROR([OpenSSL is built without full ECC support, including curves P256 and P224. You can specify a path to one with ECC support with --with-openssl-dir.]) ])
1121 dnl Let's see if we have a version mismatch between includes and libs.
1122 AC_MSG_CHECKING([for significant mismatch between openssl headers and libraries])
1124 AC_RUN_IFELSE([AC_LANG_SOURCE([AC_LANG_PROGRAM([[
1125 #include <openssl/opensslv.h>
1126 #include <openssl/crypto.h>
1128 /* Include major, minor, and fix, but not patch or status. */
1129 unsigned long mask = 0xfffff000;
1130 unsigned long linking = OpenSSL_version_num() & mask;
1131 unsigned long running = OPENSSL_VERSION_NUMBER & mask;
1132 return !(linking==running);
1133 ]])])], [openssl_ver_mismatch=no], [
1134 # This is a kludge to figure out whether compilation failed, or whether
1135 # running the program failed.
1136 if test "$ac_retval" == "1"; then
1137 openssl_ver_mismatch=inconclusive
1139 openssl_ver_mismatch=yes
1140 fi], [openssl_ver_mismatch=cross])
1141 AC_MSG_RESULT([$openssl_ver_mismatch])
1143 AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , ,
1144 [#include <openssl/ssl.h>
1147 dnl OpenSSL functions which we might not have. In theory, we could just
1148 dnl check the openssl version number, but in practice that gets pretty
1149 dnl confusing with LibreSSL, OpenSSL, and various distributions' patches
1152 ERR_load_KDF_strings \
1155 SSL_CTX_set1_groups_list \
1156 SSL_CTX_set_security_level \
1157 SSL_SESSION_get_master_key \
1158 SSL_get_client_ciphers \
1159 SSL_get_client_random \
1160 SSL_get_server_random \
1164 dnl Check if OpenSSL structures are opaque
1165 AC_CHECK_MEMBERS([SSL.state], , ,
1166 [#include <openssl/ssl.h>
1169 AC_CHECK_SIZEOF(SHA_CTX, , [AC_INCLUDES_DEFAULT()
1170 #include <openssl/sha.h>
1175 dnl We will someday make KECCAK_TINY optional, but for now we still need
1176 dnl it for SHAKE, since OpenSSL's SHAKE can't be squeezed more than
1177 dnl once. See comment in the definition of crypto_xof_t.
1179 dnl AM_CONDITIONAL(BUILD_KECCAK_TINY,
1180 dnl test "x$ac_cv_func_EVP_sha3_256" != "xyes")
1182 AM_CONDITIONAL(BUILD_KECCAK_TINY, true)
1184 dnl ======================================================================
1185 dnl Can we use KIST?
1187 dnl Define the set of checks for KIST scheduler support.
1188 AC_DEFUN([CHECK_KIST_SUPPORT],[
1189 dnl KIST needs struct tcp_info and for certain members to exist.
1191 [struct tcp_info.tcpi_unacked, struct tcp_info.tcpi_snd_mss],
1192 , ,[[#include <netinet/tcp.h>]])
1193 dnl KIST needs SIOCOUTQNSD to exist for an ioctl call.
1194 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1195 #include <linux/sockios.h>
1199 ])], have_siocoutqnsd=yes, have_siocoutqnsd=no)
1200 if test "x$have_siocoutqnsd" = "xyes"; then
1201 if test "x$ac_cv_member_struct_tcp_info_tcpi_unacked" = "xyes"; then
1202 if test "x$ac_cv_member_struct_tcp_info_tcpi_snd_mss" = "xyes"; then
1203 have_kist_support=yes
1208 dnl Now, trigger the check.
1210 AS_IF([test "x$have_kist_support" = "xyes"],
1211 [AC_DEFINE(HAVE_KIST_SUPPORT, 1, [Defined if KIST scheduler is supported
1213 [AC_MSG_NOTICE([KIST scheduler can't be used. Missing support.])])
1216 LDFLAGS="$save_LDFLAGS"
1217 CPPFLAGS="$save_CPPFLAGS"
1219 dnl ------------------------------------------------------
1220 dnl Where do you live, zlib? And how do we call you?
1222 tor_zlib_pkg_redhat="zlib"
1223 tor_zlib_pkg_debian="zlib1g"
1224 tor_zlib_devpkg_redhat="zlib-devel"
1225 tor_zlib_devpkg_debian="zlib1g-dev"
1227 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
1228 [#include <zlib.h>],
1229 [const char * zlibVersion(void);],
1230 [zlibVersion();], [--with-zlib-dir],
1233 if test "$enable_static_zlib" = "yes"; then
1234 if test "$tor_cv_library_zlib_dir" = "(system)"; then
1235 AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
1236 using --enable-static-zlib")
1238 TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
1243 AC_SUBST(TOR_ZLIB_LIBS)
1245 dnl ------------------------------------------------------
1246 dnl Where we do we find lzma?
1249 AS_HELP_STRING(--enable-lzma, [enable support for the LZMA compression scheme.]),
1250 [case "${enableval}" in
1253 * ) AC_MSG_ERROR(bad value for --enable-lzma) ;;
1254 esac], [enable_lzma=auto])
1256 if test "x$enable_lzma" = "xno"; then
1259 PKG_CHECK_MODULES([LZMA],
1264 if test "x$have_lzma" = "xno" ; then
1266 AC_MSG_WARN([Unable to find liblzma, $pkg_config_user_action, or set LZMA_CFLAGS and LZMA_LIBS.])
1270 if test "x$have_lzma" = "xyes"; then
1271 AC_DEFINE(HAVE_LZMA,1,[Have LZMA])
1272 TOR_LZMA_CFLAGS="${LZMA_CFLAGS}"
1273 TOR_LZMA_LIBS="${LZMA_LIBS}"
1275 AC_SUBST(TOR_LZMA_CFLAGS)
1276 AC_SUBST(TOR_LZMA_LIBS)
1278 dnl ------------------------------------------------------
1279 dnl Where we do we find zstd?
1282 AS_HELP_STRING(--enable-zstd, [enable support for the Zstandard compression scheme.]),
1283 [case "${enableval}" in
1286 * ) AC_MSG_ERROR(bad value for --enable-zstd) ;;
1287 esac], [enable_zstd=auto])
1289 if test "x$enable_zstd" = "xno"; then
1292 PKG_CHECK_MODULES([ZSTD],
1297 if test "x$have_zstd" = "xno" ; then
1299 AC_MSG_WARN([Unable to find libzstd, $pkg_config_user_action, or set ZSTD_CFLAGS and ZSTD_LIBS.])
1303 if test "x$have_zstd" = "xyes"; then
1304 AC_DEFINE(HAVE_ZSTD,1,[Have Zstd])
1305 TOR_ZSTD_CFLAGS="${ZSTD_CFLAGS}"
1306 TOR_ZSTD_LIBS="${ZSTD_LIBS}"
1308 dnl now check for zstd functions
1310 save_CFLAGS="$CFLAGS"
1311 LIBS="$LIBS $ZSTD_LIBS"
1312 CFLAGS="$CFLAGS $ZSTD_CFLAGS"
1313 AC_CHECK_FUNCS(ZSTD_estimateCStreamSize \
1314 ZSTD_estimateDCtxSize)
1316 CFLAGS="$save_CFLAGS"
1318 AC_SUBST(TOR_ZSTD_CFLAGS)
1319 AC_SUBST(TOR_ZSTD_LIBS)
1321 dnl ----------------------------------------------------------------------
1322 dnl Check if libcap is available for capabilities.
1324 tor_cap_pkg_debian="libcap2"
1325 tor_cap_pkg_redhat="libcap"
1326 tor_cap_devpkg_debian="libcap-dev"
1327 tor_cap_devpkg_redhat="libcap-devel"
1329 AC_CHECK_LIB([cap], [cap_init], [],
1330 AC_MSG_NOTICE([Libcap was not found. Capabilities will not be usable.])
1332 AC_CHECK_FUNCS(cap_set_proc)
1334 dnl ---------------------------------------------------------------------
1335 dnl Now that we know about our major libraries, we can check for compiler
1336 dnl and linker hardening options. We need to do this with the libraries known,
1337 dnl since sometimes the linker will like an option but not be willing to
1338 dnl use it with a build of a library.
1340 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
1341 all_libs_for_check="$TOR_ZLIB_LIBS $TOR_LIB_MATH $TOR_LIBEVENT_LIBS $TOR_OPENSSL_LIBS $TOR_SYSTEMD_LIBS $TOR_LIB_WS32 $TOR_LIB_GDI $TOR_LIB_USERENV $TOR_CAP_LIBS"
1349 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1350 #if !defined(__clang__)
1352 #endif])], have_clang=yes, have_clang=no)
1354 if test "x$enable_pic" = "xyes"; then
1355 TOR_CHECK_CFLAGS(-fPIC)
1358 if test "x$enable_gcc_hardening" != "xno"; then
1359 CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
1360 if test "x$have_clang" = "xyes"; then
1361 TOR_CHECK_CFLAGS(-Qunused-arguments)
1363 TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
1364 AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
1365 AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
1366 m4_ifdef([AS_VAR_IF],[
1367 AS_VAR_IF(can_compile, [yes],
1368 AS_VAR_IF(can_link, [yes],
1370 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.)]))
1372 AS_VAR_POPDEF([can_link])
1373 AS_VAR_POPDEF([can_compile])
1374 TOR_CHECK_CFLAGS(-Wstack-protector)
1375 TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
1376 if test "$bwin32" = "false" && test "$enable_libfuzzer" != "yes" && test "$enable_oss_fuzz" != "yes"; then
1377 if test "$enable_pic" != "yes"; then
1378 # If we have already enabled -fPIC, then we don't also need to
1379 # compile with -fPIE...
1380 TOR_CHECK_CFLAGS(-fPIE)
1382 # ... but we want to link our executables with -pie in any case, since
1383 # they're executables, not a library.
1384 TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
1386 TOR_TRY_COMPILE_WITH_CFLAGS(-fwrapv, also_link, CFLAGS_FWRAPV="-fwrapv", true)
1388 AC_MSG_CHECKING([whether we can run hardened binaries])
1389 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
1390 [AC_MSG_RESULT([yes])],
1391 [AC_MSG_RESULT([no])
1393 We can link with compiler hardening options, but we can't run with them.
1394 That's a bad sign! If you must, you can pass --disable-gcc-hardening to
1395 configure, but it would be better to figure out what the underlying problem
1397 [AC_MSG_RESULT([cross])])
1400 if test "$fragile_hardening" = "yes"; then
1401 TOR_TRY_COMPILE_WITH_CFLAGS(-ftrapv, also_link, CFLAGS_FTRAPV="-ftrapv", true)
1402 if test "$tor_cv_cflags__ftrapv" = "yes" && test "$tor_can_link__ftrapv" != "yes"; then
1404 AC_MSG_WARN([The compiler supports -ftrapv, but for some reason I was not able to link with -ftrapv. Are you missing run-time support? Run-time hardening will not work as well as it should.])
1407 if test "$tor_cv_cflags__ftrapv" != "yes"; then
1408 AC_MSG_ERROR([You requested fragile hardening, but the compiler does not seem to support -ftrapv.])
1411 TOR_TRY_COMPILE_WITH_CFLAGS([-fsanitize=address], also_link, CFLAGS_ASAN="-fsanitize=address", true)
1412 if test "$tor_cv_cflags__fsanitize_address" = "yes" && test "$tor_can_link__fsanitize_address" != "yes"; then
1413 AC_MSG_ERROR([The compiler supports -fsanitize=address, but for some reason I was not able to link when using it. Are you missing run-time support? With GCC you need libubsan.*, and with Clang you need libclang_rt.ubsan*])
1416 TOR_TRY_COMPILE_WITH_CFLAGS([-fsanitize=undefined], also_link, CFLAGS_UBSAN="-fsanitize=undefined", true)
1417 if test "$tor_cv_cflags__fsanitize_address" = "yes" && test "$tor_can_link__fsanitize_address" != "yes"; then
1418 AC_MSG_ERROR([The compiler supports -fsanitize=undefined, but for some reason I was not able to link when using it. Are you missing run-time support? With GCC you need libasan.*, and with Clang you need libclang_rt.ubsan*])
1421 TOR_TRY_COMPILE_WITH_CFLAGS([-fno-sanitize=float-divide-by-zero], also_link, CFLAGS_UBSAN="-fno-sanitize=float-divide-by-zero", true)
1422 if test "$tor_cv_cflags__fno_sanitize_float_divide_by_zero" = "yes" && test "$tor_can_link__fno_sanitize_float_divide_by_zero" != "yes"; then
1423 AC_MSG_ERROR([The compiler supports -fno-sanitize=float-divide-by-zero, but for some reason I was not able to link when using it. Are you missing run-time support? With GCC you need libasan.*, and with Clang you need libclang_rt.ubsan*])
1426 TOR_CHECK_CFLAGS([-fno-omit-frame-pointer])
1429 dnl Find the correct libraries to add in order to use the sanitizers.
1431 dnl When building Rust, Cargo will run the linker with the -nodefaultlibs
1432 dnl option, which will prevent the compiler from linking the sanitizer
1433 dnl libraries it needs. We need to specify them manually.
1435 dnl What's more, we need to specify them in a linker script rather than
1436 dnl from build.rs: these options aren't allowed in the cargo:rustc-flags
1438 RUST_LINKER_OPTIONS=""
1439 if test "x$have_clang" = "xyes"; then
1440 if test "x$CFLAGS_ASAN" != "x"; then
1441 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_ASAN -Cdefault-linker-libraries"
1443 if test "x$CFLAGS_UBSAN" != "x"; then
1444 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_UBSAN -Cdefault-linker-libraries"
1447 if test "x$CFLAGS_ASAN" != "x"; then
1448 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=address -Cdefault-linker-libraries"
1450 if test "x$CFLAGS_UBSAN" != "x"; then
1451 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=undefined -Cdefault-linker-libraries"
1454 AC_SUBST(RUST_LINKER_OPTIONS)
1456 CFLAGS_BUGTRAP="$CFLAGS_FTRAPV $CFLAGS_ASAN $CFLAGS_UBSAN"
1457 CFLAGS_CONSTTIME="$CFLAGS_FWRAPV"
1459 mulodi_fixes_ftrapv=no
1460 if test "$have_clang" = "yes"; then
1461 saved_CFLAGS="$CFLAGS"
1462 CFLAGS="$CFLAGS $CFLAGS_FTRAPV"
1463 AC_MSG_CHECKING([whether clang -ftrapv can link a 64-bit int multiply])
1468 int main(int argc, char **argv)
1470 int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
1471 * (int64_t)atoi(argv[3]);
1474 [ftrapv_can_link=yes; AC_MSG_RESULT([yes])],
1475 [ftrapv_can_link=no; AC_MSG_RESULT([no])])
1476 if test "$ftrapv_can_link" = "no"; then
1477 AC_MSG_CHECKING([whether defining __mulodi4 fixes that])
1482 int64_t __mulodi4(int64_t a, int64_t b, int *overflow) {
1486 int main(int argc, char **argv)
1488 int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
1489 * (int64_t)atoi(argv[3]);
1492 [mulodi_fixes_ftrapv=yes; AC_MSG_RESULT([yes])],
1493 [mulodi_fixes_ftrapv=no; AC_MSG_RESULT([no])])
1495 CFLAGS="$saved_CFLAGS"
1498 AM_CONDITIONAL(ADD_MULODI4, test "$mulodi_fixes_ftrapv" = "yes")
1500 dnl These cflags add bunches of branches, and we haven't been able to
1501 dnl persuade ourselves that they're suitable for code that needs to be
1503 AC_SUBST(CFLAGS_BUGTRAP)
1504 dnl These cflags are variant ones suitable for code that needs to be
1506 AC_SUBST(CFLAGS_CONSTTIME)
1508 if test "x$enable_linker_hardening" != "xno"; then
1509 TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
1512 # For backtrace support
1513 TOR_CHECK_LDFLAGS(-rdynamic)
1515 dnl ------------------------------------------------------
1516 dnl Now see if we have a -fomit-frame-pointer compiler option.
1518 saved_CFLAGS="$CFLAGS"
1519 TOR_CHECK_CFLAGS(-fomit-frame-pointer)
1520 F_OMIT_FRAME_POINTER=''
1521 if test "$saved_CFLAGS" != "$CFLAGS"; then
1522 if test "$fragile_hardening" = "yes"; then
1523 F_OMIT_FRAME_POINTER='-fomit-frame-pointer'
1526 CFLAGS="$saved_CFLAGS"
1527 AC_SUBST(F_OMIT_FRAME_POINTER)
1529 dnl ------------------------------------------------------
1530 dnl If we are adding -fomit-frame-pointer (or if the compiler's doing it
1531 dnl for us, as GCC 4.6 and later do at many optimization levels), then
1532 dnl we should try to add -fasynchronous-unwind-tables so that our backtrace
1534 TOR_CHECK_CFLAGS(-fasynchronous-unwind-tables)
1536 dnl ============================================================
1537 dnl Check for libseccomp
1539 if test "x$enable_seccomp" != "xno"; then
1540 AC_CHECK_HEADERS([seccomp.h])
1541 AC_SEARCH_LIBS(seccomp_init, [seccomp])
1544 dnl ============================================================
1545 dnl Check for libscrypt
1547 if test "x$enable_libscrypt" != "xno"; then
1548 AC_CHECK_HEADERS([libscrypt.h])
1549 AC_SEARCH_LIBS(libscrypt_scrypt, [scrypt])
1550 AC_CHECK_FUNCS([libscrypt_scrypt])
1553 dnl ============================================================
1554 dnl We need an implementation of curve25519.
1556 dnl set these defaults.
1557 build_curve25519_donna=no
1558 build_curve25519_donna_c64=no
1559 use_curve25519_donna=no
1560 use_curve25519_nacl=no
1563 dnl The best choice is using curve25519-donna-c64, but that requires
1565 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
1566 tor_cv_can_use_curve25519_donna_c64,
1568 [AC_LANG_PROGRAM([dnl
1570 typedef unsigned uint128_t __attribute__((mode(TI)));
1571 int func(uint64_t a, uint64_t b) {
1572 uint128_t c = ((uint128_t)a) * b;
1573 int ok = ((uint64_t)(c>>96)) == 522859 &&
1574 (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
1575 (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
1576 (((uint64_t)(c))&0xffffffffL) == 0;
1580 int ok = func( ((uint64_t)2000000000) * 1000000000,
1581 ((uint64_t)1234567890) << 24);
1584 [tor_cv_can_use_curve25519_donna_c64=yes],
1585 [tor_cv_can_use_curve25519_donna_c64=no],
1587 [AC_LANG_PROGRAM([dnl
1589 typedef unsigned uint128_t __attribute__((mode(TI)));
1590 int func(uint64_t a, uint64_t b) {
1591 uint128_t c = ((uint128_t)a) * b;
1592 int ok = ((uint64_t)(c>>96)) == 522859 &&
1593 (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
1594 (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
1595 (((uint64_t)(c))&0xffffffffL) == 0;
1599 int ok = func( ((uint64_t)2000000000) * 1000000000,
1600 ((uint64_t)1234567890) << 24);
1603 [tor_cv_can_use_curve25519_donna_c64=cross],
1604 [tor_cv_can_use_curve25519_donna_c64=no])])])
1606 AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
1607 nacl/crypto_scalarmult_curve25519.h])
1609 AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
1610 tor_cv_can_use_curve25519_nacl,
1611 [tor_saved_LIBS="$LIBS"
1614 [AC_LANG_PROGRAM([dnl
1615 #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
1616 #include <crypto_scalarmult_curve25519.h>
1617 #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
1618 #include <nacl/crypto_scalarmult_curve25519.h>
1620 #ifdef crypto_scalarmult_curve25519_ref_BYTES
1621 #error Hey, this is the reference implementation! That's not fast.
1624 unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
1625 ])], [tor_cv_can_use_curve25519_nacl=yes],
1626 [tor_cv_can_use_curve25519_nacl=no])
1627 LIBS="$tor_saved_LIBS" ])
1629 dnl Okay, now we need to figure out which one to actually use. Fall back
1630 dnl to curve25519-donna.c
1632 if test "x$tor_cv_can_use_curve25519_donna_c64" != "xno"; then
1633 build_curve25519_donna_c64=yes
1634 use_curve25519_donna=yes
1635 elif test "x$tor_cv_can_use_curve25519_nacl" = "xyes"; then
1636 use_curve25519_nacl=yes
1637 CURVE25519_LIBS=-lnacl
1639 build_curve25519_donna=yes
1640 use_curve25519_donna=yes
1643 if test "x$use_curve25519_donna" = "xyes"; then
1644 AC_DEFINE(USE_CURVE25519_DONNA, 1,
1645 [Defined if we should use an internal curve25519_donna{,_c64} implementation])
1647 if test "x$use_curve25519_nacl" = "xyes"; then
1648 AC_DEFINE(USE_CURVE25519_NACL, 1,
1649 [Defined if we should use a curve25519 from nacl])
1651 AM_CONDITIONAL(BUILD_CURVE25519_DONNA,
1652 test "x$build_curve25519_donna" = "xyes")
1653 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64,
1654 test "x$build_curve25519_donna_c64" = "xyes")
1655 AC_SUBST(CURVE25519_LIBS)
1657 dnl Make sure to enable support for large off_t if available.
1660 AC_CHECK_HEADERS([errno.h \
1674 gnu/libc-version.h \
1712 AC_CHECK_HEADERS(sys/param.h)
1714 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
1715 [#ifdef HAVE_SYS_TYPES_H
1716 #include <sys/types.h>
1718 #ifdef HAVE_SYS_SOCKET_H
1719 #include <sys/socket.h>
1721 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
1722 [#ifdef HAVE_SYS_TYPES_H
1723 #include <sys/types.h>
1725 #ifdef HAVE_SYS_SOCKET_H
1726 #include <sys/socket.h>
1728 #ifdef HAVE_NET_IF_H
1731 #ifdef HAVE_NETINET_IN_H
1732 #include <netinet/in.h>
1735 AC_CHECK_HEADERS(linux/if.h,[],[],
1737 #ifdef HAVE_SYS_SOCKET_H
1738 #include <sys/socket.h>
1742 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
1743 linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
1744 [#ifdef HAVE_SYS_TYPES_H
1745 #include <sys/types.h>
1747 #ifdef HAVE_SYS_SOCKET_H
1748 #include <sys/socket.h>
1750 #ifdef HAVE_LIMITS_H
1753 #ifdef HAVE_LINUX_TYPES_H
1754 #include <linux/types.h>
1756 #ifdef HAVE_NETINET_IN6_H
1757 #include <netinet/in6.h>
1759 #ifdef HAVE_NETINET_IN_H
1760 #include <netinet/in.h>
1763 AC_CHECK_HEADERS(linux/netfilter_ipv6/ip6_tables.h,
1764 linux_netfilter_ipv6_ip6_tables=1, linux_netfilter_ipv6_ip6_tables=0,
1765 [#ifdef HAVE_SYS_TYPES_H
1766 #include <sys/types.h>
1768 #ifdef HAVE_SYS_SOCKET_H
1769 #include <sys/socket.h>
1771 #ifdef HAVE_LIMITS_H
1774 #ifdef HAVE_LINUX_TYPES_H
1775 #include <linux/types.h>
1777 #ifdef HAVE_NETINET_IN6_H
1778 #include <netinet/in6.h>
1780 #ifdef HAVE_NETINET_IN_H
1781 #include <netinet/in.h>
1783 #ifdef HAVE_LINUX_IF_H
1784 #include <linux/if.h>
1788 if test "x$net_if_found" = "x1" && test "x$net_pfvar_found" = "x1"; then
1791 if test "x$linux_netfilter_ipv4" = "x1"; then
1794 if test "x$linux_netfilter_ipv6_ip6_tables" = "x1"; then
1797 if test "x$transparent_ok" = "x1"; then
1798 AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
1800 AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
1803 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
1804 [#ifdef HAVE_SYS_TYPES_H
1805 #include <sys/types.h>
1807 #ifdef HAVE_SYS_TIME_H
1808 #include <sys/time.h>
1811 AC_CHECK_SIZEOF(char)
1812 AC_CHECK_SIZEOF(short)
1813 AC_CHECK_SIZEOF(int)
1814 AC_CHECK_SIZEOF(unsigned int)
1815 AC_CHECK_SIZEOF(long)
1816 AC_CHECK_SIZEOF(long long)
1817 AC_CHECK_SIZEOF(__int64)
1818 AC_CHECK_SIZEOF(void *)
1819 AC_CHECK_SIZEOF(time_t)
1820 AC_CHECK_SIZEOF(size_t)
1821 AC_CHECK_SIZEOF(pid_t)
1823 AC_CHECK_TYPES([uint, u_char, ssize_t])
1825 AC_PC_FROM_UCONTEXT([:])
1827 dnl used to include sockaddr_storage, but everybody has that.
1828 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
1829 [#ifdef HAVE_SYS_TYPES_H
1830 #include <sys/types.h>
1832 #ifdef HAVE_NETINET_IN_H
1833 #include <netinet/in.h>
1835 #ifdef HAVE_NETINET_IN6_H
1836 #include <netinet/in6.h>
1838 #ifdef HAVE_SYS_SOCKET_H
1839 #include <sys/socket.h>
1842 #define _WIN32_WINNT 0x0501
1843 #define WIN32_LEAN_AND_MEAN
1844 #include <winsock2.h>
1845 #include <ws2tcpip.h>
1848 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
1849 [#ifdef HAVE_SYS_TYPES_H
1850 #include <sys/types.h>
1852 #ifdef HAVE_NETINET_IN_H
1853 #include <netinet/in.h>
1855 #ifdef HAVE_NETINET_IN6_H
1856 #include <netinet/in6.h>
1858 #ifdef HAVE_SYS_SOCKET_H
1859 #include <sys/socket.h>
1862 #define _WIN32_WINNT 0x0501
1863 #define WIN32_LEAN_AND_MEAN
1864 #include <winsock2.h>
1865 #include <ws2tcpip.h>
1869 AC_CHECK_TYPES([rlim_t], , ,
1870 [#ifdef HAVE_SYS_TYPES_H
1871 #include <sys/types.h>
1873 #ifdef HAVE_SYS_TIME_H
1874 #include <sys/time.h>
1876 #ifdef HAVE_SYS_RESOURCE_H
1877 #include <sys/resource.h>
1881 AX_CHECK_SIGN([time_t],
1884 #ifdef HAVE_SYS_TYPES_H
1885 #include <sys/types.h>
1887 #ifdef HAVE_SYS_TIME_H
1888 #include <sys/time.h>
1895 if test "$ax_cv_decl_time_t_signed" = "no"; then
1896 AC_MSG_ERROR([You have an unsigned time_t; Tor does not support that. Please tell the Tor developers about your interesting platform.])
1899 AX_CHECK_SIGN([size_t],
1900 [ tor_cv_size_t_signed=yes ],
1901 [ tor_cv_size_t_signed=no ], [
1902 #ifdef HAVE_SYS_TYPES_H
1903 #include <sys/types.h>
1907 if test "$ax_cv_decl_size_t_signed" = "yes"; then
1908 AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
1911 AX_CHECK_SIGN([enum always],
1912 [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
1914 enum always { AAA, BBB, CCC };
1917 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
1918 #ifdef HAVE_SYS_SOCKET_H
1919 #include <sys/socket.h>
1923 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1925 AC_CHECK_SIZEOF(cell_t)
1927 # Let's see if stdatomic works. (There are some debian clangs that screw it
1928 # up; see Tor bug #26779 and debian bug 903709.)
1929 AC_CACHE_CHECK([whether C11 stdatomic.h actually works],
1930 tor_cv_stdatomic_works,
1931 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1932 #include <stdatomic.h>
1933 struct x { atomic_size_t y; };
1934 void try_atomic_init(struct x *xx)
1936 atomic_init(&xx->y, 99);
1937 atomic_fetch_add(&xx->y, 1);
1939 ]])], [tor_cv_stdatomic_works=yes], [tor_cv_stdatomic_works=no])])
1941 if test "$tor_cv_stdatomic_works" = "yes"; then
1942 AC_DEFINE(STDATOMIC_WORKS, 1, [Set to 1 if we can compile a simple stdatomic example.])
1943 elif test "$ac_cv_header_stdatomic_h" = "yes"; then
1945 AC_MSG_WARN([Your compiler provides the stdatomic.h header, but it doesn't seem to work. I'll pretend it isn't there. If you are using Clang on Debian, maybe this is because of https://bugs.debian.org/903709 ])
1948 # Now make sure that NULL can be represented as zero bytes.
1949 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1950 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1951 [[#include <stdlib.h>
1954 #ifdef HAVE_STDDEF_H
1957 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1958 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1959 [tor_cv_null_is_zero=yes],
1960 [tor_cv_null_is_zero=no],
1961 [tor_cv_null_is_zero=cross])])
1963 if test "$tor_cv_null_is_zero" = "cross"; then
1964 # Cross-compiling; let's hope that the target isn't raving mad.
1965 AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
1968 if test "$tor_cv_null_is_zero" != "no"; then
1969 AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1970 [Define to 1 iff memset(0) sets pointers to NULL])
1973 AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
1974 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1975 [[#include <stdlib.h>
1978 #ifdef HAVE_STDDEF_H
1981 int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
1982 return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
1983 [tor_cv_dbl0_is_zero=yes],
1984 [tor_cv_dbl0_is_zero=no],
1985 [tor_cv_dbl0_is_zero=cross])])
1987 if test "$tor_cv_dbl0_is_zero" = "cross"; then
1988 # Cross-compiling; let's hope that the target isn't raving mad.
1989 AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
1992 if test "$tor_cv_dbl0_is_zero" != "no"; then
1993 AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
1994 [Define to 1 iff memset(0) sets doubles to 0.0])
1997 # And what happens when we malloc zero?
1998 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
1999 [AC_RUN_IFELSE([AC_LANG_SOURCE(
2000 [[#include <stdlib.h>
2003 #ifdef HAVE_STDDEF_H
2006 int main () { return malloc(0)?0:1; }]])],
2007 [tor_cv_malloc_zero_works=yes],
2008 [tor_cv_malloc_zero_works=no],
2009 [tor_cv_malloc_zero_works=cross])])
2011 if test "$tor_cv_malloc_zero_works" = "cross"; then
2012 # Cross-compiling; let's hope that the target isn't raving mad.
2013 AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
2016 if test "$tor_cv_malloc_zero_works" = "yes"; then
2017 AC_DEFINE([MALLOC_ZERO_WORKS], 1,
2018 [Define to 1 iff malloc(0) returns a pointer])
2021 # whether we seem to be in a 2s-complement world.
2022 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
2023 [AC_RUN_IFELSE([AC_LANG_SOURCE(
2024 [[int main () { int problem = ((-99) != (~99)+1);
2025 return problem ? 1 : 0; }]])],
2026 [tor_cv_twos_complement=yes],
2027 [tor_cv_twos_complement=no],
2028 [tor_cv_twos_complement=cross])])
2030 if test "$tor_cv_twos_complement" = "cross"; then
2031 # Cross-compiling; let's hope that the target isn't raving mad.
2032 AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
2035 if test "$tor_cv_twos_complement" != "no"; then
2036 AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
2037 [Define to 1 iff we represent negative integers with
2041 # What does shifting a negative value do?
2042 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
2043 [AC_RUN_IFELSE([AC_LANG_SOURCE(
2044 [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
2045 [tor_cv_sign_extend=yes],
2046 [tor_cv_sign_extend=no],
2047 [tor_cv_sign_extend=cross])])
2049 if test "$tor_cv_sign_extend" = "cross"; then
2050 # Cross-compiling; let's hope that the target isn't raving mad.
2051 AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
2054 if test "$tor_cv_sign_extend" != "no"; then
2055 AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
2056 [Define to 1 iff right-shifting a negative value performs sign-extension])
2059 # Is uint8_t the same type as unsigned char?
2060 AC_CACHE_CHECK([whether uint8_t is the same type as unsigned char], tor_cv_uint8_uchar,
2061 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2064 unsigned char c;]])],
2065 [tor_cv_uint8_uchar=yes],
2066 [tor_cv_uint8_uchar=no],
2067 [tor_cv_uint8_uchar=cross])])
2069 if test "$tor_cv_uint8_uchar" = "cross"; then
2070 AC_MSG_NOTICE([Cross-compiling: we'll assume that uint8_t is the same type as unsigned char])
2073 if test "$tor_cv_uint8_uchar" = "no"; then
2074 AC_MSG_ERROR([We assume that uint8_t is the same type as unsigned char, but your compiler disagrees.])
2077 AC_ARG_WITH(tcmalloc,
2078 AS_HELP_STRING(--with-tcmalloc, [use tcmalloc memory allocation library. Deprecated; see --with-malloc]))
2080 default_malloc=system
2082 if test "x$enable_openbsd_malloc" = "xyes" ; then
2083 AC_MSG_NOTICE([The --enable-openbsd-malloc argument is deprecated; use --with-malloc=openbsd instead.])
2084 default_malloc=openbsd
2087 if test "x$with_tcmalloc" = "xyes"; then
2088 AC_MSG_NOTICE([The --with-tcmalloc argument is deprecated; use --with-malloc=tcmalloc instead.])
2089 default_malloc=tcmalloc
2093 AS_HELP_STRING([--with-malloc=[system,jemalloc,tcmalloc,openbsd]],
2094 [select special malloc implementation [system]]),
2095 [ malloc="$with_malloc" ], [ malloc="$default_malloc" ])
2099 PKG_CHECK_MODULES([TCMALLOC],
2104 if test "x$have_tcmalloc" = "xno" ; then
2105 AC_MSG_ERROR([Unable to find tcmalloc requested by --with-malloc, $pkg_config_user_action, or set TCMALLOC_CFLAGS and TCMALLOC_LIBS.])
2108 CFLAGS="$CFLAGS $TCMALLOC_CFLAGS"
2109 LIBS="$TCMALLOC_LIBS $LIBS"
2113 PKG_CHECK_MODULES([JEMALLOC],
2118 if test "x$have_jemalloc" = "xno" ; then
2119 AC_MSG_ERROR([Unable to find jemalloc requested by --with-malloc, $pkg_config_user_action, or set JEMALLOC_CFLAGS and JEMALLOC_LIBS.])
2122 CFLAGS="$CFLAGS $JEMALLOC_CFLAGS"
2123 LIBS="$JEMALLOC_LIBS $LIBS"
2124 using_custom_malloc=yes
2129 AC_MSG_WARN([The openbsd malloc port is deprecated in Tor 0.3.5 and will be removed in a future version.])
2130 enable_openbsd_malloc=yes
2134 # handle this later, including the jemalloc fallback
2135 AC_CHECK_FUNCS(mallinfo)
2138 [AC_MSG_ERROR([--with-malloc=`$with_malloc' not supported, see --help])
2141 AM_CONDITIONAL(USE_OPENBSD_MALLOC, test "x$enable_openbsd_malloc" = "xyes")
2143 if test "$malloc" != "system"; then
2144 # Tell the C compiler not to use the system allocator functions.
2145 TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
2147 if test "$using_custom_malloc" = "yes"; then
2148 # Tell the C compiler not to use the system allocator functions.
2149 TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
2152 # By default, we're going to assume we don't have mlockall()
2153 # bionic and other platforms have various broken mlockall subsystems.
2154 # Some systems don't have a working mlockall, some aren't linkable,
2155 # and some have it but don't declare it.
2156 AC_CHECK_FUNCS(mlockall)
2157 AC_CHECK_DECLS([mlockall], , , [
2158 #ifdef HAVE_SYS_MMAN_H
2159 #include <sys/mman.h>
2162 # Allow user to specify an alternate syslog facility
2163 AC_ARG_WITH(syslog-facility,
2164 AS_HELP_STRING(--with-syslog-facility=LOG, [syslog facility to use (default=LOG_DAEMON)]),
2165 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
2166 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
2167 AC_SUBST(LOGFACILITY)
2169 # Check if we have getresuid and getresgid
2170 AC_CHECK_FUNCS(getresuid getresgid)
2172 # Check for gethostbyname_r in all its glorious incompatible versions.
2173 # (This logic is based on that in Python's configure.in)
2174 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
2175 [Define this if you have any gethostbyname_r()])
2177 AC_CHECK_FUNC(gethostbyname_r, [
2178 AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
2180 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
2181 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2185 struct hostent *h1, *h2;
2187 (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
2189 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2190 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2191 [Define this if gethostbyname_r takes 6 arguments])
2194 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2200 (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
2202 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2203 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2204 [Define this if gethostbyname_r takes 5 arguments])
2207 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2212 struct hostent_data hd;
2213 (void) gethostbyname_r(cp1,h1,&hd);
2215 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2216 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2217 [Define this if gethostbyname_r takes 3 arguments])
2227 AC_CACHE_CHECK([whether the C compiler supports __func__],
2228 tor_cv_have_func_macro,
2229 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2231 int main(int c, char **v) { puts(__func__); }])],
2232 tor_cv_have_func_macro=yes,
2233 tor_cv_have_func_macro=no))
2235 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
2236 tor_cv_have_FUNC_macro,
2237 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2239 int main(int c, char **v) { puts(__FUNC__); }])],
2240 tor_cv_have_FUNC_macro=yes,
2241 tor_cv_have_FUNC_macro=no))
2243 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
2244 tor_cv_have_FUNCTION_macro,
2245 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2247 int main(int c, char **v) { puts(__FUNCTION__); }])],
2248 tor_cv_have_FUNCTION_macro=yes,
2249 tor_cv_have_FUNCTION_macro=no))
2251 AC_CACHE_CHECK([whether we have extern char **environ already declared],
2252 tor_cv_have_environ_declared,
2253 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2254 #ifdef HAVE_UNISTD_H
2258 int main(int c, char **v) { char **t = environ; }])],
2259 tor_cv_have_environ_declared=yes,
2260 tor_cv_have_environ_declared=no))
2262 if test "$tor_cv_have_func_macro" = "yes"; then
2263 AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
2266 if test "$tor_cv_have_FUNC_macro" = "yes"; then
2267 AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
2270 if test "$tor_cv_have_FUNCTION_macro" = "yes"; then
2271 AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
2272 [Defined if the compiler supports __FUNCTION__])
2275 if test "$tor_cv_have_environ_declared" = "yes"; then
2276 AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
2277 [Defined if we have extern char **environ already declared])
2280 # $prefix stores the value of the --prefix command line option, or
2281 # NONE if the option wasn't set. In the case that it wasn't set, make
2282 # it be the default, so that we can use it to expand directories now.
2283 if test "x$prefix" = "xNONE"; then
2284 prefix=$ac_default_prefix
2287 # and similarly for $exec_prefix
2288 if test "x$exec_prefix" = "xNONE"; then
2292 if test "x$BUILDDIR" = "x"; then
2296 AH_TEMPLATE([BUILDDIR],[tor's build directory])
2297 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
2299 if test "x$SRCDIR" = "x"; then
2300 SRCDIR=$(cd "$srcdir"; pwd)
2302 AH_TEMPLATE([SRCDIR],[tor's sourcedir directory])
2303 AC_DEFINE_UNQUOTED(SRCDIR,"$SRCDIR")
2305 if test "x$CONFDIR" = "x"; then
2306 CONFDIR=`eval echo $sysconfdir/tor`
2309 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
2310 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
2312 BINDIR=`eval echo $bindir`
2314 LOCALSTATEDIR=`eval echo $localstatedir`
2315 AC_SUBST(LOCALSTATEDIR)
2317 if test "$bwin32" = "true"; then
2318 # Test if the linker supports the --nxcompat and --dynamicbase options
2320 save_LDFLAGS="$LDFLAGS"
2321 LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
2322 AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
2323 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
2324 [AC_MSG_RESULT([yes])]
2325 [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
2326 [AC_MSG_RESULT([no])]
2328 LDFLAGS="$save_LDFLAGS"
2331 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
2332 # than autoconf's macros like.
2333 if test "$GCC" = "yes"; then
2334 # Disable GCC's strict aliasing checks. They are an hours-to-debug
2335 # accident waiting to happen.
2336 CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
2338 # Override optimization level for non-gcc compilers
2340 enable_gcc_warnings=no
2341 enable_gcc_warnings_advisory=no
2344 # Warnings implies advisory-warnings and -Werror.
2345 if test "$enable_gcc_warnings" = "yes"; then
2346 enable_gcc_warnings_advisory=yes
2347 enable_fatal_warnings=yes
2350 # OS X Lion started deprecating the system openssl. Let's just disable
2351 # all deprecation warnings on OS X. Also, to potentially make the binary
2352 # a little smaller, let's enable dead_strip.
2356 CFLAGS="$CFLAGS -Wno-deprecated-declarations"
2357 LDFLAGS="$LDFLAGS -dead_strip" ;;
2360 TOR_WARNING_FLAGS=""
2362 # Add some more warnings which we use in development but not in the
2363 # released versions. (Some relevant gcc versions can't handle these.)
2365 # Note that we have to do this near the end of the autoconf process, or
2366 # else we may run into problems when these warnings hit on the testing C
2367 # programs that autoconf wants to build.
2368 if test "x$enable_gcc_warnings_advisory" != "xno"; then
2371 *-*-openbsd* | *-*-bitrig*)
2372 # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
2373 # That's fine, except that the headers don't pass -Wredundant-decls.
2374 # Therefore, let's disable -Wsystem-headers when we're building
2375 # with maximal warnings on OpenBSD.
2376 CFLAGS="$CFLAGS -Wno-system-headers" ;;
2379 CFLAGS_NOWARNINGS="$CFLAGS"
2381 # GCC4.3 users once report trouble with -Wstrict-overflow=5. GCC5 users
2382 # have it work better.
2383 # CFLAGS="$CFLAGS -Wstrict-overflow=1"
2385 # This warning was added in gcc 4.3, but it appears to generate
2386 # spurious warnings in gcc 4.4. I don't know if it works in 4.5.
2387 #CFLAGS="$CFLAGS -Wlogical-op"
2389 m4_foreach_w([warning_flag], [
2391 -Waddress-of-array-temporary
2392 -Waddress-of-temporary
2394 -Wanonymous-pack-parens
2397 -Warc-bridge-casts-disallowed-in-nonarc
2398 -Warc-maybe-repeated-use-of-weak
2399 -Warc-performSelector-leaks
2400 -Warc-repeated-use-of-weak
2402 -Warray-bounds-pointer-arithmetic
2404 -Wasm-operand-widths
2406 -Watomic-property-with-user-defined-accessor
2408 -Wauto-storage-class
2411 -Wbackslash-newline-escape
2412 -Wbad-array-new-length
2413 -Wbind-to-temporary-copy
2414 -Wbitfield-constant-conversion
2417 -Wbuiltin-requires-header
2419 -Wcompare-distinct-pointer-types
2420 -Wcomplex-component-init
2421 -Wconditional-type-mismatch
2423 -Wconstant-conversion
2424 -Wconstant-logical-operand
2425 -Wconstexpr-not-const
2426 -Wcustom-atomic-properties
2428 -Wdangling-initializer-list
2430 -Wdelegating-ctor-cycles
2431 -Wdeprecated-implementations
2432 -Wdeprecated-register
2433 -Wdirect-ivar-access
2435 -Wdistributed-object-modifiers
2437 -Wdollar-in-identifier-extension
2439 -Wduplicate-decl-specifier
2441 -Wduplicate-method-arg
2442 -Wduplicate-method-match
2444 -Wdynamic-class-memaccess
2445 -Wembedded-directive
2446 -Wempty-translation-unit
2448 -Wexit-time-destructors
2449 -Wexplicit-ownership-type
2450 -Wextern-initializer
2454 -Wflexible-array-extensions
2457 -Wfour-char-constants
2459 -Wglobal-constructors
2460 -Wgnu-array-member-paren-init
2462 -Wgnu-static-float-init
2465 -Widiomatic-parentheses
2466 -Wignored-attributes
2467 -Wimplicit-atomic-properties
2468 -Wimplicit-conversion-floating-point-to-bool
2469 -Wimplicit-exception-spec-mismatch
2470 -Wimplicit-fallthrough
2471 -Wimplicit-fallthrough-per-function
2472 -Wimplicit-retain-self
2473 -Wimport-preprocessor-directive-pedantic
2474 -Wincompatible-library-redeclaration
2475 -Wincompatible-pointer-types-discards-qualifiers
2476 -Wincomplete-implementation
2478 -Wincomplete-umbrella
2481 -Wint-to-void-pointer-cast
2487 -Winvalid-source-encoding
2488 -Winvalid-token-paste
2489 -Wknr-promoted-parameter
2490 -Wlarge-by-value-copy
2491 -Wliteral-conversion
2493 -Wlocal-type-template-args
2497 -Wmalformed-warning-check
2501 -Wmismatched-parameter-types
2502 -Wmismatched-return-types
2503 -Wmissing-field-initializers
2504 -Wmissing-format-attribute
2506 -Wmissing-selector-name
2508 -Wmissing-variable-declarations
2512 -Wnon-literal-null-conversion
2514 -Wnonportable-cfstrings
2520 -Wout-of-line-declaration
2522 -Woverlength-strings
2524 -Woverriding-method-mismatch
2525 -Wpointer-type-mismatch
2526 -Wpredefined-identifier-outside-function
2527 -Wprotocol-property-synthesis-ambiguity
2528 -Wreadonly-iboutlet-property
2529 -Wreadonly-setter-attrs
2531 -Wreceiver-forward-class
2533 -Wreinterpret-base-class
2534 -Wrequires-super-attribute
2535 -Wreserved-user-defined-literal
2536 -Wreturn-stack-address
2538 -Wselector-type-mismatch
2540 -Wserialized-diagnostics
2542 -Wshift-count-negative
2543 -Wshift-count-overflow
2544 -Wshift-negative-value
2546 -Wshift-sign-overflow
2548 -Wsizeof-array-argument
2549 -Wsource-uses-openmp
2552 -Wstatic-local-in-inline
2556 -Wstrlcpy-strlcat-size
2558 -Wsuggest-attribute=format
2559 -Wsuggest-attribute=noreturn
2560 -Wsuper-class-method-mismatch
2563 -Wtautological-constant-out-of-range-compare
2564 -Wtentative-definition-incomplete-type
2567 -Wtypedef-redefinition
2570 -Wundefined-internal
2571 -Wundefined-reinterpret-cast
2573 -Wunicode-whitespace
2574 -Wunknown-warning-option
2575 -Wunnamed-type-template-args
2576 -Wunneeded-member-function
2578 -Wunsupported-visibility
2579 -Wunused-but-set-parameter
2580 -Wunused-but-set-variable
2581 -Wunused-command-line-argument
2582 -Wunused-const-variable=2
2583 -Wunused-exception-parameter
2584 -Wunused-local-typedefs
2585 -Wunused-member-function
2586 -Wunused-sanitize-argument
2587 -Wunused-volatile-lvalue
2588 -Wuser-defined-literals
2591 -Wvector-conversions
2596 ], [ TOR_TRY_COMPILE_WITH_CFLAGS(warning_flag, [],
2597 [TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS warning_flag" CFLAGS="$CFLAGS warning_flag"], true)
2600 dnl We should re-enable this in some later version. Clang doesn't
2601 dnl mind, but it causes trouble with GCC.
2602 dnl -Wstrict-overflow=2
2604 dnl These seem to require annotations that we don't currently use,
2605 dnl and they give false positives in our pthreads wrappers. (Clang 4)
2607 dnl -Wthread-safety-analysis
2608 dnl -Wthread-safety-attributes
2609 dnl -Wthread-safety-beta
2610 dnl -Wthread-safety-precise
2612 W_FLAGS="$W_FLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
2613 W_FLAGS="$W_FLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
2614 W_FLAGS="$W_FLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
2615 W_FLAGS="$W_FLAGS -Wwrite-strings"
2616 W_FLAGS="$W_FLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
2617 W_FLAGS="$W_FLAGS -Waggregate-return -Wpacked -Wunused"
2618 W_FLAGS="$W_FLAGS -Wunused-parameter "
2619 # These interfere with building main() { return 0; }, which autoconf
2620 # likes to use as its default program.
2621 W_FLAGS="$W_FLAGS -Wold-style-definition -Wmissing-declarations"
2623 TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS $W_FLAGS"
2624 CFLAGS="$CFLAGS $W_FLAGS"
2626 if test "$tor_cv_cflags__Wnull_dereference" = "yes"; then
2627 AC_DEFINE([HAVE_CFLAG_WNULL_DEREFERENCE], 1, [True if we have -Wnull-dereference])
2629 if test "$tor_cv_cflags__Woverlength_strings" = "yes"; then
2630 AC_DEFINE([HAVE_CFLAG_WOVERLENGTH_STRINGS], 1, [True if we have -Woverlength-strings])
2632 if test "$tor_cv_cflags__warn_unused_const_variable_2" = "yes"; then
2633 AC_DEFINE([HAVE_CFLAG_WUNUSED_CONST_VARIABLE], 1, [True if we have -Wunused-const-variable])
2636 CFLAGS="$CFLAGS_NOWARNINGS"
2638 if test "x$enable_fatal_warnings" = "xyes"; then
2639 # I'd like to use TOR_CHECK_CFLAGS here, but I can't, since the
2640 # default autoconf programs are full of errors.
2641 CFLAGS="$CFLAGS -Werror"
2646 AC_SUBST(TOR_WARNING_FLAGS)
2648 echo "$TOR_WARNING_FLAGS">warning_flags
2650 TOR_TRY_COMPILE_WITH_CFLAGS([@warning_flags], [],
2651 CFLAGS="$CFLAGS @warning_flags",
2652 CFLAGS="$CFLAGS $TOR_WARNING_FLAGS")
2654 if test "$enable_coverage" = "yes" && test "$have_clang" = "no"; then
2658 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-coverage.])
2662 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
2668 contrib/operator-tools/tor.logrotate
2669 src/config/torrc.sample
2670 src/config/torrc.minimal
2671 src/rust/.cargo/config
2672 scripts/maint/checkOptionDocs.pl
2676 if test "x$asciidoc" = "xtrue" && test "$ASCIIDOC" = "none"; then
2677 regular_mans="doc/man/tor doc/man/tor-gencert doc/man/tor-resolve doc/man/torify"
2678 for file in $regular_mans ; do
2679 if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
2680 echo "==================================";
2682 echo "Building Tor has failed since manpages cannot be built.";
2684 echo "You need asciidoc installed to be able to build the manpages.";
2685 echo "To build without manpages, use the --disable-asciidoc argument";
2686 echo "when calling configure.";
2688 echo "==================================";
2694 if test "$fragile_hardening" = "yes"; then
2699 Warning! Building Tor with --enable-fragile-hardening (also known as
2700 --enable-expensive-hardening) makes some kinds of attacks harder, but makes
2701 other kinds of attacks easier. A Tor instance build with this option will be
2702 somewhat less vulnerable to remote code execution, arithmetic overflow, or
2703 out-of-bounds read/writes... but at the cost of becoming more vulnerable to
2704 denial of service attacks. For more information, see
2705 https://gitlab.torproject.org/tpo/core/team/-/wikis/TorFragileHardening
2712 if test "$openssl_ver_mismatch" = "yes"; then
2716 Warning! The version OpenSSL headers we get from compiling with
2717 "${TOR_CPPFLAGS_OPENSSL:-(no extra options)}"
2718 do not match version of the OpenSSL library we get when linking with
2719 "$TOR_LDFLAGS_OPENSSL $TOR_OPENSSL_LIBS".
2720 This might cause compilation to fail. Try using --with-openssl-dir to specify
2721 the exact OpenSSL path you want.
2727 # Mini-report on what will be built.
2731 PPRINT_SET_INDENT(1)
2735 AS_ECHO("Tor Version: ${PPRINT_COLOR_BLDBLU}Tor $PACKAGE_VERSION $PPRINT_COLOR_RST")
2738 PPRINT_SUBTITLE([Build Features])
2740 PPRINT_PROP_STRING([Compiler], [$CC])
2741 PPRINT_PROP_STRING([Host OS], [$host_os])
2744 test "x$enable_fatal_warnings" = "xyes" && value=1 || value=0
2745 PPRINT_PROP_BOOL([Warnings are fatal (--enable-fatal-warnings)], $value)
2747 test "x$enable_rust" = "xyes" && value=1 || value=0
2748 PPRINT_PROP_BOOL([Rust support (--enable-rust)], $value)
2750 test "x$enable_cargo_online_mode" = "xyes" && value=1 || value=0
2751 PPRINT_PROP_BOOL([Cargo Online Fetch (--enable-cargo-online-mode)], $value)
2753 test "x$enable_android" = "xyes" && value=1 || value=0
2754 PPRINT_PROP_BOOL([Android support (--enable-android)], $value)
2757 PPRINT_SUBTITLE([Static Build])
2759 test "x$enable_static_tor" = "xyes" && value=1 || value=0
2760 PPRINT_PROP_BOOL([tor (--enable-static-tor)], $value)
2762 if test "x$enable_static_libevent" = "xyes"; then
2763 PPRINT_PROP_STRING([libevent], [$TOR_LIBDIR_libevent])
2765 PPRINT_PROP_BOOL([libevent (--enable-static-libevent)], $value)
2768 if test "x$enable_static_openssl" = "xyes"; then
2769 PPRINT_PROP_STRING([libssl], [$TOR_LIBDIR_openssl])
2771 PPRINT_PROP_BOOL([libssl (--enable-static-openssl)], $value)
2774 if test "x$enable_static_zlib" = "xyes"; then
2775 PPRINT_PROP_STRING([zlib1g], [$TOR_LIBDIR_zlib])
2777 PPRINT_PROP_BOOL([zlib1g (--enable-static-zlib)], $value)
2781 PPRINT_SUBTITLE([Optional Libraries])
2783 test "x$enable_nss" = "xyes" && value=1 || value=0
2784 PPRINT_PROP_BOOL([libnss (--enable-nss)], $value)
2786 test "x$enable_seccomp" != "xno" && value=1 || value=0
2787 PPRINT_PROP_BOOL([libseccomp (--disable-seccomp)], $value)
2789 test "x$enable_libscrypt" != "xno" && value=1 || value=0
2790 PPRINT_PROP_BOOL([libscrypt (--disable-libscrypt)], $value)
2792 test "x$enable_systemd" = "xyes" && value=1 || value=0
2793 PPRINT_PROP_BOOL([Systemd support (--enable-systemd)], $value)
2795 test "x$enable_lzma" = "xyes" && value=1 || value=0
2796 PPRINT_PROP_BOOL([liblzma (--enable-lzma)], $value)
2798 test "x$enable_zstd" = "xyes" && value=1 || value=0
2799 PPRINT_PROP_BOOL([libzstd (--enable-zstd)], $value)
2802 PPRINT_SUBTITLE([Hardening])
2804 test "x$enable_gcc_hardening" != "xno" && value=1 || value=0
2805 PPRINT_PROP_BOOL([Compiler Hardening (--disable-gcc-hardening)], $value)
2807 test "x$enable_linker_hardening" != "xno" && value=1 || value=0
2808 PPRINT_PROP_BOOL([Linker Hardening (--disable-linker-hardening)], $value)
2810 test "x$fragile_hardening" = "xyes" && value=1 || value=0
2811 PPRINT_PROP_BOOL([Fragile Hardening (--enable-fragile-hardening, dev only)], $value)
2814 PPRINT_SUBTITLE([Modules])
2816 m4_foreach_w([mname], MODULES,
2818 AM_COND_IF(m4_join([], [BUILD_MODULE_], m4_toupper([]mname[])), value=1, value=0)
2819 PPRINT_PROP_BOOL([mname (--disable-module-mname)], $value)
2824 PPRINT_SUBTITLE([Documentation])
2826 test "x$enable_asciidoc" != "xno" && value=1 || value=0
2827 PPRINT_PROP_BOOL([AsciiDoc (--disable-asciidoc)], $value)
2829 test "x$enable_manpage" != "xno" && value=1 || value=0
2830 PPRINT_PROP_BOOL([Man Pages (--disable-manpage)], $value)
2832 test "x$enable_html_manual" != "xno" && value=1 || value=0
2833 PPRINT_PROP_BOOL([HTML Manual (--disable-html-manual)], $value)
2836 PPRINT_SUBTITLE([Tests])
2838 test "x$enable_unittests" != "xno" && value=1 || value=0
2839 PPRINT_PROP_BOOL([Unit tests (--disable-unittests)], $value)
2841 test "x$enable_asserts_in_tests" = "xno" && value=1 || value=0
2842 PPRINT_PROP_BOOL([assert()s enabled (--enable-asserts-in-tests, dev only)], $value)
2844 test "x$enable_coverage" = "xyes" && value=1 || value=0
2845 PPRINT_PROP_BOOL([Code Coverage (--enable-coverage)], $value)
2847 test "x$enable_libfuzzer" = "xyes" && value=1 || value=0
2848 PPRINT_PROP_BOOL([libFuzzer support (--enable-libfuzzer)], $value)
2850 test "x$enable_oss_fuzz" = "xyes" && value=1 || value=0
2851 PPRINT_PROP_BOOL([OSS-Fuzz support (--enable-oss-fuzz)], $value)
2854 PPRINT_SUBTITLE([Tracing (--enable-tracing-instrumentation-<type>)])
2856 test "x$enable_tracing_instrumentation_log_debug" = "xyes" && value=1 || value=0
2857 PPRINT_PROP_BOOL([Tracepoints to log_debug() (log-debug)], $value)
2859 test "x$enable_tracing_instrumentation_usdt" = "xyes" && value=1 || value=0
2860 PPRINT_PROP_BOOL([USDT Instrumentation (usdt)], $value)
2862 test "x$enable_tracing_instrumentation_lttng" = "xyes" && value=1 || value=0
2863 PPRINT_PROP_BOOL([LTTng Instrumentation (lttng)], $value)
2866 PPRINT_SUBTITLE([Install Directories])
2868 report_mandir="`eval eval echo $mandir`"
2869 PPRINT_PROP_STRING([Binaries], [$BINDIR])
2870 PPRINT_PROP_STRING([Configuration], [$CONFDIR])
2871 PPRINT_PROP_STRING([Man Pages], [$report_mandir])
2874 AS_ECHO(["Configure Line: ./configure $configure_flags"])
2876 if test "$tor_ac_n_warnings" != "0"; then
2879 Encountered $tor_ac_n_warnings warning(s). See messages above for more info.