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.8.8-dev])
8 AC_CONFIG_SRCDIR([src/app/main/tor_main.c])
9 AC_CONFIG_MACRO_DIR([m4])
12 AC_DEFINE_UNQUOTED([CONFIG_FLAGS], ["$configure_flags"], [Flags passed to configure])
15 # DO NOT EDIT THIS DEFINITION BY HAND UNLESS YOU KNOW WHAT YOU'RE DOING.
17 # The update_versions.py script updates this definition when the
18 # version number changes. Tor uses it to make sure that it
19 # only shuts down for missing "required protocols" when those protocols
20 # are listed as required by a consensus after this date.
21 AC_DEFINE(APPROX_RELEASE_DATE, ["2023-11-03"], # for 0.4.8.8-dev
22 [Approximate date when this software was released. (Updated when the version changes.)])
24 # "foreign" means we don't follow GNU package layout standards
25 # "1.11" means we require automake version 1.11 or newer
26 # "subdir-objects" means put .o files in the same directory as the .c files
27 AM_INIT_AUTOMAKE([foreign 1.11 subdir-objects -Wall -Werror])
30 tor_incr_n_warnings() {
31 tor_ac_n_warnings=`expr $tor_ac_n_warnings + 1`
34 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
35 AC_CONFIG_HEADERS([orconfig.h])
37 AC_USE_SYSTEM_EXTENSIONS
41 if test "x$PKG_CONFIG" = "x" ; then
42 pkg_config_user_action="install pkg-config, and check the PKG_CONFIG_PATH environment variable"
43 AC_MSG_NOTICE([Some libraries need pkg-config, including systemd, nss, lzma, zstd, and custom mallocs.])
44 AC_MSG_NOTICE([To use those libraries, $pkg_config_user_action.])
46 pkg_config_user_action="check the PKG_CONFIG_PATH environment variable"
49 if test "x$PKG_CONFIG_PATH" = "x" && test "x$prefix" != "xNONE" && test "$host" != "$build"; then
50 export PKG_CONFIG_PATH=$prefix/lib/pkgconfig
51 AC_MSG_NOTICE([set PKG_CONFIG_PATH=$PKG_CONFIG_PATH to support cross-compiling])
57 AS_HELP_STRING(--enable-gpl, [allow the inclusion of GPL-licensed code, building a version of tor and libtor covered by the GPL rather than its usual 3-clause BSD license]))
59 AS_IF([test "x$enable_gpl" = xyes],
61 AC_DEFINE(ENABLE_GPL, 1, [Defined if tor is building in GPL-licensed mode.])
67 AC_ARG_ENABLE(openbsd-malloc,
68 AS_HELP_STRING(--enable-openbsd-malloc, [use malloc code from OpenBSD. Linux only. Deprecated: see --with-malloc]))
69 AC_ARG_ENABLE(static-openssl,
70 AS_HELP_STRING(--enable-static-openssl, [link against a static openssl library. Requires --with-openssl-dir]))
71 AC_ARG_ENABLE(static-libevent,
72 AS_HELP_STRING(--enable-static-libevent, [link against a static libevent library. Requires --with-libevent-dir]))
73 AC_ARG_ENABLE(static-zlib,
74 AS_HELP_STRING(--enable-static-zlib, [link against a static zlib library. Requires --with-zlib-dir]))
75 AC_ARG_ENABLE(static-tor,
76 AS_HELP_STRING(--enable-static-tor, [create an entirely static Tor binary. Requires --with-openssl-dir and --with-libevent-dir and --with-zlib-dir]))
77 AC_ARG_ENABLE(unittests,
78 AS_HELP_STRING(--disable-unittests, [don't build unit tests for Tor. Risky!]))
79 AC_ARG_ENABLE(coverage,
80 AS_HELP_STRING(--enable-coverage, [enable coverage support in the unit-test build]))
81 AC_ARG_ENABLE(asserts-in-tests,
82 AS_HELP_STRING(--disable-asserts-in-tests, [disable tor_assert() calls in the unit tests, for branch coverage]))
83 AC_ARG_ENABLE(system-torrc,
84 AS_HELP_STRING(--disable-system-torrc, [don't look for a system-wide torrc file]))
85 AC_ARG_ENABLE(libfuzzer,
86 AS_HELP_STRING(--enable-libfuzzer, [build extra fuzzers based on 'libfuzzer']))
87 AC_ARG_ENABLE(oss-fuzz,
88 AS_HELP_STRING(--enable-oss-fuzz, [build extra fuzzers based on 'oss-fuzz' environment]))
89 AC_ARG_ENABLE(memory-sentinels,
90 AS_HELP_STRING(--disable-memory-sentinels, [disable code that tries to prevent some kinds of memory access bugs. For fuzzing only.]))
91 AC_ARG_ENABLE(restart-debugging,
92 AS_HELP_STRING(--enable-restart-debugging, [Build Tor with support for debugging in-process restart. Developers only.]))
93 AC_ARG_ENABLE(zstd-advanced-apis,
94 AS_HELP_STRING(--disable-zstd-advanced-apis, [Build without support for zstd's "static-only" APIs.]))
96 AS_HELP_STRING(--enable-nss, [Use Mozilla's NSS TLS library. (EXPERIMENTAL)]))
98 AS_HELP_STRING(--enable-pic, [Build Tor's binaries as position-independent code, suitable to link as a library.]))
100 AC_ARG_ENABLE(missing-doc-warnings,
101 AS_HELP_STRING(--enable-missing-doc-warnings, [Tell doxygen to warn about missing documentation. Makes doxygen warnings nonfatal.]))
103 if test "$enable_missing_doc_warnings" = "yes"; then
104 DOXYGEN_FATAL_WARNINGS=NO
105 DOXYGEN_WARN_ON_MISSING=YES
106 elif test "$enable_fatal_warnings" = "yes"; then
107 # Fatal warnings from doxygen are nice, but not if we're warning about
108 # missing documentation.
109 DOXYGEN_FATAL_WARNINGS=YES
110 DOXYGEN_WARN_ON_MISSING=NO
112 DOXYGEN_FATAL_WARNINGS=NO
113 DOXYGEN_WARN_ON_MISSING=NO
115 AC_SUBST(DOXYGEN_FATAL_WARNINGS)
116 AC_SUBST(DOXYGEN_WARN_ON_MISSING)
118 if test "x$enable_coverage" != "xyes" -a "x$enable_asserts_in_tests" = "xno" ; then
119 AC_MSG_ERROR([Can't disable assertions outside of coverage build])
122 AM_CONDITIONAL(UNITTESTS_ENABLED, test "x$enable_unittests" != "xno")
123 AM_CONDITIONAL(COVERAGE_ENABLED, test "x$enable_coverage" = "xyes")
124 AM_CONDITIONAL(DISABLE_ASSERTS_IN_UNIT_TESTS, test "x$enable_asserts_in_tests" = "xno")
125 AM_CONDITIONAL(LIBFUZZER_ENABLED, test "x$enable_libfuzzer" = "xyes")
126 AM_CONDITIONAL(OSS_FUZZ_ENABLED, test "x$enable_oss_fuzz" = "xyes")
127 AM_CONDITIONAL(USE_NSS, test "x$enable_nss" = "xyes")
128 AM_CONDITIONAL(USE_OPENSSL, test "x$enable_nss" != "xyes")
130 if test "x$enable_coverage" = "xyes"; then
131 AC_DEFINE(ENABLE_COVERAGE, 1,
132 [Defined if coverage support is enabled for the unit tests])
135 if test "x$enable_nss" = "xyes"; then
136 AC_DEFINE(ENABLE_NSS, 1,
137 [Defined if we're building with NSS.])
139 AC_DEFINE(ENABLE_OPENSSL, 1,
140 [Defined if we're building with OpenSSL or LibreSSL])
143 if test "$enable_static_tor" = "yes"; then
144 enable_static_libevent="yes";
145 enable_static_openssl="yes";
146 enable_static_zlib="yes";
147 TOR_STATIC_LDFLAGS="-static"
149 AC_SUBST(TOR_STATIC_LDFLAGS)
151 if test "$enable_system_torrc" = "no"; then
152 AC_DEFINE(DISABLE_SYSTEM_TORRC, 1,
153 [Defined if we're not going to look for a torrc in SYSCONF])
156 if test "$enable_memory_sentinels" = "no"; then
157 AC_DEFINE(DISABLE_MEMORY_SENTINELS, 1,
158 [Defined if we're turning off memory safety code to look for bugs])
161 AC_ARG_ENABLE(manpage,
162 AS_HELP_STRING(--disable-manpage, [Disable manpage generation.]))
164 AC_ARG_ENABLE(html-manual,
165 AS_HELP_STRING(--disable-html-manual, [Disable HTML documentation.]))
167 AC_ARG_ENABLE(asciidoc,
168 AS_HELP_STRING(--disable-asciidoc, [don't use asciidoc (disables building of manpages)]),
169 [case "${enableval}" in
170 "yes") asciidoc=true ;;
171 "no") asciidoc=false ;;
172 *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
173 esac], [asciidoc=true])
175 # systemd notify support
176 AC_ARG_ENABLE(systemd,
177 AS_HELP_STRING(--enable-systemd, [enable systemd notification support]),
178 [case "${enableval}" in
179 "yes") systemd=true ;;
180 "no") systemd=false ;;
181 * ) AC_MSG_ERROR(bad value for --enable-systemd) ;;
182 esac], [systemd=auto])
184 if test "$enable_restart_debugging" = "yes"; then
185 AC_DEFINE(ENABLE_RESTART_DEBUGGING, 1,
186 [Defined if we're building with support for in-process restart debugging.])
189 if test "$enable_zstd_advanced_apis" != "no"; then
190 AC_DEFINE(ENABLE_ZSTD_ADVANCED_APIS, 1,
191 [Defined if we're going to try to use zstd's "static-only" APIs.])
195 if test "x$enable_systemd" = "xno"; then
198 PKG_CHECK_MODULES(SYSTEMD,
202 if test "x$have_systemd" = "xno"; then
203 AC_MSG_NOTICE([Okay, checking for systemd a different way...])
204 PKG_CHECK_MODULES(SYSTEMD,
211 if test "x$have_systemd" = "xyes"; then
212 AC_DEFINE(HAVE_SYSTEMD,1,[Have systemd])
213 TOR_SYSTEMD_CFLAGS="${SYSTEMD_CFLAGS}"
214 TOR_SYSTEMD_LIBS="${SYSTEMD_LIBS}"
215 PKG_CHECK_MODULES(LIBSYSTEMD209, [libsystemd >= 209],
216 [AC_DEFINE(HAVE_SYSTEMD_209,1,[Have systemd v209 or greater])], [])
218 AC_SUBST(TOR_SYSTEMD_CFLAGS)
219 AC_SUBST(TOR_SYSTEMD_LIBS)
221 if test "x$enable_systemd" = "xyes" -a "x$have_systemd" != "xyes" ; then
222 AC_MSG_ERROR([Explicitly requested systemd support, but systemd not found, $pkg_config_user_action, or set SYSTEMD_CFLAGS and SYSTEMD_LIBS.])
227 AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
231 AC_ARG_ENABLE(gcc-warnings,
232 AS_HELP_STRING(--enable-gcc-warnings, [deprecated alias for enable-fatal-warnings]))
233 AC_ARG_ENABLE(fatal-warnings,
234 AS_HELP_STRING(--enable-fatal-warnings, [tell the compiler to treat all warnings as errors.]))
235 AC_ARG_ENABLE(gcc-warnings-advisory,
236 AS_HELP_STRING(--disable-gcc-warnings-advisory, [disable the regular verbose warnings]))
238 dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
239 AC_ARG_ENABLE(gcc-hardening,
240 AS_HELP_STRING(--disable-gcc-hardening, [disable compiler security checks]))
242 dnl Deprecated --enable-expensive-hardening but keep it for now for backward compat.
243 AC_ARG_ENABLE(expensive-hardening,
244 AS_HELP_STRING(--enable-expensive-hardening, [enable more fragile and expensive compiler hardening; makes Tor slower]))
245 AC_ARG_ENABLE(fragile-hardening,
246 AS_HELP_STRING(--enable-fragile-hardening, [enable more fragile and expensive compiler hardening; makes Tor slower]))
247 if test "x$enable_expensive_hardening" = "xyes" || test "x$enable_fragile_hardening" = "xyes"; then
248 fragile_hardening="yes"
249 AC_DEFINE(ENABLE_FRAGILE_HARDENING, 1, [Defined if we're building with additional, fragile and expensive compiler hardening])
250 AC_DEFINE(DEBUG_SMARTLIST, 1, [Enable smartlist debugging])
253 AC_ARG_ENABLE(all-bugs-are-fatal,
254 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]))
256 if test "x$enable_all_bugs_are_fatal" = "xyes"; then
257 AC_DEFINE(ALL_BUGS_ARE_FATAL, 1, [All assert failures are fatal])
260 dnl Linker hardening options
261 dnl Currently these options are ELF specific - you can't use this with MacOSX
262 AC_ARG_ENABLE(linker-hardening,
263 AS_HELP_STRING(--disable-linker-hardening, [disable linker security fixups]))
265 AC_ARG_ENABLE(local-appdata,
266 AS_HELP_STRING(--enable-local-appdata, [default to host local application data paths on Windows]))
267 if test "$enable_local_appdata" = "yes"; then
268 AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
269 [Defined if we default to host local appdata paths on Windows])
272 AC_ARG_ENABLE(tool-name-check,
273 AS_HELP_STRING(--disable-tool-name-check, [check for sanely named toolchain when cross-compiling]))
275 AC_ARG_ENABLE(seccomp,
276 AS_HELP_STRING(--disable-seccomp, [do not attempt to use libseccomp]))
278 AC_ARG_ENABLE(libscrypt,
279 AS_HELP_STRING(--disable-libscrypt, [do not attempt to use libscrypt]))
281 dnl --- Tracing Options. ---
285 dnl LTTng instrumentation option.
286 AC_ARG_ENABLE(tracing-instrumentation-lttng,
287 AS_HELP_STRING([--enable-tracing-instrumentation-lttng],
288 [build with LTTng-UST instrumentation]))
289 AM_CONDITIONAL([USE_TRACING_INSTRUMENTATION_LTTNG],
290 [test "x$enable_tracing_instrumentation_lttng" = "xyes"])
292 if test "x$enable_tracing_instrumentation_lttng" = "xyes"; then
293 AC_CHECK_HEADERS([lttng/tracepoint.h], [],
294 [AC_MSG_ERROR([LTTng instrumentation headers not found.
295 On Debian, apt install liblttng-ust-dev"])], [])
296 AC_DEFINE([USE_TRACING_INSTRUMENTATION_LTTNG], [1], [Using LTTng instrumentation])
297 TOR_TRACE_LIBS="-llttng-ust -ldl"
301 dnl USDT instrumentation option.
302 AC_ARG_ENABLE(tracing-instrumentation-usdt,
303 AS_HELP_STRING([--enable-tracing-instrumentation-usdt],
304 [build with tracing USDT instrumentation]))
305 AM_CONDITIONAL([USE_TRACING_INSTRUMENTATION_USDT],
306 [test "x$enable_tracing_instrumentation_usdt" = "xyes"])
308 if test "x$enable_tracing_instrumentation_usdt" = "xyes"; then
309 AC_CHECK_HEADERS([sys/sdt.h], [],
310 [AC_MSG_ERROR([USDT instrumentation requires sys/sdt.h header.
311 On Debian, apt install systemtap-sdt-dev])], [])
312 AC_MSG_CHECKING([STAP_PROBEV()])
313 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
314 #define SDT_USE_VARIADIC
318 STAP_PROBEV(p, n, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
322 dnl LTTng generates USDT probes if the UST library was built with
323 dnl --with-sdt. There is unfortunately no way to check that so we always
324 dnl build the USDT probes even though LTTng instrumentation was requested.
325 AC_DEFINE([USE_TRACING_INSTRUMENTATION_USDT], [1], [Using USDT instrumentation])
329 AC_MSG_ERROR([USDT tracing support requires STAP_PROBEV()])
333 dnl Tracepoints event to debug logs.
334 AC_ARG_ENABLE(tracing-instrumentation-log-debug,
335 AS_HELP_STRING([--enable-tracing-instrumentation-log-debug],
336 [build with tracing event to debug log]),
337 AC_DEFINE([USE_TRACING_INSTRUMENTATION_LOG_DEBUG], [1],
338 [Tracepoints to log debug]), [])
339 AM_CONDITIONAL([USE_TRACING_INSTRUMENTATION_LOG_DEBUG],
340 [test "x$enable_tracing_instrumentation_log_debug" = "xyes"])
341 if test "x$enable_tracing_instrumentation_log_debug" = "xyes"; then
345 dnl Define that tracing is supported if any instrumentation is used.
346 AM_COND_IF([USE_TRACING_INSTRUMENTATION_LOG_DEBUG],
347 AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
348 AM_COND_IF([USE_TRACING_INSTRUMENTATION_USDT],
349 AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
350 AM_COND_IF([USE_TRACING_INSTRUMENTATION_LTTNG],
351 AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
352 AM_CONDITIONAL([USE_TRACING], [test "x$have_tracing" = x1 ])
354 dnl Finally, define the trace libs.
355 AC_SUBST([TOR_TRACE_LIBS])
357 dnl -- End Tracing Options. --
359 dnl Enable Android only features.
360 AC_ARG_ENABLE(android,
361 AS_HELP_STRING(--enable-android, [build with Android features enabled]))
362 AM_CONDITIONAL([USE_ANDROID], [test "x$enable_android" = "xyes"])
364 if test "x$enable_android" = "xyes"; then
365 AC_DEFINE([USE_ANDROID], [1], [Compile with Android specific features enabled])
370 dnl Tor modules options. These options are namespaced with --disable-module-XXX
374 m4_define([MODULES], [relay dirauth dircache pow])
376 # Some modules are only disabled through another option. For those, we don't
377 # want to print the help in the summary at the end of the configure. Any entry
378 # in the following set will not print the "--disable-module-NAME" command in
380 m4_set_add_all([MODULES_WITH_NO_OPTIONS], [dircache])
383 m4_define([module_option_hints(relay)],
384 [AS_IF([test "x$value" = x1], [HINT_OPT([--disable-module-relay])],
386 AC_ARG_ENABLE([module-relay],
387 AS_HELP_STRING([--disable-module-relay],
388 [Build tor without the Relay modules: tor can not run as a relay, bridge, or authority. Implies --disable-module-dirauth]))
389 AM_CONDITIONAL(BUILD_MODULE_RELAY, [test "x$enable_module_relay" != "xno"])
390 AM_COND_IF(BUILD_MODULE_RELAY,
391 AC_DEFINE([HAVE_MODULE_RELAY], [1],
392 [Compile with Relay feature support]))
394 dnl Dircache module. (This cannot be enabled or disabled independently of
395 dnl the relay module. It is not listed by --list-modules for this reason.)
396 AM_CONDITIONAL(BUILD_MODULE_DIRCACHE,
397 [test "x$enable_module_relay" != "xno"])
398 AM_COND_IF(BUILD_MODULE_DIRCACHE,
399 AC_DEFINE([HAVE_MODULE_DIRCACHE], [1],
400 [Compile with directory cache support]))
402 dnl Directory Authority module.
403 m4_define([module_option_hints(dirauth)],
404 [AS_IF([test "x$value" = x1], [HINT_OPT([--disable-module-dirauth])],
406 AC_ARG_ENABLE([module-dirauth],
407 AS_HELP_STRING([--disable-module-dirauth],
408 [Build tor without the Directory Authority module: tor can not run as a directory authority or bridge authority]))
409 AM_CONDITIONAL(BUILD_MODULE_DIRAUTH,[test "x$enable_module_dirauth" != "xno" && test "x$enable_module_relay" != "xno"])
410 AM_COND_IF(BUILD_MODULE_DIRAUTH,
411 AC_DEFINE([HAVE_MODULE_DIRAUTH], [1],
412 [Compile with Directory Authority feature support]))
414 dnl Hidden Service Proof-of-Work module.
415 m4_define([module_option_hints(pow)],
416 [AS_IF([test "x$value" = x1], [HINT_OPT([--disable-module-pow])],
417 [AS_IF([test "x$license_option" != "xGPL"], [HINT_OPT([requires --enable-gpl])],
419 AC_ARG_ENABLE([module-pow],
420 AS_HELP_STRING([--disable-module-pow],
421 [Build tor without proof-of-work denial of service mitigation, normally available when building with --enable-gpl]))
422 AM_CONDITIONAL(BUILD_MODULE_POW,
423 [test "x$license_option" = "xGPL" && test "x$enable_module_pow" != "xno"])
424 AM_COND_IF(BUILD_MODULE_POW,
425 AC_DEFINE([HAVE_MODULE_POW], [1], [Compile with proof-of-work support]))
427 dnl Helper variables.
428 TOR_MODULES_ALL_ENABLED=
429 AC_DEFUN([ADD_MODULE], [
430 MODULE=m4_toupper($1)
431 TOR_MODULES_ALL_ENABLED="${TOR_MODULES_ALL_ENABLED} -DHAVE_MODULE_${MODULE}=1"
433 m4_foreach_w([module], MODULES, [ADD_MODULE([module])])
434 AC_SUBST(TOR_MODULES_ALL_ENABLED)
436 dnl check for the correct "ar" when cross-compiling.
437 dnl (AM_PROG_AR was new in automake 1.11.2, which we do not yet require,
438 dnl so kludge up a replacement for the case where it isn't there yet.)
439 m4_ifdef([AM_PROG_AR],
441 [AN_MAKEVAR([AR], [AC_PROG_AR])
442 AN_PROGRAM([ar], [AC_PROG_AR])
443 AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [:])])
446 dnl Check whether the above macro has settled for a simply named tool even
447 dnl though we're cross compiling. We must do this before running AC_PROG_CC,
448 dnl because that will find any cc on the system, not only the cross-compiler,
449 dnl and then verify that a binary built with this compiler runs on the
450 dnl build system. It will then come to the false conclusion that we're not
452 if test "x$enable_tool_name_check" != "xno"; then
453 if test "x$ac_tool_warned" = "xyes"; then
454 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.)])
455 elif test "x$ac_ct_AR" != "x" -a "x$cross_compiling" = "xmaybe"; then
456 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.)])
469 AC_DEFINE_UNQUOTED([COMPILER_VERSION],["$ax_cv_c_compiler_version"], [Compiler version])
470 AC_DEFINE_UNQUOTED([COMPILER_VENDOR],["$ax_cv_c_compiler_vendor"], [Compiler vendor])
472 AS_CASE($ax_cv_c_compiler_vendor,
473 [gnu], AC_DEFINE([COMPILER],["GCC"],[Compiler name]),
474 AC_DEFINE([COMPILER],[],[Compiler name])
477 AC_ARG_VAR([PERL], [path to Perl binary])
478 AC_CHECK_PROGS([PERL], [perl])
479 AM_CONDITIONAL(USE_PERL, [test "x$ac_cv_prog_PERL" != "x"])
481 dnl check for asciidoc and a2x
482 AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
483 AC_PATH_PROGS([A2X], [a2x a2x.py], none)
485 AM_CONDITIONAL(USE_ASCIIDOC, test "x$asciidoc" = "xtrue")
486 AM_CONDITIONAL(BUILD_MANPAGE, [test "x$enable_manpage" != "xno"])
487 AM_CONDITIONAL(BUILD_HTML_DOCS, [test "x$enable_html_manual" != "xno"])
491 dnl Before autoconf 2.70, AC_PROG_CC_C99 is supposedly necessary for some
492 dnl compilers if you want C99 support. Starting with 2.70, it is obsolete and
494 m4_version_prereq([2.70], [:], [AC_PROG_CC_C99])
496 AC_CACHE_CHECK([for Python 3], [tor_cv_PYTHON],
497 [AC_PATH_PROGS_FEATURE_CHECK([PYTHON], [ \
499 python3.8 python3.7 python3.6 python3.5 python3.4 \
501 [["$ac_path_PYTHON" -c 'import sys; sys.exit(sys.version_info[0]<3)' && tor_cv_PYTHON="$ac_path_PYTHON" ac_path_PYTHON_found=:]] )])
502 AC_SUBST([PYTHON], [$tor_cv_PYTHON])
504 PYTHON="$tor_cv_PYTHON"
506 if test "x$PYTHON" = "x"; then
508 AC_MSG_WARN([Python 3 unavailable; some tests will not be run.])
511 AM_CONDITIONAL(USEPYTHON, [test "x$PYTHON" != "x"])
513 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
514 AC_C_FLEXIBLE_ARRAY_MEMBER
516 dnl Maybe we've got an old autoconf...
517 AC_CACHE_CHECK([for flexible array members],
521 struct abc { int a; char b[]; };
523 struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
526 [tor_cv_c_flexarray=yes],
527 [tor_cv_c_flexarray=no])])
528 if test "$tor_cv_flexarray" = "yes"; then
529 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
531 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
535 AC_CACHE_CHECK([for working C99 mid-block declaration syntax],
538 [AC_LANG_PROGRAM([], [int x; x = 3; int y; y = 4 + x;])],
539 [tor_cv_c_c99_decl=yes],
540 [tor_cv_c_c99_decl=no] )])
541 if test "$tor_cv_c_c99_decl" != "yes"; then
542 AC_MSG_ERROR([Your compiler doesn't support c99 mid-block declarations. This is required as of Tor 0.2.6.x])
545 AC_CACHE_CHECK([for working C99 designated initializers],
546 tor_cv_c_c99_designated_init,
548 [AC_LANG_PROGRAM([struct s { int a; int b; };],
549 [[ struct s ss = { .b = 5, .a = 6 }; ]])],
550 [tor_cv_c_c99_designated_init=yes],
551 [tor_cv_c_c99_designated_init=no] )])
553 if test "$tor_cv_c_c99_designated_init" != "yes"; then
554 AC_MSG_ERROR([Your compiler doesn't support c99 designated initializers. This is required as of Tor 0.2.6.x])
557 saved_CFLAGS="$CFLAGS"
558 CFLAGS="$CFLAGS -Werror"
559 AC_CACHE_CHECK([for __attribute__((fallthrough))],
560 tor_cv_c_attr_fallthrough,
562 [AC_LANG_PROGRAM([extern int x; void fn(void) ;],
563 [[ switch (x) { case 1: fn(); __attribute__((fallthrough));
564 case 2: fn(); break; } ]])],
565 [tor_cv_c_attr_fallthrough=yes],
566 [tor_cv_c_attr_fallthrough=no] )])
567 CFLAGS="$saved_CFLAGS"
569 if test "$tor_cv_c_attr_fallthrough" = "yes"; then
570 AC_DEFINE(HAVE_ATTR_FALLTHROUGH, [1], [defined if we have the fallthrough attribute.])
574 AC_ARG_WITH(tor-user,
575 AS_HELP_STRING(--with-tor-user=NAME, [specify username for tor daemon]),
583 AC_ARG_WITH(tor-group,
584 AS_HELP_STRING(--with-tor-group=NAME, [specify group name for tor daemon]),
592 dnl If _WIN32 is defined and non-zero, we are building for win32
593 AC_MSG_CHECKING([for win32])
594 AC_RUN_IFELSE([AC_LANG_SOURCE([
595 int main(int c, char **v) {
606 bwin32=true; AC_MSG_RESULT([yes]),
607 bwin32=false; AC_MSG_RESULT([no]),
608 bwin32=cross; AC_MSG_RESULT([cross])
611 if test "$bwin32" = "cross"; then
612 AC_MSG_CHECKING([for win32 (cross)])
613 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
615 int main(int c, char **v) {return 0;}
618 int main(int c, char **v) {return x(y);}
621 bwin32=true; AC_MSG_RESULT([yes]),
622 bwin32=false; AC_MSG_RESULT([no]))
627 /* Defined to access windows functions and definitions for >=WinVista */
629 # define WINVER 0x0600
632 /* Defined to access _other_ windows functions and definitions for >=WinVista */
633 # ifndef _WIN32_WINNT
634 # define _WIN32_WINNT 0x0600
637 /* Defined to avoid including some windows headers as part of Windows.h */
638 # ifndef WIN32_LEAN_AND_MEAN
639 # define WIN32_LEAN_AND_MEAN 1
644 AM_CONDITIONAL(WIN32, test "x$bwin32" = "xtrue")
645 AM_CONDITIONAL(BUILD_NT_SERVICES, test "x$bwin32" = "xtrue")
646 AM_CONDITIONAL(BUILD_LIBTORRUNNER, test "x$bwin32" != "xtrue")
648 dnl Enable C99 when compiling with MIPSpro
649 AC_MSG_CHECKING([for MIPSpro compiler])
650 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
651 #if (defined(__sgi) && defined(_COMPILER_VERSION))
656 bmipspro=false; AC_MSG_RESULT(no),
657 bmipspro=true; AC_MSG_RESULT(yes))
659 if test "$bmipspro" = "true"; then
660 CFLAGS="$CFLAGS -c99"
665 AC_SEARCH_LIBS(socket, [socket network])
666 AC_SEARCH_LIBS(gethostbyname, [nsl])
667 AC_SEARCH_LIBS(dlopen, [dl])
668 AC_SEARCH_LIBS(inet_aton, [resolv])
669 AC_SEARCH_LIBS(backtrace, [execinfo])
671 AC_SEARCH_LIBS([clock_gettime], [rt])
672 if test "$LIBS" != "$saved_LIBS"; then
673 # Looks like we need -lrt for clock_gettime().
677 if test "$bwin32" = "false"; then
678 AC_SEARCH_LIBS(pthread_create, [pthread])
679 AC_SEARCH_LIBS(pthread_detach, [pthread])
682 AM_CONDITIONAL(THREADS_WIN32, test "$bwin32" = "true")
683 AM_CONDITIONAL(THREADS_PTHREADS, test "$bwin32" = "false")
687 RtlSecureZeroMemory \
691 backtrace_symbols_fd \
698 get_current_dir_name \
706 gnu_get_libc_version \
746 # Apple messed up when they added some functions: they
747 # forgot to decorate them with appropriate AVAILABLE_MAC_OS_VERSION
750 # We should only probe for these functions if we are sure that we
751 # are not targeting OS X 10.9 or earlier.
752 AC_MSG_CHECKING([for a pre-Yosemite OS X build target])
753 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
755 # include <AvailabilityMacros.h>
756 # ifndef MAC_OS_X_VERSION_10_10
757 # define MAC_OS_X_VERSION_10_10 101000
759 # if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
760 # if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
761 # error "Running on Mac OS X 10.9 or earlier"
766 [on_macos_pre_10_10=no ; AC_MSG_RESULT([no])],
767 [on_macos_pre_10_10=yes; AC_MSG_RESULT([yes])])
769 if test "$on_macos_pre_10_10" = "no"; then
771 mach_approximate_time \
775 # We should only probe for these functions if we are sure that we
776 # are not targeting OSX 10.11 or earlier.
777 AC_MSG_CHECKING([for a pre-Sierra OSX build target])
778 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
780 # include <AvailabilityMacros.h>
781 # ifndef MAC_OS_X_VERSION_10_12
782 # define MAC_OS_X_VERSION_10_12 101200
784 # if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
785 # if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
786 # error "Running on Mac OSX 10.11 or earlier"
791 [on_macos_pre_10_12=no ; AC_MSG_RESULT([no])],
792 [on_macos_pre_10_12=yes; AC_MSG_RESULT([yes])])
794 if test "$on_macos_pre_10_12" = "no"; then
801 if test "$bwin32" != "true"; then
802 AC_CHECK_HEADERS(pthread.h)
803 AC_CHECK_FUNCS(pthread_create)
804 AC_CHECK_FUNCS(pthread_condattr_setclock)
807 if test "$bwin32" = "true"; then
808 AC_CHECK_DECLS([SecureZeroMemory, _getwch], , , [
815 AM_CONDITIONAL(BUILD_READPASSPHRASE_C,
816 test "x$ac_cv_func_readpassphrase" = "xno" && test "$bwin32" = "false")
820 AC_MSG_CHECKING([whether free(NULL) works])
821 AC_RUN_IFELSE([AC_LANG_PROGRAM([
827 [free_null_ok=true; AC_MSG_RESULT(yes)],
828 [free_null_ok=false; AC_MSG_RESULT(no)],
829 [free_null_ok=cross; AC_MSG_RESULT(cross)])
831 if test "$free_null_ok" = "false"; then
832 AC_MSG_ERROR([Your libc implementation doesn't allow free(NULL), as required by C99.])
835 dnl ------------------------------------------------------
836 dnl Where do you live, libevent? And how do we call you?
838 if test "$bwin32" = "true"; then
839 TOR_LIB_WS32=-lws2_32
840 TOR_LIB_IPHLPAPI=-liphlpapi
841 TOR_LIB_SHLWAPI=-lshlwapi
843 TOR_LIB_USERENV=-luserenv
844 TOR_LIB_BCRYPT=-lbcrypt
845 TOR_LIB_CRYPT32=-lcrypt32
851 AC_SUBST(TOR_LIB_WS32)
852 AC_SUBST(TOR_LIB_GDI)
853 AC_SUBST(TOR_LIB_IPHLPAPI)
854 AC_SUBST(TOR_LIB_BCRYPT)
855 AC_SUBST(TOR_LIB_CRYPT32)
856 AC_SUBST(TOR_LIB_SHLWAPI)
857 AC_SUBST(TOR_LIB_USERENV)
859 tor_libevent_pkg_redhat="libevent"
860 tor_libevent_pkg_debian="libevent-dev"
861 tor_libevent_devpkg_redhat="libevent-devel"
862 tor_libevent_devpkg_debian="libevent-dev"
864 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
865 dnl linking for static builds.
866 STATIC_LIBEVENT_FLAGS=""
867 if test "$enable_static_libevent" = "yes"; then
868 if test "$have_rt" = "yes"; then
869 STATIC_LIBEVENT_FLAGS=" -lrt "
873 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_IPHLPAPI $TOR_LIB_BCRYPT $TOR_LIB_WS32], [
875 #include <winsock2.h>
877 #include <sys/time.h>
878 #include <sys/types.h>
879 #include <event2/event.h>], [
881 #include <winsock2.h>
884 struct event_base *event_base_new(void);
885 void event_base_free(struct event_base *);],
888 {WSADATA d; WSAStartup(0x101,&d); }
890 event_base_free(event_base_new());
891 ], [--with-libevent-dir], [/opt/libevent])
893 dnl Determine the incantation needed to link libevent.
895 save_LDFLAGS="$LDFLAGS"
896 save_CPPFLAGS="$CPPFLAGS"
898 LIBS="$STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $save_LIBS"
899 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
900 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
902 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
904 if test "$enable_static_libevent" = "yes"; then
905 if test "$tor_cv_library_libevent_dir" = "(system)"; then
906 AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
908 TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
911 if test "x$ac_cv_header_event2_event_h" = "xyes"; then
912 AC_SEARCH_LIBS(event_new, [event event_core], , AC_MSG_ERROR("libevent2 is installed but linking it failed while searching for event_new"))
913 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"))
915 if test "$ac_cv_search_event_new" != "none required"; then
916 TOR_LIBEVENT_LIBS="$ac_cv_search_event_new"
918 if test "$ac_cv_search_evdns_base_new" != "none required"; then
919 TOR_LIBEVENT_LIBS="$ac_cv_search_evdns_base_new $TOR_LIBEVENT_LIBS"
922 AC_MSG_ERROR("libevent2 is required but the headers could not be found")
926 dnl Now check for particular libevent functions.
927 AC_CHECK_FUNCS([evutil_secure_rng_set_urandom_device_file \
928 evutil_secure_rng_add_bytes \
929 evdns_base_get_nameserver_addr \
934 LDFLAGS="$save_LDFLAGS"
935 CPPFLAGS="$save_CPPFLAGS"
937 dnl Check that libevent is at least at version 2.0.10, the first stable
938 dnl release of its series
939 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
940 AC_MSG_CHECKING([whether Libevent is new enough])
941 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
942 #include <event2/event.h>
943 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000a00
949 ])], [ AC_MSG_RESULT([yes]) ],
950 [ AC_MSG_RESULT([no])
951 AC_MSG_ERROR([Libevent is not new enough. We require 2.0.10-stable or later]) ] )
954 LDFLAGS="$save_LDFLAGS"
955 CPPFLAGS="$save_CPPFLAGS"
957 AC_SUBST(TOR_LIBEVENT_LIBS)
959 dnl ------------------------------------------------------
960 dnl Where do you live, libm?
962 dnl On some platforms (Haiku/BeOS) the math library is
963 dnl part of libroot. In which case don't link against lm
966 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
967 if test "$ac_cv_search_pow" != "none required"; then
968 TOR_LIB_MATH="$ac_cv_search_pow"
971 AC_SUBST(TOR_LIB_MATH)
973 dnl ------------------------------------------------------
974 dnl Hello, NSS. You're new around here.
975 if test "x$enable_nss" = "xyes"; then
976 PKG_CHECK_MODULES(NSS,
979 [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.])])
984 dnl ------------------------------------------------------
985 dnl Where do you live, openssl? And how do we call you?
987 if test "x$enable_nss" != "xyes"; then
989 tor_openssl_pkg_redhat="openssl"
990 tor_openssl_pkg_debian="libssl-dev"
991 tor_openssl_devpkg_redhat="openssl-devel"
992 tor_openssl_devpkg_debian="libssl-dev"
994 ALT_openssl_WITHVAL=""
996 AS_HELP_STRING(--with-ssl-dir=PATH, [obsolete alias for --with-openssl-dir]),
998 if test "x$withval" != "xno" && test "x$withval" != "x"; then
999 ALT_openssl_WITHVAL="$withval"
1003 AC_MSG_NOTICE([Now, we'll look for OpenSSL >= 1.0.1])
1004 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI $TOR_LIB_WS32 $TOR_LIB_CRYPT32],
1005 [#include <openssl/ssl.h>
1006 char *getenv(const char *);],
1007 [struct ssl_cipher_st;
1008 unsigned SSL_CIPHER_get_id(const struct ssl_cipher_st *);
1009 char *getenv(const char *);],
1010 dnl This funny-looking test program calls getenv, so that the compiler
1011 dnl will neither make code that call SSL_CIPHER_get_id(NULL) [producing
1012 dnl a crash], nor optimize out the call to SSL_CIPHER_get_id().
1013 dnl We look for SSL_cipher_get_id() because it is present in
1014 dnl OpenSSL >=1.0.1, because it is not deprecated, and because Tor
1016 [if (getenv("THIS_SHOULDNT_BE_SET_X201803")) SSL_CIPHER_get_id((void *)0);], [],
1017 [/usr/local/opt/openssl /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /opt/openssl])
1019 if test "$enable_static_openssl" = "yes"; then
1020 if test "$tor_cv_library_openssl_dir" = "(system)"; then
1021 AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
1023 TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a $TOR_LIB_WS32 $TOR_LIB_CRYPT32 $TOR_LIB_BCRYPT"
1026 TOR_OPENSSL_LIBS="-lssl -lcrypto"
1028 AC_SUBST(TOR_OPENSSL_LIBS)
1030 dnl Now validate openssl, and check for particular openssl functions.
1032 save_LDFLAGS="$LDFLAGS"
1033 save_CPPFLAGS="$CPPFLAGS"
1034 LIBS="$TOR_OPENSSL_LIBS $LIBS"
1035 LDFLAGS="$TOR_LDFLAGS_openssl $LDFLAGS"
1036 CPPFLAGS="$TOR_CPPFLAGS_openssl $CPPFLAGS"
1038 dnl Tor currently uses a number of APIs that are deprecated in OpenSSL 3.0.0
1039 dnl and later. We want to migrate away from them, but that will be a lot of
1040 dnl work. (See ticket tor#40166.) For now, we disable the deprecation
1043 AC_MSG_CHECKING([for OpenSSL >= 3.0.0])
1044 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1045 #include <openssl/opensslv.h>
1046 #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x30000000L
1047 #error "you_have_version_3"
1050 [ AC_MSG_RESULT([no]) ],
1051 [ AC_MSG_RESULT([yes]);
1052 AC_DEFINE(OPENSSL_SUPPRESS_DEPRECATED, 1, [disable openssl deprecated-function warnings]) ])
1054 AC_MSG_CHECKING([for OpenSSL < 1.0.1])
1055 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1056 #include <openssl/opensslv.h>
1057 #if OPENSSL_VERSION_NUMBER < 0x1000100fL
1061 [ AC_MSG_RESULT([no]) ],
1062 [ 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.]) ])
1064 AC_MSG_CHECKING([whether LibreSSL TLS 1.3 APIs are busted])
1065 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1066 #include <openssl/opensslv.h>
1067 #if defined(LIBRESSL_VERSION_NUMBER) && \
1068 LIBRESSL_VERSION_NUMBER >= 0x3020100fL && \
1069 LIBRESSL_VERSION_NUMBER < 0x3040100fL
1073 [ AC_MSG_RESULT([no]) ],
1074 [ AC_MSG_ERROR([This version of LibreSSL won't work with Tor. Please upgrade to LibreSSL 3.4.1 or later. (Or downgrade to 3.2.0 if you really must.)]) ])
1076 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1077 #include <openssl/opensslv.h>
1078 #include <openssl/evp.h>
1079 #if defined(OPENSSL_NO_EC) || defined(OPENSSL_NO_ECDH) || defined(OPENSSL_NO_ECDSA)
1082 #if !defined(NID_X9_62_prime256v1) || !defined(NID_secp224r1)
1083 #error "curves unavailable"
1087 [ 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.]) ])
1089 dnl Let's see if we have a version mismatch between includes and libs.
1090 AC_MSG_CHECKING([for significant mismatch between openssl headers and libraries])
1092 AC_RUN_IFELSE([AC_LANG_SOURCE([AC_LANG_PROGRAM([[
1093 #include <openssl/opensslv.h>
1094 #include <openssl/crypto.h>
1096 /* Include major, minor, and fix, but not patch or status. */
1097 unsigned long mask = 0xfffff000;
1098 unsigned long linking = OpenSSL_version_num() & mask;
1099 unsigned long running = OPENSSL_VERSION_NUMBER & mask;
1100 return !(linking==running);
1101 ]])])], [openssl_ver_mismatch=no], [
1102 # This is a kludge to figure out whether compilation failed, or whether
1103 # running the program failed.
1104 if test "$ac_retval" = "1"; then
1105 openssl_ver_mismatch=inconclusive
1107 openssl_ver_mismatch=yes
1108 fi], [openssl_ver_mismatch=cross])
1109 AC_MSG_RESULT([$openssl_ver_mismatch])
1111 AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , ,
1112 [#include <openssl/ssl.h>
1115 dnl OpenSSL functions which we might not have. In theory, we could just
1116 dnl check the openssl version number, but in practice that gets pretty
1117 dnl confusing with LibreSSL, OpenSSL, and various distributions' patches
1120 ERR_load_KDF_strings \
1123 SSL_CTX_set1_groups_list \
1124 SSL_CTX_set_security_level \
1125 SSL_SESSION_get_master_key \
1126 SSL_get_client_ciphers \
1127 SSL_get_client_random \
1128 SSL_get_server_random \
1132 dnl Check if OpenSSL structures are opaque
1133 AC_CHECK_MEMBERS([SSL.state], , ,
1134 [#include <openssl/ssl.h>
1137 AC_CHECK_SIZEOF(SHA_CTX, , [AC_INCLUDES_DEFAULT()
1138 #include <openssl/sha.h>
1143 dnl We will someday make KECCAK_TINY optional, but for now we still need
1144 dnl it for SHAKE, since OpenSSL's SHAKE can't be squeezed more than
1145 dnl once. See comment in the definition of crypto_xof_t.
1147 dnl AM_CONDITIONAL(BUILD_KECCAK_TINY,
1148 dnl test "x$ac_cv_func_EVP_sha3_256" != "xyes")
1150 AM_CONDITIONAL(BUILD_KECCAK_TINY, true)
1152 dnl ======================================================================
1153 dnl Can we use KIST?
1155 dnl Define the set of checks for KIST scheduler support.
1156 AC_DEFUN([CHECK_KIST_SUPPORT],[
1157 dnl KIST needs struct tcp_info and for certain members to exist.
1159 [struct tcp_info.tcpi_unacked, struct tcp_info.tcpi_snd_mss],
1160 , ,[[#include <netinet/tcp.h>]])
1161 dnl KIST needs SIOCOUTQNSD to exist for an ioctl call.
1162 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1163 #include <linux/sockios.h>
1167 ])], have_siocoutqnsd=yes, have_siocoutqnsd=no)
1168 if test "x$have_siocoutqnsd" = "xyes"; then
1169 if test "x$ac_cv_member_struct_tcp_info_tcpi_unacked" = "xyes"; then
1170 if test "x$ac_cv_member_struct_tcp_info_tcpi_snd_mss" = "xyes"; then
1171 have_kist_support=yes
1176 dnl Now, trigger the check.
1178 AS_IF([test "x$have_kist_support" = "xyes"],
1179 [AC_DEFINE(HAVE_KIST_SUPPORT, 1, [Defined if KIST scheduler is supported
1181 [AC_MSG_NOTICE([KIST scheduler can't be used. Missing support.])])
1184 LDFLAGS="$save_LDFLAGS"
1185 CPPFLAGS="$save_CPPFLAGS"
1187 dnl ------------------------------------------------------
1188 dnl Where do you live, zlib? And how do we call you?
1190 tor_zlib_pkg_redhat="zlib"
1191 tor_zlib_pkg_debian="zlib1g"
1192 tor_zlib_devpkg_redhat="zlib-devel"
1193 tor_zlib_devpkg_debian="zlib1g-dev"
1195 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
1196 [#include <zlib.h>],
1197 [const char * zlibVersion(void);],
1198 [zlibVersion();], [--with-zlib-dir],
1201 if test "$enable_static_zlib" = "yes"; then
1202 if test "$tor_cv_library_zlib_dir" = "(system)"; then
1203 AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
1204 using --enable-static-zlib")
1206 TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
1211 AC_SUBST(TOR_ZLIB_LIBS)
1213 dnl ------------------------------------------------------
1214 dnl Where we do we find lzma?
1217 AS_HELP_STRING(--enable-lzma, [enable support for the LZMA compression scheme.]),
1218 [case "${enableval}" in
1221 * ) AC_MSG_ERROR(bad value for --enable-lzma) ;;
1222 esac], [enable_lzma=auto])
1224 if test "x$enable_lzma" = "xno"; then
1227 PKG_CHECK_MODULES([LZMA],
1232 if test "x$have_lzma" = "xno" ; then
1234 AC_MSG_WARN([Unable to find liblzma, $pkg_config_user_action, or set LZMA_CFLAGS and LZMA_LIBS.])
1238 if test "x$have_lzma" = "xyes"; then
1239 AC_DEFINE(HAVE_LZMA,1,[Have LZMA])
1240 TOR_LZMA_CFLAGS="${LZMA_CFLAGS}"
1241 TOR_LZMA_LIBS="${LZMA_LIBS}"
1243 AC_SUBST(TOR_LZMA_CFLAGS)
1244 AC_SUBST(TOR_LZMA_LIBS)
1246 dnl ------------------------------------------------------
1247 dnl Where we do we find zstd?
1250 AS_HELP_STRING(--enable-zstd, [enable support for the Zstandard compression scheme.]),
1251 [case "${enableval}" in
1254 * ) AC_MSG_ERROR(bad value for --enable-zstd) ;;
1255 esac], [enable_zstd=auto])
1257 if test "x$enable_zstd" = "xno"; then
1260 PKG_CHECK_MODULES([ZSTD],
1265 if test "x$have_zstd" = "xno" ; then
1267 AC_MSG_WARN([Unable to find libzstd, $pkg_config_user_action, or set ZSTD_CFLAGS and ZSTD_LIBS.])
1271 if test "x$have_zstd" = "xyes"; then
1272 AC_DEFINE(HAVE_ZSTD,1,[Have Zstd])
1273 TOR_ZSTD_CFLAGS="${ZSTD_CFLAGS}"
1274 TOR_ZSTD_LIBS="${ZSTD_LIBS}"
1276 dnl now check for zstd functions
1278 save_CFLAGS="$CFLAGS"
1279 LIBS="$LIBS $ZSTD_LIBS"
1280 CFLAGS="$CFLAGS $ZSTD_CFLAGS"
1281 AC_CHECK_FUNCS(ZSTD_estimateCStreamSize \
1282 ZSTD_estimateDCtxSize)
1284 CFLAGS="$save_CFLAGS"
1286 AC_SUBST(TOR_ZSTD_CFLAGS)
1287 AC_SUBST(TOR_ZSTD_LIBS)
1289 dnl ----------------------------------------------------------------------
1290 dnl Check if libcap is available for capabilities.
1292 tor_cap_pkg_debian="libcap2"
1293 tor_cap_pkg_redhat="libcap"
1294 tor_cap_devpkg_debian="libcap-dev"
1295 tor_cap_devpkg_redhat="libcap-devel"
1297 AC_CHECK_LIB([cap], [cap_init], [],
1298 AC_MSG_NOTICE([Libcap was not found. Capabilities will not be usable.])
1300 AC_CHECK_FUNCS(cap_set_proc)
1302 dnl ---------------------------------------------------------------------
1303 dnl Now that we know about our major libraries, we can check for compiler
1304 dnl and linker hardening options. We need to do this with the libraries known,
1305 dnl since sometimes the linker will like an option but not be willing to
1306 dnl use it with a build of a library.
1308 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
1309 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"
1317 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1318 #if !defined(__clang__)
1320 #endif])], have_clang=yes, have_clang=no)
1322 if test "x$enable_pic" = "xyes"; then
1323 TOR_CHECK_CFLAGS(-fPIC)
1326 if test "x$enable_gcc_hardening" != "xno"; then
1327 CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
1328 if test "x$have_clang" = "xyes"; then
1329 TOR_CHECK_CFLAGS(-Qunused-arguments)
1331 TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
1332 AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
1333 AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
1334 m4_ifdef([AS_VAR_IF],[
1335 AS_VAR_IF(can_compile, [yes],
1336 AS_VAR_IF(can_link, [yes],
1338 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.)]))
1340 AS_VAR_POPDEF([can_link])
1341 AS_VAR_POPDEF([can_compile])
1342 TOR_CHECK_CFLAGS(-Wstack-protector)
1343 TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
1344 if test "$bwin32" = "false" && test "$enable_libfuzzer" != "yes" && test "$enable_oss_fuzz" != "yes"; then
1345 if test "$enable_pic" != "yes"; then
1346 # If we have already enabled -fPIC, then we don't also need to
1347 # compile with -fPIE...
1348 TOR_CHECK_CFLAGS(-fPIE)
1350 # ... but we want to link our executables with -pie in any case, since
1351 # they're executables, not a library.
1352 TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
1354 TOR_TRY_COMPILE_WITH_CFLAGS(-fwrapv, also_link, CFLAGS_FWRAPV="-fwrapv", true)
1356 AC_MSG_CHECKING([whether we can run hardened binaries])
1357 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
1358 [AC_MSG_RESULT([yes])],
1359 [AC_MSG_RESULT([no])
1361 We can link with compiler hardening options, but we can't run with them.
1362 That's a bad sign! If you must, you can pass --disable-gcc-hardening to
1363 configure, but it would be better to figure out what the underlying problem
1365 [AC_MSG_RESULT([cross])])
1368 if test "$fragile_hardening" = "yes"; then
1369 TOR_TRY_COMPILE_WITH_CFLAGS(-ftrapv, also_link, CFLAGS_FTRAPV="-ftrapv", true)
1370 if test "$tor_cv_cflags__ftrapv" = "yes" && test "$tor_can_link__ftrapv" != "yes"; then
1372 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.])
1375 if test "$tor_cv_cflags__ftrapv" != "yes"; then
1376 AC_MSG_ERROR([You requested fragile hardening, but the compiler does not seem to support -ftrapv.])
1379 TOR_TRY_COMPILE_WITH_CFLAGS([-fsanitize=address], also_link, CFLAGS_ASAN="-fsanitize=address", true)
1380 if test "$tor_cv_cflags__fsanitize_address" = "yes" && test "$tor_can_link__fsanitize_address" != "yes"; then
1381 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*])
1384 TOR_TRY_COMPILE_WITH_CFLAGS([-fsanitize=undefined], also_link, CFLAGS_UBSAN="-fsanitize=undefined", true)
1385 if test "$tor_cv_cflags__fsanitize_address" = "yes" && test "$tor_can_link__fsanitize_address" != "yes"; then
1386 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*])
1389 TOR_TRY_COMPILE_WITH_CFLAGS([-fno-sanitize=float-divide-by-zero], also_link, CFLAGS_UBSAN="-fno-sanitize=float-divide-by-zero", true)
1390 if test "$tor_cv_cflags__fno_sanitize_float_divide_by_zero" = "yes" && test "$tor_can_link__fno_sanitize_float_divide_by_zero" != "yes"; then
1391 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*])
1394 TOR_CHECK_CFLAGS([-fno-omit-frame-pointer])
1397 CFLAGS_BUGTRAP="$CFLAGS_FTRAPV $CFLAGS_ASAN $CFLAGS_UBSAN"
1398 CFLAGS_CONSTTIME="$CFLAGS_FWRAPV"
1400 mulodi_fixes_ftrapv=no
1401 if test "$have_clang" = "yes"; then
1402 saved_CFLAGS="$CFLAGS"
1403 CFLAGS="$CFLAGS $CFLAGS_FTRAPV"
1404 AC_MSG_CHECKING([whether clang -ftrapv can link a 64-bit int multiply])
1409 int main(int argc, char **argv)
1411 int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
1412 * (int64_t)atoi(argv[3]);
1415 [ftrapv_can_link=yes; AC_MSG_RESULT([yes])],
1416 [ftrapv_can_link=no; AC_MSG_RESULT([no])])
1417 if test "$ftrapv_can_link" = "no"; then
1418 AC_MSG_CHECKING([whether defining __mulodi4 fixes that])
1423 int64_t __mulodi4(int64_t a, int64_t b, int *overflow) {
1427 int main(int argc, char **argv)
1429 int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
1430 * (int64_t)atoi(argv[3]);
1433 [mulodi_fixes_ftrapv=yes; AC_MSG_RESULT([yes])],
1434 [mulodi_fixes_ftrapv=no; AC_MSG_RESULT([no])])
1436 CFLAGS="$saved_CFLAGS"
1439 AM_CONDITIONAL(ADD_MULODI4, test "$mulodi_fixes_ftrapv" = "yes")
1441 dnl These cflags add bunches of branches, and we haven't been able to
1442 dnl persuade ourselves that they're suitable for code that needs to be
1444 AC_SUBST(CFLAGS_BUGTRAP)
1445 dnl These cflags are variant ones suitable for code that needs to be
1447 AC_SUBST(CFLAGS_CONSTTIME)
1449 if test "x$enable_linker_hardening" != "xno"; then
1450 TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
1453 # For backtrace support
1454 TOR_CHECK_LDFLAGS(-rdynamic)
1456 dnl ------------------------------------------------------
1457 dnl Now see if we have a -fomit-frame-pointer compiler option.
1459 saved_CFLAGS="$CFLAGS"
1460 TOR_CHECK_CFLAGS(-fomit-frame-pointer)
1461 F_OMIT_FRAME_POINTER=''
1462 if test "$saved_CFLAGS" != "$CFLAGS"; then
1463 if test "$fragile_hardening" = "yes"; then
1464 F_OMIT_FRAME_POINTER='-fomit-frame-pointer'
1467 CFLAGS="$saved_CFLAGS"
1468 AC_SUBST(F_OMIT_FRAME_POINTER)
1470 dnl ------------------------------------------------------
1471 dnl If we are adding -fomit-frame-pointer (or if the compiler's doing it
1472 dnl for us, as GCC 4.6 and later do at many optimization levels), then
1473 dnl we should try to add -fasynchronous-unwind-tables so that our backtrace
1475 TOR_CHECK_CFLAGS(-fasynchronous-unwind-tables)
1477 dnl ============================================================
1478 dnl Check for libseccomp
1480 if test "x$enable_seccomp" != "xno"; then
1481 AC_CHECK_HEADERS([seccomp.h])
1482 AC_SEARCH_LIBS(seccomp_init, [seccomp])
1485 dnl ============================================================
1486 dnl Check for libscrypt
1488 if test "x$enable_libscrypt" != "xno"; then
1489 AC_CHECK_HEADERS([libscrypt.h])
1490 AC_SEARCH_LIBS(libscrypt_scrypt, [scrypt])
1491 AC_CHECK_FUNCS([libscrypt_scrypt])
1494 dnl ============================================================
1495 dnl We need an implementation of curve25519.
1497 dnl set these defaults.
1498 build_curve25519_donna=no
1499 build_curve25519_donna_c64=no
1500 use_curve25519_donna=no
1501 use_curve25519_nacl=no
1504 dnl The best choice is using curve25519-donna-c64, but that requires
1506 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
1507 tor_cv_can_use_curve25519_donna_c64,
1509 [AC_LANG_PROGRAM([dnl
1511 typedef unsigned uint128_t __attribute__((mode(TI)));
1512 int func(uint64_t a, uint64_t b) {
1513 uint128_t c = ((uint128_t)a) * b;
1514 int ok = ((uint64_t)(c>>96)) == 522859 &&
1515 (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
1516 (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
1517 (((uint64_t)(c))&0xffffffffL) == 0;
1521 int ok = func( ((uint64_t)2000000000) * 1000000000,
1522 ((uint64_t)1234567890) << 24);
1525 [tor_cv_can_use_curve25519_donna_c64=yes],
1526 [tor_cv_can_use_curve25519_donna_c64=no],
1528 [AC_LANG_PROGRAM([dnl
1530 typedef unsigned uint128_t __attribute__((mode(TI)));
1531 int func(uint64_t a, uint64_t b) {
1532 uint128_t c = ((uint128_t)a) * b;
1533 int ok = ((uint64_t)(c>>96)) == 522859 &&
1534 (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
1535 (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
1536 (((uint64_t)(c))&0xffffffffL) == 0;
1540 int ok = func( ((uint64_t)2000000000) * 1000000000,
1541 ((uint64_t)1234567890) << 24);
1544 [tor_cv_can_use_curve25519_donna_c64=cross],
1545 [tor_cv_can_use_curve25519_donna_c64=no])])])
1547 AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
1548 nacl/crypto_scalarmult_curve25519.h])
1550 AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
1551 tor_cv_can_use_curve25519_nacl,
1552 [tor_saved_LIBS="$LIBS"
1555 [AC_LANG_PROGRAM([dnl
1556 #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
1557 #include <crypto_scalarmult_curve25519.h>
1558 #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
1559 #include <nacl/crypto_scalarmult_curve25519.h>
1561 #ifdef crypto_scalarmult_curve25519_ref_BYTES
1562 #error Hey, this is the reference implementation! That's not fast.
1565 unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
1566 ])], [tor_cv_can_use_curve25519_nacl=yes],
1567 [tor_cv_can_use_curve25519_nacl=no])
1568 LIBS="$tor_saved_LIBS" ])
1570 dnl Okay, now we need to figure out which one to actually use. Fall back
1571 dnl to curve25519-donna.c
1573 if test "x$tor_cv_can_use_curve25519_donna_c64" != "xno"; then
1574 build_curve25519_donna_c64=yes
1575 use_curve25519_donna=yes
1576 elif test "x$tor_cv_can_use_curve25519_nacl" = "xyes"; then
1577 use_curve25519_nacl=yes
1578 CURVE25519_LIBS=-lnacl
1580 build_curve25519_donna=yes
1581 use_curve25519_donna=yes
1584 if test "x$use_curve25519_donna" = "xyes"; then
1585 AC_DEFINE(USE_CURVE25519_DONNA, 1,
1586 [Defined if we should use an internal curve25519_donna{,_c64} implementation])
1588 if test "x$use_curve25519_nacl" = "xyes"; then
1589 AC_DEFINE(USE_CURVE25519_NACL, 1,
1590 [Defined if we should use a curve25519 from nacl])
1592 AM_CONDITIONAL(BUILD_CURVE25519_DONNA,
1593 test "x$build_curve25519_donna" = "xyes")
1594 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64,
1595 test "x$build_curve25519_donna_c64" = "xyes")
1596 AC_SUBST(CURVE25519_LIBS)
1598 dnl Make sure to enable support for large off_t if available.
1601 AC_CHECK_HEADERS([errno.h \
1615 gnu/libc-version.h \
1653 AC_CHECK_HEADERS(sys/param.h)
1655 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
1656 [#ifdef HAVE_SYS_TYPES_H
1657 #include <sys/types.h>
1659 #ifdef HAVE_SYS_SOCKET_H
1660 #include <sys/socket.h>
1662 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
1663 [#ifdef HAVE_SYS_TYPES_H
1664 #include <sys/types.h>
1666 #ifdef HAVE_SYS_SOCKET_H
1667 #include <sys/socket.h>
1669 #ifdef HAVE_NET_IF_H
1672 #ifdef HAVE_NETINET_IN_H
1673 #include <netinet/in.h>
1676 AC_CHECK_HEADERS(linux/if.h,[],[],
1678 #ifdef HAVE_SYS_SOCKET_H
1679 #include <sys/socket.h>
1683 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
1684 linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
1685 [#ifdef HAVE_SYS_TYPES_H
1686 #include <sys/types.h>
1688 #ifdef HAVE_SYS_SOCKET_H
1689 #include <sys/socket.h>
1691 #ifdef HAVE_LIMITS_H
1694 #ifdef HAVE_LINUX_TYPES_H
1695 #include <linux/types.h>
1697 #ifdef HAVE_NETINET_IN6_H
1698 #include <netinet/in6.h>
1700 #ifdef HAVE_NETINET_IN_H
1701 #include <netinet/in.h>
1704 AC_CHECK_HEADERS(linux/netfilter_ipv6/ip6_tables.h,
1705 linux_netfilter_ipv6_ip6_tables=1, linux_netfilter_ipv6_ip6_tables=0,
1706 [#ifdef HAVE_SYS_TYPES_H
1707 #include <sys/types.h>
1709 #ifdef HAVE_SYS_SOCKET_H
1710 #include <sys/socket.h>
1712 #ifdef HAVE_LIMITS_H
1715 #ifdef HAVE_LINUX_TYPES_H
1716 #include <linux/types.h>
1718 #ifdef HAVE_NETINET_IN6_H
1719 #include <netinet/in6.h>
1721 #ifdef HAVE_NETINET_IN_H
1722 #include <netinet/in.h>
1724 #ifdef HAVE_LINUX_IF_H
1725 #include <linux/if.h>
1729 if test "x$net_if_found" = "x1" && test "x$net_pfvar_found" = "x1"; then
1732 if test "x$linux_netfilter_ipv4" = "x1"; then
1735 if test "x$linux_netfilter_ipv6_ip6_tables" = "x1"; then
1738 if test "x$transparent_ok" = "x1"; then
1739 AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
1741 AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
1744 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
1745 [#ifdef HAVE_SYS_TYPES_H
1746 #include <sys/types.h>
1748 #ifdef HAVE_SYS_TIME_H
1749 #include <sys/time.h>
1752 AC_CHECK_SIZEOF(char)
1753 AC_CHECK_SIZEOF(short)
1754 AC_CHECK_SIZEOF(int)
1755 AC_CHECK_SIZEOF(unsigned int)
1756 AC_CHECK_SIZEOF(long)
1757 AC_CHECK_SIZEOF(long long)
1758 AC_CHECK_SIZEOF(__int64)
1759 AC_CHECK_SIZEOF(void *)
1760 AC_CHECK_SIZEOF(time_t)
1761 AC_CHECK_SIZEOF(size_t)
1762 AC_CHECK_SIZEOF(pid_t)
1764 AC_CHECK_TYPES([uint, u_char, ssize_t])
1766 AC_PC_FROM_UCONTEXT([:])
1768 dnl used to include sockaddr_storage, but everybody has that.
1769 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
1770 [#ifdef HAVE_SYS_TYPES_H
1771 #include <sys/types.h>
1773 #ifdef HAVE_NETINET_IN_H
1774 #include <netinet/in.h>
1776 #ifdef HAVE_NETINET_IN6_H
1777 #include <netinet/in6.h>
1779 #ifdef HAVE_SYS_SOCKET_H
1780 #include <sys/socket.h>
1783 #define _WIN32_WINNT 0x0501
1784 #define WIN32_LEAN_AND_MEAN
1785 #include <winsock2.h>
1786 #include <ws2tcpip.h>
1789 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
1790 [#ifdef HAVE_SYS_TYPES_H
1791 #include <sys/types.h>
1793 #ifdef HAVE_NETINET_IN_H
1794 #include <netinet/in.h>
1796 #ifdef HAVE_NETINET_IN6_H
1797 #include <netinet/in6.h>
1799 #ifdef HAVE_SYS_SOCKET_H
1800 #include <sys/socket.h>
1803 #define _WIN32_WINNT 0x0501
1804 #define WIN32_LEAN_AND_MEAN
1805 #include <winsock2.h>
1806 #include <ws2tcpip.h>
1810 AC_CHECK_TYPES([rlim_t], , ,
1811 [#ifdef HAVE_SYS_TYPES_H
1812 #include <sys/types.h>
1814 #ifdef HAVE_SYS_TIME_H
1815 #include <sys/time.h>
1817 #ifdef HAVE_SYS_RESOURCE_H
1818 #include <sys/resource.h>
1822 AX_CHECK_SIGN([time_t],
1825 #ifdef HAVE_SYS_TYPES_H
1826 #include <sys/types.h>
1828 #ifdef HAVE_SYS_TIME_H
1829 #include <sys/time.h>
1836 if test "$ax_cv_decl_time_t_signed" = "no"; then
1837 AC_MSG_ERROR([You have an unsigned time_t; Tor does not support that. Please tell the Tor developers about your interesting platform.])
1840 AX_CHECK_SIGN([size_t],
1841 [ tor_cv_size_t_signed=yes ],
1842 [ tor_cv_size_t_signed=no ], [
1843 #ifdef HAVE_SYS_TYPES_H
1844 #include <sys/types.h>
1848 if test "$ax_cv_decl_size_t_signed" = "yes"; then
1849 AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
1852 AX_CHECK_SIGN([enum always],
1853 [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
1855 enum always { AAA, BBB, CCC };
1858 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
1859 #ifdef HAVE_SYS_SOCKET_H
1860 #include <sys/socket.h>
1864 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1866 AC_CHECK_SIZEOF(cell_t)
1868 # Let's see if stdatomic works. (There are some debian clangs that screw it
1869 # up; see Tor bug #26779 and debian bug 903709.)
1870 AC_CACHE_CHECK([whether C11 stdatomic.h actually works],
1871 tor_cv_stdatomic_works,
1872 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1873 #include <stdatomic.h>
1874 struct x { atomic_size_t y; };
1875 void try_atomic_init(struct x *xx)
1877 atomic_init(&xx->y, 99);
1878 atomic_fetch_add(&xx->y, 1);
1880 ]])], [tor_cv_stdatomic_works=yes], [tor_cv_stdatomic_works=no])])
1882 if test "$tor_cv_stdatomic_works" = "yes"; then
1883 AC_DEFINE(STDATOMIC_WORKS, 1, [Set to 1 if we can compile a simple stdatomic example.])
1884 elif test "$ac_cv_header_stdatomic_h" = "yes"; then
1886 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 ])
1889 # Now make sure that NULL can be represented as zero bytes.
1890 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1891 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1892 [[#include <stdlib.h>
1895 #ifdef HAVE_STDDEF_H
1898 int main (void) { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1899 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1900 [tor_cv_null_is_zero=yes],
1901 [tor_cv_null_is_zero=no],
1902 [tor_cv_null_is_zero=cross])])
1904 if test "$tor_cv_null_is_zero" = "cross"; then
1905 # Cross-compiling; let's hope that the target isn't raving mad.
1906 AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
1909 if test "$tor_cv_null_is_zero" != "no"; then
1910 AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1911 [Define to 1 iff memset(0) sets pointers to NULL])
1914 AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
1915 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1916 [[#include <stdlib.h>
1919 #ifdef HAVE_STDDEF_H
1922 int main (void) { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
1923 return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
1924 [tor_cv_dbl0_is_zero=yes],
1925 [tor_cv_dbl0_is_zero=no],
1926 [tor_cv_dbl0_is_zero=cross])])
1928 if test "$tor_cv_dbl0_is_zero" = "cross"; then
1929 # Cross-compiling; let's hope that the target isn't raving mad.
1930 AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
1933 if test "$tor_cv_dbl0_is_zero" != "no"; then
1934 AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
1935 [Define to 1 iff memset(0) sets doubles to 0.0])
1938 # And what happens when we malloc zero?
1939 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
1940 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1941 [[#include <stdlib.h>
1944 #ifdef HAVE_STDDEF_H
1947 int main (void) { return malloc(0)?0:1; }]])],
1948 [tor_cv_malloc_zero_works=yes],
1949 [tor_cv_malloc_zero_works=no],
1950 [tor_cv_malloc_zero_works=cross])])
1952 if test "$tor_cv_malloc_zero_works" = "cross"; then
1953 # Cross-compiling; let's hope that the target isn't raving mad.
1954 AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
1957 if test "$tor_cv_malloc_zero_works" = "yes"; then
1958 AC_DEFINE([MALLOC_ZERO_WORKS], 1,
1959 [Define to 1 iff malloc(0) returns a pointer])
1962 # whether we seem to be in a 2s-complement world.
1963 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
1964 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1965 [[int main (void) { int problem = ((-99) != (~99)+1);
1966 return problem ? 1 : 0; }]])],
1967 [tor_cv_twos_complement=yes],
1968 [tor_cv_twos_complement=no],
1969 [tor_cv_twos_complement=cross])])
1971 if test "$tor_cv_twos_complement" = "cross"; then
1972 # Cross-compiling; let's hope that the target isn't raving mad.
1973 AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
1976 if test "$tor_cv_twos_complement" != "no"; then
1977 AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
1978 [Define to 1 iff we represent negative integers with
1982 # What does shifting a negative value do?
1983 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
1984 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1985 [[int main (void) { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
1986 [tor_cv_sign_extend=yes],
1987 [tor_cv_sign_extend=no],
1988 [tor_cv_sign_extend=cross])])
1990 if test "$tor_cv_sign_extend" = "cross"; then
1991 # Cross-compiling; let's hope that the target isn't raving mad.
1992 AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
1995 if test "$tor_cv_sign_extend" != "no"; then
1996 AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
1997 [Define to 1 iff right-shifting a negative value performs sign-extension])
2000 # Is uint8_t the same type as unsigned char?
2001 AC_CACHE_CHECK([whether uint8_t is the same type as unsigned char], tor_cv_uint8_uchar,
2002 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2005 unsigned char c;]])],
2006 [tor_cv_uint8_uchar=yes],
2007 [tor_cv_uint8_uchar=no],
2008 [tor_cv_uint8_uchar=cross])])
2010 if test "$tor_cv_uint8_uchar" = "cross"; then
2011 AC_MSG_NOTICE([Cross-compiling: we'll assume that uint8_t is the same type as unsigned char])
2014 if test "$tor_cv_uint8_uchar" = "no"; then
2015 AC_MSG_ERROR([We assume that uint8_t is the same type as unsigned char, but your compiler disagrees.])
2018 AC_ARG_WITH(tcmalloc,
2019 AS_HELP_STRING(--with-tcmalloc, [use tcmalloc memory allocation library. Deprecated; see --with-malloc]))
2021 default_malloc=system
2023 if test "x$enable_openbsd_malloc" = "xyes" ; then
2024 AC_MSG_NOTICE([The --enable-openbsd-malloc argument is deprecated; use --with-malloc=openbsd instead.])
2025 default_malloc=openbsd
2028 if test "x$with_tcmalloc" = "xyes"; then
2029 AC_MSG_NOTICE([The --with-tcmalloc argument is deprecated; use --with-malloc=tcmalloc instead.])
2030 default_malloc=tcmalloc
2034 AS_HELP_STRING([--with-malloc=[system,jemalloc,tcmalloc,openbsd]],
2035 [select special malloc implementation [system]]),
2036 [ malloc="$with_malloc" ], [ malloc="$default_malloc" ])
2040 PKG_CHECK_MODULES([TCMALLOC],
2045 if test "x$have_tcmalloc" = "xno" ; then
2046 AC_MSG_ERROR([Unable to find tcmalloc requested by --with-malloc, $pkg_config_user_action, or set TCMALLOC_CFLAGS and TCMALLOC_LIBS.])
2049 CFLAGS="$CFLAGS $TCMALLOC_CFLAGS"
2050 LIBS="$TCMALLOC_LIBS $LIBS"
2054 PKG_CHECK_MODULES([JEMALLOC],
2059 if test "x$have_jemalloc" = "xno" ; then
2060 AC_MSG_ERROR([Unable to find jemalloc requested by --with-malloc, $pkg_config_user_action, or set JEMALLOC_CFLAGS and JEMALLOC_LIBS.])
2063 CFLAGS="$CFLAGS $JEMALLOC_CFLAGS"
2064 LIBS="$JEMALLOC_LIBS $LIBS"
2065 using_custom_malloc=yes
2070 AC_MSG_WARN([The openbsd malloc port is deprecated in Tor 0.3.5 and will be removed in a future version.])
2071 enable_openbsd_malloc=yes
2075 # handle this later, including the jemalloc fallback
2078 [AC_MSG_ERROR([--with-malloc=`$with_malloc' not supported, see --help])
2081 AM_CONDITIONAL(USE_OPENBSD_MALLOC, test "x$enable_openbsd_malloc" = "xyes")
2083 if test "$malloc" != "system"; then
2084 # Tell the C compiler not to use the system allocator functions.
2085 TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
2087 if test "$using_custom_malloc" = "yes"; then
2088 # Tell the C compiler not to use the system allocator functions.
2089 TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
2092 # By default, we're going to assume we don't have mlockall()
2093 # bionic and other platforms have various broken mlockall subsystems.
2094 # Some systems don't have a working mlockall, some aren't linkable,
2095 # and some have it but don't declare it.
2096 AC_CHECK_FUNCS(mlockall)
2097 AC_CHECK_DECLS([mlockall], , , [
2098 #ifdef HAVE_SYS_MMAN_H
2099 #include <sys/mman.h>
2102 # Allow user to specify an alternate syslog facility
2103 AC_ARG_WITH(syslog-facility,
2104 AS_HELP_STRING(--with-syslog-facility=LOG, [syslog facility to use (default=LOG_DAEMON)]),
2105 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
2106 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
2107 AC_SUBST(LOGFACILITY)
2109 # Check if we have getresuid and getresgid
2110 AC_CHECK_FUNCS(getresuid getresgid)
2112 # Check for gethostbyname_r in all its glorious incompatible versions.
2113 # (This logic is based on that in Python's configure.in)
2114 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
2115 [Define this if you have any gethostbyname_r()])
2117 AC_CHECK_FUNC(gethostbyname_r, [
2118 AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
2120 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
2121 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2125 struct hostent *h1, *h2;
2127 (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
2129 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2130 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2131 [Define this if gethostbyname_r takes 6 arguments])
2134 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2140 (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
2142 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2143 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2144 [Define this if gethostbyname_r takes 5 arguments])
2147 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2152 struct hostent_data hd;
2153 (void) gethostbyname_r(cp1,h1,&hd);
2155 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2156 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2157 [Define this if gethostbyname_r takes 3 arguments])
2167 AC_CACHE_CHECK([whether the C compiler supports __func__],
2168 tor_cv_have_func_macro,
2169 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2171 int main(int c, char **v) { puts(__func__); }])],
2172 tor_cv_have_func_macro=yes,
2173 tor_cv_have_func_macro=no))
2175 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
2176 tor_cv_have_FUNC_macro,
2177 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2179 int main(int c, char **v) { puts(__FUNC__); }])],
2180 tor_cv_have_FUNC_macro=yes,
2181 tor_cv_have_FUNC_macro=no))
2183 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
2184 tor_cv_have_FUNCTION_macro,
2185 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2187 int main(int c, char **v) { puts(__FUNCTION__); }])],
2188 tor_cv_have_FUNCTION_macro=yes,
2189 tor_cv_have_FUNCTION_macro=no))
2191 AC_CACHE_CHECK([whether we have extern char **environ already declared],
2192 tor_cv_have_environ_declared,
2193 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2194 #ifdef HAVE_UNISTD_H
2198 int main(int c, char **v) { char **t = environ; }])],
2199 tor_cv_have_environ_declared=yes,
2200 tor_cv_have_environ_declared=no))
2202 if test "$tor_cv_have_func_macro" = "yes"; then
2203 AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
2206 if test "$tor_cv_have_FUNC_macro" = "yes"; then
2207 AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
2210 if test "$tor_cv_have_FUNCTION_macro" = "yes"; then
2211 AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
2212 [Defined if the compiler supports __FUNCTION__])
2215 if test "$tor_cv_have_environ_declared" = "yes"; then
2216 AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
2217 [Defined if we have extern char **environ already declared])
2220 # $prefix stores the value of the --prefix command line option, or
2221 # NONE if the option wasn't set. In the case that it wasn't set, make
2222 # it be the default, so that we can use it to expand directories now.
2223 if test "x$prefix" = "xNONE"; then
2224 prefix=$ac_default_prefix
2227 # and similarly for $exec_prefix
2228 if test "x$exec_prefix" = "xNONE"; then
2232 if test "x$BUILDDIR" = "x"; then
2236 AH_TEMPLATE([BUILDDIR],[tor's build directory])
2237 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
2239 if test "x$SRCDIR" = "x"; then
2240 SRCDIR=$(cd "$srcdir"; pwd)
2242 AH_TEMPLATE([SRCDIR],[tor's sourcedir directory])
2243 AC_DEFINE_UNQUOTED(SRCDIR,"$SRCDIR")
2245 if test "x$CONFDIR" = "x"; then
2246 CONFDIR=`eval echo $sysconfdir/tor`
2249 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
2250 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
2252 BINDIR=`eval echo $bindir`
2254 LOCALSTATEDIR=`eval echo $localstatedir`
2255 AC_SUBST(LOCALSTATEDIR)
2257 if test "$bwin32" = "true"; then
2258 # Test if the linker supports the --nxcompat and --dynamicbase options
2260 save_LDFLAGS="$LDFLAGS"
2261 LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
2262 AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
2263 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
2264 [AC_MSG_RESULT([yes])]
2265 [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
2266 [AC_MSG_RESULT([no])]
2268 LDFLAGS="$save_LDFLAGS"
2271 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
2272 # than autoconf's macros like.
2273 if test "$GCC" = "yes"; then
2274 # Disable GCC's strict aliasing checks. They are an hours-to-debug
2275 # accident waiting to happen.
2276 CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
2278 # Override optimization level for non-gcc compilers
2280 enable_gcc_warnings=no
2281 enable_gcc_warnings_advisory=no
2284 # Warnings implies advisory-warnings and -Werror.
2285 if test "$enable_gcc_warnings" = "yes"; then
2286 enable_gcc_warnings_advisory=yes
2287 enable_fatal_warnings=yes
2290 # OS X Lion started deprecating the system openssl. Let's just disable
2291 # all deprecation warnings on OS X. Also, to potentially make the binary
2292 # a little smaller, let's enable dead_strip.
2296 CFLAGS="$CFLAGS -Wno-deprecated-declarations"
2297 LDFLAGS="$LDFLAGS -dead_strip" ;;
2300 TOR_WARNING_FLAGS=""
2302 # Add some more warnings which we use in development but not in the
2303 # released versions. (Some relevant gcc versions can't handle these.)
2305 # Note that we have to do this near the end of the autoconf process, or
2306 # else we may run into problems when these warnings hit on the testing C
2307 # programs that autoconf wants to build.
2308 if test "x$enable_gcc_warnings_advisory" != "xno"; then
2311 *-*-openbsd* | *-*-bitrig*)
2312 # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
2313 # That's fine, except that the headers don't pass -Wredundant-decls.
2314 # Therefore, let's disable -Wsystem-headers when we're building
2315 # with maximal warnings on OpenBSD.
2316 CFLAGS="$CFLAGS -Wno-system-headers" ;;
2319 CFLAGS_NOWARNINGS="$CFLAGS"
2321 # GCC4.3 users once report trouble with -Wstrict-overflow=5. GCC5 users
2322 # have it work better.
2323 # CFLAGS="$CFLAGS -Wstrict-overflow=1"
2325 # This warning was added in gcc 4.3, but it appears to generate
2326 # spurious warnings in gcc 4.4. I don't know if it works in 4.5.
2327 #CFLAGS="$CFLAGS -Wlogical-op"
2329 m4_foreach_w([warning_flag], [
2331 -Waddress-of-array-temporary
2332 -Waddress-of-temporary
2334 -Wanonymous-pack-parens
2337 -Warc-bridge-casts-disallowed-in-nonarc
2338 -Warc-maybe-repeated-use-of-weak
2339 -Warc-performSelector-leaks
2340 -Warc-repeated-use-of-weak
2342 -Warray-bounds-pointer-arithmetic
2344 -Wasm-operand-widths
2346 -Watomic-property-with-user-defined-accessor
2348 -Wauto-storage-class
2351 -Wbackslash-newline-escape
2352 -Wbad-array-new-length
2353 -Wbind-to-temporary-copy
2354 -Wbitfield-constant-conversion
2357 -Wbuiltin-requires-header
2359 -Wcompare-distinct-pointer-types
2360 -Wcomplex-component-init
2361 -Wconditional-type-mismatch
2363 -Wconstant-conversion
2364 -Wconstant-logical-operand
2365 -Wconstexpr-not-const
2366 -Wcustom-atomic-properties
2368 -Wdangling-initializer-list
2370 -Wdelegating-ctor-cycles
2371 -Wdeprecated-implementations
2372 -Wdeprecated-register
2373 -Wdirect-ivar-access
2375 -Wdistributed-object-modifiers
2377 -Wdollar-in-identifier-extension
2379 -Wduplicate-decl-specifier
2381 -Wduplicate-method-arg
2382 -Wduplicate-method-match
2384 -Wdynamic-class-memaccess
2385 -Wembedded-directive
2386 -Wempty-translation-unit
2388 -Wexit-time-destructors
2389 -Wexplicit-ownership-type
2390 -Wextern-initializer
2393 -Wflexible-array-extensions
2396 -Wfour-char-constants
2398 -Wglobal-constructors
2399 -Wgnu-array-member-paren-init
2401 -Wgnu-static-float-init
2404 -Widiomatic-parentheses
2405 -Wignored-attributes
2406 -Wimplicit-atomic-properties
2407 -Wimplicit-conversion-floating-point-to-bool
2408 -Wimplicit-exception-spec-mismatch
2409 -Wimplicit-fallthrough
2410 -Wimplicit-fallthrough-per-function
2411 -Wimplicit-retain-self
2412 -Wimport-preprocessor-directive-pedantic
2413 -Wincompatible-library-redeclaration
2414 -Wincompatible-pointer-types-discards-qualifiers
2415 -Wincomplete-implementation
2417 -Wincomplete-umbrella
2420 -Wint-to-void-pointer-cast
2426 -Winvalid-source-encoding
2427 -Winvalid-token-paste
2428 -Wknr-promoted-parameter
2429 -Wlarge-by-value-copy
2430 -Wliteral-conversion
2432 -Wlocal-type-template-args
2436 -Wmalformed-warning-check
2440 -Wmismatched-parameter-types
2441 -Wmismatched-return-types
2442 -Wmissing-field-initializers
2443 -Wmissing-format-attribute
2445 -Wmissing-selector-name
2447 -Wmissing-variable-declarations
2451 -Wnon-literal-null-conversion
2453 -Wnonportable-cfstrings
2459 -Wout-of-line-declaration
2461 -Woverlength-strings
2463 -Woverriding-method-mismatch
2464 -Wpointer-type-mismatch
2465 -Wpredefined-identifier-outside-function
2466 -Wprotocol-property-synthesis-ambiguity
2467 -Wreadonly-iboutlet-property
2468 -Wreadonly-setter-attrs
2470 -Wreceiver-forward-class
2472 -Wreinterpret-base-class
2473 -Wrequires-super-attribute
2474 -Wreserved-user-defined-literal
2475 -Wreturn-stack-address
2477 -Wselector-type-mismatch
2479 -Wserialized-diagnostics
2481 -Wshift-count-negative
2482 -Wshift-count-overflow
2483 -Wshift-negative-value
2485 -Wshift-sign-overflow
2487 -Wsizeof-array-argument
2488 -Wsource-uses-openmp
2491 -Wstatic-local-in-inline
2495 -Wstrlcpy-strlcat-size
2497 -Wsuggest-attribute=format
2498 -Wsuggest-attribute=noreturn
2499 -Wsuper-class-method-mismatch
2502 -Wtautological-constant-out-of-range-compare
2503 -Wtentative-definition-incomplete-type
2506 -Wtypedef-redefinition
2509 -Wundefined-internal
2510 -Wundefined-reinterpret-cast
2512 -Wunicode-whitespace
2513 -Wunknown-warning-option
2514 -Wunnamed-type-template-args
2515 -Wunneeded-member-function
2517 -Wunsupported-visibility
2518 -Wunused-but-set-parameter
2519 -Wunused-but-set-variable
2520 -Wunused-command-line-argument
2521 -Wunused-const-variable=2
2522 -Wunused-exception-parameter
2523 -Wunused-local-typedefs
2524 -Wunused-member-function
2525 -Wunused-sanitize-argument
2526 -Wunused-volatile-lvalue
2527 -Wuser-defined-literals
2530 -Wvector-conversions
2535 ], [ TOR_TRY_COMPILE_WITH_CFLAGS(warning_flag, [],
2536 [TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS warning_flag" CFLAGS="$CFLAGS warning_flag"], true)
2539 AX_CHECK_COMPILE_FLAG([-Wextra-semi], [CFLAGS="$CFLAGS -Wextra-semi"], [], [-Werror])
2541 dnl We should re-enable this in some later version. Clang doesn't
2542 dnl mind, but it causes trouble with GCC.
2543 dnl -Wstrict-overflow=2
2545 dnl These seem to require annotations that we don't currently use,
2546 dnl and they give false positives in our pthreads wrappers. (Clang 4)
2548 dnl -Wthread-safety-analysis
2549 dnl -Wthread-safety-attributes
2550 dnl -Wthread-safety-beta
2551 dnl -Wthread-safety-precise
2553 W_FLAGS="$W_FLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
2554 W_FLAGS="$W_FLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
2555 W_FLAGS="$W_FLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
2556 W_FLAGS="$W_FLAGS -Wwrite-strings"
2557 W_FLAGS="$W_FLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
2558 W_FLAGS="$W_FLAGS -Waggregate-return -Wpacked -Wunused"
2559 W_FLAGS="$W_FLAGS -Wunused-parameter "
2560 # These interfere with building main() { return 0; }, which autoconf
2561 # likes to use as its default program.
2562 W_FLAGS="$W_FLAGS -Wold-style-definition -Wmissing-declarations"
2564 TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS $W_FLAGS"
2565 CFLAGS="$CFLAGS $W_FLAGS"
2567 if test "$tor_cv_cflags__Wnull_dereference" = "yes"; then
2568 AC_DEFINE([HAVE_CFLAG_WNULL_DEREFERENCE], 1, [True if we have -Wnull-dereference])
2570 if test "$tor_cv_cflags__Woverlength_strings" = "yes"; then
2571 AC_DEFINE([HAVE_CFLAG_WOVERLENGTH_STRINGS], 1, [True if we have -Woverlength-strings])
2573 if test "$tor_cv_cflags__warn_unused_const_variable_2" = "yes"; then
2574 AC_DEFINE([HAVE_CFLAG_WUNUSED_CONST_VARIABLE], 1, [True if we have -Wunused-const-variable])
2577 CFLAGS="$CFLAGS_NOWARNINGS"
2579 if test "x$enable_fatal_warnings" = "xyes"; then
2580 # I'd like to use TOR_CHECK_CFLAGS here, but I can't, since the
2581 # default autoconf programs are full of errors.
2582 CFLAGS="$CFLAGS -Werror"
2587 AC_SUBST(TOR_WARNING_FLAGS)
2589 echo "$TOR_WARNING_FLAGS">warning_flags
2591 TOR_TRY_COMPILE_WITH_CFLAGS([@warning_flags], [],
2592 CFLAGS="$CFLAGS @warning_flags",
2593 CFLAGS="$CFLAGS $TOR_WARNING_FLAGS")
2595 if test "$enable_coverage" = "yes" && test "$have_clang" = "no"; then
2599 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.])
2603 # These HashX parameter definitions are needed in CPPFLAGS when compiling
2604 # the equix and hashx ext modules, but elsewhere in tor we can use orconfig.h
2606 m4_define([equix_hashx_size], [8])
2607 [HASHX_SIZE=]equix_hashx_size
2608 AC_SUBST([HASHX_SIZE])
2609 AC_DEFINE([HASHX_SIZE], equix_hashx_size,
2610 [Output size in bytes for the internal customization of HashX])
2611 AC_DEFINE([HASHX_STATIC], [1], [We statically link with HashX])
2612 AC_DEFINE([EQUIX_STATIC], [1], [We statically link with EquiX])
2614 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
2619 contrib/operator-tools/tor.logrotate
2620 src/config/torrc.sample
2621 src/config/torrc.minimal
2622 scripts/maint/checkOptionDocs.pl
2626 if test "x$asciidoc" = "xtrue" && test "$ASCIIDOC" = "none"; then
2627 regular_mans="doc/man/tor doc/man/tor-gencert doc/man/tor-resolve doc/man/torify"
2628 for file in $regular_mans ; do
2629 if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
2630 echo "==================================";
2632 echo "Building Tor has failed since manpages cannot be built.";
2634 echo "You need asciidoc installed to be able to build the manpages.";
2635 echo "To build without manpages, use the --disable-asciidoc argument";
2636 echo "when calling configure.";
2638 echo "==================================";
2644 if test "$fragile_hardening" = "yes"; then
2649 Warning! Building Tor with --enable-fragile-hardening (also known as
2650 --enable-expensive-hardening) makes some kinds of attacks harder, but makes
2651 other kinds of attacks easier. A Tor instance build with this option will be
2652 somewhat less vulnerable to remote code execution, arithmetic overflow, or
2653 out-of-bounds read/writes... but at the cost of becoming more vulnerable to
2654 denial of service attacks. For more information, see
2655 https://gitlab.torproject.org/tpo/core/team/-/wikis/TorFragileHardening
2662 if test "$openssl_ver_mismatch" = "yes"; then
2666 Warning! The version OpenSSL headers we get from compiling with
2667 "${TOR_CPPFLAGS_OPENSSL:-(no extra options)}"
2668 do not match version of the OpenSSL library we get when linking with
2669 "$TOR_LDFLAGS_OPENSSL $TOR_OPENSSL_LIBS".
2670 This might cause compilation to fail. Try using --with-openssl-dir to specify
2671 the exact OpenSSL path you want.
2677 # Mini-report on what will be built.
2681 PPRINT_SET_INDENT(1)
2685 AS_ECHO("Tor Version: ${PPRINT_COLOR_BLDBLU}Tor $PACKAGE_VERSION $PPRINT_COLOR_RST")
2688 PPRINT_SUBTITLE([Build Features])
2690 PPRINT_PROP_STRING([Compiler], [$CC])
2691 PPRINT_PROP_STRING([Host OS], [$host_os])
2692 PPRINT_PROP_STRING([License Option], [$license_option])
2695 test "x$enable_fatal_warnings" = "xyes" && value=1 || value=0
2696 PPRINT_PROP_BOOL([Warnings are fatal (--enable-fatal-warnings)], $value)
2698 test "x$enable_android" = "xyes" && value=1 || value=0
2699 PPRINT_PROP_BOOL([Android support (--enable-android)], $value)
2702 PPRINT_SUBTITLE([Static Build])
2704 test "x$enable_static_tor" = "xyes" && value=1 || value=0
2705 PPRINT_PROP_BOOL([tor (--enable-static-tor)], $value)
2707 if test "x$enable_static_libevent" = "xyes"; then
2708 PPRINT_PROP_STRING([libevent], [$TOR_LIBDIR_libevent])
2710 PPRINT_PROP_BOOL([libevent (--enable-static-libevent)], $value)
2713 if test "x$enable_static_openssl" = "xyes"; then
2714 PPRINT_PROP_STRING([libssl], [$TOR_LIBDIR_openssl])
2716 PPRINT_PROP_BOOL([libssl (--enable-static-openssl)], $value)
2719 if test "x$enable_static_zlib" = "xyes"; then
2720 PPRINT_PROP_STRING([zlib1g], [$TOR_LIBDIR_zlib])
2722 PPRINT_PROP_BOOL([zlib1g (--enable-static-zlib)], $value)
2726 PPRINT_SUBTITLE([Optional Libraries])
2728 test "x$enable_nss" = "xyes" && value=1 || value=0
2729 PPRINT_PROP_BOOL([libnss (--enable-nss)], $value)
2731 test "x$enable_seccomp" != "xno" && value=1 || value=0
2732 PPRINT_PROP_BOOL([libseccomp (--disable-seccomp)], $value)
2734 test "x$enable_libscrypt" != "xno" && value=1 || value=0
2735 PPRINT_PROP_BOOL([libscrypt (--disable-libscrypt)], $value)
2737 test "x$enable_systemd" = "xyes" && value=1 || value=0
2738 PPRINT_PROP_BOOL([Systemd support (--enable-systemd)], $value)
2740 test "x$have_lzma" = "xyes" && value=1 || value=0
2741 PPRINT_PROP_BOOL([liblzma (--enable-lzma)], $value)
2743 test "x$have_zstd" = "xyes" && value=1 || value=0
2744 PPRINT_PROP_BOOL([libzstd (--enable-zstd)], $value)
2747 PPRINT_SUBTITLE([Hardening])
2749 test "x$enable_gcc_hardening" != "xno" && value=1 || value=0
2750 PPRINT_PROP_BOOL([Compiler Hardening (--disable-gcc-hardening)], $value)
2752 test "x$enable_linker_hardening" != "xno" && value=1 || value=0
2753 PPRINT_PROP_BOOL([Linker Hardening (--disable-linker-hardening)], $value)
2755 test "x$fragile_hardening" = "xyes" && value=1 || value=0
2756 PPRINT_PROP_BOOL([Fragile Hardening (--enable-fragile-hardening, dev only)], $value)
2759 PPRINT_SUBTITLE([Modules])
2761 # Modules have documentation hints indicating how they can be enabled
2762 # or disabled, and those hints can select which version of our message
2763 # to show based on variables at configure-time.
2765 # Each "module_option_hints(<name>)" macro, if it exists, must
2766 # visit exactly one HINT_* macro using shell conditionals.
2768 m4_foreach_w([mname], MODULES,
2770 AM_COND_IF(m4_join([], [BUILD_MODULE_], m4_toupper([]mname[])), value=1, value=0)
2771 m4_pushdef([HINT_OPT], [PPRINT_PROP_BOOL](mname ($1), [[$value]]))
2772 m4_pushdef([HINT_NONE], [PPRINT_PROP_BOOL](mname, [[$value]]))
2773 m4_ifdef([module_option_hints](mname),
2774 [m4_indir([module_option_hints](mname))],
2776 m4_popdef([HINT_OPT], [HINT_NONE])
2781 PPRINT_SUBTITLE([Documentation])
2783 test "x$enable_asciidoc" != "xno" && value=1 || value=0
2784 PPRINT_PROP_BOOL([AsciiDoc (--disable-asciidoc)], $value)
2786 test "x$enable_manpage" != "xno" && value=1 || value=0
2787 PPRINT_PROP_BOOL([Man Pages (--disable-manpage)], $value)
2789 test "x$enable_html_manual" != "xno" && value=1 || value=0
2790 PPRINT_PROP_BOOL([HTML Manual (--disable-html-manual)], $value)
2793 PPRINT_SUBTITLE([Tests])
2795 test "x$enable_unittests" != "xno" && value=1 || value=0
2796 PPRINT_PROP_BOOL([Unit tests (--disable-unittests)], $value)
2798 test "x$enable_asserts_in_tests" = "xno" && value=1 || value=0
2799 PPRINT_PROP_BOOL([assert()s enabled (--enable-asserts-in-tests, dev only)], $value)
2801 test "x$enable_coverage" = "xyes" && value=1 || value=0
2802 PPRINT_PROP_BOOL([Code Coverage (--enable-coverage)], $value)
2804 test "x$enable_libfuzzer" = "xyes" && value=1 || value=0
2805 PPRINT_PROP_BOOL([libFuzzer support (--enable-libfuzzer)], $value)
2807 test "x$enable_oss_fuzz" = "xyes" && value=1 || value=0
2808 PPRINT_PROP_BOOL([OSS-Fuzz support (--enable-oss-fuzz)], $value)
2811 PPRINT_SUBTITLE([Tracing (--enable-tracing-instrumentation-<type>)])
2813 test "x$enable_tracing_instrumentation_log_debug" = "xyes" && value=1 || value=0
2814 PPRINT_PROP_BOOL([Tracepoints to log_debug() (log-debug)], $value)
2816 test "x$enable_tracing_instrumentation_usdt" = "xyes" && value=1 || value=0
2817 PPRINT_PROP_BOOL([USDT Instrumentation (usdt)], $value)
2819 test "x$enable_tracing_instrumentation_lttng" = "xyes" && value=1 || value=0
2820 PPRINT_PROP_BOOL([LTTng Instrumentation (lttng)], $value)
2823 PPRINT_SUBTITLE([Install Directories])
2825 report_mandir="`eval eval echo $mandir`"
2826 PPRINT_PROP_STRING([Binaries], [$BINDIR])
2827 PPRINT_PROP_STRING([Configuration], [$CONFDIR])
2828 PPRINT_PROP_STRING([Man Pages], [$report_mandir])
2831 AS_ECHO(["Configure Line: ./configure $configure_flags"])
2833 if test "$tor_ac_n_warnings" != "0"; then
2836 Encountered $tor_ac_n_warnings warning(s). See messages above for more info.