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.4.7-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, ["2021-02-03"], # for 0.4.4.7-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])
27 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
28 AC_CONFIG_HEADERS([orconfig.h])
30 AC_USE_SYSTEM_EXTENSIONS
34 if test "x$PKG_CONFIG" = "x" ; then
35 pkg_config_user_action="install pkg-config, and check the PKG_CONFIG_PATH environment variable"
36 AC_MSG_NOTICE([Some libraries need pkg-config, including systemd, nss, lzma, zstd, and custom mallocs.])
37 AC_MSG_NOTICE([To use those libraries, $pkg_config_user_action.])
39 pkg_config_user_action="check the PKG_CONFIG_PATH environment variable"
42 if test "x$PKG_CONFIG_PATH" = "x" && test "x$prefix" != "xNONE" && test "$host" != "$build"; then
43 export PKG_CONFIG_PATH=$prefix/lib/pkgconfig
44 AC_MSG_NOTICE([set PKG_CONFIG_PATH=$PKG_CONFIG_PATH to support cross-compiling])
47 AC_ARG_ENABLE(openbsd-malloc,
48 AS_HELP_STRING(--enable-openbsd-malloc, [use malloc code from OpenBSD. Linux only. Deprecated: see --with-malloc]))
49 AC_ARG_ENABLE(static-openssl,
50 AS_HELP_STRING(--enable-static-openssl, [link against a static openssl library. Requires --with-openssl-dir]))
51 AC_ARG_ENABLE(static-libevent,
52 AS_HELP_STRING(--enable-static-libevent, [link against a static libevent library. Requires --with-libevent-dir]))
53 AC_ARG_ENABLE(static-zlib,
54 AS_HELP_STRING(--enable-static-zlib, [link against a static zlib library. Requires --with-zlib-dir]))
55 AC_ARG_ENABLE(static-tor,
56 AS_HELP_STRING(--enable-static-tor, [create an entirely static Tor binary. Requires --with-openssl-dir and --with-libevent-dir and --with-zlib-dir]))
57 AC_ARG_ENABLE(unittests,
58 AS_HELP_STRING(--disable-unittests, [don't build unit tests for Tor. Risky!]))
59 AC_ARG_ENABLE(coverage,
60 AS_HELP_STRING(--enable-coverage, [enable coverage support in the unit-test build]))
61 AC_ARG_ENABLE(asserts-in-tests,
62 AS_HELP_STRING(--disable-asserts-in-tests, [disable tor_assert() calls in the unit tests, for branch coverage]))
63 AC_ARG_ENABLE(system-torrc,
64 AS_HELP_STRING(--disable-system-torrc, [don't look for a system-wide torrc file]))
65 AC_ARG_ENABLE(libfuzzer,
66 AS_HELP_STRING(--enable-libfuzzer, [build extra fuzzers based on 'libfuzzer']))
67 AC_ARG_ENABLE(oss-fuzz,
68 AS_HELP_STRING(--enable-oss-fuzz, [build extra fuzzers based on 'oss-fuzz' environment]))
69 AC_ARG_ENABLE(memory-sentinels,
70 AS_HELP_STRING(--disable-memory-sentinels, [disable code that tries to prevent some kinds of memory access bugs. For fuzzing only.]))
72 AS_HELP_STRING(--enable-rust, [enable rust integration]))
73 AC_ARG_ENABLE(cargo-online-mode,
74 AS_HELP_STRING(--enable-cargo-online-mode, [Allow cargo to make network requests to fetch crates. For builds with rust only.]))
75 AC_ARG_ENABLE(restart-debugging,
76 AS_HELP_STRING(--enable-restart-debugging, [Build Tor with support for debugging in-process restart. Developers only.]))
77 AC_ARG_ENABLE(zstd-advanced-apis,
78 AS_HELP_STRING(--disable-zstd-advanced-apis, [Build without support for zstd's "static-only" APIs.]))
80 AS_HELP_STRING(--enable-nss, [Use Mozilla's NSS TLS library. (EXPERIMENTAL)]))
82 AS_HELP_STRING(--enable-pic, [Build Tor's binaries as position-independent code, suitable to link as a library.]))
84 AC_ARG_ENABLE(missing-doc-warnings,
85 AS_HELP_STRING(--enable-missing-doc-warnings, [Tell doxygen to warn about missing documentation. Makes doxygen warnings nonfatal.]))
87 if test "$enable_missing_doc_warnings" = "yes"; then
88 DOXYGEN_FATAL_WARNINGS=NO
89 DOXYGEN_WARN_ON_MISSING=YES
90 elif test "$enable_fatal_warnings" = "yes"; then
91 # Fatal warnings from doxygen are nice, but not if we're warning about
92 # missing documentation.
93 DOXYGEN_FATAL_WARNINGS=YES
94 DOXYGEN_WARN_ON_MISSING=NO
96 DOXYGEN_FATAL_WARNINGS=NO
97 DOXYGEN_WARN_ON_MISSING=NO
99 AC_SUBST(DOXYGEN_FATAL_WARNINGS)
100 AC_SUBST(DOXYGEN_WARN_ON_MISSING)
102 if test "x$enable_coverage" != "xyes" -a "x$enable_asserts_in_tests" = "xno" ; then
103 AC_MSG_ERROR([Can't disable assertions outside of coverage build])
106 AM_CONDITIONAL(UNITTESTS_ENABLED, test "x$enable_unittests" != "xno")
107 AM_CONDITIONAL(COVERAGE_ENABLED, test "x$enable_coverage" = "xyes")
108 AM_CONDITIONAL(DISABLE_ASSERTS_IN_UNIT_TESTS, test "x$enable_asserts_in_tests" = "xno")
109 AM_CONDITIONAL(LIBFUZZER_ENABLED, test "x$enable_libfuzzer" = "xyes")
110 AM_CONDITIONAL(OSS_FUZZ_ENABLED, test "x$enable_oss_fuzz" = "xyes")
111 AM_CONDITIONAL(USE_RUST, test "x$enable_rust" = "xyes")
112 AM_CONDITIONAL(USE_NSS, test "x$enable_nss" = "xyes")
113 AM_CONDITIONAL(USE_OPENSSL, test "x$enable_nss" != "xyes")
115 if test "x$enable_nss" = "xyes"; then
116 AC_DEFINE(ENABLE_NSS, 1,
117 [Defined if we're building with NSS.])
119 AC_DEFINE(ENABLE_OPENSSL, 1,
120 [Defined if we're building with OpenSSL or LibreSSL])
123 if test "$enable_static_tor" = "yes"; then
124 enable_static_libevent="yes";
125 enable_static_openssl="yes";
126 enable_static_zlib="yes";
127 CFLAGS="$CFLAGS -static"
130 if test "$enable_system_torrc" = "no"; then
131 AC_DEFINE(DISABLE_SYSTEM_TORRC, 1,
132 [Defined if we're not going to look for a torrc in SYSCONF])
135 if test "$enable_memory_sentinels" = "no"; then
136 AC_DEFINE(DISABLE_MEMORY_SENTINELS, 1,
137 [Defined if we're turning off memory safety code to look for bugs])
140 AC_ARG_ENABLE(manpage,
141 AS_HELP_STRING(--disable-manpage, [Disable manpage generation.]))
143 AC_ARG_ENABLE(html-manual,
144 AS_HELP_STRING(--disable-html-manual, [Disable HTML documentation.]))
146 AC_ARG_ENABLE(asciidoc,
147 AS_HELP_STRING(--disable-asciidoc, [don't use asciidoc (disables building of manpages)]),
148 [case "${enableval}" in
149 "yes") asciidoc=true ;;
150 "no") asciidoc=false ;;
151 *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
152 esac], [asciidoc=true])
154 # systemd notify support
155 AC_ARG_ENABLE(systemd,
156 AS_HELP_STRING(--enable-systemd, [enable systemd notification support]),
157 [case "${enableval}" in
158 "yes") systemd=true ;;
159 "no") systemd=false ;;
160 * ) AC_MSG_ERROR(bad value for --enable-systemd) ;;
161 esac], [systemd=auto])
163 if test "$enable_restart_debugging" = "yes"; then
164 AC_DEFINE(ENABLE_RESTART_DEBUGGING, 1,
165 [Defined if we're building with support for in-process restart debugging.])
168 if test "$enable_zstd_advanced_apis" != "no"; then
169 AC_DEFINE(ENABLE_ZSTD_ADVANCED_APIS, 1,
170 [Defined if we're going to try to use zstd's "static-only" APIs.])
174 if test "x$enable_systemd" = "xno"; then
177 PKG_CHECK_MODULES(SYSTEMD,
181 if test "x$have_systemd" = "xno"; then
182 AC_MSG_NOTICE([Okay, checking for systemd a different way...])
183 PKG_CHECK_MODULES(SYSTEMD,
190 if test "x$have_systemd" = "xyes"; then
191 AC_DEFINE(HAVE_SYSTEMD,1,[Have systemd])
192 TOR_SYSTEMD_CFLAGS="${SYSTEMD_CFLAGS}"
193 TOR_SYSTEMD_LIBS="${SYSTEMD_LIBS}"
194 PKG_CHECK_MODULES(LIBSYSTEMD209, [libsystemd >= 209],
195 [AC_DEFINE(HAVE_SYSTEMD_209,1,[Have systemd v209 or greater])], [])
197 AC_SUBST(TOR_SYSTEMD_CFLAGS)
198 AC_SUBST(TOR_SYSTEMD_LIBS)
200 if test "x$enable_systemd" = "xyes" -a "x$have_systemd" != "xyes" ; then
201 AC_MSG_ERROR([Explicitly requested systemd support, but systemd not found, $pkg_config_user_action, or set SYSTEMD_CFLAGS and SYSTEMD_LIBS.])
206 AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
210 AC_ARG_ENABLE(gcc-warnings,
211 AS_HELP_STRING(--enable-gcc-warnings, [deprecated alias for enable-fatal-warnings]))
212 AC_ARG_ENABLE(fatal-warnings,
213 AS_HELP_STRING(--enable-fatal-warnings, [tell the compiler to treat all warnings as errors.]))
214 AC_ARG_ENABLE(gcc-warnings-advisory,
215 AS_HELP_STRING(--disable-gcc-warnings-advisory, [disable the regular verbose warnings]))
217 dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
218 AC_ARG_ENABLE(gcc-hardening,
219 AS_HELP_STRING(--disable-gcc-hardening, [disable compiler security checks]))
221 dnl Deprecated --enable-expensive-hardening but keep it for now for backward compat.
222 AC_ARG_ENABLE(expensive-hardening,
223 AS_HELP_STRING(--enable-expensive-hardening, [enable more fragile and expensive compiler hardening; makes Tor slower]))
224 AC_ARG_ENABLE(fragile-hardening,
225 AS_HELP_STRING(--enable-fragile-hardening, [enable more fragile and expensive compiler hardening; makes Tor slower]))
226 if test "x$enable_expensive_hardening" = "xyes" || test "x$enable_fragile_hardening" = "xyes"; then
227 fragile_hardening="yes"
228 AC_DEFINE(DEBUG_SMARTLIST, 1, [Enable smartlist debugging])
231 AC_ARG_ENABLE(all-bugs-are-fatal,
232 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]))
234 if test "x$enable_all_bugs_are_fatal" = "xyes"; then
235 AC_DEFINE(ALL_BUGS_ARE_FATAL, 1, [All assert failures are fatal])
238 dnl Linker hardening options
239 dnl Currently these options are ELF specific - you can't use this with MacOSX
240 AC_ARG_ENABLE(linker-hardening,
241 AS_HELP_STRING(--disable-linker-hardening, [disable linker security fixups]))
243 AC_ARG_ENABLE(local-appdata,
244 AS_HELP_STRING(--enable-local-appdata, [default to host local application data paths on Windows]))
245 if test "$enable_local_appdata" = "yes"; then
246 AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
247 [Defined if we default to host local appdata paths on Windows])
250 AC_ARG_ENABLE(tool-name-check,
251 AS_HELP_STRING(--disable-tool-name-check, [check for sanely named toolchain when cross-compiling]))
253 AC_ARG_ENABLE(seccomp,
254 AS_HELP_STRING(--disable-seccomp, [do not attempt to use libseccomp]))
256 AC_ARG_ENABLE(libscrypt,
257 AS_HELP_STRING(--disable-libscrypt, [do not attempt to use libscrypt]))
259 dnl Enable event tracing which are transformed to debug log statement.
260 AC_ARG_ENABLE(event-tracing-debug,
261 AS_HELP_STRING(--enable-event-tracing-debug, [build with event tracing to debug log]))
262 AM_CONDITIONAL([USE_EVENT_TRACING_DEBUG], [test "x$enable_event_tracing_debug" = "xyes"])
264 if test x$enable_event_tracing_debug = xyes; then
265 AC_DEFINE([USE_EVENT_TRACING_DEBUG], [1], [Tracing framework to log debug])
266 AC_DEFINE([TOR_EVENT_TRACING_ENABLED], [1], [Compile the event tracing instrumentation])
269 dnl Enable Android only features.
270 AC_ARG_ENABLE(android,
271 AS_HELP_STRING(--enable-android, [build with Android features enabled]))
272 AM_CONDITIONAL([USE_ANDROID], [test "x$enable_android" = "xyes"])
274 if test "x$enable_android" = "xyes"; then
275 AC_DEFINE([USE_ANDROID], [1], [Compile with Android specific features enabled])
277 dnl Check if the Android log library is available.
278 AC_CHECK_HEADERS([android/log.h])
279 AC_SEARCH_LIBS(__android_log_write, [log])
284 dnl Tor modules options. These options are namespaced with --disable-module-XXX
288 m4_define(MODULES, relay dirauth dircache)
291 AC_ARG_ENABLE([module-relay],
292 AS_HELP_STRING([--disable-module-relay],
293 [Build tor without the Relay modules: tor can not run as a relay, bridge, or authority. Implies --disable-module-dirauth]))
294 AM_CONDITIONAL(BUILD_MODULE_RELAY, [test "x$enable_module_relay" != "xno"])
295 AM_COND_IF(BUILD_MODULE_RELAY,
296 AC_DEFINE([HAVE_MODULE_RELAY], [1],
297 [Compile with Relay feature support]))
299 dnl Dircache module. (This cannot be enabled or disabled independently of
300 dnl the relay module. It is not listed by --list-modules for this reason.)
301 AM_CONDITIONAL(BUILD_MODULE_DIRCACHE,
302 [test "x$enable_module_relay" != "xno"])
303 AM_COND_IF(BUILD_MODULE_DIRCACHE,
304 AC_DEFINE([HAVE_MODULE_DIRCACHE], [1],
305 [Compile with directory cache support]))
307 dnl Directory Authority module.
308 AC_ARG_ENABLE([module-dirauth],
309 AS_HELP_STRING([--disable-module-dirauth],
310 [Build tor without the Directory Authority module: tor can not run as a directory authority or bridge authority]))
311 AM_CONDITIONAL(BUILD_MODULE_DIRAUTH,[test "x$enable_module_dirauth" != "xno" && test "x$enable_module_relay" != "xno"])
312 AM_COND_IF(BUILD_MODULE_DIRAUTH,
313 AC_DEFINE([HAVE_MODULE_DIRAUTH], [1],
314 [Compile with Directory Authority feature support]))
316 dnl Helper variables.
317 TOR_MODULES_ALL_ENABLED=
318 AC_DEFUN([ADD_MODULE], [
319 MODULE=m4_toupper($1)
320 TOR_MODULES_ALL_ENABLED="${TOR_MODULES_ALL_ENABLED} -DHAVE_MODULE_${MODULE}=1"
322 m4_foreach_w([module], MODULES, [ADD_MODULE([module])])
323 AC_SUBST(TOR_MODULES_ALL_ENABLED)
325 dnl check for the correct "ar" when cross-compiling.
326 dnl (AM_PROG_AR was new in automake 1.11.2, which we do not yet require,
327 dnl so kludge up a replacement for the case where it isn't there yet.)
328 m4_ifdef([AM_PROG_AR],
330 [AN_MAKEVAR([AR], [AC_PROG_AR])
331 AN_PROGRAM([ar], [AC_PROG_AR])
332 AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [:])])
335 dnl Check whether the above macro has settled for a simply named tool even
336 dnl though we're cross compiling. We must do this before running AC_PROG_CC,
337 dnl because that will find any cc on the system, not only the cross-compiler,
338 dnl and then verify that a binary built with this compiler runs on the
339 dnl build system. It will then come to the false conclusion that we're not
341 if test "x$enable_tool_name_check" != "xno"; then
342 if test "x$ac_tool_warned" = "xyes"; then
343 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.)])
344 elif test "x$ac_ct_AR" != "x" -a "x$cross_compiling" = "xmaybe"; then
345 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.)])
355 AC_ARG_VAR([PERL], [path to Perl binary])
356 AC_CHECK_PROGS([PERL], [perl])
357 AM_CONDITIONAL(USE_PERL, [test "x$ac_cv_prog_PERL" != "x"])
359 dnl check for asciidoc and a2x
360 AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
361 AC_PATH_PROGS([A2X], [a2x a2x.py], none)
363 AM_CONDITIONAL(USE_ASCIIDOC, test "x$asciidoc" = "xtrue")
364 AM_CONDITIONAL(BUILD_MANPAGE, [test "x$enable_manpage" != "xno"])
365 AM_CONDITIONAL(BUILD_HTML_DOCS, [test "x$enable_html_manual" != "xno"])
370 AC_CACHE_CHECK([for Python 3], [tor_cv_PYTHON],
371 [AC_PATH_PROGS_FEATURE_CHECK([PYTHON], [ \
373 python3.8 python3.7 python3.6 python3.5 python3.4 \
375 [["$ac_path_PYTHON" -c 'import sys; sys.exit(sys.version_info[0]<3)' && tor_cv_PYTHON="$ac_path_PYTHON" ac_path_PYTHON_found=:]] )])
376 AC_SUBST([PYTHON], [$tor_cv_PYTHON])
378 PYTHON="$tor_cv_PYTHON"
380 if test "x$PYTHON" = "x"; then
381 AC_MSG_WARN([Python 3 unavailable; some tests will not be run.])
384 AM_CONDITIONAL(USEPYTHON, [test "x$PYTHON" != "x"])
386 dnl List all external rust crates we depend on here. Include the version
391 AC_SUBST(rust_crates)
393 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
394 AC_C_FLEXIBLE_ARRAY_MEMBER
396 dnl Maybe we've got an old autoconf...
397 AC_CACHE_CHECK([for flexible array members],
401 struct abc { int a; char b[]; };
403 struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
406 [tor_cv_c_flexarray=yes],
407 [tor_cv_c_flexarray=no])])
408 if test "$tor_cv_flexarray" = "yes"; then
409 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
411 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
415 AC_CACHE_CHECK([for working C99 mid-block declaration syntax],
418 [AC_LANG_PROGRAM([], [int x; x = 3; int y; y = 4 + x;])],
419 [tor_cv_c_c99_decl=yes],
420 [tor_cv_c_c99_decl=no] )])
421 if test "$tor_cv_c_c99_decl" != "yes"; then
422 AC_MSG_ERROR([Your compiler doesn't support c99 mid-block declarations. This is required as of Tor 0.2.6.x])
425 AC_CACHE_CHECK([for working C99 designated initializers],
426 tor_cv_c_c99_designated_init,
428 [AC_LANG_PROGRAM([struct s { int a; int b; };],
429 [[ struct s ss = { .b = 5, .a = 6 }; ]])],
430 [tor_cv_c_c99_designated_init=yes],
431 [tor_cv_c_c99_designated_init=no] )])
433 if test "$tor_cv_c_c99_designated_init" != "yes"; then
434 AC_MSG_ERROR([Your compiler doesn't support c99 designated initializers. This is required as of Tor 0.2.6.x])
437 saved_CFLAGS="$CFLAGS"
438 CFLAGS="$CFLAGS -Werror"
439 AC_CACHE_CHECK([for __attribute__((fallthrough))],
440 tor_cv_c_attr_fallthrough,
442 [AC_LANG_PROGRAM([extern int x; void fn(void) ;],
443 [[ switch (x) { case 1: fn(); __attribute__((fallthrough));
444 case 2: fn(); break; } ]])],
445 [tor_cv_c_attr_fallthrough=yes],
446 [tor_cv_c_attr_fallthrough=no] )])
447 CFLAGS="$saved_CFLAGS"
449 if test "$tor_cv_c_attr_fallthrough" = "yes"; then
450 AC_DEFINE(HAVE_ATTR_FALLTHROUGH, [1], [defined if we have the fallthrough attribute.])
454 AC_ARG_WITH(tor-user,
455 AS_HELP_STRING(--with-tor-user=NAME, [specify username for tor daemon]),
463 AC_ARG_WITH(tor-group,
464 AS_HELP_STRING(--with-tor-group=NAME, [specify group name for tor daemon]),
472 dnl If _WIN32 is defined and non-zero, we are building for win32
473 AC_MSG_CHECKING([for win32])
474 AC_RUN_IFELSE([AC_LANG_SOURCE([
475 int main(int c, char **v) {
486 bwin32=true; AC_MSG_RESULT([yes]),
487 bwin32=false; AC_MSG_RESULT([no]),
488 bwin32=cross; AC_MSG_RESULT([cross])
491 if test "$bwin32" = "cross"; then
492 AC_MSG_CHECKING([for win32 (cross)])
493 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
495 int main(int c, char **v) {return 0;}
498 int main(int c, char **v) {return x(y);}
501 bwin32=true; AC_MSG_RESULT([yes]),
502 bwin32=false; AC_MSG_RESULT([no]))
507 /* Defined to access windows functions and definitions for >=WinXP */
509 # define WINVER 0x0501
512 /* Defined to access _other_ windows functions and definitions for >=WinXP */
513 # ifndef _WIN32_WINNT
514 # define _WIN32_WINNT 0x0501
517 /* Defined to avoid including some windows headers as part of Windows.h */
518 # ifndef WIN32_LEAN_AND_MEAN
519 # define WIN32_LEAN_AND_MEAN 1
524 AM_CONDITIONAL(WIN32, test "x$bwin32" = "xtrue")
525 AM_CONDITIONAL(BUILD_NT_SERVICES, test "x$bwin32" = "xtrue")
526 AM_CONDITIONAL(BUILD_LIBTORRUNNER, test "x$bwin32" != "xtrue")
528 dnl Enable C99 when compiling with MIPSpro
529 AC_MSG_CHECKING([for MIPSpro compiler])
530 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
531 #if (defined(__sgi) && defined(_COMPILER_VERSION))
536 bmipspro=false; AC_MSG_RESULT(no),
537 bmipspro=true; AC_MSG_RESULT(yes))
539 if test "$bmipspro" = "true"; then
540 CFLAGS="$CFLAGS -c99"
545 AC_ARG_VAR([TOR_RUST_TARGET], [Rust target, must be specified when cross-compiling (HOST != BUILD). example: i686-pc-windows-gnu])
547 if test "x$enable_rust" = "xyes"; then
548 AC_ARG_VAR([RUSTC], [path to the rustc binary])
549 AC_CHECK_PROG([RUSTC], [rustc], [rustc],[no])
550 if test "x$RUSTC" = "xno"; then
551 AC_MSG_ERROR([rustc unavailable but rust integration requested.])
554 AC_ARG_VAR([CARGO], [path to the cargo binary])
555 AC_CHECK_PROG([CARGO], [cargo], [cargo],[no])
556 if test "x$CARGO" = "xno"; then
557 AC_MSG_ERROR([cargo unavailable but rust integration requested.])
560 AC_DEFINE([HAVE_RUST], 1, [have Rust])
561 if test "x$enable_fatal_warnings" = "xyes"; then
566 if test "x$enable_cargo_online_mode" = "xyes"; then
570 CARGO_ONLINE=--frozen
573 dnl When we're not allowed to touch the network, we need crate dependencies
574 dnl locally available.
575 AC_MSG_CHECKING([rust crate dependencies])
576 AC_ARG_VAR([TOR_RUST_DEPENDENCIES], [path to directory with local crate mirror])
577 if test "x$TOR_RUST_DEPENDENCIES" = "x"; then
578 TOR_RUST_DEPENDENCIES="${srcdir}/src/ext/rust/crates"
580 dnl Check whether the path exists before we try to cd into it.
581 if test ! -d "$TOR_RUST_DEPENDENCIES"; then
582 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.])
585 dnl Make the path absolute, since we'll be using it from within a
587 TOR_RUST_DEPENDENCIES=$(cd "$TOR_RUST_DEPENDENCIES" ; pwd)
589 for dep in $rust_crates; do
590 if test ! -d "$TOR_RUST_DEPENDENCIES"/"$dep"; then
591 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.])
595 if test "x$ERRORED" = "x"; then
600 dnl For now both MSVC and MinGW rust libraries will output static libs with
601 dnl the MSVC naming convention.
602 if test "$bwin32" = "true"; then
603 tor_rust_static_name=tor_rust.lib
605 tor_rust_static_name=libtor_rust.a
610 if test -n "$TOR_RUST_TARGET"; then
611 if test "$host" = "$build"; then
612 AC_MSG_ERROR([HOST = BUILD is invalid if TOR_RUST_TARGET is specified, see configure --help for more information.])
614 RUST_TARGET_PROP="target = '$TOR_RUST_TARGET'"
615 TOR_RUST_LIB_PATH="src/rust/target/$TOR_RUST_TARGET/release/$tor_rust_static_name"
617 if test "$host" != "$build"; then
618 AC_MSG_ERROR([TOR_RUST_TARGET must be specified when cross-compiling with Rust enabled.])
621 TOR_RUST_LIB_PATH="src/rust/target/release/$tor_rust_static_name"
624 AC_SUBST(RUST_TARGET_PROP)
625 AC_SUBST(TOR_RUST_LIB_PATH)
626 AC_SUBST(CARGO_ONLINE)
630 dnl Let's check the rustc version, too
631 AC_MSG_CHECKING([rust version])
632 RUSTC_VERSION=`$RUSTC --version`
633 RUSTC_VERSION_MAJOR=`$RUSTC --version | cut -d ' ' -f 2 | cut -d '.' -f 1`
634 RUSTC_VERSION_MINOR=`$RUSTC --version | cut -d ' ' -f 2 | cut -d '.' -f 2`
635 if test "x$RUSTC_VERSION_MAJOR" = "x" -o "x$RUSTC_VERSION_MINOR" = "x"; then
636 AC_MSG_ERROR([rustc version couldn't be identified])
638 if test "$RUSTC_VERSION_MAJOR" -lt 2 -a "$RUSTC_VERSION_MINOR" -lt 31; then
639 AC_MSG_ERROR([rustc must be at least version 1.31.0])
641 AC_MSG_RESULT([$RUSTC_VERSION])
644 AC_SEARCH_LIBS(socket, [socket network])
645 AC_SEARCH_LIBS(gethostbyname, [nsl])
646 AC_SEARCH_LIBS(dlopen, [dl])
647 AC_SEARCH_LIBS(inet_aton, [resolv])
648 AC_SEARCH_LIBS(backtrace, [execinfo])
650 AC_SEARCH_LIBS([clock_gettime], [rt])
651 if test "$LIBS" != "$saved_LIBS"; then
652 # Looks like we need -lrt for clock_gettime().
656 if test "$bwin32" = "false"; then
657 AC_SEARCH_LIBS(pthread_create, [pthread])
658 AC_SEARCH_LIBS(pthread_detach, [pthread])
661 AM_CONDITIONAL(THREADS_WIN32, test "$bwin32" = "true")
662 AM_CONDITIONAL(THREADS_PTHREADS, test "$bwin32" = "false")
666 RtlSecureZeroMemory \
670 backtrace_symbols_fd \
677 get_current_dir_name \
686 gnu_get_libc_version \
724 # Apple messed up when they added some functions: they
725 # forgot to decorate them with appropriate AVAILABLE_MAC_OS_VERSION
728 # We should only probe for these functions if we are sure that we
729 # are not targeting OS X 10.9 or earlier.
730 AC_MSG_CHECKING([for a pre-Yosemite OS X build target])
731 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
733 # include <AvailabilityMacros.h>
734 # ifndef MAC_OS_X_VERSION_10_10
735 # define MAC_OS_X_VERSION_10_10 101000
737 # if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
738 # if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
739 # error "Running on Mac OS X 10.9 or earlier"
744 [on_macos_pre_10_10=no ; AC_MSG_RESULT([no])],
745 [on_macos_pre_10_10=yes; AC_MSG_RESULT([yes])])
747 if test "$on_macos_pre_10_10" = "no"; then
749 mach_approximate_time \
753 # We should only probe for these functions if we are sure that we
754 # are not targeting OSX 10.11 or earlier.
755 AC_MSG_CHECKING([for a pre-Sierra OSX build target])
756 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
758 # include <AvailabilityMacros.h>
759 # ifndef MAC_OS_X_VERSION_10_12
760 # define MAC_OS_X_VERSION_10_12 101200
762 # if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
763 # if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
764 # error "Running on Mac OSX 10.11 or earlier"
769 [on_macos_pre_10_12=no ; AC_MSG_RESULT([no])],
770 [on_macos_pre_10_12=yes; AC_MSG_RESULT([yes])])
772 if test "$on_macos_pre_10_12" = "no"; then
779 if test "$bwin32" != "true"; then
780 AC_CHECK_HEADERS(pthread.h)
781 AC_CHECK_FUNCS(pthread_create)
782 AC_CHECK_FUNCS(pthread_condattr_setclock)
785 if test "$bwin32" = "true"; then
786 AC_CHECK_DECLS([SecureZeroMemory, _getwch], , , [
793 AM_CONDITIONAL(BUILD_READPASSPHRASE_C,
794 test "x$ac_cv_func_readpassphrase" = "xno" && test "$bwin32" = "false")
796 AC_MSG_CHECKING([whether free(NULL) works])
797 AC_RUN_IFELSE([AC_LANG_PROGRAM([
803 [free_null_ok=true; AC_MSG_RESULT(yes)],
804 [free_null_ok=false; AC_MSG_RESULT(no)],
805 [free_null_ok=cross; AC_MSG_RESULT(cross)])
807 if test "$free_null_ok" = "false"; then
808 AC_MSG_ERROR([Your libc implementation doesn't allow free(NULL), as required by C99.])
811 dnl ------------------------------------------------------
812 dnl Where do you live, libevent? And how do we call you?
814 if test "$bwin32" = "true"; then
815 TOR_LIB_WS32=-lws2_32
816 TOR_LIB_IPHLPAPI=-liphlpapi
817 # Some of the cargo-cults recommend -lwsock32 as well, but I don't
818 # think it's actually necessary.
820 TOR_LIB_USERENV=-luserenv
826 AC_SUBST(TOR_LIB_WS32)
827 AC_SUBST(TOR_LIB_GDI)
828 AC_SUBST(TOR_LIB_IPHLPAPI)
829 AC_SUBST(TOR_LIB_USERENV)
831 tor_libevent_pkg_redhat="libevent"
832 tor_libevent_pkg_debian="libevent-dev"
833 tor_libevent_devpkg_redhat="libevent-devel"
834 tor_libevent_devpkg_debian="libevent-dev"
836 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
837 dnl linking for static builds.
838 STATIC_LIBEVENT_FLAGS=""
839 if test "$enable_static_libevent" = "yes"; then
840 if test "$have_rt" = "yes"; then
841 STATIC_LIBEVENT_FLAGS=" -lrt "
845 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
847 #include <winsock2.h>
849 #include <sys/time.h>
850 #include <sys/types.h>
851 #include <event2/event.h>], [
853 #include <winsock2.h>
856 struct event_base *event_base_new(void);
857 void event_base_free(struct event_base *);],
860 {WSADATA d; WSAStartup(0x101,&d); }
862 event_base_free(event_base_new());
863 ], [--with-libevent-dir], [/opt/libevent])
865 dnl Determine the incantation needed to link libevent.
867 save_LDFLAGS="$LDFLAGS"
868 save_CPPFLAGS="$CPPFLAGS"
870 LIBS="$STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $save_LIBS"
871 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
872 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
874 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
876 if test "$enable_static_libevent" = "yes"; then
877 if test "$tor_cv_library_libevent_dir" = "(system)"; then
878 AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
880 TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
883 if test "x$ac_cv_header_event2_event_h" = "xyes"; then
884 AC_SEARCH_LIBS(event_new, [event event_core], , AC_MSG_ERROR("libevent2 is installed but linking it failed while searching for event_new"))
885 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"))
887 if test "$ac_cv_search_event_new" != "none required"; then
888 TOR_LIBEVENT_LIBS="$ac_cv_search_event_new"
890 if test "$ac_cv_search_evdns_base_new" != "none required"; then
891 TOR_LIBEVENT_LIBS="$ac_cv_search_evdns_base_new $TOR_LIBEVENT_LIBS"
894 AC_MSG_ERROR("libevent2 is required but the headers could not be found")
898 dnl Now check for particular libevent functions.
899 AC_CHECK_FUNCS([evutil_secure_rng_set_urandom_device_file \
900 evutil_secure_rng_add_bytes \
901 evdns_base_get_nameserver_addr \
906 LDFLAGS="$save_LDFLAGS"
907 CPPFLAGS="$save_CPPFLAGS"
909 dnl Check that libevent is at least at version 2.0.10, the first stable
910 dnl release of its series
911 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
912 AC_MSG_CHECKING([whether Libevent is new enough])
913 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
914 #include <event2/event.h>
915 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000a00
921 ])], [ AC_MSG_RESULT([yes]) ],
922 [ AC_MSG_RESULT([no])
923 AC_MSG_ERROR([Libevent is not new enough. We require 2.0.10-stable or later]) ] )
926 LDFLAGS="$save_LDFLAGS"
927 CPPFLAGS="$save_CPPFLAGS"
929 AC_SUBST(TOR_LIBEVENT_LIBS)
931 dnl ------------------------------------------------------
932 dnl Where do you live, libm?
934 dnl On some platforms (Haiku/BeOS) the math library is
935 dnl part of libroot. In which case don't link against lm
938 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
939 if test "$ac_cv_search_pow" != "none required"; then
940 TOR_LIB_MATH="$ac_cv_search_pow"
943 AC_SUBST(TOR_LIB_MATH)
945 dnl ------------------------------------------------------
946 dnl Hello, NSS. You're new around here.
947 if test "x$enable_nss" = "xyes"; then
948 PKG_CHECK_MODULES(NSS,
951 [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.])])
956 dnl ------------------------------------------------------
957 dnl Where do you live, openssl? And how do we call you?
959 if test "x$enable_nss" != "xyes"; then
961 tor_openssl_pkg_redhat="openssl"
962 tor_openssl_pkg_debian="libssl-dev"
963 tor_openssl_devpkg_redhat="openssl-devel"
964 tor_openssl_devpkg_debian="libssl-dev"
966 ALT_openssl_WITHVAL=""
968 AS_HELP_STRING(--with-ssl-dir=PATH, [obsolete alias for --with-openssl-dir]),
970 if test "x$withval" != "xno" && test "x$withval" != "x"; then
971 ALT_openssl_WITHVAL="$withval"
975 AC_MSG_NOTICE([Now, we'll look for OpenSSL >= 1.0.1])
976 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI $TOR_LIB_WS32],
977 [#include <openssl/ssl.h>
978 char *getenv(const char *);],
979 [struct ssl_cipher_st;
980 unsigned SSL_CIPHER_get_id(const struct ssl_cipher_st *);
981 char *getenv(const char *);],
982 dnl This funny-looking test program calls getenv, so that the compiler
983 dnl will neither make code that call SSL_CIPHER_get_id(NULL) [producing
984 dnl a crash], nor optimize out the call to SSL_CIPHER_get_id().
985 dnl We look for SSL_cipher_get_id() because it is present in
986 dnl OpenSSL >=1.0.1, because it is not deprecated, and because Tor
988 [if (getenv("THIS_SHOULDNT_BE_SET_X201803")) SSL_CIPHER_get_id((void *)0);], [],
989 [/usr/local/opt/openssl /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /opt/openssl])
991 dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
993 if test "$enable_static_openssl" = "yes"; then
994 if test "$tor_cv_library_openssl_dir" = "(system)"; then
995 AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
997 TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
1000 TOR_OPENSSL_LIBS="-lssl -lcrypto"
1002 AC_SUBST(TOR_OPENSSL_LIBS)
1004 dnl Now check for particular openssl functions.
1006 save_LDFLAGS="$LDFLAGS"
1007 save_CPPFLAGS="$CPPFLAGS"
1008 LIBS="$TOR_OPENSSL_LIBS $LIBS"
1009 LDFLAGS="$TOR_LDFLAGS_openssl $LDFLAGS"
1010 CPPFLAGS="$TOR_CPPFLAGS_openssl $CPPFLAGS"
1012 dnl Tor currently uses a number of APIs that are deprecated in OpenSSL 3.0.0
1013 dnl and later. We want to migrate away from them, but that will be a lot of
1014 dnl work. (See ticket tor#40166.) For now, we disable the deprecation
1017 AC_MSG_CHECKING([for OpenSSL >= 3.0.0])
1018 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1019 #include <openssl/opensslv.h>
1020 #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER <= 0x30000000L
1021 #error "you_have_version_3"
1024 [ AC_MSG_RESULT([no]) ],
1025 [ AC_MSG_RESULT([yes]);
1026 AC_DEFINE(OPENSSL_SUPPRESS_DEPRECATED, 1, [disable openssl deprecated-function warnings]) ])
1028 AC_MSG_CHECKING([for OpenSSL < 1.0.1])
1029 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1030 #include <openssl/opensslv.h>
1031 #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1000100fL
1035 [ AC_MSG_RESULT([no]) ],
1036 [ 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.]) ])
1038 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1039 #include <openssl/opensslv.h>
1040 #include <openssl/evp.h>
1041 #if defined(OPENSSL_NO_EC) || defined(OPENSSL_NO_ECDH) || defined(OPENSSL_NO_ECDSA)
1044 #if !defined(NID_X9_62_prime256v1) || !defined(NID_secp224r1)
1045 #error "curves unavailable"
1049 [ 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.]) ])
1051 AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , ,
1052 [#include <openssl/ssl.h>
1055 dnl OpenSSL functions which we might not have. In theory, we could just
1056 dnl check the openssl version number, but in practice that gets pretty
1057 dnl confusing with LibreSSL, OpenSSL, and various distributions' patches
1060 ERR_load_KDF_strings \
1064 SSL_CTX_set1_groups_list \
1065 SSL_CTX_set_security_level \
1066 SSL_SESSION_get_master_key \
1067 SSL_get_client_ciphers \
1068 SSL_get_client_random \
1069 SSL_get_server_random \
1073 dnl Check if OpenSSL structures are opaque
1074 AC_CHECK_MEMBERS([SSL.state], , ,
1075 [#include <openssl/ssl.h>
1078 AC_CHECK_SIZEOF(SHA_CTX, , [AC_INCLUDES_DEFAULT()
1079 #include <openssl/sha.h>
1084 dnl We will someday make KECCAK_TINY optional, but for now we still need
1085 dnl it for SHAKE, since OpenSSL's SHAKE can't be squeezed more than
1086 dnl once. See comment in the definition of crypto_xof_t.
1088 dnl AM_CONDITIONAL(BUILD_KECCAK_TINY,
1089 dnl test "x$ac_cv_func_EVP_sha3_256" != "xyes")
1091 AM_CONDITIONAL(BUILD_KECCAK_TINY, true)
1093 dnl ======================================================================
1094 dnl Can we use KIST?
1096 dnl Define the set of checks for KIST scheduler support.
1097 AC_DEFUN([CHECK_KIST_SUPPORT],[
1098 dnl KIST needs struct tcp_info and for certain members to exist.
1100 [struct tcp_info.tcpi_unacked, struct tcp_info.tcpi_snd_mss],
1101 , ,[[#include <netinet/tcp.h>]])
1102 dnl KIST needs SIOCOUTQNSD to exist for an ioctl call.
1103 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1104 #include <linux/sockios.h>
1108 ])], have_siocoutqnsd=yes, have_siocoutqnsd=no)
1109 if test "x$have_siocoutqnsd" = "xyes"; then
1110 if test "x$ac_cv_member_struct_tcp_info_tcpi_unacked" = "xyes"; then
1111 if test "x$ac_cv_member_struct_tcp_info_tcpi_snd_mss" = "xyes"; then
1112 have_kist_support=yes
1117 dnl Now, trigger the check.
1119 AS_IF([test "x$have_kist_support" = "xyes"],
1120 [AC_DEFINE(HAVE_KIST_SUPPORT, 1, [Defined if KIST scheduler is supported
1122 [AC_MSG_NOTICE([KIST scheduler can't be used. Missing support.])])
1125 LDFLAGS="$save_LDFLAGS"
1126 CPPFLAGS="$save_CPPFLAGS"
1128 dnl ------------------------------------------------------
1129 dnl Where do you live, zlib? And how do we call you?
1131 tor_zlib_pkg_redhat="zlib"
1132 tor_zlib_pkg_debian="zlib1g"
1133 tor_zlib_devpkg_redhat="zlib-devel"
1134 tor_zlib_devpkg_debian="zlib1g-dev"
1136 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
1137 [#include <zlib.h>],
1138 [const char * zlibVersion(void);],
1139 [zlibVersion();], [--with-zlib-dir],
1142 if test "$enable_static_zlib" = "yes"; then
1143 if test "$tor_cv_library_zlib_dir" = "(system)"; then
1144 AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
1145 using --enable-static-zlib")
1147 TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
1152 AC_SUBST(TOR_ZLIB_LIBS)
1154 dnl ------------------------------------------------------
1155 dnl Where we do we find lzma?
1158 AS_HELP_STRING(--enable-lzma, [enable support for the LZMA compression scheme.]),
1159 [case "${enableval}" in
1162 * ) AC_MSG_ERROR(bad value for --enable-lzma) ;;
1163 esac], [enable_lzma=auto])
1165 if test "x$enable_lzma" = "xno"; then
1168 PKG_CHECK_MODULES([LZMA],
1173 if test "x$have_lzma" = "xno" ; then
1174 AC_MSG_WARN([Unable to find liblzma, $pkg_config_user_action, or set LZMA_CFLAGS and LZMA_LIBS.])
1178 if test "x$have_lzma" = "xyes"; then
1179 AC_DEFINE(HAVE_LZMA,1,[Have LZMA])
1180 TOR_LZMA_CFLAGS="${LZMA_CFLAGS}"
1181 TOR_LZMA_LIBS="${LZMA_LIBS}"
1183 AC_SUBST(TOR_LZMA_CFLAGS)
1184 AC_SUBST(TOR_LZMA_LIBS)
1186 dnl ------------------------------------------------------
1187 dnl Where we do we find zstd?
1190 AS_HELP_STRING(--enable-zstd, [enable support for the Zstandard compression scheme.]),
1191 [case "${enableval}" in
1194 * ) AC_MSG_ERROR(bad value for --enable-zstd) ;;
1195 esac], [enable_zstd=auto])
1197 if test "x$enable_zstd" = "xno"; then
1200 PKG_CHECK_MODULES([ZSTD],
1205 if test "x$have_zstd" = "xno" ; then
1206 AC_MSG_WARN([Unable to find libzstd, $pkg_config_user_action, or set ZSTD_CFLAGS and ZSTD_LIBS.])
1210 if test "x$have_zstd" = "xyes"; then
1211 AC_DEFINE(HAVE_ZSTD,1,[Have Zstd])
1212 TOR_ZSTD_CFLAGS="${ZSTD_CFLAGS}"
1213 TOR_ZSTD_LIBS="${ZSTD_LIBS}"
1215 dnl now check for zstd functions
1217 save_CFLAGS="$CFLAGS"
1218 LIBS="$LIBS $ZSTD_LIBS"
1219 CFLAGS="$CFLAGS $ZSTD_CFLAGS"
1220 AC_CHECK_FUNCS(ZSTD_estimateCStreamSize \
1221 ZSTD_estimateDCtxSize)
1223 CFLAGS="$save_CFLAGS"
1225 AC_SUBST(TOR_ZSTD_CFLAGS)
1226 AC_SUBST(TOR_ZSTD_LIBS)
1228 dnl ----------------------------------------------------------------------
1229 dnl Check if libcap is available for capabilities.
1231 tor_cap_pkg_debian="libcap2"
1232 tor_cap_pkg_redhat="libcap"
1233 tor_cap_devpkg_debian="libcap-dev"
1234 tor_cap_devpkg_redhat="libcap-devel"
1236 AC_CHECK_LIB([cap], [cap_init], [],
1237 AC_MSG_NOTICE([Libcap was not found. Capabilities will not be usable.])
1239 AC_CHECK_FUNCS(cap_set_proc)
1241 dnl ---------------------------------------------------------------------
1242 dnl Now that we know about our major libraries, we can check for compiler
1243 dnl and linker hardening options. We need to do this with the libraries known,
1244 dnl since sometimes the linker will like an option but not be willing to
1245 dnl use it with a build of a library.
1247 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
1248 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"
1256 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1257 #if !defined(__clang__)
1259 #endif])], have_clang=yes, have_clang=no)
1261 if test "x$enable_pic" = "xyes"; then
1262 TOR_CHECK_CFLAGS(-fPIC)
1265 if test "x$enable_gcc_hardening" != "xno"; then
1266 CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
1267 if test "x$have_clang" = "xyes"; then
1268 TOR_CHECK_CFLAGS(-Qunused-arguments)
1270 TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
1271 AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
1272 AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
1273 m4_ifdef([AS_VAR_IF],[
1274 AS_VAR_IF(can_compile, [yes],
1275 AS_VAR_IF(can_link, [yes],
1277 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.)]))
1279 AS_VAR_POPDEF([can_link])
1280 AS_VAR_POPDEF([can_compile])
1281 TOR_CHECK_CFLAGS(-Wstack-protector)
1282 TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
1283 if test "$bwin32" = "false" && test "$enable_libfuzzer" != "yes" && test "$enable_oss_fuzz" != "yes"; then
1284 if test "$enable_pic" != "yes"; then
1285 # If we have already enabled -fPIC, then we don't also need to
1286 # compile with -fPIE...
1287 TOR_CHECK_CFLAGS(-fPIE)
1289 # ... but we want to link our executables with -pie in any case, since
1290 # they're executables, not a library.
1291 TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
1293 TOR_TRY_COMPILE_WITH_CFLAGS(-fwrapv, also_link, CFLAGS_FWRAPV="-fwrapv", true)
1295 AC_MSG_CHECKING([whether we can run hardened binaries])
1296 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
1297 [AC_MSG_RESULT([yes])],
1298 [AC_MSG_RESULT([no])
1300 We can link with compiler hardening options, but we can't run with them.
1301 That's a bad sign! If you must, you can pass --disable-gcc-hardening to
1302 configure, but it would be better to figure out what the underlying problem
1304 [AC_MSG_RESULT([cross])])
1307 if test "$fragile_hardening" = "yes"; then
1308 TOR_TRY_COMPILE_WITH_CFLAGS(-ftrapv, also_link, CFLAGS_FTRAPV="-ftrapv", true)
1309 if test "$tor_cv_cflags__ftrapv" = "yes" && test "$tor_can_link__ftrapv" != "yes"; then
1310 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.])
1313 if test "$tor_cv_cflags__ftrapv" != "yes"; then
1314 AC_MSG_ERROR([You requested fragile hardening, but the compiler does not seem to support -ftrapv.])
1317 TOR_TRY_COMPILE_WITH_CFLAGS([-fsanitize=address], also_link, CFLAGS_ASAN="-fsanitize=address", true)
1318 if test "$tor_cv_cflags__fsanitize_address" = "yes" && test "$tor_can_link__fsanitize_address" != "yes"; then
1319 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*])
1322 TOR_TRY_COMPILE_WITH_CFLAGS([-fsanitize=undefined], also_link, CFLAGS_UBSAN="-fsanitize=undefined", true)
1323 if test "$tor_cv_cflags__fsanitize_address" = "yes" && test "$tor_can_link__fsanitize_address" != "yes"; then
1324 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*])
1327 TOR_TRY_COMPILE_WITH_CFLAGS([-fno-sanitize=float-divide-by-zero], also_link, CFLAGS_UBSAN="-fno-sanitize=float-divide-by-zero", true)
1328 if test "$tor_cv_cflags__fno_sanitize_float_divide_by_zero" = "yes" && test "$tor_can_link__fno_sanitize_float_divide_by_zero" != "yes"; then
1329 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*])
1332 TOR_CHECK_CFLAGS([-fno-omit-frame-pointer])
1335 dnl Find the correct libraries to add in order to use the sanitizers.
1337 dnl When building Rust, Cargo will run the linker with the -nodefaultlibs
1338 dnl option, which will prevent the compiler from linking the sanitizer
1339 dnl libraries it needs. We need to specify them manually.
1341 dnl What's more, we need to specify them in a linker script rather than
1342 dnl from build.rs: these options aren't allowed in the cargo:rustc-flags
1344 RUST_LINKER_OPTIONS=""
1345 if test "x$have_clang" = "xyes"; then
1346 if test "x$CFLAGS_ASAN" != "x"; then
1347 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_ASAN -Cdefault-linker-libraries"
1349 if test "x$CFLAGS_UBSAN" != "x"; then
1350 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_UBSAN -Cdefault-linker-libraries"
1353 if test "x$CFLAGS_ASAN" != "x"; then
1354 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=address -Cdefault-linker-libraries"
1356 if test "x$CFLAGS_UBSAN" != "x"; then
1357 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=undefined -Cdefault-linker-libraries"
1360 AC_SUBST(RUST_LINKER_OPTIONS)
1362 CFLAGS_BUGTRAP="$CFLAGS_FTRAPV $CFLAGS_ASAN $CFLAGS_UBSAN"
1363 CFLAGS_CONSTTIME="$CFLAGS_FWRAPV"
1365 mulodi_fixes_ftrapv=no
1366 if test "$have_clang" = "yes"; then
1367 saved_CFLAGS="$CFLAGS"
1368 CFLAGS="$CFLAGS $CFLAGS_FTRAPV"
1369 AC_MSG_CHECKING([whether clang -ftrapv can link a 64-bit int multiply])
1374 int main(int argc, char **argv)
1376 int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
1377 * (int64_t)atoi(argv[3]);
1380 [ftrapv_can_link=yes; AC_MSG_RESULT([yes])],
1381 [ftrapv_can_link=no; AC_MSG_RESULT([no])])
1382 if test "$ftrapv_can_link" = "no"; then
1383 AC_MSG_CHECKING([whether defining __mulodi4 fixes that])
1388 int64_t __mulodi4(int64_t a, int64_t b, int *overflow) {
1392 int main(int argc, char **argv)
1394 int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
1395 * (int64_t)atoi(argv[3]);
1398 [mulodi_fixes_ftrapv=yes; AC_MSG_RESULT([yes])],
1399 [mulodi_fixes_ftrapv=no; AC_MSG_RESULT([no])])
1401 CFLAGS="$saved_CFLAGS"
1404 AM_CONDITIONAL(ADD_MULODI4, test "$mulodi_fixes_ftrapv" = "yes")
1406 dnl These cflags add bunches of branches, and we haven't been able to
1407 dnl persuade ourselves that they're suitable for code that needs to be
1409 AC_SUBST(CFLAGS_BUGTRAP)
1410 dnl These cflags are variant ones sutable for code that needs to be
1412 AC_SUBST(CFLAGS_CONSTTIME)
1414 if test "x$enable_linker_hardening" != "xno"; then
1415 TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
1418 # For backtrace support
1419 TOR_CHECK_LDFLAGS(-rdynamic)
1421 dnl ------------------------------------------------------
1422 dnl Now see if we have a -fomit-frame-pointer compiler option.
1424 saved_CFLAGS="$CFLAGS"
1425 TOR_CHECK_CFLAGS(-fomit-frame-pointer)
1426 F_OMIT_FRAME_POINTER=''
1427 if test "$saved_CFLAGS" != "$CFLAGS"; then
1428 if test "$fragile_hardening" = "yes"; then
1429 F_OMIT_FRAME_POINTER='-fomit-frame-pointer'
1432 CFLAGS="$saved_CFLAGS"
1433 AC_SUBST(F_OMIT_FRAME_POINTER)
1435 dnl ------------------------------------------------------
1436 dnl If we are adding -fomit-frame-pointer (or if the compiler's doing it
1437 dnl for us, as GCC 4.6 and later do at many optimization levels), then
1438 dnl we should try to add -fasynchronous-unwind-tables so that our backtrace
1440 TOR_CHECK_CFLAGS(-fasynchronous-unwind-tables)
1442 dnl ============================================================
1443 dnl Check for libseccomp
1445 if test "x$enable_seccomp" != "xno"; then
1446 AC_CHECK_HEADERS([seccomp.h])
1447 AC_SEARCH_LIBS(seccomp_init, [seccomp])
1450 dnl ============================================================
1451 dnl Check for libscrypt
1453 if test "x$enable_libscrypt" != "xno"; then
1454 AC_CHECK_HEADERS([libscrypt.h])
1455 AC_SEARCH_LIBS(libscrypt_scrypt, [scrypt])
1456 AC_CHECK_FUNCS([libscrypt_scrypt])
1459 dnl ============================================================
1460 dnl We need an implementation of curve25519.
1462 dnl set these defaults.
1463 build_curve25519_donna=no
1464 build_curve25519_donna_c64=no
1465 use_curve25519_donna=no
1466 use_curve25519_nacl=no
1469 dnl The best choice is using curve25519-donna-c64, but that requires
1471 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
1472 tor_cv_can_use_curve25519_donna_c64,
1474 [AC_LANG_PROGRAM([dnl
1476 typedef unsigned uint128_t __attribute__((mode(TI)));
1477 int func(uint64_t a, uint64_t b) {
1478 uint128_t c = ((uint128_t)a) * b;
1479 int ok = ((uint64_t)(c>>96)) == 522859 &&
1480 (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
1481 (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
1482 (((uint64_t)(c))&0xffffffffL) == 0;
1486 int ok = func( ((uint64_t)2000000000) * 1000000000,
1487 ((uint64_t)1234567890) << 24);
1490 [tor_cv_can_use_curve25519_donna_c64=yes],
1491 [tor_cv_can_use_curve25519_donna_c64=no],
1493 [AC_LANG_PROGRAM([dnl
1495 typedef unsigned uint128_t __attribute__((mode(TI)));
1496 int func(uint64_t a, uint64_t b) {
1497 uint128_t c = ((uint128_t)a) * b;
1498 int ok = ((uint64_t)(c>>96)) == 522859 &&
1499 (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
1500 (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
1501 (((uint64_t)(c))&0xffffffffL) == 0;
1505 int ok = func( ((uint64_t)2000000000) * 1000000000,
1506 ((uint64_t)1234567890) << 24);
1509 [tor_cv_can_use_curve25519_donna_c64=cross],
1510 [tor_cv_can_use_curve25519_donna_c64=no])])])
1512 AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
1513 nacl/crypto_scalarmult_curve25519.h])
1515 AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
1516 tor_cv_can_use_curve25519_nacl,
1517 [tor_saved_LIBS="$LIBS"
1520 [AC_LANG_PROGRAM([dnl
1521 #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
1522 #include <crypto_scalarmult_curve25519.h>
1523 #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
1524 #include <nacl/crypto_scalarmult_curve25519.h>
1526 #ifdef crypto_scalarmult_curve25519_ref_BYTES
1527 #error Hey, this is the reference implementation! That's not fast.
1530 unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
1531 ])], [tor_cv_can_use_curve25519_nacl=yes],
1532 [tor_cv_can_use_curve25519_nacl=no])
1533 LIBS="$tor_saved_LIBS" ])
1535 dnl Okay, now we need to figure out which one to actually use. Fall back
1536 dnl to curve25519-donna.c
1538 if test "x$tor_cv_can_use_curve25519_donna_c64" != "xno"; then
1539 build_curve25519_donna_c64=yes
1540 use_curve25519_donna=yes
1541 elif test "x$tor_cv_can_use_curve25519_nacl" = "xyes"; then
1542 use_curve25519_nacl=yes
1543 CURVE25519_LIBS=-lnacl
1545 build_curve25519_donna=yes
1546 use_curve25519_donna=yes
1549 if test "x$use_curve25519_donna" = "xyes"; then
1550 AC_DEFINE(USE_CURVE25519_DONNA, 1,
1551 [Defined if we should use an internal curve25519_donna{,_c64} implementation])
1553 if test "x$use_curve25519_nacl" = "xyes"; then
1554 AC_DEFINE(USE_CURVE25519_NACL, 1,
1555 [Defined if we should use a curve25519 from nacl])
1557 AM_CONDITIONAL(BUILD_CURVE25519_DONNA,
1558 test "x$build_curve25519_donna" = "xyes")
1559 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64,
1560 test "x$build_curve25519_donna_c64" = "xyes")
1561 AC_SUBST(CURVE25519_LIBS)
1563 dnl Make sure to enable support for large off_t if available.
1566 AC_CHECK_HEADERS([errno.h \
1580 gnu/libc-version.h \
1620 AC_CHECK_HEADERS(sys/param.h)
1622 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
1623 [#ifdef HAVE_SYS_TYPES_H
1624 #include <sys/types.h>
1626 #ifdef HAVE_SYS_SOCKET_H
1627 #include <sys/socket.h>
1629 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
1630 [#ifdef HAVE_SYS_TYPES_H
1631 #include <sys/types.h>
1633 #ifdef HAVE_SYS_SOCKET_H
1634 #include <sys/socket.h>
1636 #ifdef HAVE_NET_IF_H
1639 #ifdef HAVE_NETINET_IN_H
1640 #include <netinet/in.h>
1643 AC_CHECK_HEADERS(linux/if.h,[],[],
1645 #ifdef HAVE_SYS_SOCKET_H
1646 #include <sys/socket.h>
1650 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
1651 linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
1652 [#ifdef HAVE_SYS_TYPES_H
1653 #include <sys/types.h>
1655 #ifdef HAVE_SYS_SOCKET_H
1656 #include <sys/socket.h>
1658 #ifdef HAVE_LIMITS_H
1661 #ifdef HAVE_LINUX_TYPES_H
1662 #include <linux/types.h>
1664 #ifdef HAVE_NETINET_IN6_H
1665 #include <netinet/in6.h>
1667 #ifdef HAVE_NETINET_IN_H
1668 #include <netinet/in.h>
1671 AC_CHECK_HEADERS(linux/netfilter_ipv6/ip6_tables.h,
1672 linux_netfilter_ipv6_ip6_tables=1, linux_netfilter_ipv6_ip6_tables=0,
1673 [#ifdef HAVE_SYS_TYPES_H
1674 #include <sys/types.h>
1676 #ifdef HAVE_SYS_SOCKET_H
1677 #include <sys/socket.h>
1679 #ifdef HAVE_LIMITS_H
1682 #ifdef HAVE_LINUX_TYPES_H
1683 #include <linux/types.h>
1685 #ifdef HAVE_NETINET_IN6_H
1686 #include <netinet/in6.h>
1688 #ifdef HAVE_NETINET_IN_H
1689 #include <netinet/in.h>
1691 #ifdef HAVE_LINUX_IF_H
1692 #include <linux/if.h>
1696 if test "x$net_if_found" = "x1" && test "x$net_pfvar_found" = "x1"; then
1699 if test "x$linux_netfilter_ipv4" = "x1"; then
1702 if test "x$linux_netfilter_ipv6_ip6_tables" = "x1"; then
1705 if test "x$transparent_ok" = "x1"; then
1706 AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
1708 AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
1711 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
1712 [#ifdef HAVE_SYS_TYPES_H
1713 #include <sys/types.h>
1715 #ifdef HAVE_SYS_TIME_H
1716 #include <sys/time.h>
1719 AC_CHECK_SIZEOF(char)
1720 AC_CHECK_SIZEOF(short)
1721 AC_CHECK_SIZEOF(int)
1722 AC_CHECK_SIZEOF(unsigned int)
1723 AC_CHECK_SIZEOF(long)
1724 AC_CHECK_SIZEOF(long long)
1725 AC_CHECK_SIZEOF(__int64)
1726 AC_CHECK_SIZEOF(void *)
1727 AC_CHECK_SIZEOF(time_t)
1728 AC_CHECK_SIZEOF(size_t)
1729 AC_CHECK_SIZEOF(pid_t)
1731 AC_CHECK_TYPES([uint, u_char, ssize_t])
1733 AC_PC_FROM_UCONTEXT([:])
1735 dnl used to include sockaddr_storage, but everybody has that.
1736 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
1737 [#ifdef HAVE_SYS_TYPES_H
1738 #include <sys/types.h>
1740 #ifdef HAVE_NETINET_IN_H
1741 #include <netinet/in.h>
1743 #ifdef HAVE_NETINET_IN6_H
1744 #include <netinet/in6.h>
1746 #ifdef HAVE_SYS_SOCKET_H
1747 #include <sys/socket.h>
1750 #define _WIN32_WINNT 0x0501
1751 #define WIN32_LEAN_AND_MEAN
1752 #include <winsock2.h>
1753 #include <ws2tcpip.h>
1756 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
1757 [#ifdef HAVE_SYS_TYPES_H
1758 #include <sys/types.h>
1760 #ifdef HAVE_NETINET_IN_H
1761 #include <netinet/in.h>
1763 #ifdef HAVE_NETINET_IN6_H
1764 #include <netinet/in6.h>
1766 #ifdef HAVE_SYS_SOCKET_H
1767 #include <sys/socket.h>
1770 #define _WIN32_WINNT 0x0501
1771 #define WIN32_LEAN_AND_MEAN
1772 #include <winsock2.h>
1773 #include <ws2tcpip.h>
1777 AC_CHECK_TYPES([rlim_t], , ,
1778 [#ifdef HAVE_SYS_TYPES_H
1779 #include <sys/types.h>
1781 #ifdef HAVE_SYS_TIME_H
1782 #include <sys/time.h>
1784 #ifdef HAVE_SYS_RESOURCE_H
1785 #include <sys/resource.h>
1789 AX_CHECK_SIGN([time_t],
1792 #ifdef HAVE_SYS_TYPES_H
1793 #include <sys/types.h>
1795 #ifdef HAVE_SYS_TIME_H
1796 #include <sys/time.h>
1803 if test "$ax_cv_decl_time_t_signed" = "no"; then
1804 AC_MSG_ERROR([You have an unsigned time_t; Tor does not support that. Please tell the Tor developers about your interesting platform.])
1807 AX_CHECK_SIGN([size_t],
1808 [ tor_cv_size_t_signed=yes ],
1809 [ tor_cv_size_t_signed=no ], [
1810 #ifdef HAVE_SYS_TYPES_H
1811 #include <sys/types.h>
1815 if test "$ax_cv_decl_size_t_signed" = "yes"; then
1816 AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
1819 AX_CHECK_SIGN([enum always],
1820 [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
1822 enum always { AAA, BBB, CCC };
1825 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
1826 #ifdef HAVE_SYS_SOCKET_H
1827 #include <sys/socket.h>
1831 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1833 AC_CHECK_SIZEOF(cell_t)
1835 # Let's see if stdatomic works. (There are some debian clangs that screw it
1836 # up; see Tor bug #26779 and debian bug 903709.)
1837 AC_CACHE_CHECK([whether C11 stdatomic.h actually works],
1838 tor_cv_stdatomic_works,
1839 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1840 #include <stdatomic.h>
1841 struct x { atomic_size_t y; };
1842 void try_atomic_init(struct x *xx)
1844 atomic_init(&xx->y, 99);
1845 atomic_fetch_add(&xx->y, 1);
1847 ]])], [tor_cv_stdatomic_works=yes], [tor_cv_stdatomic_works=no])])
1849 if test "$tor_cv_stdatomic_works" = "yes"; then
1850 AC_DEFINE(STDATOMIC_WORKS, 1, [Set to 1 if we can compile a simple stdatomic example.])
1851 elif test "$ac_cv_header_stdatomic_h" = "yes"; then
1852 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 ])
1855 # Now make sure that NULL can be represented as zero bytes.
1856 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1857 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1858 [[#include <stdlib.h>
1861 #ifdef HAVE_STDDEF_H
1864 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1865 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1866 [tor_cv_null_is_zero=yes],
1867 [tor_cv_null_is_zero=no],
1868 [tor_cv_null_is_zero=cross])])
1870 if test "$tor_cv_null_is_zero" = "cross"; then
1871 # Cross-compiling; let's hope that the target isn't raving mad.
1872 AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
1875 if test "$tor_cv_null_is_zero" != "no"; then
1876 AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1877 [Define to 1 iff memset(0) sets pointers to NULL])
1880 AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
1881 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1882 [[#include <stdlib.h>
1885 #ifdef HAVE_STDDEF_H
1888 int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
1889 return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
1890 [tor_cv_dbl0_is_zero=yes],
1891 [tor_cv_dbl0_is_zero=no],
1892 [tor_cv_dbl0_is_zero=cross])])
1894 if test "$tor_cv_dbl0_is_zero" = "cross"; then
1895 # Cross-compiling; let's hope that the target isn't raving mad.
1896 AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
1899 if test "$tor_cv_dbl0_is_zero" != "no"; then
1900 AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
1901 [Define to 1 iff memset(0) sets doubles to 0.0])
1904 # And what happens when we malloc zero?
1905 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
1906 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1907 [[#include <stdlib.h>
1910 #ifdef HAVE_STDDEF_H
1913 int main () { return malloc(0)?0:1; }]])],
1914 [tor_cv_malloc_zero_works=yes],
1915 [tor_cv_malloc_zero_works=no],
1916 [tor_cv_malloc_zero_works=cross])])
1918 if test "$tor_cv_malloc_zero_works" = "cross"; then
1919 # Cross-compiling; let's hope that the target isn't raving mad.
1920 AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
1923 if test "$tor_cv_malloc_zero_works" = "yes"; then
1924 AC_DEFINE([MALLOC_ZERO_WORKS], 1,
1925 [Define to 1 iff malloc(0) returns a pointer])
1928 # whether we seem to be in a 2s-complement world.
1929 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
1930 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1931 [[int main () { int problem = ((-99) != (~99)+1);
1932 return problem ? 1 : 0; }]])],
1933 [tor_cv_twos_complement=yes],
1934 [tor_cv_twos_complement=no],
1935 [tor_cv_twos_complement=cross])])
1937 if test "$tor_cv_twos_complement" = "cross"; then
1938 # Cross-compiling; let's hope that the target isn't raving mad.
1939 AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
1942 if test "$tor_cv_twos_complement" != "no"; then
1943 AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
1944 [Define to 1 iff we represent negative integers with
1948 # What does shifting a negative value do?
1949 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
1950 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1951 [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
1952 [tor_cv_sign_extend=yes],
1953 [tor_cv_sign_extend=no],
1954 [tor_cv_sign_extend=cross])])
1956 if test "$tor_cv_sign_extend" = "cross"; then
1957 # Cross-compiling; let's hope that the target isn't raving mad.
1958 AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
1961 if test "$tor_cv_sign_extend" != "no"; then
1962 AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
1963 [Define to 1 iff right-shifting a negative value performs sign-extension])
1966 # Is uint8_t the same type as unsigned char?
1967 AC_CACHE_CHECK([whether uint8_t is the same type as unsigned char], tor_cv_uint8_uchar,
1968 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1971 unsigned char c;]])],
1972 [tor_cv_uint8_uchar=yes],
1973 [tor_cv_uint8_uchar=no],
1974 [tor_cv_uint8_uchar=cross])])
1976 if test "$tor_cv_uint8_uchar" = "cross"; then
1977 AC_MSG_NOTICE([Cross-compiling: we'll assume that uint8_t is the same type as unsigned char])
1980 if test "$tor_cv_uint8_uchar" = "no"; then
1981 AC_MSG_ERROR([We assume that uint8_t is the same type as unsigned char, but your compiler disagrees.])
1984 AC_ARG_WITH(tcmalloc,
1985 AS_HELP_STRING(--with-tcmalloc, [use tcmalloc memory allocation library. Deprecated; see --with-malloc]))
1987 default_malloc=system
1989 if test "x$enable_openbsd_malloc" = "xyes" ; then
1990 AC_MSG_NOTICE([The --enable-openbsd-malloc argument is deprecated; use --with-malloc=openbsd instead.])
1991 default_malloc=openbsd
1994 if test "x$with_tcmalloc" = "xyes"; then
1995 AC_MSG_NOTICE([The --with-tcmalloc argument is deprecated; use --with-malloc=tcmalloc instead.])
1996 default_malloc=tcmalloc
2000 AS_HELP_STRING([--with-malloc=[system,jemalloc,tcmalloc,openbsd]],
2001 [select special malloc implementation [system]]),
2002 [ malloc="$with_malloc" ], [ malloc="$default_malloc" ])
2006 PKG_CHECK_MODULES([TCMALLOC],
2011 if test "x$have_tcmalloc" = "xno" ; then
2012 AC_MSG_ERROR([Unable to find tcmalloc requested by --with-malloc, $pkg_config_user_action, or set TCMALLOC_CFLAGS and TCMALLOC_LIBS.])
2015 CFLAGS="$CFLAGS $TCMALLOC_CFLAGS"
2016 LIBS="$TCMALLOC_LIBS $LIBS"
2020 PKG_CHECK_MODULES([JEMALLOC],
2025 if test "x$have_jemalloc" = "xno" ; then
2026 AC_MSG_ERROR([Unable to find jemalloc requested by --with-malloc, $pkg_config_user_action, or set JEMALLOC_CFLAGS and JEMALLOC_LIBS.])
2029 CFLAGS="$CFLAGS $JEMALLOC_CFLAGS"
2030 LIBS="$JEMALLOC_LIBS $LIBS"
2031 using_custom_malloc=yes
2035 AC_MSG_WARN([The openbsd malloc port is deprecated in Tor 0.3.5 and will be removed in a future version.])
2036 enable_openbsd_malloc=yes
2040 # handle this later, including the jemalloc fallback
2043 [AC_MSG_ERROR([--with-malloc=`$with_malloc' not supported, see --help])
2046 AM_CONDITIONAL(USE_OPENBSD_MALLOC, test "x$enable_openbsd_malloc" = "xyes")
2048 if test "$malloc" != "system"; then
2049 # Tell the C compiler not to use the system allocator functions.
2050 TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
2052 if test "$using_custom_malloc" = "yes"; then
2053 # Tell the C compiler not to use the system allocator functions.
2054 TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
2057 # By default, we're going to assume we don't have mlockall()
2058 # bionic and other platforms have various broken mlockall subsystems.
2059 # Some systems don't have a working mlockall, some aren't linkable,
2060 # and some have it but don't declare it.
2061 AC_CHECK_FUNCS(mlockall)
2062 AC_CHECK_DECLS([mlockall], , , [
2063 #ifdef HAVE_SYS_MMAN_H
2064 #include <sys/mman.h>
2067 # Allow user to specify an alternate syslog facility
2068 AC_ARG_WITH(syslog-facility,
2069 AS_HELP_STRING(--with-syslog-facility=LOG, [syslog facility to use (default=LOG_DAEMON)]),
2070 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
2071 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
2072 AC_SUBST(LOGFACILITY)
2074 # Check if we have getresuid and getresgid
2075 AC_CHECK_FUNCS(getresuid getresgid)
2077 # Check for gethostbyname_r in all its glorious incompatible versions.
2078 # (This logic is based on that in Python's configure.in)
2079 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
2080 [Define this if you have any gethostbyname_r()])
2082 AC_CHECK_FUNC(gethostbyname_r, [
2083 AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
2085 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
2086 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2090 struct hostent *h1, *h2;
2092 (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
2094 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2095 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2096 [Define this if gethostbyname_r takes 6 arguments])
2099 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2105 (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
2107 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2108 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2109 [Define this if gethostbyname_r takes 5 arguments])
2112 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2117 struct hostent_data hd;
2118 (void) gethostbyname_r(cp1,h1,&hd);
2120 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2121 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2122 [Define this if gethostbyname_r takes 3 arguments])
2132 AC_CACHE_CHECK([whether the C compiler supports __func__],
2133 tor_cv_have_func_macro,
2134 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2136 int main(int c, char **v) { puts(__func__); }])],
2137 tor_cv_have_func_macro=yes,
2138 tor_cv_have_func_macro=no))
2140 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
2141 tor_cv_have_FUNC_macro,
2142 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2144 int main(int c, char **v) { puts(__FUNC__); }])],
2145 tor_cv_have_FUNC_macro=yes,
2146 tor_cv_have_FUNC_macro=no))
2148 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
2149 tor_cv_have_FUNCTION_macro,
2150 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2152 int main(int c, char **v) { puts(__FUNCTION__); }])],
2153 tor_cv_have_FUNCTION_macro=yes,
2154 tor_cv_have_FUNCTION_macro=no))
2156 AC_CACHE_CHECK([whether we have extern char **environ already declared],
2157 tor_cv_have_environ_declared,
2158 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2159 #ifdef HAVE_UNISTD_H
2163 int main(int c, char **v) { char **t = environ; }])],
2164 tor_cv_have_environ_declared=yes,
2165 tor_cv_have_environ_declared=no))
2167 if test "$tor_cv_have_func_macro" = "yes"; then
2168 AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
2171 if test "$tor_cv_have_FUNC_macro" = "yes"; then
2172 AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
2175 if test "$tor_cv_have_FUNCTION_macro" = "yes"; then
2176 AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
2177 [Defined if the compiler supports __FUNCTION__])
2180 if test "$tor_cv_have_environ_declared" = "yes"; then
2181 AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
2182 [Defined if we have extern char **environ already declared])
2185 # $prefix stores the value of the --prefix command line option, or
2186 # NONE if the option wasn't set. In the case that it wasn't set, make
2187 # it be the default, so that we can use it to expand directories now.
2188 if test "x$prefix" = "xNONE"; then
2189 prefix=$ac_default_prefix
2192 # and similarly for $exec_prefix
2193 if test "x$exec_prefix" = "xNONE"; then
2197 if test "x$BUILDDIR" = "x"; then
2201 AH_TEMPLATE([BUILDDIR],[tor's build directory])
2202 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
2204 if test "x$SRCDIR" = "x"; then
2205 SRCDIR=$(cd "$srcdir"; pwd)
2207 AH_TEMPLATE([SRCDIR],[tor's sourcedir directory])
2208 AC_DEFINE_UNQUOTED(SRCDIR,"$SRCDIR")
2210 if test "x$CONFDIR" = "x"; then
2211 CONFDIR=`eval echo $sysconfdir/tor`
2214 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
2215 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
2217 BINDIR=`eval echo $bindir`
2219 LOCALSTATEDIR=`eval echo $localstatedir`
2220 AC_SUBST(LOCALSTATEDIR)
2222 if test "$bwin32" = "true"; then
2223 # Test if the linker supports the --nxcompat and --dynamicbase options
2225 save_LDFLAGS="$LDFLAGS"
2226 LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
2227 AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
2228 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
2229 [AC_MSG_RESULT([yes])]
2230 [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
2231 [AC_MSG_RESULT([no])]
2233 LDFLAGS="$save_LDFLAGS"
2236 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
2237 # than autoconf's macros like.
2238 if test "$GCC" = "yes"; then
2239 # Disable GCC's strict aliasing checks. They are an hours-to-debug
2240 # accident waiting to happen.
2241 CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
2243 # Override optimization level for non-gcc compilers
2245 enable_gcc_warnings=no
2246 enable_gcc_warnings_advisory=no
2249 # Warnings implies advisory-warnings and -Werror.
2250 if test "$enable_gcc_warnings" = "yes"; then
2251 enable_gcc_warnings_advisory=yes
2252 enable_fatal_warnings=yes
2255 # OS X Lion started deprecating the system openssl. Let's just disable
2256 # all deprecation warnings on OS X. Also, to potentially make the binary
2257 # a little smaller, let's enable dead_strip.
2261 CFLAGS="$CFLAGS -Wno-deprecated-declarations"
2262 LDFLAGS="$LDFLAGS -dead_strip" ;;
2265 TOR_WARNING_FLAGS=""
2267 # Add some more warnings which we use in development but not in the
2268 # released versions. (Some relevant gcc versions can't handle these.)
2270 # Note that we have to do this near the end of the autoconf process, or
2271 # else we may run into problems when these warnings hit on the testing C
2272 # programs that autoconf wants to build.
2273 if test "x$enable_gcc_warnings_advisory" != "xno"; then
2276 *-*-openbsd* | *-*-bitrig*)
2277 # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
2278 # That's fine, except that the headers don't pass -Wredundant-decls.
2279 # Therefore, let's disable -Wsystem-headers when we're building
2280 # with maximal warnings on OpenBSD.
2281 CFLAGS="$CFLAGS -Wno-system-headers" ;;
2284 CFLAGS_NOWARNINGS="$CFLAGS"
2286 # GCC4.3 users once report trouble with -Wstrict-overflow=5. GCC5 users
2287 # have it work better.
2288 # CFLAGS="$CFLAGS -Wstrict-overflow=1"
2290 # This warning was added in gcc 4.3, but it appears to generate
2291 # spurious warnings in gcc 4.4. I don't know if it works in 4.5.
2292 #CFLAGS="$CFLAGS -Wlogical-op"
2294 m4_foreach_w([warning_flag], [
2296 -Waddress-of-array-temporary
2297 -Waddress-of-temporary
2299 -Wanonymous-pack-parens
2302 -Warc-bridge-casts-disallowed-in-nonarc
2303 -Warc-maybe-repeated-use-of-weak
2304 -Warc-performSelector-leaks
2305 -Warc-repeated-use-of-weak
2307 -Warray-bounds-pointer-arithmetic
2309 -Wasm-operand-widths
2311 -Watomic-property-with-user-defined-accessor
2313 -Wauto-storage-class
2316 -Wbackslash-newline-escape
2317 -Wbad-array-new-length
2318 -Wbind-to-temporary-copy
2319 -Wbitfield-constant-conversion
2322 -Wbuiltin-requires-header
2324 -Wcompare-distinct-pointer-types
2325 -Wcomplex-component-init
2326 -Wconditional-type-mismatch
2328 -Wconstant-conversion
2329 -Wconstant-logical-operand
2330 -Wconstexpr-not-const
2331 -Wcustom-atomic-properties
2333 -Wdangling-initializer-list
2335 -Wdelegating-ctor-cycles
2336 -Wdeprecated-implementations
2337 -Wdeprecated-register
2338 -Wdirect-ivar-access
2340 -Wdistributed-object-modifiers
2342 -Wdollar-in-identifier-extension
2344 -Wduplicate-decl-specifier
2346 -Wduplicate-method-arg
2347 -Wduplicate-method-match
2349 -Wdynamic-class-memaccess
2350 -Wembedded-directive
2351 -Wempty-translation-unit
2353 -Wexit-time-destructors
2354 -Wexplicit-ownership-type
2355 -Wextern-initializer
2359 -Wflexible-array-extensions
2362 -Wfour-char-constants
2364 -Wglobal-constructors
2365 -Wgnu-array-member-paren-init
2367 -Wgnu-static-float-init
2370 -Widiomatic-parentheses
2371 -Wignored-attributes
2372 -Wimplicit-atomic-properties
2373 -Wimplicit-conversion-floating-point-to-bool
2374 -Wimplicit-exception-spec-mismatch
2375 -Wimplicit-fallthrough
2376 -Wimplicit-fallthrough-per-function
2377 -Wimplicit-retain-self
2378 -Wimport-preprocessor-directive-pedantic
2379 -Wincompatible-library-redeclaration
2380 -Wincompatible-pointer-types-discards-qualifiers
2381 -Wincomplete-implementation
2383 -Wincomplete-umbrella
2386 -Wint-to-void-pointer-cast
2392 -Winvalid-source-encoding
2393 -Winvalid-token-paste
2394 -Wknr-promoted-parameter
2395 -Wlarge-by-value-copy
2396 -Wliteral-conversion
2398 -Wlocal-type-template-args
2402 -Wmalformed-warning-check
2406 -Wmismatched-parameter-types
2407 -Wmismatched-return-types
2408 -Wmissing-field-initializers
2409 -Wmissing-format-attribute
2411 -Wmissing-selector-name
2413 -Wmissing-variable-declarations
2417 -Wnon-literal-null-conversion
2419 -Wnonportable-cfstrings
2425 -Wout-of-line-declaration
2427 -Woverlength-strings
2429 -Woverriding-method-mismatch
2430 -Wpointer-type-mismatch
2431 -Wpredefined-identifier-outside-function
2432 -Wprotocol-property-synthesis-ambiguity
2433 -Wreadonly-iboutlet-property
2434 -Wreadonly-setter-attrs
2436 -Wreceiver-forward-class
2438 -Wreinterpret-base-class
2439 -Wrequires-super-attribute
2440 -Wreserved-user-defined-literal
2441 -Wreturn-stack-address
2443 -Wselector-type-mismatch
2445 -Wserialized-diagnostics
2447 -Wshift-count-negative
2448 -Wshift-count-overflow
2449 -Wshift-negative-value
2451 -Wshift-sign-overflow
2453 -Wsizeof-array-argument
2454 -Wsource-uses-openmp
2457 -Wstatic-local-in-inline
2461 -Wstrlcpy-strlcat-size
2463 -Wsuggest-attribute=format
2464 -Wsuggest-attribute=noreturn
2465 -Wsuper-class-method-mismatch
2468 -Wtautological-constant-out-of-range-compare
2469 -Wtentative-definition-incomplete-type
2472 -Wtypedef-redefinition
2475 -Wundefined-internal
2476 -Wundefined-reinterpret-cast
2478 -Wunicode-whitespace
2479 -Wunknown-warning-option
2480 -Wunnamed-type-template-args
2481 -Wunneeded-member-function
2483 -Wunsupported-visibility
2484 -Wunused-but-set-parameter
2485 -Wunused-but-set-variable
2486 -Wunused-command-line-argument
2487 -Wunused-const-variable=2
2488 -Wunused-exception-parameter
2489 -Wunused-local-typedefs
2490 -Wunused-member-function
2491 -Wunused-sanitize-argument
2492 -Wunused-volatile-lvalue
2493 -Wuser-defined-literals
2496 -Wvector-conversions
2501 ], [ TOR_TRY_COMPILE_WITH_CFLAGS(warning_flag, [],
2502 [TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS warning_flag" CFLAGS="$CFLAGS warning_flag"], true)
2505 dnl We should re-enable this in some later version. Clang doesn't
2506 dnl mind, but it causes trouble with GCC.
2507 dnl -Wstrict-overflow=2
2509 dnl These seem to require annotations that we don't currently use,
2510 dnl and they give false positives in our pthreads wrappers. (Clang 4)
2512 dnl -Wthread-safety-analysis
2513 dnl -Wthread-safety-attributes
2514 dnl -Wthread-safety-beta
2515 dnl -Wthread-safety-precise
2517 W_FLAGS="$W_FLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
2518 W_FLAGS="$W_FLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
2519 W_FLAGS="$W_FLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
2520 W_FLAGS="$W_FLAGS -Wwrite-strings"
2521 W_FLAGS="$W_FLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
2522 W_FLAGS="$W_FLAGS -Waggregate-return -Wpacked -Wunused"
2523 W_FLAGS="$W_FLAGS -Wunused-parameter "
2524 # These interfere with building main() { return 0; }, which autoconf
2525 # likes to use as its default program.
2526 W_FLAGS="$W_FLAGS -Wold-style-definition -Wmissing-declarations"
2528 TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS $W_FLAGS"
2529 CFLAGS="$CFLAGS $W_FLAGS"
2531 if test "$tor_cv_cflags__Wnull_dereference" = "yes"; then
2532 AC_DEFINE([HAVE_CFLAG_WNULL_DEREFERENCE], 1, [True if we have -Wnull-dereference])
2534 if test "$tor_cv_cflags__Woverlength_strings" = "yes"; then
2535 AC_DEFINE([HAVE_CFLAG_WOVERLENGTH_STRINGS], 1, [True if we have -Woverlength-strings])
2537 if test "$tor_cv_cflags__warn_unused_const_variable_2" = "yes"; then
2538 AC_DEFINE([HAVE_CFLAG_WUNUSED_CONST_VARIABLE], 1, [True if we have -Wunused-const-variable])
2541 CFLAGS="$CFLAGS_NOWARNINGS"
2543 if test "x$enable_fatal_warnings" = "xyes"; then
2544 # I'd like to use TOR_CHECK_CFLAGS here, but I can't, since the
2545 # default autoconf programs are full of errors.
2546 CFLAGS="$CFLAGS -Werror"
2551 AC_SUBST(TOR_WARNING_FLAGS)
2553 echo "$TOR_WARNING_FLAGS">warning_flags
2555 TOR_TRY_COMPILE_WITH_CFLAGS([@warning_flags], [],
2556 CFLAGS="$CFLAGS @warning_flags",
2557 CFLAGS="$CFLAGS $TOR_WARNING_FLAGS")
2559 if test "$enable_coverage" = "yes" && test "$have_clang" = "no"; then
2562 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.])
2566 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
2572 contrib/operator-tools/tor.logrotate
2573 contrib/dist/tor.service
2574 src/config/torrc.sample
2575 src/config/torrc.minimal
2576 src/rust/.cargo/config
2577 scripts/maint/checkOptionDocs.pl
2581 if test "x$asciidoc" = "xtrue" && test "$ASCIIDOC" = "none"; then
2582 regular_mans="doc/tor doc/tor-gencert doc/tor-resolve doc/torify"
2583 for file in $regular_mans ; do
2584 if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
2585 echo "==================================";
2587 echo "Building Tor has failed since manpages cannot be built.";
2589 echo "You need asciidoc installed to be able to build the manpages.";
2590 echo "To build without manpages, use the --disable-asciidoc argument";
2591 echo "when calling configure.";
2593 echo "==================================";
2599 if test "$fragile_hardening" = "yes"; then
2603 Warning! Building Tor with --enable-fragile-hardening (also known as
2604 --enable-expensive-hardening) makes some kinds of attacks harder, but makes
2605 other kinds of attacks easier. A Tor instance build with this option will be
2606 somewhat less vulnerable to remote code execution, arithmetic overflow, or
2607 out-of-bounds read/writes... but at the cost of becoming more vulnerable to
2608 denial of service attacks. For more information, see
2609 https://trac.torproject.org/projects/tor/wiki/doc/TorFragileHardening
2617 # Mini-report on what will be built.
2621 PPRINT_SET_INDENT(1)
2625 AS_ECHO("Tor Version: ${PPRINT_COLOR_BLDBLU}Tor $PACKAGE_VERSION $PPRINT_COLOR_RST")
2628 PPRINT_SUBTITLE([Build Features])
2630 PPRINT_PROP_STRING([Compiler], [$CC])
2631 PPRINT_PROP_STRING([Host OS], [$host_os])
2634 test "x$enable_fatal_warnings" = "xyes" && value=1 || value=0
2635 PPRINT_PROP_BOOL([Warnings are fatal (--enable-fatal-warnings)], $value)
2637 test "x$enable_rust" = "xyes" && value=1 || value=0
2638 PPRINT_PROP_BOOL([Rust support (--enable-rust)], $value)
2640 test "x$enable_cargo_online_mode" = "xyes" && value=1 || value=0
2641 PPRINT_PROP_BOOL([Cargo Online Fetch (--enable-cargo-online-mode)], $value)
2643 test "x$enable_android" = "xyes" && value=1 || value=0
2644 PPRINT_PROP_BOOL([Android support (--enable-android)], $value)
2647 PPRINT_SUBTITLE([Static Build])
2649 test "x$enable_static_tor" = "xyes" && value=1 || value=0
2650 PPRINT_PROP_BOOL([tor (--enable-static-tor)], $value)
2652 if test "x$enable_static_libevent" = "xyes"; then
2653 PPRINT_PROP_STRING([libevent], [$TOR_LIBDIR_libevent])
2655 PPRINT_PROP_BOOL([libevent (--enable-static-libevent)], $value)
2658 if test "x$enable_static_openssl" = "xyes"; then
2659 PPRINT_PROP_STRING([libssl], [$TOR_LIBDIR_openssl])
2661 PPRINT_PROP_BOOL([libssl (--enable-static-openssl)], $value)
2664 if test "x$enable_static_zlib" = "xyes"; then
2665 PPRINT_PROP_STRING([zlib1g], [$TOR_LIBDIR_zlib])
2667 PPRINT_PROP_BOOL([zlib1g (--enable-static-zlib)], $value)
2671 PPRINT_SUBTITLE([Optional Libraries])
2673 test "x$enable_nss" = "xyes" && value=1 || value=0
2674 PPRINT_PROP_BOOL([libnss (--enable-nss)], $value)
2676 test "x$enable_seccomp" != "xno" && value=1 || value=0
2677 PPRINT_PROP_BOOL([libseccomp (--disable-seccomp)], $value)
2679 test "x$enable_libscrypt" != "xno" && value=1 || value=0
2680 PPRINT_PROP_BOOL([libscrypt (--disable-libscrypt)], $value)
2682 test "x$enable_systemd" = "xyes" && value=1 || value=0
2683 PPRINT_PROP_BOOL([Systemd support (--enable-systemd)], $value)
2685 test "x$enable_lzma" = "xyes" && value=1 || value=0
2686 PPRINT_PROP_BOOL([liblzma (--enable-lzma)], $value)
2688 test "x$enable_zstd" = "xyes" && value=1 || value=0
2689 PPRINT_PROP_BOOL([libzstd (--enable-zstd)], $value)
2692 PPRINT_SUBTITLE([Hardening])
2694 test "x$enable_gcc_hardening" != "xno" && value=1 || value=0
2695 PPRINT_PROP_BOOL([Compiler Hardening (--disable-gcc-hardening)], $value)
2697 test "x$enable_linker_hardening" != "xno" && value=1 || value=0
2698 PPRINT_PROP_BOOL([Linker Hardening (--disable-linker-hardening)], $value)
2700 test "x$fragile_hardening" = "xyes" && value=1 || value=0
2701 PPRINT_PROP_BOOL([Fragile Hardening (--enable-fragile-hardening, dev only)], $value)
2704 PPRINT_SUBTITLE([Modules])
2706 m4_foreach_w([mname], MODULES,
2708 AM_COND_IF(m4_join([], [BUILD_MODULE_], m4_toupper([]mname[])), value=1, value=0)
2709 PPRINT_PROP_BOOL([mname (--disable-module-mname)], $value)
2714 PPRINT_SUBTITLE([Documentation])
2716 test "x$enable_asciidoc" != "xno" && value=1 || value=0
2717 PPRINT_PROP_BOOL([AsciiDoc (--disable-asciidoc)], $value)
2719 test "x$enable_manpage" != "xno" && value=1 || value=0
2720 PPRINT_PROP_BOOL([Man Pages (--disable-manpage)], $value)
2722 test "x$enable_html_manual" != "xno" && value=1 || value=0
2723 PPRINT_PROP_BOOL([HTML Manual (--disable-html-manual)], $value)
2726 PPRINT_SUBTITLE([Tests])
2728 test "x$enable_unittests" != "xno" && value=1 || value=0
2729 PPRINT_PROP_BOOL([Unit tests (--disable-unittests)], $value)
2731 test "x$enable_asserts_in_tests" = "xno" && value=1 || value=0
2732 PPRINT_PROP_BOOL([assert()s enabled (--enable-asserts-in-tests, dev only)], $value)
2734 test "x$enable_coverage" = "xyes" && value=1 || value=0
2735 PPRINT_PROP_BOOL([Code Coverage (--enable-coverage)], $value)
2737 test "x$enable_libfuzzer" = "xyes" && value=1 || value=0
2738 PPRINT_PROP_BOOL([libFuzzer support (--enable-libfuzzer)], $value)
2740 test "x$enable_oss_fuzz" = "xyes" && value=1 || value=0
2741 PPRINT_PROP_BOOL([OSS-Fuzz support (--enable-oss-fuzz)], $value)
2744 PPRINT_SUBTITLE([Install Directories])
2746 report_mandir="`eval eval echo $mandir`"
2747 PPRINT_PROP_STRING([Binaries], [$BINDIR])
2748 PPRINT_PROP_STRING([Configuration], [$CONFDIR])
2749 PPRINT_PROP_STRING([Man Pages], [$report_mandir])
2752 AS_ECHO(["Configure Line: ./configure $configure_flags"])