Update geoip files to match ipfire location db, 2022/04/27.
[tor.git] / configure.ac
blob5fd03df5adf6a43124e01608891403e37a91c6fd
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
6 AC_PREREQ([2.63])
7 AC_INIT([tor],[0.4.7.6-rc-dev])
8 AC_CONFIG_SRCDIR([src/app/main/tor_main.c])
9 AC_CONFIG_MACRO_DIR([m4])
11 configure_flags="$*"
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, ["2022-04-07"], # for 0.4.7.6-rc-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])
29 tor_ac_n_warnings=0
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
38 AC_CANONICAL_HOST
40 PKG_PROG_PKG_CONFIG
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.])
45 else
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])
54 AC_ARG_ENABLE(openbsd-malloc,
55    AS_HELP_STRING(--enable-openbsd-malloc, [use malloc code from OpenBSD.  Linux only. Deprecated: see --with-malloc]))
56 AC_ARG_ENABLE(static-openssl,
57    AS_HELP_STRING(--enable-static-openssl, [link against a static openssl library. Requires --with-openssl-dir]))
58 AC_ARG_ENABLE(static-libevent,
59    AS_HELP_STRING(--enable-static-libevent, [link against a static libevent library. Requires --with-libevent-dir]))
60 AC_ARG_ENABLE(static-zlib,
61    AS_HELP_STRING(--enable-static-zlib, [link against a static zlib library. Requires --with-zlib-dir]))
62 AC_ARG_ENABLE(static-tor,
63    AS_HELP_STRING(--enable-static-tor, [create an entirely static Tor binary. Requires --with-openssl-dir and --with-libevent-dir and --with-zlib-dir]))
64 AC_ARG_ENABLE(unittests,
65    AS_HELP_STRING(--disable-unittests, [don't build unit tests for Tor. Risky!]))
66 AC_ARG_ENABLE(coverage,
67    AS_HELP_STRING(--enable-coverage, [enable coverage support in the unit-test build]))
68 AC_ARG_ENABLE(asserts-in-tests,
69    AS_HELP_STRING(--disable-asserts-in-tests, [disable tor_assert() calls in the unit tests, for branch coverage]))
70 AC_ARG_ENABLE(system-torrc,
71    AS_HELP_STRING(--disable-system-torrc, [don't look for a system-wide torrc file]))
72 AC_ARG_ENABLE(libfuzzer,
73    AS_HELP_STRING(--enable-libfuzzer, [build extra fuzzers based on 'libfuzzer']))
74 AC_ARG_ENABLE(oss-fuzz,
75    AS_HELP_STRING(--enable-oss-fuzz, [build extra fuzzers based on 'oss-fuzz' environment]))
76 AC_ARG_ENABLE(memory-sentinels,
77    AS_HELP_STRING(--disable-memory-sentinels, [disable code that tries to prevent some kinds of memory access bugs. For fuzzing only.]))
78 AC_ARG_ENABLE(restart-debugging,
79    AS_HELP_STRING(--enable-restart-debugging, [Build Tor with support for debugging in-process restart. Developers only.]))
80 AC_ARG_ENABLE(zstd-advanced-apis,
81    AS_HELP_STRING(--disable-zstd-advanced-apis, [Build without support for zstd's "static-only" APIs.]))
82 AC_ARG_ENABLE(nss,
83    AS_HELP_STRING(--enable-nss, [Use Mozilla's NSS TLS library. (EXPERIMENTAL)]))
84 AC_ARG_ENABLE(pic,
85    AS_HELP_STRING(--enable-pic, [Build Tor's binaries as position-independent code, suitable to link as a library.]))
87 AC_ARG_ENABLE(missing-doc-warnings,
88    AS_HELP_STRING(--enable-missing-doc-warnings, [Tell doxygen to warn about missing documentation. Makes doxygen warnings nonfatal.]))
90 if test "$enable_missing_doc_warnings" = "yes"; then
91    DOXYGEN_FATAL_WARNINGS=NO
92    DOXYGEN_WARN_ON_MISSING=YES
93 elif test "$enable_fatal_warnings" = "yes"; then
94    # Fatal warnings from doxygen are nice, but not if we're warning about
95    # missing documentation.
96    DOXYGEN_FATAL_WARNINGS=YES
97    DOXYGEN_WARN_ON_MISSING=NO
98 else
99    DOXYGEN_FATAL_WARNINGS=NO
100    DOXYGEN_WARN_ON_MISSING=NO
102 AC_SUBST(DOXYGEN_FATAL_WARNINGS)
103 AC_SUBST(DOXYGEN_WARN_ON_MISSING)
105 if test "x$enable_coverage" != "xyes" -a "x$enable_asserts_in_tests" = "xno" ; then
106     AC_MSG_ERROR([Can't disable assertions outside of coverage build])
109 AM_CONDITIONAL(UNITTESTS_ENABLED, test "x$enable_unittests" != "xno")
110 AM_CONDITIONAL(COVERAGE_ENABLED, test "x$enable_coverage" = "xyes")
111 AM_CONDITIONAL(DISABLE_ASSERTS_IN_UNIT_TESTS, test "x$enable_asserts_in_tests" = "xno")
112 AM_CONDITIONAL(LIBFUZZER_ENABLED, test "x$enable_libfuzzer" = "xyes")
113 AM_CONDITIONAL(OSS_FUZZ_ENABLED, test "x$enable_oss_fuzz" = "xyes")
114 AM_CONDITIONAL(USE_NSS, test "x$enable_nss" = "xyes")
115 AM_CONDITIONAL(USE_OPENSSL, test "x$enable_nss" != "xyes")
117 if test "x$enable_coverage" = "xyes"; then
118   AC_DEFINE(ENABLE_COVERAGE, 1,
119             [Defined if coverage support is enabled for the unit tests])
122 if test "x$enable_nss" = "xyes"; then
123   AC_DEFINE(ENABLE_NSS, 1,
124             [Defined if we're building with NSS.])
125 else
126   AC_DEFINE(ENABLE_OPENSSL, 1,
127             [Defined if we're building with OpenSSL or LibreSSL])
130 if test "$enable_static_tor" = "yes"; then
131   enable_static_libevent="yes";
132   enable_static_openssl="yes";
133   enable_static_zlib="yes";
134   TOR_STATIC_LDFLAGS="-static"
136 AC_SUBST(TOR_STATIC_LDFLAGS)
138 if test "$enable_system_torrc" = "no"; then
139   AC_DEFINE(DISABLE_SYSTEM_TORRC, 1,
140             [Defined if we're not going to look for a torrc in SYSCONF])
143 if test "$enable_memory_sentinels" = "no"; then
144   AC_DEFINE(DISABLE_MEMORY_SENTINELS, 1,
145            [Defined if we're turning off memory safety code to look for bugs])
148 AC_ARG_ENABLE(manpage,
149               AS_HELP_STRING(--disable-manpage, [Disable manpage generation.]))
151 AC_ARG_ENABLE(html-manual,
152               AS_HELP_STRING(--disable-html-manual, [Disable HTML documentation.]))
154 AC_ARG_ENABLE(asciidoc,
155      AS_HELP_STRING(--disable-asciidoc, [don't use asciidoc (disables building of manpages)]),
156      [case "${enableval}" in
157         "yes") asciidoc=true ;;
158         "no")  asciidoc=false ;;
159         *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
160       esac], [asciidoc=true])
162 # systemd notify support
163 AC_ARG_ENABLE(systemd,
164       AS_HELP_STRING(--enable-systemd, [enable systemd notification support]),
165       [case "${enableval}" in
166         "yes") systemd=true ;;
167         "no")  systemd=false ;;
168         * ) AC_MSG_ERROR(bad value for --enable-systemd) ;;
169       esac], [systemd=auto])
171 if test "$enable_restart_debugging" = "yes"; then
172   AC_DEFINE(ENABLE_RESTART_DEBUGGING, 1,
173             [Defined if we're building with support for in-process restart debugging.])
176 if test "$enable_zstd_advanced_apis" != "no"; then
177    AC_DEFINE(ENABLE_ZSTD_ADVANCED_APIS, 1,
178              [Defined if we're going to try to use zstd's "static-only" APIs.])
181 # systemd support
182 if test "x$enable_systemd" = "xno"; then
183     have_systemd=no;
184 else
185     PKG_CHECK_MODULES(SYSTEMD,
186         [libsystemd-daemon],
187         have_systemd=yes,
188         have_systemd=no)
189     if test "x$have_systemd" = "xno"; then
190         AC_MSG_NOTICE([Okay, checking for systemd a different way...])
191         PKG_CHECK_MODULES(SYSTEMD,
192             [libsystemd],
193             have_systemd=yes,
194             have_systemd=no)
195     fi
198 if test "x$have_systemd" = "xyes"; then
199     AC_DEFINE(HAVE_SYSTEMD,1,[Have systemd])
200     TOR_SYSTEMD_CFLAGS="${SYSTEMD_CFLAGS}"
201     TOR_SYSTEMD_LIBS="${SYSTEMD_LIBS}"
202     PKG_CHECK_MODULES(LIBSYSTEMD209, [libsystemd >= 209],
203          [AC_DEFINE(HAVE_SYSTEMD_209,1,[Have systemd v209 or greater])], [])
205 AC_SUBST(TOR_SYSTEMD_CFLAGS)
206 AC_SUBST(TOR_SYSTEMD_LIBS)
208 if test "x$enable_systemd" = "xyes" -a "x$have_systemd" != "xyes" ; then
209     AC_MSG_ERROR([Explicitly requested systemd support, but systemd not found, $pkg_config_user_action, or set SYSTEMD_CFLAGS and SYSTEMD_LIBS.])
212 case "$host" in
213    *-*-solaris* )
214      AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
215      ;;
216 esac
218 AC_ARG_ENABLE(gcc-warnings,
219      AS_HELP_STRING(--enable-gcc-warnings, [deprecated alias for enable-fatal-warnings]))
220 AC_ARG_ENABLE(fatal-warnings,
221      AS_HELP_STRING(--enable-fatal-warnings, [tell the compiler to treat all warnings as errors.]))
222 AC_ARG_ENABLE(gcc-warnings-advisory,
223      AS_HELP_STRING(--disable-gcc-warnings-advisory, [disable the regular verbose warnings]))
225 dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
226 AC_ARG_ENABLE(gcc-hardening,
227     AS_HELP_STRING(--disable-gcc-hardening, [disable compiler security checks]))
229 dnl Deprecated --enable-expensive-hardening but keep it for now for backward compat.
230 AC_ARG_ENABLE(expensive-hardening,
231     AS_HELP_STRING(--enable-expensive-hardening, [enable more fragile and expensive compiler hardening; makes Tor slower]))
232 AC_ARG_ENABLE(fragile-hardening,
233     AS_HELP_STRING(--enable-fragile-hardening, [enable more fragile and expensive compiler hardening; makes Tor slower]))
234 if test "x$enable_expensive_hardening" = "xyes" || test "x$enable_fragile_hardening" = "xyes"; then
235   fragile_hardening="yes"
236   AC_DEFINE(ENABLE_FRAGILE_HARDENING, 1, [Defined if we're building with additional, fragile and expensive compiler hardening])
237   AC_DEFINE(DEBUG_SMARTLIST, 1, [Enable smartlist debugging])
240 AC_ARG_ENABLE(all-bugs-are-fatal,
241    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]))
243 if test "x$enable_all_bugs_are_fatal" = "xyes"; then
244   AC_DEFINE(ALL_BUGS_ARE_FATAL, 1, [All assert failures are fatal])
247 dnl Linker hardening options
248 dnl Currently these options are ELF specific - you can't use this with MacOSX
249 AC_ARG_ENABLE(linker-hardening,
250     AS_HELP_STRING(--disable-linker-hardening, [disable linker security fixups]))
252 AC_ARG_ENABLE(local-appdata,
253    AS_HELP_STRING(--enable-local-appdata, [default to host local application data paths on Windows]))
254 if test "$enable_local_appdata" = "yes"; then
255   AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
256             [Defined if we default to host local appdata paths on Windows])
259 AC_ARG_ENABLE(tool-name-check,
260      AS_HELP_STRING(--disable-tool-name-check, [check for sanely named toolchain when cross-compiling]))
262 AC_ARG_ENABLE(seccomp,
263      AS_HELP_STRING(--disable-seccomp, [do not attempt to use libseccomp]))
265 AC_ARG_ENABLE(libscrypt,
266      AS_HELP_STRING(--disable-libscrypt, [do not attempt to use libscrypt]))
268 dnl --- Tracing Options. ---
270 TOR_TRACE_LIBS=
272 dnl LTTng instrumentation option.
273 AC_ARG_ENABLE(tracing-instrumentation-lttng,
274               AS_HELP_STRING([--enable-tracing-instrumentation-lttng],
275                              [build with LTTng-UST instrumentation]))
276 AM_CONDITIONAL([USE_TRACING_INSTRUMENTATION_LTTNG],
277                [test "x$enable_tracing_instrumentation_lttng" = "xyes"])
279 if test "x$enable_tracing_instrumentation_lttng" = "xyes"; then
280   AC_CHECK_HEADERS([lttng/tracepoint.h], [],
281                    [AC_MSG_ERROR([LTTng instrumentation headers not found.
282                                   On Debian, apt install liblttng-ust-dev"])], [])
283   AC_DEFINE([USE_TRACING_INSTRUMENTATION_LTTNG], [1], [Using LTTng instrumentation])
284   TOR_TRACE_LIBS="-llttng-ust -ldl"
285   have_tracing=1
288 dnl USDT instrumentation option.
289 AC_ARG_ENABLE(tracing-instrumentation-usdt,
290               AS_HELP_STRING([--enable-tracing-instrumentation-usdt],
291                              [build with tracing USDT instrumentation]))
292 AM_CONDITIONAL([USE_TRACING_INSTRUMENTATION_USDT],
293                [test "x$enable_tracing_instrumentation_usdt" = "xyes"])
295 if test "x$enable_tracing_instrumentation_usdt" = "xyes"; then
296   AC_CHECK_HEADERS([sys/sdt.h], [],
297                    [AC_MSG_ERROR([USDT instrumentation requires sys/sdt.h header.
298                                   On Debian, apt install systemtap-sdt-dev])], [])
299   AC_MSG_CHECKING([STAP_PROBEV()])
300   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
301     #define SDT_USE_VARIADIC
302     #include <sys/sdt.h>
303     void test(void)
304     {
305       STAP_PROBEV(p, n, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
306     }
307   ]])], [
308     AC_MSG_RESULT([yes])
309     dnl LTTng generates USDT probes if the UST library was built with
310     dnl --with-sdt. There is unfortunately no way to check that so we always
311     dnl build the USDT probes even though LTTng instrumentation was requested.
312     AC_DEFINE([USE_TRACING_INSTRUMENTATION_USDT], [1], [Using USDT instrumentation])
313     have_tracing=1
314   ], [
315     AC_MSG_RESULT([no])
316     AC_MSG_ERROR([USDT tracing support requires STAP_PROBEV()])
317   ])
320 dnl Tracepoints event to debug logs.
321 AC_ARG_ENABLE(tracing-instrumentation-log-debug,
322      AS_HELP_STRING([--enable-tracing-instrumentation-log-debug],
323                     [build with tracing event to debug log]),
324      AC_DEFINE([USE_TRACING_INSTRUMENTATION_LOG_DEBUG], [1],
325                [Tracepoints to log debug]), [])
326 AM_CONDITIONAL([USE_TRACING_INSTRUMENTATION_LOG_DEBUG],
327                [test "x$enable_tracing_instrumentation_log_debug" = "xyes"])
328 if test "x$enable_tracing_instrumentation_log_debug" = "xyes"; then
329   have_tracing=1
332 dnl Define that tracing is supported if any instrumentation is used.
333 AM_COND_IF([USE_TRACING_INSTRUMENTATION_LOG_DEBUG],
334            AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
335 AM_COND_IF([USE_TRACING_INSTRUMENTATION_USDT],
336            AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
337 AM_COND_IF([USE_TRACING_INSTRUMENTATION_LTTNG],
338            AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
339 AM_CONDITIONAL([USE_TRACING], [test "x$have_tracing" = x1 ])
341 dnl Finally, define the trace libs.
342 AC_SUBST([TOR_TRACE_LIBS])
344 dnl -- End Tracing Options. --
346 dnl Enable Android only features.
347 AC_ARG_ENABLE(android,
348      AS_HELP_STRING(--enable-android, [build with Android features enabled]))
349 AM_CONDITIONAL([USE_ANDROID], [test "x$enable_android" = "xyes"])
351 if test "x$enable_android" = "xyes"; then
352   AC_DEFINE([USE_ANDROID], [1], [Compile with Android specific features enabled])
356 dnl ---
357 dnl Tor modules options. These options are namespaced with --disable-module-XXX
358 dnl ---
360 dnl All our modules.
361 m4_define(MODULES, relay dirauth dircache)
363 # Some modules are only disabled through another option. For those, we don't
364 # want to print the help in the summary at the end of the configure. Any entry
365 # in the following set will not print the "--disable-module-NAME" command in
366 # the summary.
367 m4_set_add_all([MODULES_WITH_NO_OPTIONS], [dircache])
369 dnl Relay module.
370 AC_ARG_ENABLE([module-relay],
371               AS_HELP_STRING([--disable-module-relay],
372                              [Build tor without the Relay modules: tor can not run as a relay, bridge, or authority. Implies --disable-module-dirauth]))
373 AM_CONDITIONAL(BUILD_MODULE_RELAY, [test "x$enable_module_relay" != "xno"])
374 AM_COND_IF(BUILD_MODULE_RELAY,
375            AC_DEFINE([HAVE_MODULE_RELAY], [1],
376                      [Compile with Relay feature support]))
378 dnl Dircache module.  (This cannot be enabled or disabled independently of
379 dnl the relay module.  It is not listed by --list-modules for this reason.)
380 AM_CONDITIONAL(BUILD_MODULE_DIRCACHE,
381                [test "x$enable_module_relay" != "xno"])
382 AM_COND_IF(BUILD_MODULE_DIRCACHE,
383            AC_DEFINE([HAVE_MODULE_DIRCACHE], [1],
384                      [Compile with directory cache support]))
386 dnl Directory Authority module.
387 AC_ARG_ENABLE([module-dirauth],
388               AS_HELP_STRING([--disable-module-dirauth],
389                              [Build tor without the Directory Authority module: tor can not run as a directory authority or bridge authority]))
390 AM_CONDITIONAL(BUILD_MODULE_DIRAUTH,[test "x$enable_module_dirauth" != "xno" && test "x$enable_module_relay" != "xno"])
391 AM_COND_IF(BUILD_MODULE_DIRAUTH,
392            AC_DEFINE([HAVE_MODULE_DIRAUTH], [1],
393                      [Compile with Directory Authority feature support]))
395 dnl Helper variables.
396 TOR_MODULES_ALL_ENABLED=
397 AC_DEFUN([ADD_MODULE], [
398     MODULE=m4_toupper($1)
399     TOR_MODULES_ALL_ENABLED="${TOR_MODULES_ALL_ENABLED} -DHAVE_MODULE_${MODULE}=1"
401 m4_foreach_w([module], MODULES, [ADD_MODULE([module])])
402 AC_SUBST(TOR_MODULES_ALL_ENABLED)
404 dnl check for the correct "ar" when cross-compiling.
405 dnl   (AM_PROG_AR was new in automake 1.11.2, which we do not yet require,
406 dnl    so kludge up a replacement for the case where it isn't there yet.)
407 m4_ifdef([AM_PROG_AR],
408          [AM_PROG_AR],
409          [AN_MAKEVAR([AR], [AC_PROG_AR])
410           AN_PROGRAM([ar], [AC_PROG_AR])
411           AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [:])])
412           AC_PROG_AR])
414 dnl Check whether the above macro has settled for a simply named tool even
415 dnl though we're cross compiling. We must do this before running AC_PROG_CC,
416 dnl because that will find any cc on the system, not only the cross-compiler,
417 dnl and then verify that a binary built with this compiler runs on the
418 dnl build system. It will then come to the false conclusion that we're not
419 dnl cross-compiling.
420 if test "x$enable_tool_name_check" != "xno"; then
421     if test "x$ac_tool_warned" = "xyes"; then
422         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.)])
423         elif test "x$ac_ct_AR" != "x" -a "x$cross_compiling" = "xmaybe"; then
424                 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.)])
425         fi
428 AC_PROG_CC
429 AC_PROG_CPP
430 AC_PROG_MAKE_SET
431 AC_PROG_RANLIB
432 AC_PROG_SED
434 AX_COMPILER_VERSION
435 AX_COMPILER_VENDOR
437 AC_DEFINE_UNQUOTED([COMPILER_VERSION],["$ax_cv_c_compiler_version"], [Compiler version])
438 AC_DEFINE_UNQUOTED([COMPILER_VENDOR],["$ax_cv_c_compiler_vendor"], [Compiler vendor])
440 AS_CASE($ax_cv_c_compiler_vendor,
441         [gnu], AC_DEFINE([COMPILER],["GCC"],[Compiler name]),
442         AC_DEFINE([COMPILER],[],[Compiler name])
445 AC_ARG_VAR([PERL], [path to Perl binary])
446 AC_CHECK_PROGS([PERL], [perl])
447 AM_CONDITIONAL(USE_PERL, [test "x$ac_cv_prog_PERL" != "x"])
449 dnl check for asciidoc and a2x
450 AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
451 AC_PATH_PROGS([A2X], [a2x a2x.py], none)
453 AM_CONDITIONAL(USE_ASCIIDOC, test "x$asciidoc" = "xtrue")
454 AM_CONDITIONAL(BUILD_MANPAGE, [test "x$enable_manpage" != "xno"])
455 AM_CONDITIONAL(BUILD_HTML_DOCS, [test "x$enable_html_manual" != "xno"])
457 AM_PROG_CC_C_O
459 dnl Before autoconf 2.70, AC_PROG_CC_C99 is supposedly necessary for some
460 dnl compilers if you want C99 support. Starting with 2.70, it is obsolete and
461 dnl forbidden.
462 m4_version_prereq([2.70], [:], [AC_PROG_CC_C99])
464 AC_CACHE_CHECK([for Python 3], [tor_cv_PYTHON],
465    [AC_PATH_PROGS_FEATURE_CHECK([PYTHON], [ \
466         python3 \
467         python3.8 python3.7 python3.6 python3.5 python3.4 \
468         python ],
469    [["$ac_path_PYTHON" -c 'import sys; sys.exit(sys.version_info[0]<3)' && tor_cv_PYTHON="$ac_path_PYTHON" ac_path_PYTHON_found=:]] )])
470 AC_SUBST([PYTHON], [$tor_cv_PYTHON])
472 PYTHON="$tor_cv_PYTHON"
474 if test "x$PYTHON" = "x"; then
475   tor_incr_n_warnings
476   AC_MSG_WARN([Python 3 unavailable; some tests will not be run.])
479 AM_CONDITIONAL(USEPYTHON, [test "x$PYTHON" != "x"])
481 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
482 AC_C_FLEXIBLE_ARRAY_MEMBER
483 ], [
484  dnl Maybe we've got an old autoconf...
485  AC_CACHE_CHECK([for flexible array members],
486      tor_cv_c_flexarray,
487      [AC_COMPILE_IFELSE(
488        AC_LANG_PROGRAM([
489  struct abc { int a; char b[]; };
490 ], [
491  struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
492  def->b[0] = 33;
494   [tor_cv_c_flexarray=yes],
495   [tor_cv_c_flexarray=no])])
496  if test "$tor_cv_flexarray" = "yes"; then
497    AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
498  else
499    AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
500  fi
503 AC_CACHE_CHECK([for working C99 mid-block declaration syntax],
504       tor_cv_c_c99_decl,
505       [AC_COMPILE_IFELSE(
506          [AC_LANG_PROGRAM([], [int x; x = 3; int y; y = 4 + x;])],
507          [tor_cv_c_c99_decl=yes],
508          [tor_cv_c_c99_decl=no] )])
509 if test "$tor_cv_c_c99_decl" != "yes"; then
510   AC_MSG_ERROR([Your compiler doesn't support c99 mid-block declarations. This is required as of Tor 0.2.6.x])
513 AC_CACHE_CHECK([for working C99 designated initializers],
514       tor_cv_c_c99_designated_init,
515       [AC_COMPILE_IFELSE(
516          [AC_LANG_PROGRAM([struct s { int a; int b; };],
517                [[ struct s ss = { .b = 5, .a = 6 }; ]])],
518          [tor_cv_c_c99_designated_init=yes],
519          [tor_cv_c_c99_designated_init=no] )])
521 if test "$tor_cv_c_c99_designated_init" != "yes"; then
522   AC_MSG_ERROR([Your compiler doesn't support c99 designated initializers. This is required as of Tor 0.2.6.x])
525 saved_CFLAGS="$CFLAGS"
526 CFLAGS="$CFLAGS -Werror"
527 AC_CACHE_CHECK([for __attribute__((fallthrough))],
528       tor_cv_c_attr_fallthrough,
529       [AC_COMPILE_IFELSE(
530          [AC_LANG_PROGRAM([extern int x; void fn(void) ;],
531                [[ switch (x) { case 1: fn(); __attribute__((fallthrough));
532                                case 2: fn(); break; } ]])],
533          [tor_cv_c_attr_fallthrough=yes],
534          [tor_cv_c_attr_fallthrough=no] )])
535 CFLAGS="$saved_CFLAGS"
537 if test "$tor_cv_c_attr_fallthrough" = "yes"; then
538   AC_DEFINE(HAVE_ATTR_FALLTHROUGH, [1], [defined if we have the fallthrough attribute.])
541 TORUSER=_tor
542 AC_ARG_WITH(tor-user,
543         AS_HELP_STRING(--with-tor-user=NAME, [specify username for tor daemon]),
544         [
545            TORUSER=$withval
546         ]
548 AC_SUBST(TORUSER)
550 TORGROUP=_tor
551 AC_ARG_WITH(tor-group,
552         AS_HELP_STRING(--with-tor-group=NAME, [specify group name for tor daemon]),
553         [
554            TORGROUP=$withval
555         ]
557 AC_SUBST(TORGROUP)
560 dnl If _WIN32 is defined and non-zero, we are building for win32
561 AC_MSG_CHECKING([for win32])
562 AC_RUN_IFELSE([AC_LANG_SOURCE([
563 int main(int c, char **v) {
564 #ifdef _WIN32
565 #if _WIN32
566   return 0;
567 #else
568   return 1;
569 #endif
570 #else
571   return 2;
572 #endif
573 }])],
574 bwin32=true; AC_MSG_RESULT([yes]),
575 bwin32=false; AC_MSG_RESULT([no]),
576 bwin32=cross; AC_MSG_RESULT([cross])
579 if test "$bwin32" = "cross"; then
580 AC_MSG_CHECKING([for win32 (cross)])
581 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
582 #ifdef _WIN32
583 int main(int c, char **v) {return 0;}
584 #else
585 #error
586 int main(int c, char **v) {return x(y);}
587 #endif
588 ])],
589 bwin32=true; AC_MSG_RESULT([yes]),
590 bwin32=false; AC_MSG_RESULT([no]))
593 AH_BOTTOM([
594 #ifdef _WIN32
595 /* Defined to access windows functions and definitions for >=WinVista */
596 # ifndef WINVER
597 #  define WINVER 0x0600
598 # endif
600 /* Defined to access _other_ windows functions and definitions for >=WinVista */
601 # ifndef _WIN32_WINNT
602 #  define _WIN32_WINNT 0x0600
603 # endif
605 /* Defined to avoid including some windows headers as part of Windows.h */
606 # ifndef WIN32_LEAN_AND_MEAN
607 #  define WIN32_LEAN_AND_MEAN 1
608 # endif
609 #endif
612 AM_CONDITIONAL(WIN32, test "x$bwin32" = "xtrue")
613 AM_CONDITIONAL(BUILD_NT_SERVICES, test "x$bwin32" = "xtrue")
614 AM_CONDITIONAL(BUILD_LIBTORRUNNER, test "x$bwin32" != "xtrue")
616 dnl Enable C99 when compiling with MIPSpro
617 AC_MSG_CHECKING([for MIPSpro compiler])
618 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
619 #if (defined(__sgi) && defined(_COMPILER_VERSION))
620 #error
621   return x(y);
622 #endif
623 ])],
624 bmipspro=false; AC_MSG_RESULT(no),
625 bmipspro=true; AC_MSG_RESULT(yes))
627 if test "$bmipspro" = "true"; then
628   CFLAGS="$CFLAGS -c99"
631 AC_C_BIGENDIAN
633 AC_SEARCH_LIBS(socket, [socket network])
634 AC_SEARCH_LIBS(gethostbyname, [nsl])
635 AC_SEARCH_LIBS(dlopen, [dl])
636 AC_SEARCH_LIBS(inet_aton, [resolv])
637 AC_SEARCH_LIBS(backtrace, [execinfo])
638 saved_LIBS="$LIBS"
639 AC_SEARCH_LIBS([clock_gettime], [rt])
640 if test "$LIBS" != "$saved_LIBS"; then
641    # Looks like we need -lrt for clock_gettime().
642    have_rt=yes
645 if test "$bwin32" = "false"; then
646   AC_SEARCH_LIBS(pthread_create, [pthread])
647   AC_SEARCH_LIBS(pthread_detach, [pthread])
650 AM_CONDITIONAL(THREADS_WIN32, test "$bwin32" = "true")
651 AM_CONDITIONAL(THREADS_PTHREADS, test "$bwin32" = "false")
653 AC_CHECK_FUNCS(
654         _NSGetEnviron \
655         RtlSecureZeroMemory \
656         SecureZeroMemory \
657         accept4 \
658         backtrace \
659         backtrace_symbols_fd \
660         eventfd \
661         explicit_bzero \
662         timingsafe_memcmp \
663         flock \
664         fsync \
665         ftime \
666         get_current_dir_name \
667         getaddrinfo \
668         getdelim \
669         getifaddrs \
670         getline \
671         getrlimit \
672         gettimeofday \
673         gmtime_r \
674         gnu_get_libc_version \
675         inet_aton \
676         ioctl \
677         issetugid \
678         llround \
679         localtime_r \
680         lround \
681         madvise \
682         memmem \
683         memset_s \
684         minherit \
685         mmap \
686         pipe \
687         pipe2 \
688         prctl \
689         readpassphrase \
690         rint \
691         sigaction \
692         snprintf \
693         socketpair \
694         statvfs \
695         strncasecmp \
696         strcasecmp \
697         strlcat \
698         strlcpy \
699         strnlen \
700         strptime \
701         strtok_r \
702         strtoull \
703         sysconf \
704         sysctl \
705         timegm \
706         truncate \
707         uname \
708         usleep \
709         vasprintf \
710         _vscprintf \
711         vsnprintf
714 # Apple messed up when they added some functions: they
715 # forgot to decorate them with appropriate AVAILABLE_MAC_OS_VERSION
716 # checks.
718 # We should only probe for these functions if we are sure that we
719 # are not targeting OS X 10.9 or earlier.
720 AC_MSG_CHECKING([for a pre-Yosemite OS X build target])
721 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
722 #ifdef __APPLE__
723 #  include <AvailabilityMacros.h>
724 #  ifndef MAC_OS_X_VERSION_10_10
725 #    define MAC_OS_X_VERSION_10_10 101000
726 #  endif
727 #  if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
728 #    if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
729 #      error "Running on Mac OS X 10.9 or earlier"
730 #    endif
731 #  endif
732 #endif
733 ]], [[]])],
734    [on_macos_pre_10_10=no ; AC_MSG_RESULT([no])],
735    [on_macos_pre_10_10=yes; AC_MSG_RESULT([yes])])
737 if test "$on_macos_pre_10_10" = "no"; then
738   AC_CHECK_FUNCS(
739         mach_approximate_time \
740   )
743 # We should only probe for these functions if we are sure that we
744 # are not targeting OSX 10.11 or earlier.
745 AC_MSG_CHECKING([for a pre-Sierra OSX build target])
746 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
747 #ifdef __APPLE__
748 #  include <AvailabilityMacros.h>
749 #  ifndef MAC_OS_X_VERSION_10_12
750 #    define MAC_OS_X_VERSION_10_12 101200
751 #  endif
752 #  if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
753 #    if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
754 #      error "Running on Mac OSX 10.11 or earlier"
755 #    endif
756 #  endif
757 #endif
758 ]], [[]])],
759    [on_macos_pre_10_12=no ; AC_MSG_RESULT([no])],
760    [on_macos_pre_10_12=yes; AC_MSG_RESULT([yes])])
762 if test "$on_macos_pre_10_12" = "no"; then
763   AC_CHECK_FUNCS(
764         clock_gettime \
765         getentropy \
766   )
769 if test "$bwin32" != "true"; then
770   AC_CHECK_HEADERS(pthread.h)
771   AC_CHECK_FUNCS(pthread_create)
772   AC_CHECK_FUNCS(pthread_condattr_setclock)
775 if test "$bwin32" = "true"; then
776   AC_CHECK_DECLS([SecureZeroMemory, _getwch], , , [
777 #include <windows.h>
778 #include <conio.h>
779 #include <wchar.h>
780                  ])
783 AM_CONDITIONAL(BUILD_READPASSPHRASE_C,
784   test "x$ac_cv_func_readpassphrase" = "xno" && test "$bwin32" = "false")
786 AC_CHECK_FUNCS(glob)
788 AC_MSG_CHECKING([whether free(NULL) works])
789 AC_RUN_IFELSE([AC_LANG_PROGRAM([
790   #include <stdlib.h>
791 ], [
792 char *p = NULL;
793 free(p);
794 ])],
795 [free_null_ok=true; AC_MSG_RESULT(yes)],
796 [free_null_ok=false; AC_MSG_RESULT(no)],
797 [free_null_ok=cross; AC_MSG_RESULT(cross)])
799 if test "$free_null_ok" = "false"; then
800    AC_MSG_ERROR([Your libc implementation doesn't allow free(NULL), as required by C99.])
803 dnl ------------------------------------------------------
804 dnl Where do you live, libevent?  And how do we call you?
806 if test "$bwin32" = "true"; then
807   TOR_LIB_WS32=-lws2_32
808   TOR_LIB_IPHLPAPI=-liphlpapi
809   TOR_LIB_SHLWAPI=-lshlwapi
810   TOR_LIB_GDI=-lgdi32
811   TOR_LIB_USERENV=-luserenv
812   TOR_LIB_BCRYPT=-lbcrypt
813   TOR_LIB_CRYPT32=-lcrypt32
814 else
815   TOR_LIB_WS32=
816   TOR_LIB_GDI=
817   TOR_LIB_USERENV=
819 AC_SUBST(TOR_LIB_WS32)
820 AC_SUBST(TOR_LIB_GDI)
821 AC_SUBST(TOR_LIB_IPHLPAPI)
822 AC_SUBST(TOR_LIB_BCRYPT)
823 AC_SUBST(TOR_LIB_CRYPT32)
824 AC_SUBST(TOR_LIB_SHLWAPI)
825 AC_SUBST(TOR_LIB_USERENV)
827 tor_libevent_pkg_redhat="libevent"
828 tor_libevent_pkg_debian="libevent-dev"
829 tor_libevent_devpkg_redhat="libevent-devel"
830 tor_libevent_devpkg_debian="libevent-dev"
832 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
833 dnl linking for static builds.
834 STATIC_LIBEVENT_FLAGS=""
835 if test "$enable_static_libevent" = "yes"; then
836     if test "$have_rt" = "yes"; then
837       STATIC_LIBEVENT_FLAGS=" -lrt "
838     fi
841 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_IPHLPAPI $TOR_LIB_BCRYPT $TOR_LIB_WS32], [
842 #ifdef _WIN32
843 #include <winsock2.h>
844 #endif
845 #include <sys/time.h>
846 #include <sys/types.h>
847 #include <event2/event.h>], [
848 #ifdef _WIN32
849 #include <winsock2.h>
850 #endif
851 struct event_base;
852 struct event_base *event_base_new(void);
853 void event_base_free(struct event_base *);],
854     [
855 #ifdef _WIN32
856 {WSADATA d; WSAStartup(0x101,&d); }
857 #endif
858 event_base_free(event_base_new());
859 ], [--with-libevent-dir], [/opt/libevent])
861 dnl Determine the incantation needed to link libevent.
862 save_LIBS="$LIBS"
863 save_LDFLAGS="$LDFLAGS"
864 save_CPPFLAGS="$CPPFLAGS"
866 LIBS="$STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $save_LIBS"
867 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
868 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
870 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
872 if test "$enable_static_libevent" = "yes"; then
873    if test "$tor_cv_library_libevent_dir" = "(system)"; then
874      AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
875    else
876      TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
877    fi
878 else
879      if test "x$ac_cv_header_event2_event_h" = "xyes"; then
880        AC_SEARCH_LIBS(event_new, [event event_core], , AC_MSG_ERROR("libevent2 is installed but linking it failed while searching for event_new"))
881        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"))
883        if test "$ac_cv_search_event_new" != "none required"; then
884          TOR_LIBEVENT_LIBS="$ac_cv_search_event_new"
885        fi
886        if test "$ac_cv_search_evdns_base_new" != "none required"; then
887          TOR_LIBEVENT_LIBS="$ac_cv_search_evdns_base_new $TOR_LIBEVENT_LIBS"
888        fi
889      else
890        AC_MSG_ERROR("libevent2 is required but the headers could not be found")
891      fi
894 dnl Now check for particular libevent functions.
895 AC_CHECK_FUNCS([evutil_secure_rng_set_urandom_device_file \
896                 evutil_secure_rng_add_bytes \
897                 evdns_base_get_nameserver_addr \
901 LIBS="$save_LIBS"
902 LDFLAGS="$save_LDFLAGS"
903 CPPFLAGS="$save_CPPFLAGS"
905 dnl Check that libevent is at least at version 2.0.10, the first stable
906 dnl release of its series
907 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
908 AC_MSG_CHECKING([whether Libevent is new enough])
909 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
910 #include <event2/event.h>
911 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000a00
912 #error
913 int x = y(zz);
914 #else
915 int x = 1;
916 #endif
917 ])], [ AC_MSG_RESULT([yes]) ],
918    [ AC_MSG_RESULT([no])
919      AC_MSG_ERROR([Libevent is not new enough.  We require 2.0.10-stable or later]) ] )
921 LIBS="$save_LIBS"
922 LDFLAGS="$save_LDFLAGS"
923 CPPFLAGS="$save_CPPFLAGS"
925 AC_SUBST(TOR_LIBEVENT_LIBS)
927 dnl ------------------------------------------------------
928 dnl Where do you live, libm?
930 dnl On some platforms (Haiku/BeOS) the math library is
931 dnl part of libroot. In which case don't link against lm
932 TOR_LIB_MATH=""
933 save_LIBS="$LIBS"
934 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
935 if test "$ac_cv_search_pow" != "none required"; then
936     TOR_LIB_MATH="$ac_cv_search_pow"
938 LIBS="$save_LIBS"
939 AC_SUBST(TOR_LIB_MATH)
941 dnl ------------------------------------------------------
942 dnl Hello, NSS.  You're new around here.
943 if test "x$enable_nss" = "xyes"; then
944   PKG_CHECK_MODULES(NSS,
945      [nss],
946      [have_nss=yes],
947      [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.])])
948   AC_SUBST(NSS_CFLAGS)
949   AC_SUBST(NSS_LIBS)
952 dnl ------------------------------------------------------
953 dnl Where do you live, openssl?  And how do we call you?
955 if test "x$enable_nss" != "xyes"; then
957 tor_openssl_pkg_redhat="openssl"
958 tor_openssl_pkg_debian="libssl-dev"
959 tor_openssl_devpkg_redhat="openssl-devel"
960 tor_openssl_devpkg_debian="libssl-dev"
962 ALT_openssl_WITHVAL=""
963 AC_ARG_WITH(ssl-dir,
964   AS_HELP_STRING(--with-ssl-dir=PATH, [obsolete alias for --with-openssl-dir]),
965   [
966       if test "x$withval" != "xno" && test "x$withval" != "x"; then
967          ALT_openssl_WITHVAL="$withval"
968       fi
969   ])
971 AC_MSG_NOTICE([Now, we'll look for OpenSSL >= 1.0.1])
972 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI $TOR_LIB_WS32 $TOR_LIB_CRYPT32],
973     [#include <openssl/ssl.h>
974      char *getenv(const char *);],
975     [struct ssl_cipher_st;
976      unsigned SSL_CIPHER_get_id(const struct ssl_cipher_st *);
977      char *getenv(const char *);],
978     dnl This funny-looking test program calls getenv, so that the compiler
979     dnl will neither make code that call SSL_CIPHER_get_id(NULL) [producing
980     dnl a crash], nor optimize out the call to SSL_CIPHER_get_id().
981     dnl We look for SSL_cipher_get_id() because it is present in
982     dnl OpenSSL >=1.0.1, because it is not deprecated, and because Tor
983     dnl depends on it.
984     [if (getenv("THIS_SHOULDNT_BE_SET_X201803")) SSL_CIPHER_get_id((void *)0);], [],
985     [/usr/local/opt/openssl /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /opt/openssl])
987 if test "$enable_static_openssl" = "yes"; then
988    if test "$tor_cv_library_openssl_dir" = "(system)"; then
989      AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
990    else
991      TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a $TOR_LIB_WS32 $TOR_LIB_CRYPT32 $TOR_LIB_BCRYPT"
992    fi
993 else
994      TOR_OPENSSL_LIBS="-lssl -lcrypto"
996 AC_SUBST(TOR_OPENSSL_LIBS)
998 dnl Now validate openssl, and check for particular openssl functions.
999 save_LIBS="$LIBS"
1000 save_LDFLAGS="$LDFLAGS"
1001 save_CPPFLAGS="$CPPFLAGS"
1002 LIBS="$TOR_OPENSSL_LIBS $LIBS"
1003 LDFLAGS="$TOR_LDFLAGS_openssl $LDFLAGS"
1004 CPPFLAGS="$TOR_CPPFLAGS_openssl $CPPFLAGS"
1006 dnl Tor currently uses a number of APIs that are deprecated in OpenSSL 3.0.0
1007 dnl and later.  We want to migrate away from them, but that will be a lot of
1008 dnl work. (See ticket tor#40166.)  For now, we disable the deprecation
1009 dnl warnings.
1011 AC_MSG_CHECKING([for OpenSSL >= 3.0.0])
1012 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1013 #include <openssl/opensslv.h>
1014 #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x30000000L
1015 #error "you_have_version_3"
1016 #endif
1017    ]], [[]])],
1018    [ AC_MSG_RESULT([no]) ],
1019    [ AC_MSG_RESULT([yes]);
1020      AC_DEFINE(OPENSSL_SUPPRESS_DEPRECATED, 1, [disable openssl deprecated-function warnings]) ])
1022 AC_MSG_CHECKING([for OpenSSL < 1.0.1])
1023 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1024 #include <openssl/opensslv.h>
1025 #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1000100fL
1026 #error "too old"
1027 #endif
1028    ]], [[]])],
1029    [ AC_MSG_RESULT([no]) ],
1030    [ 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.]) ])
1032 AC_MSG_CHECKING([whether LibreSSL TLS 1.3 APIs are busted])
1033 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1034 #include <openssl/opensslv.h>
1035 #if defined(LIBRESSL_VERSION_NUMBER) && \
1036      LIBRESSL_VERSION_NUMBER >= 0x3020100fL && \
1037      LIBRESSL_VERSION_NUMBER < 0x3040100fL
1038 #error "oh no"
1039 #endif
1040    ]], [[]])],
1041    [ AC_MSG_RESULT([no]) ],
1042    [ 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.)]) ])
1044 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1045 #include <openssl/opensslv.h>
1046 #include <openssl/evp.h>
1047 #if defined(OPENSSL_NO_EC) || defined(OPENSSL_NO_ECDH) || defined(OPENSSL_NO_ECDSA)
1048 #error "no ECC"
1049 #endif
1050 #if !defined(NID_X9_62_prime256v1) || !defined(NID_secp224r1)
1051 #error "curves unavailable"
1052 #endif
1053    ]], [[]])],
1054    [ : ],
1055    [ 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.]) ])
1057 dnl Let's see if we have a version mismatch between includes and libs.
1058 AC_MSG_CHECKING([for significant mismatch between openssl headers and libraries])
1059 ac_retval=foo
1060 AC_RUN_IFELSE([AC_LANG_SOURCE([AC_LANG_PROGRAM([[
1061  #include <openssl/opensslv.h>
1062  #include <openssl/crypto.h>
1063 ]], [[
1064   /* Include major, minor, and fix, but not patch or status. */
1065   unsigned long mask = 0xfffff000;
1066   unsigned long linking = OpenSSL_version_num() & mask;
1067   unsigned long running = OPENSSL_VERSION_NUMBER & mask;
1068   return !(linking==running);
1069 ]])])], [openssl_ver_mismatch=no], [
1070    # This is a kludge to figure out whether compilation failed, or whether
1071    # running the program failed.
1072    if test "$ac_retval" = "1"; then
1073       openssl_ver_mismatch=inconclusive
1074    else
1075       openssl_ver_mismatch=yes
1076    fi], [openssl_ver_mismatch=cross])
1077 AC_MSG_RESULT([$openssl_ver_mismatch])
1079 AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , ,
1080 [#include <openssl/ssl.h>
1083 dnl OpenSSL functions which we might not have.  In theory, we could just
1084 dnl check the openssl version number, but in practice that gets pretty
1085 dnl confusing with LibreSSL, OpenSSL, and various distributions' patches
1086 dnl to them.
1087 AC_CHECK_FUNCS([ \
1088                 ERR_load_KDF_strings \
1089                 EVP_PBE_scrypt \
1090                 SSL_CIPHER_find \
1091                 SSL_CTX_set1_groups_list \
1092                 SSL_CTX_set_security_level \
1093                 SSL_SESSION_get_master_key \
1094                 SSL_get_client_ciphers \
1095                 SSL_get_client_random \
1096                 SSL_get_server_random \
1097                 TLS_method \
1098                ])
1100 dnl Check if OpenSSL structures are opaque
1101 AC_CHECK_MEMBERS([SSL.state], , ,
1102 [#include <openssl/ssl.h>
1105 AC_CHECK_SIZEOF(SHA_CTX, , [AC_INCLUDES_DEFAULT()
1106 #include <openssl/sha.h>
1109 fi # enable_nss
1111 dnl We will someday make KECCAK_TINY optional, but for now we still need
1112 dnl it for SHAKE, since OpenSSL's SHAKE can't be squeezed more than
1113 dnl once.  See comment in the definition of crypto_xof_t.
1115 dnl AM_CONDITIONAL(BUILD_KECCAK_TINY,
1116 dnl   test "x$ac_cv_func_EVP_sha3_256" != "xyes")
1118 AM_CONDITIONAL(BUILD_KECCAK_TINY, true)
1120 dnl ======================================================================
1121 dnl Can we use KIST?
1123 dnl Define the set of checks for KIST scheduler support.
1124 AC_DEFUN([CHECK_KIST_SUPPORT],[
1125   dnl KIST needs struct tcp_info and for certain members to exist.
1126   AC_CHECK_MEMBERS(
1127     [struct tcp_info.tcpi_unacked, struct tcp_info.tcpi_snd_mss],
1128     , ,[[#include <netinet/tcp.h>]])
1129   dnl KIST needs SIOCOUTQNSD to exist for an ioctl call.
1130   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1131                      #include <linux/sockios.h>
1132                      #ifndef SIOCOUTQNSD
1133                      #error
1134                      #endif
1135                      ])], have_siocoutqnsd=yes, have_siocoutqnsd=no)
1136   if test "x$have_siocoutqnsd" = "xyes"; then
1137     if test "x$ac_cv_member_struct_tcp_info_tcpi_unacked" = "xyes"; then
1138       if test "x$ac_cv_member_struct_tcp_info_tcpi_snd_mss" = "xyes"; then
1139         have_kist_support=yes
1140       fi
1141     fi
1142   fi
1144 dnl Now, trigger the check.
1145 CHECK_KIST_SUPPORT
1146 AS_IF([test "x$have_kist_support" = "xyes"],
1147       [AC_DEFINE(HAVE_KIST_SUPPORT, 1, [Defined if KIST scheduler is supported
1148                                         on this system])],
1149       [AC_MSG_NOTICE([KIST scheduler can't be used. Missing support.])])
1151 LIBS="$save_LIBS"
1152 LDFLAGS="$save_LDFLAGS"
1153 CPPFLAGS="$save_CPPFLAGS"
1155 dnl ------------------------------------------------------
1156 dnl Where do you live, zlib?  And how do we call you?
1158 tor_zlib_pkg_redhat="zlib"
1159 tor_zlib_pkg_debian="zlib1g"
1160 tor_zlib_devpkg_redhat="zlib-devel"
1161 tor_zlib_devpkg_debian="zlib1g-dev"
1163 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
1164     [#include <zlib.h>],
1165     [const char * zlibVersion(void);],
1166     [zlibVersion();], [--with-zlib-dir],
1167     [/opt/zlib])
1169 if test "$enable_static_zlib" = "yes"; then
1170    if test "$tor_cv_library_zlib_dir" = "(system)"; then
1171      AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
1172  using --enable-static-zlib")
1173    else
1174      TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
1175    fi
1176 else
1177      TOR_ZLIB_LIBS="-lz"
1179 AC_SUBST(TOR_ZLIB_LIBS)
1181 dnl ------------------------------------------------------
1182 dnl Where we do we find lzma?
1184 AC_ARG_ENABLE(lzma,
1185       AS_HELP_STRING(--enable-lzma, [enable support for the LZMA compression scheme.]),
1186       [case "${enableval}" in
1187         "yes") ;;
1188         "no")  ;;
1189         * ) AC_MSG_ERROR(bad value for --enable-lzma) ;;
1190       esac], [enable_lzma=auto])
1192 if test "x$enable_lzma" = "xno"; then
1193     have_lzma=no;
1194 else
1195     PKG_CHECK_MODULES([LZMA],
1196                       [liblzma],
1197                       have_lzma=yes,
1198                       have_lzma=no)
1200     if test "x$have_lzma" = "xno" ; then
1201         tor_incr_n_warnings
1202         AC_MSG_WARN([Unable to find liblzma, $pkg_config_user_action, or set LZMA_CFLAGS and LZMA_LIBS.])
1203     fi
1206 if test "x$have_lzma" = "xyes"; then
1207     AC_DEFINE(HAVE_LZMA,1,[Have LZMA])
1208     TOR_LZMA_CFLAGS="${LZMA_CFLAGS}"
1209     TOR_LZMA_LIBS="${LZMA_LIBS}"
1211 AC_SUBST(TOR_LZMA_CFLAGS)
1212 AC_SUBST(TOR_LZMA_LIBS)
1214 dnl ------------------------------------------------------
1215 dnl Where we do we find zstd?
1217 AC_ARG_ENABLE(zstd,
1218       AS_HELP_STRING(--enable-zstd, [enable support for the Zstandard compression scheme.]),
1219       [case "${enableval}" in
1220         "yes") ;;
1221         "no")  ;;
1222         * ) AC_MSG_ERROR(bad value for --enable-zstd) ;;
1223       esac], [enable_zstd=auto])
1225 if test "x$enable_zstd" = "xno"; then
1226     have_zstd=no;
1227 else
1228     PKG_CHECK_MODULES([ZSTD],
1229                       [libzstd >= 1.1],
1230                       have_zstd=yes,
1231                       have_zstd=no)
1233     if test "x$have_zstd" = "xno" ; then
1234         tor_incr_n_warnings
1235         AC_MSG_WARN([Unable to find libzstd, $pkg_config_user_action, or set ZSTD_CFLAGS and ZSTD_LIBS.])
1236     fi
1239 if test "x$have_zstd" = "xyes"; then
1240     AC_DEFINE(HAVE_ZSTD,1,[Have Zstd])
1241     TOR_ZSTD_CFLAGS="${ZSTD_CFLAGS}"
1242     TOR_ZSTD_LIBS="${ZSTD_LIBS}"
1244     dnl now check for zstd functions
1245     save_LIBS="$LIBS"
1246     save_CFLAGS="$CFLAGS"
1247     LIBS="$LIBS $ZSTD_LIBS"
1248     CFLAGS="$CFLAGS $ZSTD_CFLAGS"
1249     AC_CHECK_FUNCS(ZSTD_estimateCStreamSize \
1250                    ZSTD_estimateDCtxSize)
1251     LIBS="$save_LIBS"
1252     CFLAGS="$save_CFLAGS"
1254 AC_SUBST(TOR_ZSTD_CFLAGS)
1255 AC_SUBST(TOR_ZSTD_LIBS)
1257 dnl ----------------------------------------------------------------------
1258 dnl Check if libcap is available for capabilities.
1260 tor_cap_pkg_debian="libcap2"
1261 tor_cap_pkg_redhat="libcap"
1262 tor_cap_devpkg_debian="libcap-dev"
1263 tor_cap_devpkg_redhat="libcap-devel"
1265 AC_CHECK_LIB([cap], [cap_init], [],
1266   AC_MSG_NOTICE([Libcap was not found. Capabilities will not be usable.])
1268 AC_CHECK_FUNCS(cap_set_proc)
1270 dnl ---------------------------------------------------------------------
1271 dnl Now that we know about our major libraries, we can check for compiler
1272 dnl and linker hardening options.  We need to do this with the libraries known,
1273 dnl since sometimes the linker will like an option but not be willing to
1274 dnl use it with a build of a library.
1276 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
1277 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"
1279 CFLAGS_FTRAPV=
1280 CFLAGS_FWRAPV=
1281 CFLAGS_ASAN=
1282 CFLAGS_UBSAN=
1285 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1286 #if !defined(__clang__)
1287 #error
1288 #endif])], have_clang=yes, have_clang=no)
1290 if test "x$enable_pic" = "xyes"; then
1291     TOR_CHECK_CFLAGS(-fPIC)
1294 if test "x$enable_gcc_hardening" != "xno"; then
1295     CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
1296     if test "x$have_clang" = "xyes"; then
1297         TOR_CHECK_CFLAGS(-Qunused-arguments)
1298     fi
1299     TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
1300     AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
1301     AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
1302 m4_ifdef([AS_VAR_IF],[
1303     AS_VAR_IF(can_compile, [yes],
1304         AS_VAR_IF(can_link, [yes],
1305                   [],
1306                   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.)]))
1307         )])
1308     AS_VAR_POPDEF([can_link])
1309     AS_VAR_POPDEF([can_compile])
1310     TOR_CHECK_CFLAGS(-Wstack-protector)
1311     TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
1312     if test "$bwin32" = "false" && test "$enable_libfuzzer" != "yes" && test "$enable_oss_fuzz" != "yes"; then
1313        if test "$enable_pic" != "yes"; then
1314            # If we have already enabled -fPIC, then we don't also need to
1315            # compile with -fPIE...
1316            TOR_CHECK_CFLAGS(-fPIE)
1317        fi
1318        # ... but we want to link our executables with -pie in any case, since
1319        # they're executables, not a library.
1320        TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
1321     fi
1322     TOR_TRY_COMPILE_WITH_CFLAGS(-fwrapv, also_link, CFLAGS_FWRAPV="-fwrapv", true)
1324    AC_MSG_CHECKING([whether we can run hardened binaries])
1325    AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
1326         [AC_MSG_RESULT([yes])],
1327         [AC_MSG_RESULT([no])
1328          AC_MSG_ERROR([dnl
1329  We can link with compiler hardening options, but we can't run with them.
1330  That's a bad sign! If you must, you can pass --disable-gcc-hardening to
1331  configure, but it would be better to figure out what the underlying problem
1332  is.])],
1333         [AC_MSG_RESULT([cross])])
1336 if test "$fragile_hardening" = "yes"; then
1337     TOR_TRY_COMPILE_WITH_CFLAGS(-ftrapv, also_link, CFLAGS_FTRAPV="-ftrapv", true)
1338    if test "$tor_cv_cflags__ftrapv" = "yes" && test "$tor_can_link__ftrapv" != "yes"; then
1339       tor_incr_n_warnings
1340       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.])
1341    fi
1343    if test "$tor_cv_cflags__ftrapv" != "yes"; then
1344      AC_MSG_ERROR([You requested fragile hardening, but the compiler does not seem to support -ftrapv.])
1345    fi
1347    TOR_TRY_COMPILE_WITH_CFLAGS([-fsanitize=address], also_link, CFLAGS_ASAN="-fsanitize=address", true)
1348     if test "$tor_cv_cflags__fsanitize_address" = "yes" && test "$tor_can_link__fsanitize_address" != "yes"; then
1349       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*])
1350     fi
1352    TOR_TRY_COMPILE_WITH_CFLAGS([-fsanitize=undefined], also_link, CFLAGS_UBSAN="-fsanitize=undefined", true)
1353     if test "$tor_cv_cflags__fsanitize_address" = "yes" && test "$tor_can_link__fsanitize_address" != "yes"; then
1354       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*])
1355     fi
1357    TOR_TRY_COMPILE_WITH_CFLAGS([-fno-sanitize=float-divide-by-zero], also_link, CFLAGS_UBSAN="-fno-sanitize=float-divide-by-zero", true)
1358     if test "$tor_cv_cflags__fno_sanitize_float_divide_by_zero" = "yes" && test "$tor_can_link__fno_sanitize_float_divide_by_zero" != "yes"; then
1359       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*])
1360     fi
1362 TOR_CHECK_CFLAGS([-fno-omit-frame-pointer])
1365 CFLAGS_BUGTRAP="$CFLAGS_FTRAPV $CFLAGS_ASAN $CFLAGS_UBSAN"
1366 CFLAGS_CONSTTIME="$CFLAGS_FWRAPV"
1368 mulodi_fixes_ftrapv=no
1369 if test "$have_clang" = "yes"; then
1370   saved_CFLAGS="$CFLAGS"
1371   CFLAGS="$CFLAGS $CFLAGS_FTRAPV"
1372   AC_MSG_CHECKING([whether clang -ftrapv can link a 64-bit int multiply])
1373   AC_LINK_IFELSE([
1374       AC_LANG_SOURCE([[
1375           #include <stdint.h>
1376           #include <stdlib.h>
1377           int main(int argc, char **argv)
1378           {
1379             int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
1380                         * (int64_t)atoi(argv[3]);
1381             return x == 9;
1382           } ]])],
1383           [ftrapv_can_link=yes; AC_MSG_RESULT([yes])],
1384           [ftrapv_can_link=no; AC_MSG_RESULT([no])])
1385   if test "$ftrapv_can_link" = "no"; then
1386     AC_MSG_CHECKING([whether defining __mulodi4 fixes that])
1387     AC_LINK_IFELSE([
1388       AC_LANG_SOURCE([[
1389           #include <stdint.h>
1390           #include <stdlib.h>
1391           int64_t __mulodi4(int64_t a, int64_t b, int *overflow) {
1392              *overflow=0;
1393              return a;
1394           }
1395           int main(int argc, char **argv)
1396           {
1397             int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
1398                         * (int64_t)atoi(argv[3]);
1399             return x == 9;
1400           } ]])],
1401           [mulodi_fixes_ftrapv=yes; AC_MSG_RESULT([yes])],
1402           [mulodi_fixes_ftrapv=no; AC_MSG_RESULT([no])])
1403   fi
1404   CFLAGS="$saved_CFLAGS"
1407 AM_CONDITIONAL(ADD_MULODI4, test "$mulodi_fixes_ftrapv" = "yes")
1409 dnl These cflags add bunches of branches, and we haven't been able to
1410 dnl persuade ourselves that they're suitable for code that needs to be
1411 dnl constant time.
1412 AC_SUBST(CFLAGS_BUGTRAP)
1413 dnl These cflags are variant ones suitable for code that needs to be
1414 dnl constant-time.
1415 AC_SUBST(CFLAGS_CONSTTIME)
1417 if test "x$enable_linker_hardening" != "xno"; then
1418     TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
1421 # For backtrace support
1422 TOR_CHECK_LDFLAGS(-rdynamic)
1424 dnl ------------------------------------------------------
1425 dnl Now see if we have a -fomit-frame-pointer compiler option.
1427 saved_CFLAGS="$CFLAGS"
1428 TOR_CHECK_CFLAGS(-fomit-frame-pointer)
1429 F_OMIT_FRAME_POINTER=''
1430 if test "$saved_CFLAGS" != "$CFLAGS"; then
1431   if test "$fragile_hardening" = "yes"; then
1432     F_OMIT_FRAME_POINTER='-fomit-frame-pointer'
1433   fi
1435 CFLAGS="$saved_CFLAGS"
1436 AC_SUBST(F_OMIT_FRAME_POINTER)
1438 dnl ------------------------------------------------------
1439 dnl If we are adding -fomit-frame-pointer (or if the compiler's doing it
1440 dnl for us, as GCC 4.6 and later do at many optimization levels), then
1441 dnl we should try to add -fasynchronous-unwind-tables so that our backtrace
1442 dnl code will work.
1443 TOR_CHECK_CFLAGS(-fasynchronous-unwind-tables)
1445 dnl ============================================================
1446 dnl Check for libseccomp
1448 if test "x$enable_seccomp" != "xno"; then
1449   AC_CHECK_HEADERS([seccomp.h])
1450   AC_SEARCH_LIBS(seccomp_init, [seccomp])
1453 dnl ============================================================
1454 dnl Check for libscrypt
1456 if test "x$enable_libscrypt" != "xno"; then
1457   AC_CHECK_HEADERS([libscrypt.h])
1458   AC_SEARCH_LIBS(libscrypt_scrypt, [scrypt])
1459   AC_CHECK_FUNCS([libscrypt_scrypt])
1462 dnl ============================================================
1463 dnl We need an implementation of curve25519.
1465 dnl set these defaults.
1466 build_curve25519_donna=no
1467 build_curve25519_donna_c64=no
1468 use_curve25519_donna=no
1469 use_curve25519_nacl=no
1470 CURVE25519_LIBS=
1472 dnl The best choice is using curve25519-donna-c64, but that requires
1473 dnl that we
1474 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
1475   tor_cv_can_use_curve25519_donna_c64,
1476   [AC_RUN_IFELSE(
1477     [AC_LANG_PROGRAM([dnl
1478       #include <stdint.h>
1479       typedef unsigned uint128_t __attribute__((mode(TI)));
1480   int func(uint64_t a, uint64_t b) {
1481            uint128_t c = ((uint128_t)a) * b;
1482            int ok = ((uint64_t)(c>>96)) == 522859 &&
1483              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
1484                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
1485                  (((uint64_t)(c))&0xffffffffL) == 0;
1486            return ok;
1487       }
1488   ], [dnl
1489     int ok = func( ((uint64_t)2000000000) * 1000000000,
1490                    ((uint64_t)1234567890) << 24);
1491         return !ok;
1492       ])],
1493   [tor_cv_can_use_curve25519_donna_c64=yes],
1494       [tor_cv_can_use_curve25519_donna_c64=no],
1495   [AC_LINK_IFELSE(
1496         [AC_LANG_PROGRAM([dnl
1497       #include <stdint.h>
1498       typedef unsigned uint128_t __attribute__((mode(TI)));
1499   int func(uint64_t a, uint64_t b) {
1500            uint128_t c = ((uint128_t)a) * b;
1501            int ok = ((uint64_t)(c>>96)) == 522859 &&
1502              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
1503                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
1504                  (((uint64_t)(c))&0xffffffffL) == 0;
1505            return ok;
1506       }
1507   ], [dnl
1508     int ok = func( ((uint64_t)2000000000) * 1000000000,
1509                  ((uint64_t)1234567890) << 24);
1510         return !ok;
1511       ])],
1512           [tor_cv_can_use_curve25519_donna_c64=cross],
1513       [tor_cv_can_use_curve25519_donna_c64=no])])])
1515 AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
1516                   nacl/crypto_scalarmult_curve25519.h])
1518 AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
1519   tor_cv_can_use_curve25519_nacl,
1520   [tor_saved_LIBS="$LIBS"
1521    LIBS="$LIBS -lnacl"
1522    AC_LINK_IFELSE(
1523      [AC_LANG_PROGRAM([dnl
1524        #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
1525        #include <crypto_scalarmult_curve25519.h>
1526    #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
1527    #include <nacl/crypto_scalarmult_curve25519.h>
1528    #endif
1529        #ifdef crypto_scalarmult_curve25519_ref_BYTES
1530    #error Hey, this is the reference implementation! That's not fast.
1531    #endif
1532      ], [
1533    unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
1534      ])], [tor_cv_can_use_curve25519_nacl=yes],
1535      [tor_cv_can_use_curve25519_nacl=no])
1536    LIBS="$tor_saved_LIBS" ])
1538  dnl Okay, now we need to figure out which one to actually use. Fall back
1539  dnl to curve25519-donna.c
1541  if test "x$tor_cv_can_use_curve25519_donna_c64" != "xno"; then
1542    build_curve25519_donna_c64=yes
1543    use_curve25519_donna=yes
1544  elif test "x$tor_cv_can_use_curve25519_nacl" = "xyes"; then
1545    use_curve25519_nacl=yes
1546    CURVE25519_LIBS=-lnacl
1547  else
1548    build_curve25519_donna=yes
1549    use_curve25519_donna=yes
1550  fi
1552 if test "x$use_curve25519_donna" = "xyes"; then
1553   AC_DEFINE(USE_CURVE25519_DONNA, 1,
1554             [Defined if we should use an internal curve25519_donna{,_c64} implementation])
1556 if test "x$use_curve25519_nacl" = "xyes"; then
1557   AC_DEFINE(USE_CURVE25519_NACL, 1,
1558             [Defined if we should use a curve25519 from nacl])
1560 AM_CONDITIONAL(BUILD_CURVE25519_DONNA,
1561   test "x$build_curve25519_donna" = "xyes")
1562 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64,
1563   test "x$build_curve25519_donna_c64" = "xyes")
1564 AC_SUBST(CURVE25519_LIBS)
1566 dnl Make sure to enable support for large off_t if available.
1567 AC_SYS_LARGEFILE
1569 AC_CHECK_HEADERS([errno.h \
1570                   fcntl.h \
1571                   signal.h \
1572                   string.h \
1573                   sys/capability.h \
1574                   sys/fcntl.h \
1575                   sys/stat.h \
1576                   sys/time.h \
1577                   sys/types.h \
1578                   time.h \
1579                   unistd.h \
1580                   arpa/inet.h \
1581                   crt_externs.h \
1582                   execinfo.h \
1583                   gnu/libc-version.h \
1584                   grp.h \
1585                   ifaddrs.h \
1586                   inttypes.h \
1587                   limits.h \
1588                   linux/types.h \
1589                   mach/vm_inherit.h \
1590                   machine/limits.h \
1591                   malloc.h \
1592                   netdb.h \
1593                   netinet/in.h \
1594                   netinet/in6.h \
1595                   pwd.h \
1596                   readpassphrase.h \
1597                   stdatomic.h \
1598                   sys/eventfd.h \
1599                   sys/file.h \
1600                   sys/ioctl.h \
1601                   sys/limits.h \
1602                   sys/mman.h \
1603                   sys/param.h \
1604                   sys/prctl.h \
1605                   sys/random.h \
1606                   sys/resource.h \
1607                   sys/select.h \
1608                   sys/socket.h \
1609                   sys/statvfs.h \
1610                   sys/syscall.h \
1611                   sys/sysctl.h \
1612                   sys/time.h \
1613                   sys/types.h \
1614                   sys/un.h \
1615                   sys/utime.h \
1616                   sys/wait.h \
1617                   syslog.h \
1618                   utime.h \
1619                   glob.h])
1621 AC_CHECK_HEADERS(sys/param.h)
1623 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
1624 [#ifdef HAVE_SYS_TYPES_H
1625 #include <sys/types.h>
1626 #endif
1627 #ifdef HAVE_SYS_SOCKET_H
1628 #include <sys/socket.h>
1629 #endif])
1630 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
1631 [#ifdef HAVE_SYS_TYPES_H
1632 #include <sys/types.h>
1633 #endif
1634 #ifdef HAVE_SYS_SOCKET_H
1635 #include <sys/socket.h>
1636 #endif
1637 #ifdef HAVE_NET_IF_H
1638 #include <net/if.h>
1639 #endif
1640 #ifdef HAVE_NETINET_IN_H
1641 #include <netinet/in.h>
1642 #endif])
1644 AC_CHECK_HEADERS(linux/if.h,[],[],
1646 #ifdef HAVE_SYS_SOCKET_H
1647 #include <sys/socket.h>
1648 #endif
1651 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
1652         linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
1653 [#ifdef HAVE_SYS_TYPES_H
1654 #include <sys/types.h>
1655 #endif
1656 #ifdef HAVE_SYS_SOCKET_H
1657 #include <sys/socket.h>
1658 #endif
1659 #ifdef HAVE_LIMITS_H
1660 #include <limits.h>
1661 #endif
1662 #ifdef HAVE_LINUX_TYPES_H
1663 #include <linux/types.h>
1664 #endif
1665 #ifdef HAVE_NETINET_IN6_H
1666 #include <netinet/in6.h>
1667 #endif
1668 #ifdef HAVE_NETINET_IN_H
1669 #include <netinet/in.h>
1670 #endif])
1672 AC_CHECK_HEADERS(linux/netfilter_ipv6/ip6_tables.h,
1673         linux_netfilter_ipv6_ip6_tables=1, linux_netfilter_ipv6_ip6_tables=0,
1674 [#ifdef HAVE_SYS_TYPES_H
1675 #include <sys/types.h>
1676 #endif
1677 #ifdef HAVE_SYS_SOCKET_H
1678 #include <sys/socket.h>
1679 #endif
1680 #ifdef HAVE_LIMITS_H
1681 #include <limits.h>
1682 #endif
1683 #ifdef HAVE_LINUX_TYPES_H
1684 #include <linux/types.h>
1685 #endif
1686 #ifdef HAVE_NETINET_IN6_H
1687 #include <netinet/in6.h>
1688 #endif
1689 #ifdef HAVE_NETINET_IN_H
1690 #include <netinet/in.h>
1691 #endif
1692 #ifdef HAVE_LINUX_IF_H
1693 #include <linux/if.h>
1694 #endif])
1696 transparent_ok=0
1697 if test "x$net_if_found" = "x1" && test "x$net_pfvar_found" = "x1"; then
1698   transparent_ok=1
1700 if test "x$linux_netfilter_ipv4" = "x1"; then
1701   transparent_ok=1
1703 if test "x$linux_netfilter_ipv6_ip6_tables" = "x1"; then
1704   transparent_ok=1
1706 if test "x$transparent_ok" = "x1"; then
1707   AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
1708 else
1709   AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
1712 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
1713 [#ifdef HAVE_SYS_TYPES_H
1714 #include <sys/types.h>
1715 #endif
1716 #ifdef HAVE_SYS_TIME_H
1717 #include <sys/time.h>
1718 #endif])
1720 AC_CHECK_SIZEOF(char)
1721 AC_CHECK_SIZEOF(short)
1722 AC_CHECK_SIZEOF(int)
1723 AC_CHECK_SIZEOF(unsigned int)
1724 AC_CHECK_SIZEOF(long)
1725 AC_CHECK_SIZEOF(long long)
1726 AC_CHECK_SIZEOF(__int64)
1727 AC_CHECK_SIZEOF(void *)
1728 AC_CHECK_SIZEOF(time_t)
1729 AC_CHECK_SIZEOF(size_t)
1730 AC_CHECK_SIZEOF(pid_t)
1732 AC_CHECK_TYPES([uint, u_char, ssize_t])
1734 AC_PC_FROM_UCONTEXT([:])
1736 dnl used to include sockaddr_storage, but everybody has that.
1737 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
1738 [#ifdef HAVE_SYS_TYPES_H
1739 #include <sys/types.h>
1740 #endif
1741 #ifdef HAVE_NETINET_IN_H
1742 #include <netinet/in.h>
1743 #endif
1744 #ifdef HAVE_NETINET_IN6_H
1745 #include <netinet/in6.h>
1746 #endif
1747 #ifdef HAVE_SYS_SOCKET_H
1748 #include <sys/socket.h>
1749 #endif
1750 #ifdef _WIN32
1751 #define _WIN32_WINNT 0x0501
1752 #define WIN32_LEAN_AND_MEAN
1753 #include <winsock2.h>
1754 #include <ws2tcpip.h>
1755 #endif
1757 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
1758 [#ifdef HAVE_SYS_TYPES_H
1759 #include <sys/types.h>
1760 #endif
1761 #ifdef HAVE_NETINET_IN_H
1762 #include <netinet/in.h>
1763 #endif
1764 #ifdef HAVE_NETINET_IN6_H
1765 #include <netinet/in6.h>
1766 #endif
1767 #ifdef HAVE_SYS_SOCKET_H
1768 #include <sys/socket.h>
1769 #endif
1770 #ifdef _WIN32
1771 #define _WIN32_WINNT 0x0501
1772 #define WIN32_LEAN_AND_MEAN
1773 #include <winsock2.h>
1774 #include <ws2tcpip.h>
1775 #endif
1778 AC_CHECK_TYPES([rlim_t], , ,
1779 [#ifdef HAVE_SYS_TYPES_H
1780 #include <sys/types.h>
1781 #endif
1782 #ifdef HAVE_SYS_TIME_H
1783 #include <sys/time.h>
1784 #endif
1785 #ifdef HAVE_SYS_RESOURCE_H
1786 #include <sys/resource.h>
1787 #endif
1790 AX_CHECK_SIGN([time_t],
1791        [ : ],
1792        [ : ], [
1793 #ifdef HAVE_SYS_TYPES_H
1794 #include <sys/types.h>
1795 #endif
1796 #ifdef HAVE_SYS_TIME_H
1797 #include <sys/time.h>
1798 #endif
1799 #ifdef HAVE_TIME_H
1800 #include <time.h>
1801 #endif
1804 if test "$ax_cv_decl_time_t_signed" = "no"; then
1805   AC_MSG_ERROR([You have an unsigned time_t; Tor does not support that. Please tell the Tor developers about your interesting platform.])
1808 AX_CHECK_SIGN([size_t],
1809        [ tor_cv_size_t_signed=yes ],
1810        [ tor_cv_size_t_signed=no ], [
1811 #ifdef HAVE_SYS_TYPES_H
1812 #include <sys/types.h>
1813 #endif
1816 if test "$ax_cv_decl_size_t_signed" = "yes"; then
1817   AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
1820 AX_CHECK_SIGN([enum always],
1821        [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
1822        [ : ], [
1823  enum always { AAA, BBB, CCC };
1826 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
1827 #ifdef HAVE_SYS_SOCKET_H
1828 #include <sys/socket.h>
1829 #endif
1832 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1834 AC_CHECK_SIZEOF(cell_t)
1836 # Let's see if stdatomic works. (There are some debian clangs that screw it
1837 # up; see Tor bug #26779 and debian bug 903709.)
1838 AC_CACHE_CHECK([whether C11 stdatomic.h actually works],
1839                tor_cv_stdatomic_works,
1840 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1841 #include <stdatomic.h>
1842 struct x { atomic_size_t y; };
1843 void try_atomic_init(struct x *xx)
1845   atomic_init(&xx->y, 99);
1846   atomic_fetch_add(&xx->y, 1);
1848 ]])], [tor_cv_stdatomic_works=yes], [tor_cv_stdatomic_works=no])])
1850 if test "$tor_cv_stdatomic_works" = "yes"; then
1851    AC_DEFINE(STDATOMIC_WORKS, 1, [Set to 1 if we can compile a simple stdatomic example.])
1852 elif test "$ac_cv_header_stdatomic_h" = "yes"; then
1853    tor_incr_n_warnings
1854    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 ])
1857 # Now make sure that NULL can be represented as zero bytes.
1858 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1859 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1860 [[#include <stdlib.h>
1861 #include <string.h>
1862 #include <stdio.h>
1863 #ifdef HAVE_STDDEF_H
1864 #include <stddef.h>
1865 #endif
1866 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1867 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1868        [tor_cv_null_is_zero=yes],
1869        [tor_cv_null_is_zero=no],
1870        [tor_cv_null_is_zero=cross])])
1872 if test "$tor_cv_null_is_zero" = "cross"; then
1873   # Cross-compiling; let's hope that the target isn't raving mad.
1874   AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
1877 if test "$tor_cv_null_is_zero" != "no"; then
1878   AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1879             [Define to 1 iff memset(0) sets pointers to NULL])
1882 AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
1883 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1884 [[#include <stdlib.h>
1885 #include <string.h>
1886 #include <stdio.h>
1887 #ifdef HAVE_STDDEF_H
1888 #include <stddef.h>
1889 #endif
1890 int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
1891 return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
1892        [tor_cv_dbl0_is_zero=yes],
1893        [tor_cv_dbl0_is_zero=no],
1894        [tor_cv_dbl0_is_zero=cross])])
1896 if test "$tor_cv_dbl0_is_zero" = "cross"; then
1897   # Cross-compiling; let's hope that the target isn't raving mad.
1898   AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
1901 if test "$tor_cv_dbl0_is_zero" != "no"; then
1902   AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
1903             [Define to 1 iff memset(0) sets doubles to 0.0])
1906 # And what happens when we malloc zero?
1907 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
1908 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1909 [[#include <stdlib.h>
1910 #include <string.h>
1911 #include <stdio.h>
1912 #ifdef HAVE_STDDEF_H
1913 #include <stddef.h>
1914 #endif
1915 int main () { return malloc(0)?0:1; }]])],
1916        [tor_cv_malloc_zero_works=yes],
1917        [tor_cv_malloc_zero_works=no],
1918        [tor_cv_malloc_zero_works=cross])])
1920 if test "$tor_cv_malloc_zero_works" = "cross"; then
1921   # Cross-compiling; let's hope that the target isn't raving mad.
1922   AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
1925 if test "$tor_cv_malloc_zero_works" = "yes"; then
1926   AC_DEFINE([MALLOC_ZERO_WORKS], 1,
1927             [Define to 1 iff malloc(0) returns a pointer])
1930 # whether we seem to be in a 2s-complement world.
1931 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
1932 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1933 [[int main () { int problem = ((-99) != (~99)+1);
1934 return problem ? 1 : 0; }]])],
1935        [tor_cv_twos_complement=yes],
1936        [tor_cv_twos_complement=no],
1937        [tor_cv_twos_complement=cross])])
1939 if test "$tor_cv_twos_complement" = "cross"; then
1940   # Cross-compiling; let's hope that the target isn't raving mad.
1941   AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
1944 if test "$tor_cv_twos_complement" != "no"; then
1945   AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
1946             [Define to 1 iff we represent negative integers with
1947              two's complement])
1950 # What does shifting a negative value do?
1951 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
1952 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1953 [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
1954        [tor_cv_sign_extend=yes],
1955        [tor_cv_sign_extend=no],
1956        [tor_cv_sign_extend=cross])])
1958 if test "$tor_cv_sign_extend" = "cross"; then
1959   # Cross-compiling; let's hope that the target isn't raving mad.
1960   AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
1963 if test "$tor_cv_sign_extend" != "no"; then
1964   AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
1965             [Define to 1 iff right-shifting a negative value performs sign-extension])
1968 # Is uint8_t the same type as unsigned char?
1969 AC_CACHE_CHECK([whether uint8_t is the same type as unsigned char], tor_cv_uint8_uchar,
1970 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1971 #include <stdint.h>
1972 extern uint8_t c;
1973 unsigned char c;]])],
1974        [tor_cv_uint8_uchar=yes],
1975        [tor_cv_uint8_uchar=no],
1976        [tor_cv_uint8_uchar=cross])])
1978 if test "$tor_cv_uint8_uchar" = "cross"; then
1979   AC_MSG_NOTICE([Cross-compiling: we'll assume that uint8_t is the same type as unsigned char])
1982 if test "$tor_cv_uint8_uchar" = "no"; then
1983   AC_MSG_ERROR([We assume that uint8_t is the same type as unsigned char, but your compiler disagrees.])
1986 AC_ARG_WITH(tcmalloc,
1987 AS_HELP_STRING(--with-tcmalloc, [use tcmalloc memory allocation library. Deprecated; see --with-malloc]))
1989 default_malloc=system
1991 if test "x$enable_openbsd_malloc" = "xyes" ; then
1992   AC_MSG_NOTICE([The --enable-openbsd-malloc argument is deprecated; use --with-malloc=openbsd instead.])
1993   default_malloc=openbsd
1996 if test "x$with_tcmalloc" = "xyes"; then
1997   AC_MSG_NOTICE([The --with-tcmalloc argument is deprecated; use --with-malloc=tcmalloc instead.])
1998   default_malloc=tcmalloc
2001 AC_ARG_WITH(malloc,
2002    AS_HELP_STRING([--with-malloc=[system,jemalloc,tcmalloc,openbsd]],
2003                   [select special malloc implementation [system]]),
2004    [ malloc="$with_malloc" ], [ malloc="$default_malloc" ])
2006 AS_CASE([$malloc],
2007   [tcmalloc], [
2008       PKG_CHECK_MODULES([TCMALLOC],
2009                         [libtcmalloc],
2010                         have_tcmalloc=yes,
2011                         have_tcmalloc=no)
2013       if test "x$have_tcmalloc" = "xno" ; then
2014           AC_MSG_ERROR([Unable to find tcmalloc requested by --with-malloc, $pkg_config_user_action, or set TCMALLOC_CFLAGS and TCMALLOC_LIBS.])
2015       fi
2017       CFLAGS="$CFLAGS $TCMALLOC_CFLAGS"
2018       LIBS="$TCMALLOC_LIBS $LIBS"
2019   ],
2021   [jemalloc], [
2022       PKG_CHECK_MODULES([JEMALLOC],
2023                         [jemalloc],
2024                         have_jemalloc=yes,
2025                         have_jemalloc=no)
2027       if test "x$have_jemalloc" = "xno" ; then
2028           AC_MSG_ERROR([Unable to find jemalloc requested by --with-malloc, $pkg_config_user_action, or set JEMALLOC_CFLAGS and JEMALLOC_LIBS.])
2029       fi
2031       CFLAGS="$CFLAGS $JEMALLOC_CFLAGS"
2032       LIBS="$JEMALLOC_LIBS $LIBS"
2033       using_custom_malloc=yes
2034   ],
2036   [openbsd], [
2037     tor_incr_n_warnings
2038     AC_MSG_WARN([The openbsd malloc port is deprecated in Tor 0.3.5 and will be removed in a future version.])
2039     enable_openbsd_malloc=yes
2040   ],
2042   [system], [
2043      # handle this later, including the jemalloc fallback
2044   ],
2046   [AC_MSG_ERROR([--with-malloc=`$with_malloc' not supported, see --help])
2049 AM_CONDITIONAL(USE_OPENBSD_MALLOC, test "x$enable_openbsd_malloc" = "xyes")
2051 if test "$malloc" != "system"; then
2052   # Tell the C compiler not to use the system allocator functions.
2053   TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
2055 if test "$using_custom_malloc" = "yes"; then
2056   # Tell the C compiler not to use the system allocator functions.
2057   TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
2060 # By default, we're going to assume we don't have mlockall()
2061 # bionic and other platforms have various broken mlockall subsystems.
2062 # Some systems don't have a working mlockall, some aren't linkable,
2063 # and some have it but don't declare it.
2064 AC_CHECK_FUNCS(mlockall)
2065 AC_CHECK_DECLS([mlockall], , , [
2066 #ifdef HAVE_SYS_MMAN_H
2067 #include <sys/mman.h>
2068 #endif])
2070 # Allow user to specify an alternate syslog facility
2071 AC_ARG_WITH(syslog-facility,
2072 AS_HELP_STRING(--with-syslog-facility=LOG, [syslog facility to use (default=LOG_DAEMON)]),
2073 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
2074 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
2075 AC_SUBST(LOGFACILITY)
2077 # Check if we have getresuid and getresgid
2078 AC_CHECK_FUNCS(getresuid getresgid)
2080 # Check for gethostbyname_r in all its glorious incompatible versions.
2081 #   (This logic is based on that in Python's configure.in)
2082 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
2083   [Define this if you have any gethostbyname_r()])
2085 AC_CHECK_FUNC(gethostbyname_r, [
2086   AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
2087   OLD_CFLAGS=$CFLAGS
2088   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
2089   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2090 #include <netdb.h>
2091   ]], [[
2092     char *cp1, *cp2;
2093     struct hostent *h1, *h2;
2094     int i1, i2;
2095     (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
2096   ]])],[
2097     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2098     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2099      [Define this if gethostbyname_r takes 6 arguments])
2100     AC_MSG_RESULT(6)
2101   ], [
2102     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2103 #include <netdb.h>
2104     ]], [[
2105       char *cp1, *cp2;
2106       struct hostent *h1;
2107       int i1, i2;
2108       (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
2109     ]])], [
2110       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2111       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2112         [Define this if gethostbyname_r takes 5 arguments])
2113       AC_MSG_RESULT(5)
2114    ], [
2115       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2116 #include <netdb.h>
2117      ]], [[
2118        char *cp1;
2119        struct hostent *h1;
2120        struct hostent_data hd;
2121        (void) gethostbyname_r(cp1,h1,&hd);
2122      ]])], [
2123        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2124        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2125          [Define this if gethostbyname_r takes 3 arguments])
2126        AC_MSG_RESULT(3)
2127      ], [
2128        AC_MSG_RESULT(0)
2129      ])
2130   ])
2131  ])
2132  CFLAGS=$OLD_CFLAGS
2135 AC_CACHE_CHECK([whether the C compiler supports __func__],
2136   tor_cv_have_func_macro,
2137   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2138 #include <stdio.h>
2139 int main(int c, char **v) { puts(__func__); }])],
2140   tor_cv_have_func_macro=yes,
2141   tor_cv_have_func_macro=no))
2143 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
2144   tor_cv_have_FUNC_macro,
2145   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2146 #include <stdio.h>
2147 int main(int c, char **v) { puts(__FUNC__); }])],
2148   tor_cv_have_FUNC_macro=yes,
2149   tor_cv_have_FUNC_macro=no))
2151 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
2152   tor_cv_have_FUNCTION_macro,
2153   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2154 #include <stdio.h>
2155 int main(int c, char **v) { puts(__FUNCTION__); }])],
2156   tor_cv_have_FUNCTION_macro=yes,
2157   tor_cv_have_FUNCTION_macro=no))
2159 AC_CACHE_CHECK([whether we have extern char **environ already declared],
2160   tor_cv_have_environ_declared,
2161   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2162 #ifdef HAVE_UNISTD_H
2163 #include <unistd.h>
2164 #endif
2165 #include <stdlib.h>
2166 int main(int c, char **v) { char **t = environ; }])],
2167   tor_cv_have_environ_declared=yes,
2168   tor_cv_have_environ_declared=no))
2170 if test "$tor_cv_have_func_macro" = "yes"; then
2171   AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
2174 if test "$tor_cv_have_FUNC_macro" = "yes"; then
2175   AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
2178 if test "$tor_cv_have_FUNCTION_macro" = "yes"; then
2179   AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
2180            [Defined if the compiler supports __FUNCTION__])
2183 if test "$tor_cv_have_environ_declared" = "yes"; then
2184   AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
2185            [Defined if we have extern char **environ already declared])
2188 # $prefix stores the value of the --prefix command line option, or
2189 # NONE if the option wasn't set.  In the case that it wasn't set, make
2190 # it be the default, so that we can use it to expand directories now.
2191 if test "x$prefix" = "xNONE"; then
2192   prefix=$ac_default_prefix
2195 # and similarly for $exec_prefix
2196 if test "x$exec_prefix" = "xNONE"; then
2197   exec_prefix=$prefix
2200 if test "x$BUILDDIR" = "x"; then
2201   BUILDDIR=`pwd`
2203 AC_SUBST(BUILDDIR)
2204 AH_TEMPLATE([BUILDDIR],[tor's build directory])
2205 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
2207 if test "x$SRCDIR" = "x"; then
2208   SRCDIR=$(cd "$srcdir"; pwd)
2210 AH_TEMPLATE([SRCDIR],[tor's sourcedir directory])
2211 AC_DEFINE_UNQUOTED(SRCDIR,"$SRCDIR")
2213 if test "x$CONFDIR" = "x"; then
2214   CONFDIR=`eval echo $sysconfdir/tor`
2216 AC_SUBST(CONFDIR)
2217 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
2218 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
2220 BINDIR=`eval echo $bindir`
2221 AC_SUBST(BINDIR)
2222 LOCALSTATEDIR=`eval echo $localstatedir`
2223 AC_SUBST(LOCALSTATEDIR)
2225 if test "$bwin32" = "true"; then
2226   # Test if the linker supports the --nxcompat and --dynamicbase options
2227   # for Windows
2228   save_LDFLAGS="$LDFLAGS"
2229   LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
2230   AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
2231   AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
2232     [AC_MSG_RESULT([yes])]
2233     [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
2234     [AC_MSG_RESULT([no])]
2235   )
2236   LDFLAGS="$save_LDFLAGS"
2239 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
2240 # than autoconf's macros like.
2241 if test "$GCC" = "yes"; then
2242   # Disable GCC's strict aliasing checks.  They are an hours-to-debug
2243   # accident waiting to happen.
2244   CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
2245 else
2246   # Override optimization level for non-gcc compilers
2247   CFLAGS="$CFLAGS -O"
2248   enable_gcc_warnings=no
2249   enable_gcc_warnings_advisory=no
2252 # Warnings implies advisory-warnings and -Werror.
2253 if test "$enable_gcc_warnings" = "yes"; then
2254   enable_gcc_warnings_advisory=yes
2255   enable_fatal_warnings=yes
2258 # OS X Lion started deprecating the system openssl. Let's just disable
2259 # all deprecation warnings on OS X. Also, to potentially make the binary
2260 # a little smaller, let's enable dead_strip.
2261 case "$host_os" in
2263  darwin*)
2264     CFLAGS="$CFLAGS -Wno-deprecated-declarations"
2265     LDFLAGS="$LDFLAGS -dead_strip" ;;
2266 esac
2268 TOR_WARNING_FLAGS=""
2270 # Add some more warnings which we use in development but not in the
2271 # released versions.  (Some relevant gcc versions can't handle these.)
2273 # Note that we have to do this near the end  of the autoconf process, or
2274 # else we may run into problems when these warnings hit on the testing C
2275 # programs that autoconf wants to build.
2276 if test "x$enable_gcc_warnings_advisory" != "xno"; then
2278   case "$host" in
2279     *-*-openbsd* | *-*-bitrig*)
2280       # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
2281       # That's fine, except that the headers don't pass -Wredundant-decls.
2282       # Therefore, let's disable -Wsystem-headers when we're building
2283       # with maximal warnings on OpenBSD.
2284       CFLAGS="$CFLAGS -Wno-system-headers" ;;
2285   esac
2287   CFLAGS_NOWARNINGS="$CFLAGS"
2289   # GCC4.3 users once report trouble with -Wstrict-overflow=5.  GCC5 users
2290   # have it work better.
2291   # CFLAGS="$CFLAGS -Wstrict-overflow=1"
2293   # This warning was added in gcc 4.3, but it appears to generate
2294   # spurious warnings in gcc 4.4.  I don't know if it works in 4.5.
2295   #CFLAGS="$CFLAGS -Wlogical-op"
2297   m4_foreach_w([warning_flag], [
2298      -Waddress
2299      -Waddress-of-array-temporary
2300      -Waddress-of-temporary
2301      -Wambiguous-macro
2302      -Wanonymous-pack-parens
2303      -Warc
2304      -Warc-abi
2305      -Warc-bridge-casts-disallowed-in-nonarc
2306      -Warc-maybe-repeated-use-of-weak
2307      -Warc-performSelector-leaks
2308      -Warc-repeated-use-of-weak
2309      -Warray-bounds
2310      -Warray-bounds-pointer-arithmetic
2311      -Wasm
2312      -Wasm-operand-widths
2313      -Watomic-properties
2314      -Watomic-property-with-user-defined-accessor
2315      -Wauto-import
2316      -Wauto-storage-class
2317      -Wauto-var-id
2318      -Wavailability
2319      -Wbackslash-newline-escape
2320      -Wbad-array-new-length
2321      -Wbind-to-temporary-copy
2322      -Wbitfield-constant-conversion
2323      -Wbool-conversion
2324      -Wbool-conversions
2325      -Wbuiltin-requires-header
2326      -Wchar-align
2327      -Wcompare-distinct-pointer-types
2328      -Wcomplex-component-init
2329      -Wconditional-type-mismatch
2330      -Wconfig-macros
2331      -Wconstant-conversion
2332      -Wconstant-logical-operand
2333      -Wconstexpr-not-const
2334      -Wcustom-atomic-properties
2335      -Wdangling-field
2336      -Wdangling-initializer-list
2337      -Wdate-time
2338      -Wdelegating-ctor-cycles
2339      -Wdeprecated-implementations
2340      -Wdeprecated-register
2341      -Wdirect-ivar-access
2342      -Wdiscard-qual
2343      -Wdistributed-object-modifiers
2344      -Wdivision-by-zero
2345      -Wdollar-in-identifier-extension
2346      -Wdouble-promotion
2347      -Wduplicate-decl-specifier
2348      -Wduplicate-enum
2349      -Wduplicate-method-arg
2350      -Wduplicate-method-match
2351      -Wduplicated-cond
2352      -Wdynamic-class-memaccess
2353      -Wembedded-directive
2354      -Wempty-translation-unit
2355      -Wenum-conversion
2356      -Wexit-time-destructors
2357      -Wexplicit-ownership-type
2358      -Wextern-initializer
2359      -Wextra
2360      -Wextra-semi
2361      -Wextra-tokens
2362      -Wflexible-array-extensions
2363      -Wfloat-conversion
2364      -Wformat-non-iso
2365      -Wfour-char-constants
2366      -Wgcc-compat
2367      -Wglobal-constructors
2368      -Wgnu-array-member-paren-init
2369      -Wgnu-designator
2370      -Wgnu-static-float-init
2371      -Wheader-guard
2372      -Wheader-hygiene
2373      -Widiomatic-parentheses
2374      -Wignored-attributes
2375      -Wimplicit-atomic-properties
2376      -Wimplicit-conversion-floating-point-to-bool
2377      -Wimplicit-exception-spec-mismatch
2378      -Wimplicit-fallthrough
2379      -Wimplicit-fallthrough-per-function
2380      -Wimplicit-retain-self
2381      -Wimport-preprocessor-directive-pedantic
2382      -Wincompatible-library-redeclaration
2383      -Wincompatible-pointer-types-discards-qualifiers
2384      -Wincomplete-implementation
2385      -Wincomplete-module
2386      -Wincomplete-umbrella
2387      -Winit-self
2388      -Wint-conversions
2389      -Wint-to-void-pointer-cast
2390      -Winteger-overflow
2391      -Winvalid-constexpr
2392      -Winvalid-iboutlet
2393      -Winvalid-noreturn
2394      -Winvalid-pp-token
2395      -Winvalid-source-encoding
2396      -Winvalid-token-paste
2397      -Wknr-promoted-parameter
2398      -Wlarge-by-value-copy
2399      -Wliteral-conversion
2400      -Wliteral-range
2401      -Wlocal-type-template-args
2402      -Wlogical-op
2403      -Wloop-analysis
2404      -Wmain-return-type
2405      -Wmalformed-warning-check
2406      -Wmethod-signatures
2407      -Wmicrosoft
2408      -Wmicrosoft-exists
2409      -Wmismatched-parameter-types
2410      -Wmismatched-return-types
2411      -Wmissing-field-initializers
2412      -Wmissing-format-attribute
2413      -Wmissing-noreturn
2414      -Wmissing-selector-name
2415      -Wmissing-sysroot
2416      -Wmissing-variable-declarations
2417      -Wmodule-conflict
2418      -Wnested-anon-types
2419      -Wnewline-eof
2420      -Wnon-literal-null-conversion
2421      -Wnon-pod-varargs
2422      -Wnonportable-cfstrings
2423      -Wnormalized=nfkc
2424      -Wnull-arithmetic
2425      -Wnull-character
2426      -Wnull-conversion
2427      -Wnull-dereference
2428      -Wout-of-line-declaration
2429      -Wover-aligned
2430      -Woverlength-strings
2431      -Woverride-init
2432      -Woverriding-method-mismatch
2433      -Wpointer-type-mismatch
2434      -Wpredefined-identifier-outside-function
2435      -Wprotocol-property-synthesis-ambiguity
2436      -Wreadonly-iboutlet-property
2437      -Wreadonly-setter-attrs
2438      -Wreceiver-expr
2439      -Wreceiver-forward-class
2440      -Wreceiver-is-weak
2441      -Wreinterpret-base-class
2442      -Wrequires-super-attribute
2443      -Wreserved-user-defined-literal
2444      -Wreturn-stack-address
2445      -Wsection
2446      -Wselector-type-mismatch
2447      -Wsentinel
2448      -Wserialized-diagnostics
2449      -Wshadow
2450      -Wshift-count-negative
2451      -Wshift-count-overflow
2452      -Wshift-negative-value
2453      -Wshift-overflow=2
2454      -Wshift-sign-overflow
2455      -Wshorten-64-to-32
2456      -Wsizeof-array-argument
2457      -Wsource-uses-openmp
2458      -Wstatic-float-init
2459      -Wstatic-in-inline
2460      -Wstatic-local-in-inline
2461      -Wstrict-overflow=1
2462      -Wstring-compare
2463      -Wstring-conversion
2464      -Wstrlcpy-strlcat-size
2465      -Wstrncat-size
2466      -Wsuggest-attribute=format
2467      -Wsuggest-attribute=noreturn
2468      -Wsuper-class-method-mismatch
2469      -Wswitch-bool
2470      -Wsync-nand
2471      -Wtautological-constant-out-of-range-compare
2472      -Wtentative-definition-incomplete-type
2473      -Wtrampolines
2474      -Wtype-safety
2475      -Wtypedef-redefinition
2476      -Wtypename-missing
2477      -Wundefined-inline
2478      -Wundefined-internal
2479      -Wundefined-reinterpret-cast
2480      -Wunicode
2481      -Wunicode-whitespace
2482      -Wunknown-warning-option
2483      -Wunnamed-type-template-args
2484      -Wunneeded-member-function
2485      -Wunsequenced
2486      -Wunsupported-visibility
2487      -Wunused-but-set-parameter
2488      -Wunused-but-set-variable
2489      -Wunused-command-line-argument
2490      -Wunused-const-variable=2
2491      -Wunused-exception-parameter
2492      -Wunused-local-typedefs
2493      -Wunused-member-function
2494      -Wunused-sanitize-argument
2495      -Wunused-volatile-lvalue
2496      -Wuser-defined-literals
2497      -Wvariadic-macros
2498      -Wvector-conversion
2499      -Wvector-conversions
2500      -Wvexing-parse
2501      -Wvisibility
2502      -Wvla-extension
2503      -Wzero-length-array
2504   ], [ TOR_TRY_COMPILE_WITH_CFLAGS(warning_flag, [],
2505               [TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS warning_flag" CFLAGS="$CFLAGS warning_flag"], true)
2506      ])
2508 dnl    We should re-enable this in some later version.  Clang doesn't
2509 dnl    mind, but it causes trouble with GCC.
2510 dnl     -Wstrict-overflow=2
2512 dnl    These seem to require annotations that we don't currently use,
2513 dnl    and they give false positives in our pthreads wrappers. (Clang 4)
2514 dnl     -Wthread-safety
2515 dnl     -Wthread-safety-analysis
2516 dnl     -Wthread-safety-attributes
2517 dnl     -Wthread-safety-beta
2518 dnl     -Wthread-safety-precise
2520   W_FLAGS="$W_FLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
2521   W_FLAGS="$W_FLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
2522   W_FLAGS="$W_FLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
2523   W_FLAGS="$W_FLAGS -Wwrite-strings"
2524   W_FLAGS="$W_FLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
2525   W_FLAGS="$W_FLAGS -Waggregate-return -Wpacked -Wunused"
2526   W_FLAGS="$W_FLAGS -Wunused-parameter "
2527   # These interfere with building main() { return 0; }, which autoconf
2528   # likes to use as its default program.
2529   W_FLAGS="$W_FLAGS -Wold-style-definition -Wmissing-declarations"
2531   TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS $W_FLAGS"
2532   CFLAGS="$CFLAGS $W_FLAGS"
2534   if test "$tor_cv_cflags__Wnull_dereference" = "yes"; then
2535     AC_DEFINE([HAVE_CFLAG_WNULL_DEREFERENCE], 1, [True if we have -Wnull-dereference])
2536   fi
2537   if test "$tor_cv_cflags__Woverlength_strings" = "yes"; then
2538     AC_DEFINE([HAVE_CFLAG_WOVERLENGTH_STRINGS], 1, [True if we have -Woverlength-strings])
2539   fi
2540   if test "$tor_cv_cflags__warn_unused_const_variable_2" = "yes"; then
2541     AC_DEFINE([HAVE_CFLAG_WUNUSED_CONST_VARIABLE], 1, [True if we have -Wunused-const-variable])
2542   fi
2544   CFLAGS="$CFLAGS_NOWARNINGS"
2546   if test "x$enable_fatal_warnings" = "xyes"; then
2547     # I'd like to use TOR_CHECK_CFLAGS here, but I can't, since the
2548     # default autoconf programs are full of errors.
2549     CFLAGS="$CFLAGS -Werror"
2550   fi
2554 AC_SUBST(TOR_WARNING_FLAGS)
2556 echo "$TOR_WARNING_FLAGS">warning_flags
2558 TOR_TRY_COMPILE_WITH_CFLAGS([@warning_flags], [],
2559                             CFLAGS="$CFLAGS @warning_flags",
2560                             CFLAGS="$CFLAGS $TOR_WARNING_FLAGS")
2562 if test "$enable_coverage" = "yes" && test "$have_clang" = "no"; then
2563    case "$host_os" in
2564     darwin*)
2565       tor_incr_n_warnings
2566       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.])
2567    esac
2570 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
2572 AC_CONFIG_FILES([
2573         Doxyfile
2574         Makefile
2575         contrib/operator-tools/tor.logrotate
2576         src/config/torrc.sample
2577         src/config/torrc.minimal
2578         scripts/maint/checkOptionDocs.pl
2579         warning_flags
2582 if test "x$asciidoc" = "xtrue" && test "$ASCIIDOC" = "none"; then
2583   regular_mans="doc/man/tor doc/man/tor-gencert doc/man/tor-resolve doc/man/torify"
2584   for file in $regular_mans ; do
2585     if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
2586       echo "==================================";
2587       echo;
2588       echo "Building Tor has failed since manpages cannot be built.";
2589       echo;
2590       echo "You need asciidoc installed to be able to build the manpages.";
2591       echo "To build without manpages, use the --disable-asciidoc argument";
2592       echo "when calling configure.";
2593       echo;
2594       echo "==================================";
2595       exit 1;
2596     fi
2597   done
2600 if test "$fragile_hardening" = "yes"; then
2601   tor_incr_n_warnings
2602   AC_MSG_WARN([
2604 ============
2605 Warning!  Building Tor with --enable-fragile-hardening (also known as
2606 --enable-expensive-hardening) makes some kinds of attacks harder, but makes
2607 other kinds of attacks easier. A Tor instance build with this option will be
2608 somewhat less vulnerable to remote code execution, arithmetic overflow, or
2609 out-of-bounds read/writes... but at the cost of becoming more vulnerable to
2610 denial of service attacks. For more information, see
2611 https://gitlab.torproject.org/tpo/core/team/-/wikis/TorFragileHardening
2612 ============
2613   ])
2616 AC_OUTPUT
2618 if test "$openssl_ver_mismatch" = "yes"; then
2619    tor_incr_n_warnings
2620    AC_MSG_WARN([
2621 ============
2622 Warning! The version OpenSSL headers we get from compiling with
2623     "${TOR_CPPFLAGS_OPENSSL:-(no extra options)}"
2624 do not match version of the OpenSSL library we get when linking with
2625     "$TOR_LDFLAGS_OPENSSL $TOR_OPENSSL_LIBS".
2626 This might cause compilation to fail. Try using --with-openssl-dir to specify
2627 the exact OpenSSL path you want.
2628 ============
2633 # Mini-report on what will be built.
2636 PPRINT_INIT
2637 PPRINT_SET_INDENT(1)
2638 PPRINT_SET_TS(65)
2640 AS_ECHO
2641 AS_ECHO("Tor Version: ${PPRINT_COLOR_BLDBLU}Tor $PACKAGE_VERSION $PPRINT_COLOR_RST")
2642 AS_ECHO
2644 PPRINT_SUBTITLE([Build Features])
2646 PPRINT_PROP_STRING([Compiler], [$CC])
2647 PPRINT_PROP_STRING([Host OS], [$host_os])
2648 AS_ECHO
2650 test "x$enable_fatal_warnings" = "xyes" && value=1 || value=0
2651 PPRINT_PROP_BOOL([Warnings are fatal (--enable-fatal-warnings)], $value)
2653 test "x$enable_android" = "xyes" && value=1 || value=0
2654 PPRINT_PROP_BOOL([Android support (--enable-android)], $value)
2656 AS_ECHO
2657 PPRINT_SUBTITLE([Static Build])
2659 test "x$enable_static_tor" = "xyes" && value=1 || value=0
2660 PPRINT_PROP_BOOL([tor (--enable-static-tor)], $value)
2662 if test "x$enable_static_libevent" = "xyes"; then
2663   PPRINT_PROP_STRING([libevent], [$TOR_LIBDIR_libevent])
2664 else
2665   PPRINT_PROP_BOOL([libevent (--enable-static-libevent)], $value)
2668 if test "x$enable_static_openssl" = "xyes"; then
2669   PPRINT_PROP_STRING([libssl], [$TOR_LIBDIR_openssl])
2670 else
2671   PPRINT_PROP_BOOL([libssl (--enable-static-openssl)], $value)
2674 if test "x$enable_static_zlib" = "xyes"; then
2675   PPRINT_PROP_STRING([zlib1g], [$TOR_LIBDIR_zlib])
2676 else
2677   PPRINT_PROP_BOOL([zlib1g (--enable-static-zlib)], $value)
2680 AS_ECHO
2681 PPRINT_SUBTITLE([Optional Libraries])
2683 test "x$enable_nss" = "xyes" && value=1 || value=0
2684 PPRINT_PROP_BOOL([libnss (--enable-nss)], $value)
2686 test "x$enable_seccomp" != "xno" && value=1 || value=0
2687 PPRINT_PROP_BOOL([libseccomp (--disable-seccomp)], $value)
2689 test "x$enable_libscrypt" != "xno" && value=1 || value=0
2690 PPRINT_PROP_BOOL([libscrypt (--disable-libscrypt)], $value)
2692 test "x$enable_systemd" = "xyes" && value=1 || value=0
2693 PPRINT_PROP_BOOL([Systemd support (--enable-systemd)], $value)
2695 test "x$have_lzma" = "xyes" && value=1 || value=0
2696 PPRINT_PROP_BOOL([liblzma (--enable-lzma)], $value)
2698 test "x$have_zstd" = "xyes" && value=1 || value=0
2699 PPRINT_PROP_BOOL([libzstd (--enable-zstd)], $value)
2701 AS_ECHO
2702 PPRINT_SUBTITLE([Hardening])
2704 test "x$enable_gcc_hardening" != "xno" && value=1 || value=0
2705 PPRINT_PROP_BOOL([Compiler Hardening (--disable-gcc-hardening)], $value)
2707 test "x$enable_linker_hardening" != "xno" && value=1 || value=0
2708 PPRINT_PROP_BOOL([Linker Hardening (--disable-linker-hardening)], $value)
2710 test "x$fragile_hardening" = "xyes" && value=1 || value=0
2711 PPRINT_PROP_BOOL([Fragile Hardening (--enable-fragile-hardening, dev only)], $value)
2713 AS_ECHO
2714 PPRINT_SUBTITLE([Modules])
2716 m4_foreach_w([mname], MODULES,
2717   [
2718     AM_COND_IF(m4_join([], [BUILD_MODULE_], m4_toupper([]mname[])), value=1, value=0)
2719     m4_set_contains([MODULES_WITH_NO_OPTIONS], mname,
2720                     PPRINT_PROP_BOOL([mname], $value),
2721                     PPRINT_PROP_BOOL([mname (--disable-module-mname)], $value))
2722   ]
2725 AS_ECHO
2726 PPRINT_SUBTITLE([Documentation])
2728 test "x$enable_asciidoc" != "xno" && value=1 || value=0
2729 PPRINT_PROP_BOOL([AsciiDoc (--disable-asciidoc)], $value)
2731 test "x$enable_manpage" != "xno" && value=1 || value=0
2732 PPRINT_PROP_BOOL([Man Pages (--disable-manpage)], $value)
2734 test "x$enable_html_manual" != "xno" && value=1 || value=0
2735 PPRINT_PROP_BOOL([HTML Manual (--disable-html-manual)], $value)
2737 AS_ECHO
2738 PPRINT_SUBTITLE([Tests])
2740 test "x$enable_unittests" != "xno" && value=1 || value=0
2741 PPRINT_PROP_BOOL([Unit tests (--disable-unittests)], $value)
2743 test "x$enable_asserts_in_tests" = "xno" && value=1 || value=0
2744 PPRINT_PROP_BOOL([assert()s enabled (--enable-asserts-in-tests, dev only)], $value)
2746 test "x$enable_coverage" = "xyes" && value=1 || value=0
2747 PPRINT_PROP_BOOL([Code Coverage (--enable-coverage)], $value)
2749 test "x$enable_libfuzzer" = "xyes" && value=1 || value=0
2750 PPRINT_PROP_BOOL([libFuzzer support (--enable-libfuzzer)], $value)
2752 test "x$enable_oss_fuzz" = "xyes" && value=1 || value=0
2753 PPRINT_PROP_BOOL([OSS-Fuzz support (--enable-oss-fuzz)], $value)
2755 AS_ECHO
2756 PPRINT_SUBTITLE([Tracing (--enable-tracing-instrumentation-<type>)])
2758 test "x$enable_tracing_instrumentation_log_debug" = "xyes" && value=1 || value=0
2759 PPRINT_PROP_BOOL([Tracepoints to log_debug() (log-debug)], $value)
2761 test "x$enable_tracing_instrumentation_usdt" = "xyes" && value=1 || value=0
2762 PPRINT_PROP_BOOL([USDT Instrumentation (usdt)], $value)
2764 test "x$enable_tracing_instrumentation_lttng" = "xyes" && value=1 || value=0
2765 PPRINT_PROP_BOOL([LTTng Instrumentation (lttng)], $value)
2767 AS_ECHO
2768 PPRINT_SUBTITLE([Install Directories])
2770 report_mandir="`eval eval echo $mandir`"
2771 PPRINT_PROP_STRING([Binaries], [$BINDIR])
2772 PPRINT_PROP_STRING([Configuration], [$CONFDIR])
2773 PPRINT_PROP_STRING([Man Pages], [$report_mandir])
2775 AS_ECHO
2776 AS_ECHO(["Configure Line: ./configure $configure_flags"])
2778 if test "$tor_ac_n_warnings" != "0"; then
2779   AS_ECHO
2780   PPRINT_WARN([
2781 Encountered $tor_ac_n_warnings warning(s). See messages above for more info.
2782   ])