Edits on 0.4.4.1-alpha changelog
[tor.git] / configure.ac
blob2fb680572b1ffe8cf9863445735ec1b1e68ea81f
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.4.1-alpha])
8 AC_CONFIG_SRCDIR([src/app/main/tor_main.c])
9 AC_CONFIG_MACRO_DIR([m4])
11 configure_flags="$*"
13 # DO NOT EDIT THIS DEFINITION BY HAND UNLESS YOU KNOW WHAT YOU'RE DOING.
15 # The update_versions.py script updates this definition when the
16 # version number changes.  Tor uses it to make sure that it
17 # only shuts down for missing "required protocols" when those protocols
18 # are listed as required by a consensus after this date.
19 AC_DEFINE(APPROX_RELEASE_DATE, ["2020-06-15"], # for 0.4.4.1-alpha
20           [Approximate date when this software was released. (Updated when the version changes.)])
22 # "foreign" means we don't follow GNU package layout standards
23 # "1.11" means we require automake version 1.11 or newer
24 # "subdir-objects" means put .o files in the same directory as the .c files
25 AM_INIT_AUTOMAKE([foreign 1.11 subdir-objects -Wall -Werror])
27 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
28 AC_CONFIG_HEADERS([orconfig.h])
30 AC_USE_SYSTEM_EXTENSIONS
31 AC_CANONICAL_HOST
33 PKG_PROG_PKG_CONFIG
34 if test "x$PKG_CONFIG" = "x" ; then
35     pkg_config_user_action="install pkg-config, and check the PKG_CONFIG_PATH environment variable"
36     AC_MSG_NOTICE([Some libraries need pkg-config, including systemd, nss, lzma, zstd, and custom mallocs.])
37     AC_MSG_NOTICE([To use those libraries, $pkg_config_user_action.])
38 else
39     pkg_config_user_action="check the PKG_CONFIG_PATH environment variable"
42 if test "x$PKG_CONFIG_PATH" = "x" && test "x$prefix" != "xNONE" && test "$host" != "$build"; then
43    export PKG_CONFIG_PATH=$prefix/lib/pkgconfig
44    AC_MSG_NOTICE([set PKG_CONFIG_PATH=$PKG_CONFIG_PATH to support cross-compiling])
47 AC_ARG_ENABLE(openbsd-malloc,
48    AS_HELP_STRING(--enable-openbsd-malloc, [use malloc code from OpenBSD.  Linux only. Deprecated: see --with-malloc]))
49 AC_ARG_ENABLE(static-openssl,
50    AS_HELP_STRING(--enable-static-openssl, [link against a static openssl library. Requires --with-openssl-dir]))
51 AC_ARG_ENABLE(static-libevent,
52    AS_HELP_STRING(--enable-static-libevent, [link against a static libevent library. Requires --with-libevent-dir]))
53 AC_ARG_ENABLE(static-zlib,
54    AS_HELP_STRING(--enable-static-zlib, [link against a static zlib library. Requires --with-zlib-dir]))
55 AC_ARG_ENABLE(static-tor,
56    AS_HELP_STRING(--enable-static-tor, [create an entirely static Tor binary. Requires --with-openssl-dir and --with-libevent-dir and --with-zlib-dir]))
57 AC_ARG_ENABLE(unittests,
58    AS_HELP_STRING(--disable-unittests, [don't build unit tests for Tor. Risky!]))
59 AC_ARG_ENABLE(coverage,
60    AS_HELP_STRING(--enable-coverage, [enable coverage support in the unit-test build]))
61 AC_ARG_ENABLE(asserts-in-tests,
62    AS_HELP_STRING(--disable-asserts-in-tests, [disable tor_assert() calls in the unit tests, for branch coverage]))
63 AC_ARG_ENABLE(system-torrc,
64    AS_HELP_STRING(--disable-system-torrc, [don't look for a system-wide torrc file]))
65 AC_ARG_ENABLE(libfuzzer,
66    AS_HELP_STRING(--enable-libfuzzer, [build extra fuzzers based on 'libfuzzer']))
67 AC_ARG_ENABLE(oss-fuzz,
68    AS_HELP_STRING(--enable-oss-fuzz, [build extra fuzzers based on 'oss-fuzz' environment]))
69 AC_ARG_ENABLE(memory-sentinels,
70    AS_HELP_STRING(--disable-memory-sentinels, [disable code that tries to prevent some kinds of memory access bugs. For fuzzing only.]))
71 AC_ARG_ENABLE(rust,
72    AS_HELP_STRING(--enable-rust, [enable rust integration]))
73 AC_ARG_ENABLE(cargo-online-mode,
74    AS_HELP_STRING(--enable-cargo-online-mode, [Allow cargo to make network requests to fetch crates. For builds with rust only.]))
75 AC_ARG_ENABLE(restart-debugging,
76    AS_HELP_STRING(--enable-restart-debugging, [Build Tor with support for debugging in-process restart. Developers only.]))
77 AC_ARG_ENABLE(zstd-advanced-apis,
78    AS_HELP_STRING(--disable-zstd-advanced-apis, [Build without support for zstd's "static-only" APIs.]))
79 AC_ARG_ENABLE(nss,
80    AS_HELP_STRING(--enable-nss, [Use Mozilla's NSS TLS library. (EXPERIMENTAL)]))
81 AC_ARG_ENABLE(pic,
82    AS_HELP_STRING(--enable-pic, [Build Tor's binaries as position-independent code, suitable to link as a library.]))
84 AC_ARG_ENABLE(missing-doc-warnings,
85    AS_HELP_STRING(--enable-missing-doc-warnings, [Tell doxygen to warn about missing documentation. Makes doxygen warnings nonfatal.]))
87 if test "$enable_missing_doc_warnings" = "yes"; then
88    DOXYGEN_FATAL_WARNINGS=NO
89    DOXYGEN_WARN_ON_MISSING=YES
90 elif test "$enable_fatal_warnings" = "yes"; then
91    # Fatal warnings from doxygen are nice, but not if we're warning about
92    # missing documentation.
93    DOXYGEN_FATAL_WARNINGS=YES
94    DOXYGEN_WARN_ON_MISSING=NO
95 else
96    DOXYGEN_FATAL_WARNINGS=NO
97    DOXYGEN_WARN_ON_MISSING=NO
99 AC_SUBST(DOXYGEN_FATAL_WARNINGS)
100 AC_SUBST(DOXYGEN_WARN_ON_MISSING)
102 if test "x$enable_coverage" != "xyes" -a "x$enable_asserts_in_tests" = "xno" ; then
103     AC_MSG_ERROR([Can't disable assertions outside of coverage build])
106 AM_CONDITIONAL(UNITTESTS_ENABLED, test "x$enable_unittests" != "xno")
107 AM_CONDITIONAL(COVERAGE_ENABLED, test "x$enable_coverage" = "xyes")
108 AM_CONDITIONAL(DISABLE_ASSERTS_IN_UNIT_TESTS, test "x$enable_asserts_in_tests" = "xno")
109 AM_CONDITIONAL(LIBFUZZER_ENABLED, test "x$enable_libfuzzer" = "xyes")
110 AM_CONDITIONAL(OSS_FUZZ_ENABLED, test "x$enable_oss_fuzz" = "xyes")
111 AM_CONDITIONAL(USE_RUST, test "x$enable_rust" = "xyes")
112 AM_CONDITIONAL(USE_NSS, test "x$enable_nss" = "xyes")
113 AM_CONDITIONAL(USE_OPENSSL, test "x$enable_nss" != "xyes")
115 if test "x$enable_nss" = "xyes"; then
116   AC_DEFINE(ENABLE_NSS, 1,
117             [Defined if we're building with NSS.])
118 else
119   AC_DEFINE(ENABLE_OPENSSL, 1,
120             [Defined if we're building with OpenSSL or LibreSSL])
123 if test "$enable_static_tor" = "yes"; then
124   enable_static_libevent="yes";
125   enable_static_openssl="yes";
126   enable_static_zlib="yes";
127   CFLAGS="$CFLAGS -static"
130 if test "$enable_system_torrc" = "no"; then
131   AC_DEFINE(DISABLE_SYSTEM_TORRC, 1,
132             [Defined if we're not going to look for a torrc in SYSCONF])
135 if test "$enable_memory_sentinels" = "no"; then
136   AC_DEFINE(DISABLE_MEMORY_SENTINELS, 1,
137            [Defined if we're turning off memory safety code to look for bugs])
140 AC_ARG_ENABLE(manpage,
141               AS_HELP_STRING(--disable-manpage, [Disable manpage generation.]))
143 AC_ARG_ENABLE(html-manual,
144               AS_HELP_STRING(--disable-html-manual, [Disable HTML documentation.]))
146 AC_ARG_ENABLE(asciidoc,
147      AS_HELP_STRING(--disable-asciidoc, [don't use asciidoc (disables building of manpages)]),
148      [case "${enableval}" in
149         "yes") asciidoc=true ;;
150         "no")  asciidoc=false ;;
151         *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
152       esac], [asciidoc=true])
154 # systemd notify support
155 AC_ARG_ENABLE(systemd,
156       AS_HELP_STRING(--enable-systemd, [enable systemd notification support]),
157       [case "${enableval}" in
158         "yes") systemd=true ;;
159         "no")  systemd=false ;;
160         * ) AC_MSG_ERROR(bad value for --enable-systemd) ;;
161       esac], [systemd=auto])
163 if test "$enable_restart_debugging" = "yes"; then
164   AC_DEFINE(ENABLE_RESTART_DEBUGGING, 1,
165             [Defined if we're building with support for in-process restart debugging.])
168 if test "$enable_zstd_advanced_apis" != "no"; then
169    AC_DEFINE(ENABLE_ZSTD_ADVANCED_APIS, 1,
170              [Defined if we're going to try to use zstd's "static-only" APIs.])
173 # systemd support
174 if test "x$enable_systemd" = "xno"; then
175     have_systemd=no;
176 else
177     PKG_CHECK_MODULES(SYSTEMD,
178         [libsystemd-daemon],
179         have_systemd=yes,
180         have_systemd=no)
181     if test "x$have_systemd" = "xno"; then
182         AC_MSG_NOTICE([Okay, checking for systemd a different way...])
183         PKG_CHECK_MODULES(SYSTEMD,
184             [libsystemd],
185             have_systemd=yes,
186             have_systemd=no)
187     fi
190 if test "x$have_systemd" = "xyes"; then
191     AC_DEFINE(HAVE_SYSTEMD,1,[Have systemd])
192     TOR_SYSTEMD_CFLAGS="${SYSTEMD_CFLAGS}"
193     TOR_SYSTEMD_LIBS="${SYSTEMD_LIBS}"
194     PKG_CHECK_MODULES(LIBSYSTEMD209, [libsystemd >= 209],
195          [AC_DEFINE(HAVE_SYSTEMD_209,1,[Have systemd v209 or greater])], [])
197 AC_SUBST(TOR_SYSTEMD_CFLAGS)
198 AC_SUBST(TOR_SYSTEMD_LIBS)
200 if test "x$enable_systemd" = "xyes" -a "x$have_systemd" != "xyes" ; then
201     AC_MSG_ERROR([Explicitly requested systemd support, but systemd not found, $pkg_config_user_action, or set SYSTEMD_CFLAGS and SYSTEMD_LIBS.])
204 case "$host" in
205    *-*-solaris* )
206      AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
207      ;;
208 esac
210 AC_ARG_ENABLE(gcc-warnings,
211      AS_HELP_STRING(--enable-gcc-warnings, [deprecated alias for enable-fatal-warnings]))
212 AC_ARG_ENABLE(fatal-warnings,
213      AS_HELP_STRING(--enable-fatal-warnings, [tell the compiler to treat all warnings as errors.]))
214 AC_ARG_ENABLE(gcc-warnings-advisory,
215      AS_HELP_STRING(--disable-gcc-warnings-advisory, [disable the regular verbose warnings]))
217 dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
218 AC_ARG_ENABLE(gcc-hardening,
219     AS_HELP_STRING(--disable-gcc-hardening, [disable compiler security checks]))
221 dnl Deprecated --enable-expensive-hardening but keep it for now for backward compat.
222 AC_ARG_ENABLE(expensive-hardening,
223     AS_HELP_STRING(--enable-expensive-hardening, [enable more fragile and expensive compiler hardening; makes Tor slower]))
224 AC_ARG_ENABLE(fragile-hardening,
225     AS_HELP_STRING(--enable-fragile-hardening, [enable more fragile and expensive compiler hardening; makes Tor slower]))
226 if test "x$enable_expensive_hardening" = "xyes" || test "x$enable_fragile_hardening" = "xyes"; then
227   fragile_hardening="yes"
228   AC_DEFINE(DEBUG_SMARTLIST, 1, [Enable smartlist debugging])
231 AC_ARG_ENABLE(all-bugs-are-fatal,
232    AS_HELP_STRING(--enable-all-bugs-are-fatal, [force all soft asserts in Tor codebase (tor_assert_nonfatal(), BUG(), etc.) to act as hard asserts (tor_assert() and equivalents); makes Tor fragile; only recommended for dev builds]))
234 if test "x$enable_all_bugs_are_fatal" = "xyes"; then
235   AC_DEFINE(ALL_BUGS_ARE_FATAL, 1, [All assert failures are fatal])
238 dnl Linker hardening options
239 dnl Currently these options are ELF specific - you can't use this with MacOSX
240 AC_ARG_ENABLE(linker-hardening,
241     AS_HELP_STRING(--disable-linker-hardening, [disable linker security fixups]))
243 AC_ARG_ENABLE(local-appdata,
244    AS_HELP_STRING(--enable-local-appdata, [default to host local application data paths on Windows]))
245 if test "$enable_local_appdata" = "yes"; then
246   AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
247             [Defined if we default to host local appdata paths on Windows])
250 AC_ARG_ENABLE(tool-name-check,
251      AS_HELP_STRING(--disable-tool-name-check, [check for sanely named toolchain when cross-compiling]))
253 AC_ARG_ENABLE(seccomp,
254      AS_HELP_STRING(--disable-seccomp, [do not attempt to use libseccomp]))
256 AC_ARG_ENABLE(libscrypt,
257      AS_HELP_STRING(--disable-libscrypt, [do not attempt to use libscrypt]))
259 dnl Enable event tracing which are transformed to debug log statement.
260 AC_ARG_ENABLE(event-tracing-debug,
261      AS_HELP_STRING(--enable-event-tracing-debug, [build with event tracing to debug log]))
262 AM_CONDITIONAL([USE_EVENT_TRACING_DEBUG], [test "x$enable_event_tracing_debug" = "xyes"])
264 if test x$enable_event_tracing_debug = xyes; then
265   AC_DEFINE([USE_EVENT_TRACING_DEBUG], [1], [Tracing framework to log debug])
266   AC_DEFINE([TOR_EVENT_TRACING_ENABLED], [1], [Compile the event tracing instrumentation])
269 dnl Enable Android only features.
270 AC_ARG_ENABLE(android,
271      AS_HELP_STRING(--enable-android, [build with Android features enabled]))
272 AM_CONDITIONAL([USE_ANDROID], [test "x$enable_android" = "xyes"])
274 if test "x$enable_android" = "xyes"; then
275   AC_DEFINE([USE_ANDROID], [1], [Compile with Android specific features enabled])
277   dnl Check if the Android log library is available.
278   AC_CHECK_HEADERS([android/log.h])
279   AC_SEARCH_LIBS(__android_log_write, [log])
283 dnl ---
284 dnl Tor modules options. These options are namespaced with --disable-module-XXX
285 dnl ---
287 dnl All our modules.
288 m4_define(MODULES, relay dirauth dircache)
290 dnl Relay module.
291 AC_ARG_ENABLE([module-relay],
292               AS_HELP_STRING([--disable-module-relay],
293                              [Build tor without the Relay modules: tor can not run as a relay, bridge, or authority. Implies --disable-module-dirauth]))
294 AM_CONDITIONAL(BUILD_MODULE_RELAY, [test "x$enable_module_relay" != "xno"])
295 AM_COND_IF(BUILD_MODULE_RELAY,
296            AC_DEFINE([HAVE_MODULE_RELAY], [1],
297                      [Compile with Relay feature support]))
299 dnl Dircache module.  (This cannot be enabled or disabled independently of
300 dnl the relay module.  It is not listed by --list-modules for this reason.)
301 AM_CONDITIONAL(BUILD_MODULE_DIRCACHE,
302                [test "x$enable_module_relay" != "xno"])
303 AM_COND_IF(BUILD_MODULE_DIRCACHE,
304            AC_DEFINE([HAVE_MODULE_DIRCACHE], [1],
305                      [Compile with directory cache support]))
307 dnl Directory Authority module.
308 AC_ARG_ENABLE([module-dirauth],
309               AS_HELP_STRING([--disable-module-dirauth],
310                              [Build tor without the Directory Authority module: tor can not run as a directory authority or bridge authority]))
311 AM_CONDITIONAL(BUILD_MODULE_DIRAUTH,[test "x$enable_module_dirauth" != "xno" && test "x$enable_module_relay" != "xno"])
312 AM_COND_IF(BUILD_MODULE_DIRAUTH,
313            AC_DEFINE([HAVE_MODULE_DIRAUTH], [1],
314                      [Compile with Directory Authority feature support]))
316 dnl Helper variables.
317 TOR_MODULES_ALL_ENABLED=
318 AC_DEFUN([ADD_MODULE], [
319     MODULE=m4_toupper($1)
320     TOR_MODULES_ALL_ENABLED="${TOR_MODULES_ALL_ENABLED} -DHAVE_MODULE_${MODULE}=1"
322 m4_foreach_w([module], MODULES, [ADD_MODULE([module])])
323 AC_SUBST(TOR_MODULES_ALL_ENABLED)
325 dnl check for the correct "ar" when cross-compiling.
326 dnl   (AM_PROG_AR was new in automake 1.11.2, which we do not yet require,
327 dnl    so kludge up a replacement for the case where it isn't there yet.)
328 m4_ifdef([AM_PROG_AR],
329          [AM_PROG_AR],
330          [AN_MAKEVAR([AR], [AC_PROG_AR])
331           AN_PROGRAM([ar], [AC_PROG_AR])
332           AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [:])])
333           AC_PROG_AR])
335 dnl Check whether the above macro has settled for a simply named tool even
336 dnl though we're cross compiling. We must do this before running AC_PROG_CC,
337 dnl because that will find any cc on the system, not only the cross-compiler,
338 dnl and then verify that a binary built with this compiler runs on the
339 dnl build system. It will then come to the false conclusion that we're not
340 dnl cross-compiling.
341 if test "x$enable_tool_name_check" != "xno"; then
342     if test "x$ac_tool_warned" = "xyes"; then
343         AC_MSG_ERROR([We are cross compiling but could not find a properly named toolchain. Do you have your cross-compiling toolchain in PATH? (You can --disable-tool-name-check to ignore this.)])
344         elif test "x$ac_ct_AR" != "x" -a "x$cross_compiling" = "xmaybe"; then
345                 AC_MSG_ERROR([We think we are cross compiling but could not find a properly named toolchain. Do you have your cross-compiling toolchain in PATH? (You can --disable-tool-name-check to ignore this.)])
346         fi
349 AC_PROG_CC
350 AC_PROG_CPP
351 AC_PROG_MAKE_SET
352 AC_PROG_RANLIB
353 AC_PROG_SED
355 AC_ARG_VAR([PERL], [path to Perl binary])
356 AC_CHECK_PROGS([PERL], [perl])
357 AM_CONDITIONAL(USE_PERL, [test "x$ac_cv_prog_PERL" != "x"])
359 dnl check for asciidoc and a2x
360 AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
361 AC_PATH_PROGS([A2X], [a2x a2x.py], none)
363 AM_CONDITIONAL(USE_ASCIIDOC, test "x$asciidoc" = "xtrue")
364 AM_CONDITIONAL(BUILD_MANPAGE, [test "x$enable_manpage" != "xno"])
365 AM_CONDITIONAL(BUILD_HTML_DOCS, [test "x$enable_html_manual" != "xno"])
367 AM_PROG_CC_C_O
368 AC_PROG_CC_C99
370 AC_CACHE_CHECK([for Python 3], [tor_cv_PYTHON],
371    [AC_PATH_PROGS_FEATURE_CHECK([PYTHON], [ \
372         python3 \
373         python3.8 python3.7 python3.6 python3.5 python3.4 \
374         python ],
375    [["$ac_path_PYTHON" -c 'import sys; sys.exit(sys.version_info[0]<3)' && tor_cv_PYTHON="$ac_path_PYTHON" ac_path_PYTHON_found=:]] )])
376 AC_SUBST([PYTHON], [$tor_cv_PYTHON])
378 PYTHON="$tor_cv_PYTHON"
380 if test "x$PYTHON" = "x"; then
381   AC_MSG_WARN([Python 3 unavailable; some tests will not be run.])
384 AM_CONDITIONAL(USEPYTHON, [test "x$PYTHON" != "x"])
386 dnl List all external rust crates we depend on here. Include the version
387 rust_crates=" \
388     digest-0.7.2 \
389     libc-0.2.39 \
391 AC_SUBST(rust_crates)
393 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
394 AC_C_FLEXIBLE_ARRAY_MEMBER
395 ], [
396  dnl Maybe we've got an old autoconf...
397  AC_CACHE_CHECK([for flexible array members],
398      tor_cv_c_flexarray,
399      [AC_COMPILE_IFELSE(
400        AC_LANG_PROGRAM([
401  struct abc { int a; char b[]; };
402 ], [
403  struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
404  def->b[0] = 33;
406   [tor_cv_c_flexarray=yes],
407   [tor_cv_c_flexarray=no])])
408  if test "$tor_cv_flexarray" = "yes"; then
409    AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
410  else
411    AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
412  fi
415 AC_CACHE_CHECK([for working C99 mid-block declaration syntax],
416       tor_cv_c_c99_decl,
417       [AC_COMPILE_IFELSE(
418          [AC_LANG_PROGRAM([], [int x; x = 3; int y; y = 4 + x;])],
419          [tor_cv_c_c99_decl=yes],
420          [tor_cv_c_c99_decl=no] )])
421 if test "$tor_cv_c_c99_decl" != "yes"; then
422   AC_MSG_ERROR([Your compiler doesn't support c99 mid-block declarations. This is required as of Tor 0.2.6.x])
425 AC_CACHE_CHECK([for working C99 designated initializers],
426       tor_cv_c_c99_designated_init,
427       [AC_COMPILE_IFELSE(
428          [AC_LANG_PROGRAM([struct s { int a; int b; };],
429                [[ struct s ss = { .b = 5, .a = 6 }; ]])],
430          [tor_cv_c_c99_designated_init=yes],
431          [tor_cv_c_c99_designated_init=no] )])
433 if test "$tor_cv_c_c99_designated_init" != "yes"; then
434   AC_MSG_ERROR([Your compiler doesn't support c99 designated initializers. This is required as of Tor 0.2.6.x])
437 saved_CFLAGS="$CFLAGS"
438 CFLAGS="$CFLAGS -Werror"
439 AC_CACHE_CHECK([for __attribute__((fallthrough))],
440       tor_cv_c_attr_fallthrough,
441       [AC_COMPILE_IFELSE(
442          [AC_LANG_PROGRAM([extern int x; void fn(void) ;],
443                [[ switch (x) { case 1: fn(); __attribute__((fallthrough));
444                                case 2: fn(); break; } ]])],
445          [tor_cv_c_attr_fallthrough=yes],
446          [tor_cv_c_attr_fallthrough=no] )])
447 CFLAGS="$saved_CFLAGS"
449 if test "$tor_cv_c_attr_fallthrough" = "yes"; then
450   AC_DEFINE(HAVE_ATTR_FALLTHROUGH, [1], [defined if we have the fallthrough attribute.])
453 TORUSER=_tor
454 AC_ARG_WITH(tor-user,
455         AS_HELP_STRING(--with-tor-user=NAME, [specify username for tor daemon]),
456         [
457            TORUSER=$withval
458         ]
460 AC_SUBST(TORUSER)
462 TORGROUP=_tor
463 AC_ARG_WITH(tor-group,
464         AS_HELP_STRING(--with-tor-group=NAME, [specify group name for tor daemon]),
465         [
466            TORGROUP=$withval
467         ]
469 AC_SUBST(TORGROUP)
472 dnl If _WIN32 is defined and non-zero, we are building for win32
473 AC_MSG_CHECKING([for win32])
474 AC_RUN_IFELSE([AC_LANG_SOURCE([
475 int main(int c, char **v) {
476 #ifdef _WIN32
477 #if _WIN32
478   return 0;
479 #else
480   return 1;
481 #endif
482 #else
483   return 2;
484 #endif
485 }])],
486 bwin32=true; AC_MSG_RESULT([yes]),
487 bwin32=false; AC_MSG_RESULT([no]),
488 bwin32=cross; AC_MSG_RESULT([cross])
491 if test "$bwin32" = "cross"; then
492 AC_MSG_CHECKING([for win32 (cross)])
493 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
494 #ifdef _WIN32
495 int main(int c, char **v) {return 0;}
496 #else
497 #error
498 int main(int c, char **v) {return x(y);}
499 #endif
500 ])],
501 bwin32=true; AC_MSG_RESULT([yes]),
502 bwin32=false; AC_MSG_RESULT([no]))
505 AH_BOTTOM([
506 #ifdef _WIN32
507 /* Defined to access windows functions and definitions for >=WinXP */
508 # ifndef WINVER
509 #  define WINVER 0x0501
510 # endif
512 /* Defined to access _other_ windows functions and definitions for >=WinXP */
513 # ifndef _WIN32_WINNT
514 #  define _WIN32_WINNT 0x0501
515 # endif
517 /* Defined to avoid including some windows headers as part of Windows.h */
518 # ifndef WIN32_LEAN_AND_MEAN
519 #  define WIN32_LEAN_AND_MEAN 1
520 # endif
521 #endif
524 AM_CONDITIONAL(WIN32, test "x$bwin32" = "xtrue")
525 AM_CONDITIONAL(BUILD_NT_SERVICES, test "x$bwin32" = "xtrue")
526 AM_CONDITIONAL(BUILD_LIBTORRUNNER, test "x$bwin32" != "xtrue")
528 dnl Enable C99 when compiling with MIPSpro
529 AC_MSG_CHECKING([for MIPSpro compiler])
530 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
531 #if (defined(__sgi) && defined(_COMPILER_VERSION))
532 #error
533   return x(y);
534 #endif
535 ])],
536 bmipspro=false; AC_MSG_RESULT(no),
537 bmipspro=true; AC_MSG_RESULT(yes))
539 if test "$bmipspro" = "true"; then
540   CFLAGS="$CFLAGS -c99"
543 AC_C_BIGENDIAN
545 AC_ARG_VAR([TOR_RUST_TARGET], [Rust target, must be specified when cross-compiling (HOST != BUILD). example: i686-pc-windows-gnu])
547 if test "x$enable_rust" = "xyes"; then
548   AC_ARG_VAR([RUSTC], [path to the rustc binary])
549   AC_CHECK_PROG([RUSTC], [rustc], [rustc],[no])
550   if test "x$RUSTC" = "xno"; then
551     AC_MSG_ERROR([rustc unavailable but rust integration requested.])
552   fi
554   AC_ARG_VAR([CARGO], [path to the cargo binary])
555   AC_CHECK_PROG([CARGO], [cargo], [cargo],[no])
556   if test "x$CARGO" = "xno"; then
557     AC_MSG_ERROR([cargo unavailable but rust integration requested.])
558   fi
560   AC_DEFINE([HAVE_RUST], 1, [have Rust])
561   if test "x$enable_fatal_warnings" = "xyes"; then
562     RUST_WARN=
563   else
564     RUST_WARN=#
565   fi
566   if test "x$enable_cargo_online_mode" = "xyes"; then
567     CARGO_ONLINE=
568     RUST_DL=#
569   else
570     CARGO_ONLINE=--frozen
571     RUST_DL=
573     dnl When we're not allowed to touch the network, we need crate dependencies
574     dnl locally available.
575     AC_MSG_CHECKING([rust crate dependencies])
576     AC_ARG_VAR([TOR_RUST_DEPENDENCIES], [path to directory with local crate mirror])
577     if test "x$TOR_RUST_DEPENDENCIES" = "x"; then
578       TOR_RUST_DEPENDENCIES="${srcdir}/src/ext/rust/crates"
579     fi
580     dnl Check whether the path exists before we try to cd into it.
581     if test ! -d "$TOR_RUST_DEPENDENCIES"; then
582       AC_MSG_ERROR([Rust dependency directory $TOR_RUST_DEPENDENCIES does not exist. Specify a dependency directory using the TOR_RUST_DEPENDENCIES variable or allow cargo to fetch crates using --enable-cargo-online-mode.])
583       ERRORED=1
584     fi
585     dnl Make the path absolute, since we'll be using it from within a
586     dnl subdirectory.
587     TOR_RUST_DEPENDENCIES=$(cd "$TOR_RUST_DEPENDENCIES" ; pwd)
589     for dep in $rust_crates; do
590       if test ! -d "$TOR_RUST_DEPENDENCIES"/"$dep"; then
591         AC_MSG_ERROR([Failure to find rust dependency $TOR_RUST_DEPENDENCIES/$dep. Specify a dependency directory using the TOR_RUST_DEPENDENCIES variable or allow cargo to fetch crates using --enable-cargo-online-mode.])
592         ERRORED=1
593       fi
594     done
595     if test "x$ERRORED" = "x"; then
596       AC_MSG_RESULT([yes])
597     fi
598   fi
600   dnl For now both MSVC and MinGW rust libraries will output static libs with
601   dnl the MSVC naming convention.
602   if test "$bwin32" = "true"; then
603     tor_rust_static_name=tor_rust.lib
604   else
605     tor_rust_static_name=libtor_rust.a
606   fi
608   AC_CANONICAL_BUILD
610   if test -n "$TOR_RUST_TARGET"; then
611     if test "$host" = "$build"; then
612       AC_MSG_ERROR([HOST = BUILD is invalid if TOR_RUST_TARGET is specified, see configure --help for more information.])
613     fi
614     RUST_TARGET_PROP="target = '$TOR_RUST_TARGET'"
615     TOR_RUST_LIB_PATH="src/rust/target/$TOR_RUST_TARGET/release/$tor_rust_static_name"
616   else
617     if test "$host" != "$build"; then
618       AC_MSG_ERROR([TOR_RUST_TARGET must be specified when cross-compiling with Rust enabled.])
619     fi
620     RUST_TARGET_PROP=
621     TOR_RUST_LIB_PATH="src/rust/target/release/$tor_rust_static_name"
622   fi
624   AC_SUBST(RUST_TARGET_PROP)
625   AC_SUBST(TOR_RUST_LIB_PATH)
626   AC_SUBST(CARGO_ONLINE)
627   AC_SUBST(RUST_WARN)
628   AC_SUBST(RUST_DL)
630   dnl Let's check the rustc version, too
631   AC_MSG_CHECKING([rust version])
632   RUSTC_VERSION=`$RUSTC --version`
633   RUSTC_VERSION_MAJOR=`$RUSTC --version | cut -d ' ' -f 2 | cut -d '.' -f 1`
634   RUSTC_VERSION_MINOR=`$RUSTC --version | cut -d ' ' -f 2 | cut -d '.' -f 2`
635   if test "x$RUSTC_VERSION_MAJOR" = "x" -o "x$RUSTC_VERSION_MINOR" = "x"; then
636     AC_MSG_ERROR([rustc version couldn't be identified])
637   fi
638   if test "$RUSTC_VERSION_MAJOR" -lt 2 -a "$RUSTC_VERSION_MINOR" -lt 31; then
639     AC_MSG_ERROR([rustc must be at least version 1.31.0])
640   fi
641   AC_MSG_RESULT([$RUSTC_VERSION])
644 AC_SEARCH_LIBS(socket, [socket network])
645 AC_SEARCH_LIBS(gethostbyname, [nsl])
646 AC_SEARCH_LIBS(dlopen, [dl])
647 AC_SEARCH_LIBS(inet_aton, [resolv])
648 AC_SEARCH_LIBS(backtrace, [execinfo])
649 saved_LIBS="$LIBS"
650 AC_SEARCH_LIBS([clock_gettime], [rt])
651 if test "$LIBS" != "$saved_LIBS"; then
652    # Looks like we need -lrt for clock_gettime().
653    have_rt=yes
656 if test "$bwin32" = "false"; then
657   AC_SEARCH_LIBS(pthread_create, [pthread])
658   AC_SEARCH_LIBS(pthread_detach, [pthread])
661 AM_CONDITIONAL(THREADS_WIN32, test "$bwin32" = "true")
662 AM_CONDITIONAL(THREADS_PTHREADS, test "$bwin32" = "false")
664 AC_CHECK_FUNCS(
665         _NSGetEnviron \
666         RtlSecureZeroMemory \
667         SecureZeroMemory \
668         accept4 \
669         backtrace \
670         backtrace_symbols_fd \
671         eventfd \
672         explicit_bzero \
673         timingsafe_memcmp \
674         flock \
675         fsync \
676         ftime \
677         get_current_dir_name \
678         getaddrinfo \
679         getdelim \
680         getifaddrs \
681         getline \
682         getpass \
683         getrlimit \
684         gettimeofday \
685         gmtime_r \
686         gnu_get_libc_version \
687         htonll \
688         inet_aton \
689         ioctl \
690         issetugid \
691         llround \
692         localtime_r \
693         lround \
694         madvise \
695         memmem \
696         memset_s \
697         minherit \
698         mmap \
699         pipe \
700         pipe2 \
701         prctl \
702         readpassphrase \
703         rint \
704         sigaction \
705         socketpair \
706         statvfs \
707         strncasecmp \
708         strcasecmp \
709         strlcat \
710         strlcpy \
711         strnlen \
712         strptime \
713         strtok_r \
714         strtoull \
715         sysconf \
716         sysctl \
717         truncate \
718         uname \
719         usleep \
720         vasprintf \
721         _vscprintf
724 # Apple messed up when they added some functions: they
725 # forgot to decorate them with appropriate AVAILABLE_MAC_OS_VERSION
726 # checks.
728 # We should only probe for these functions if we are sure that we
729 # are not targeting OS X 10.9 or earlier.
730 AC_MSG_CHECKING([for a pre-Yosemite OS X build target])
731 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
732 #ifdef __APPLE__
733 #  include <AvailabilityMacros.h>
734 #  ifndef MAC_OS_X_VERSION_10_10
735 #    define MAC_OS_X_VERSION_10_10 101000
736 #  endif
737 #  if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
738 #    if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
739 #      error "Running on Mac OS X 10.9 or earlier"
740 #    endif
741 #  endif
742 #endif
743 ]], [[]])],
744    [on_macos_pre_10_10=no ; AC_MSG_RESULT([no])],
745    [on_macos_pre_10_10=yes; AC_MSG_RESULT([yes])])
747 if test "$on_macos_pre_10_10" = "no"; then
748   AC_CHECK_FUNCS(
749         mach_approximate_time \
750   )
753 # We should only probe for these functions if we are sure that we
754 # are not targeting OSX 10.11 or earlier.
755 AC_MSG_CHECKING([for a pre-Sierra OSX build target])
756 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
757 #ifdef __APPLE__
758 #  include <AvailabilityMacros.h>
759 #  ifndef MAC_OS_X_VERSION_10_12
760 #    define MAC_OS_X_VERSION_10_12 101200
761 #  endif
762 #  if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
763 #    if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
764 #      error "Running on Mac OSX 10.11 or earlier"
765 #    endif
766 #  endif
767 #endif
768 ]], [[]])],
769    [on_macos_pre_10_12=no ; AC_MSG_RESULT([no])],
770    [on_macos_pre_10_12=yes; AC_MSG_RESULT([yes])])
772 if test "$on_macos_pre_10_12" = "no"; then
773   AC_CHECK_FUNCS(
774         clock_gettime \
775         getentropy \
776   )
779 if test "$bwin32" != "true"; then
780   AC_CHECK_HEADERS(pthread.h)
781   AC_CHECK_FUNCS(pthread_create)
782   AC_CHECK_FUNCS(pthread_condattr_setclock)
785 if test "$bwin32" = "true"; then
786   AC_CHECK_DECLS([SecureZeroMemory, _getwch], , , [
787 #include <windows.h>
788 #include <conio.h>
789 #include <wchar.h>
790                  ])
793 AM_CONDITIONAL(BUILD_READPASSPHRASE_C,
794   test "x$ac_cv_func_readpassphrase" = "xno" && test "$bwin32" = "false")
796 AC_MSG_CHECKING([whether free(NULL) works])
797 AC_RUN_IFELSE([AC_LANG_PROGRAM([
798   #include <stdlib.h>
799 ], [
800 char *p = NULL;
801 free(p);
802 ])],
803 [free_null_ok=true; AC_MSG_RESULT(yes)],
804 [free_null_ok=false; AC_MSG_RESULT(no)],
805 [free_null_ok=cross; AC_MSG_RESULT(cross)])
807 if test "$free_null_ok" = "false"; then
808    AC_MSG_ERROR([Your libc implementation doesn't allow free(NULL), as required by C99.])
811 dnl ------------------------------------------------------
812 dnl Where do you live, libevent?  And how do we call you?
814 if test "$bwin32" = "true"; then
815   TOR_LIB_WS32=-lws2_32
816   TOR_LIB_IPHLPAPI=-liphlpapi
817   # Some of the cargo-cults recommend -lwsock32 as well, but I don't
818   # think it's actually necessary.
819   TOR_LIB_GDI=-lgdi32
820   TOR_LIB_USERENV=-luserenv
821 else
822   TOR_LIB_WS32=
823   TOR_LIB_GDI=
824   TOR_LIB_USERENV=
826 AC_SUBST(TOR_LIB_WS32)
827 AC_SUBST(TOR_LIB_GDI)
828 AC_SUBST(TOR_LIB_IPHLPAPI)
829 AC_SUBST(TOR_LIB_USERENV)
831 tor_libevent_pkg_redhat="libevent"
832 tor_libevent_pkg_debian="libevent-dev"
833 tor_libevent_devpkg_redhat="libevent-devel"
834 tor_libevent_devpkg_debian="libevent-dev"
836 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
837 dnl linking for static builds.
838 STATIC_LIBEVENT_FLAGS=""
839 if test "$enable_static_libevent" = "yes"; then
840     if test "$have_rt" = "yes"; then
841       STATIC_LIBEVENT_FLAGS=" -lrt "
842     fi
845 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
846 #ifdef _WIN32
847 #include <winsock2.h>
848 #endif
849 #include <sys/time.h>
850 #include <sys/types.h>
851 #include <event2/event.h>], [
852 #ifdef _WIN32
853 #include <winsock2.h>
854 #endif
855 struct event_base;
856 struct event_base *event_base_new(void);
857 void event_base_free(struct event_base *);],
858     [
859 #ifdef _WIN32
860 {WSADATA d; WSAStartup(0x101,&d); }
861 #endif
862 event_base_free(event_base_new());
863 ], [--with-libevent-dir], [/opt/libevent])
865 dnl Determine the incantation needed to link libevent.
866 save_LIBS="$LIBS"
867 save_LDFLAGS="$LDFLAGS"
868 save_CPPFLAGS="$CPPFLAGS"
870 LIBS="$STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $save_LIBS"
871 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
872 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
874 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
876 if test "$enable_static_libevent" = "yes"; then
877    if test "$tor_cv_library_libevent_dir" = "(system)"; then
878      AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
879    else
880      TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
881    fi
882 else
883      if test "x$ac_cv_header_event2_event_h" = "xyes"; then
884        AC_SEARCH_LIBS(event_new, [event event_core], , AC_MSG_ERROR("libevent2 is installed but linking it failed while searching for event_new"))
885        AC_SEARCH_LIBS(evdns_base_new, [event event_extra], , AC_MSG_ERROR("libevent2 is installed but linking it failed while searching for evdns_base_new"))
887        if test "$ac_cv_search_event_new" != "none required"; then
888          TOR_LIBEVENT_LIBS="$ac_cv_search_event_new"
889        fi
890        if test "$ac_cv_search_evdns_base_new" != "none required"; then
891          TOR_LIBEVENT_LIBS="$ac_cv_search_evdns_base_new $TOR_LIBEVENT_LIBS"
892        fi
893      else
894        AC_MSG_ERROR("libevent2 is required but the headers could not be found")
895      fi
898 dnl Now check for particular libevent functions.
899 AC_CHECK_FUNCS([evutil_secure_rng_set_urandom_device_file \
900                 evutil_secure_rng_add_bytes \
901                 evdns_base_get_nameserver_addr \
905 LIBS="$save_LIBS"
906 LDFLAGS="$save_LDFLAGS"
907 CPPFLAGS="$save_CPPFLAGS"
909 dnl Check that libevent is at least at version 2.0.10, the first stable
910 dnl release of its series
911 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
912 AC_MSG_CHECKING([whether Libevent is new enough])
913 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
914 #include <event2/event.h>
915 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000a00
916 #error
917 int x = y(zz);
918 #else
919 int x = 1;
920 #endif
921 ])], [ AC_MSG_RESULT([yes]) ],
922    [ AC_MSG_RESULT([no])
923      AC_MSG_ERROR([Libevent is not new enough.  We require 2.0.10-stable or later]) ] )
925 LIBS="$save_LIBS"
926 LDFLAGS="$save_LDFLAGS"
927 CPPFLAGS="$save_CPPFLAGS"
929 AC_SUBST(TOR_LIBEVENT_LIBS)
931 dnl ------------------------------------------------------
932 dnl Where do you live, libm?
934 dnl On some platforms (Haiku/BeOS) the math library is
935 dnl part of libroot. In which case don't link against lm
936 TOR_LIB_MATH=""
937 save_LIBS="$LIBS"
938 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
939 if test "$ac_cv_search_pow" != "none required"; then
940     TOR_LIB_MATH="$ac_cv_search_pow"
942 LIBS="$save_LIBS"
943 AC_SUBST(TOR_LIB_MATH)
945 dnl ------------------------------------------------------
946 dnl Hello, NSS.  You're new around here.
947 if test "x$enable_nss" = "xyes"; then
948   PKG_CHECK_MODULES(NSS,
949      [nss],
950      [have_nss=yes],
951      [have_nss=no; AC_MSG_ERROR([You asked for NSS but I can't find it, $pkg_config_user_action, or set NSS_CFLAGS and NSS_LIBS.])])
952   AC_SUBST(NSS_CFLAGS)
953   AC_SUBST(NSS_LIBS)
956 dnl ------------------------------------------------------
957 dnl Where do you live, openssl?  And how do we call you?
959 if test "x$enable_nss" != "xyes"; then
961 tor_openssl_pkg_redhat="openssl"
962 tor_openssl_pkg_debian="libssl-dev"
963 tor_openssl_devpkg_redhat="openssl-devel"
964 tor_openssl_devpkg_debian="libssl-dev"
966 ALT_openssl_WITHVAL=""
967 AC_ARG_WITH(ssl-dir,
968   AS_HELP_STRING(--with-ssl-dir=PATH, [obsolete alias for --with-openssl-dir]),
969   [
970       if test "x$withval" != "xno" && test "x$withval" != "x"; then
971          ALT_openssl_WITHVAL="$withval"
972       fi
973   ])
975 AC_MSG_NOTICE([Now, we'll look for OpenSSL >= 1.0.1])
976 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI $TOR_LIB_WS32],
977     [#include <openssl/ssl.h>
978      char *getenv(const char *);],
979     [struct ssl_cipher_st;
980      unsigned SSL_CIPHER_get_id(const struct ssl_cipher_st *);
981      char *getenv(const char *);],
982     dnl This funny-looking test program calls getenv, so that the compiler
983     dnl will neither make code that call SSL_CIPHER_get_id(NULL) [producing
984     dnl a crash], nor optimize out the call to SSL_CIPHER_get_id().
985     dnl We look for SSL_cipher_get_id() because it is present in
986     dnl OpenSSL >=1.0.1, because it is not deprecated, and because Tor
987     dnl depends on it.
988     [if (getenv("THIS_SHOULDNT_BE_SET_X201803")) SSL_CIPHER_get_id((void *)0);], [],
989     [/usr/local/opt/openssl /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /opt/openssl])
991 dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
993 if test "$enable_static_openssl" = "yes"; then
994    if test "$tor_cv_library_openssl_dir" = "(system)"; then
995      AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
996    else
997      TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
998    fi
999 else
1000      TOR_OPENSSL_LIBS="-lssl -lcrypto"
1002 AC_SUBST(TOR_OPENSSL_LIBS)
1004 dnl Now check for particular openssl functions.
1005 save_LIBS="$LIBS"
1006 save_LDFLAGS="$LDFLAGS"
1007 save_CPPFLAGS="$CPPFLAGS"
1008 LIBS="$TOR_OPENSSL_LIBS $LIBS"
1009 LDFLAGS="$TOR_LDFLAGS_openssl $LDFLAGS"
1010 CPPFLAGS="$TOR_CPPFLAGS_openssl $CPPFLAGS"
1012 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1013 #include <openssl/opensslv.h>
1014 #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1000100fL
1015 #error "too old"
1016 #endif
1017    ]], [[]])],
1018    [ : ],
1019    [ 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.]) ])
1021 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1022 #include <openssl/opensslv.h>
1023 #include <openssl/evp.h>
1024 #if defined(OPENSSL_NO_EC) || defined(OPENSSL_NO_ECDH) || defined(OPENSSL_NO_ECDSA)
1025 #error "no ECC"
1026 #endif
1027 #if !defined(NID_X9_62_prime256v1) || !defined(NID_secp224r1)
1028 #error "curves unavailable"
1029 #endif
1030    ]], [[]])],
1031    [ : ],
1032    [ 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.]) ])
1034 AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , ,
1035 [#include <openssl/ssl.h>
1038 dnl OpenSSL functions which we might not have.  In theory, we could just
1039 dnl check the openssl version number, but in practice that gets pretty
1040 dnl confusing with LibreSSL, OpenSSL, and various distributions' patches
1041 dnl to them.
1042 AC_CHECK_FUNCS([ \
1043                 ERR_load_KDF_strings \
1044                 EVP_PBE_scrypt \
1045                 EVP_sha3_256 \
1046                 SSL_CIPHER_find \
1047                 SSL_CTX_set1_groups_list \
1048                 SSL_CTX_set_security_level \
1049                 SSL_SESSION_get_master_key \
1050                 SSL_get_client_ciphers \
1051                 SSL_get_client_random \
1052                 SSL_get_server_random \
1053                 TLS_method \
1054                ])
1056 dnl Check if OpenSSL structures are opaque
1057 AC_CHECK_MEMBERS([SSL.state], , ,
1058 [#include <openssl/ssl.h>
1061 AC_CHECK_SIZEOF(SHA_CTX, , [AC_INCLUDES_DEFAULT()
1062 #include <openssl/sha.h>
1065 fi # enable_nss
1067 dnl We will someday make KECCAK_TINY optional, but for now we still need
1068 dnl it for SHAKE, since OpenSSL's SHAKE can't be squeezed more than
1069 dnl once.  See comment in the definition of crypto_xof_t.
1071 dnl AM_CONDITIONAL(BUILD_KECCAK_TINY,
1072 dnl   test "x$ac_cv_func_EVP_sha3_256" != "xyes")
1074 AM_CONDITIONAL(BUILD_KECCAK_TINY, true)
1076 dnl ======================================================================
1077 dnl Can we use KIST?
1079 dnl Define the set of checks for KIST scheduler support.
1080 AC_DEFUN([CHECK_KIST_SUPPORT],[
1081   dnl KIST needs struct tcp_info and for certain members to exist.
1082   AC_CHECK_MEMBERS(
1083     [struct tcp_info.tcpi_unacked, struct tcp_info.tcpi_snd_mss],
1084     , ,[[#include <netinet/tcp.h>]])
1085   dnl KIST needs SIOCOUTQNSD to exist for an ioctl call.
1086   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1087                      #include <linux/sockios.h>
1088                      #ifndef SIOCOUTQNSD
1089                      #error
1090                      #endif
1091                      ])], have_siocoutqnsd=yes, have_siocoutqnsd=no)
1092   if test "x$have_siocoutqnsd" = "xyes"; then
1093     if test "x$ac_cv_member_struct_tcp_info_tcpi_unacked" = "xyes"; then
1094       if test "x$ac_cv_member_struct_tcp_info_tcpi_snd_mss" = "xyes"; then
1095         have_kist_support=yes
1096       fi
1097     fi
1098   fi
1100 dnl Now, trigger the check.
1101 CHECK_KIST_SUPPORT
1102 AS_IF([test "x$have_kist_support" = "xyes"],
1103       [AC_DEFINE(HAVE_KIST_SUPPORT, 1, [Defined if KIST scheduler is supported
1104                                         on this system])],
1105       [AC_MSG_NOTICE([KIST scheduler can't be used. Missing support.])])
1107 LIBS="$save_LIBS"
1108 LDFLAGS="$save_LDFLAGS"
1109 CPPFLAGS="$save_CPPFLAGS"
1111 dnl ------------------------------------------------------
1112 dnl Where do you live, zlib?  And how do we call you?
1114 tor_zlib_pkg_redhat="zlib"
1115 tor_zlib_pkg_debian="zlib1g"
1116 tor_zlib_devpkg_redhat="zlib-devel"
1117 tor_zlib_devpkg_debian="zlib1g-dev"
1119 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
1120     [#include <zlib.h>],
1121     [const char * zlibVersion(void);],
1122     [zlibVersion();], [--with-zlib-dir],
1123     [/opt/zlib])
1125 if test "$enable_static_zlib" = "yes"; then
1126    if test "$tor_cv_library_zlib_dir" = "(system)"; then
1127      AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
1128  using --enable-static-zlib")
1129    else
1130      TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
1131    fi
1132 else
1133      TOR_ZLIB_LIBS="-lz"
1135 AC_SUBST(TOR_ZLIB_LIBS)
1137 dnl ------------------------------------------------------
1138 dnl Where we do we find lzma?
1140 AC_ARG_ENABLE(lzma,
1141       AS_HELP_STRING(--enable-lzma, [enable support for the LZMA compression scheme.]),
1142       [case "${enableval}" in
1143         "yes") ;;
1144         "no")  ;;
1145         * ) AC_MSG_ERROR(bad value for --enable-lzma) ;;
1146       esac], [enable_lzma=auto])
1148 if test "x$enable_lzma" = "xno"; then
1149     have_lzma=no;
1150 else
1151     PKG_CHECK_MODULES([LZMA],
1152                       [liblzma],
1153                       have_lzma=yes,
1154                       have_lzma=no)
1156     if test "x$have_lzma" = "xno" ; then
1157         AC_MSG_WARN([Unable to find liblzma, $pkg_config_user_action, or set LZMA_CFLAGS and LZMA_LIBS.])
1158     fi
1161 if test "x$have_lzma" = "xyes"; then
1162     AC_DEFINE(HAVE_LZMA,1,[Have LZMA])
1163     TOR_LZMA_CFLAGS="${LZMA_CFLAGS}"
1164     TOR_LZMA_LIBS="${LZMA_LIBS}"
1166 AC_SUBST(TOR_LZMA_CFLAGS)
1167 AC_SUBST(TOR_LZMA_LIBS)
1169 dnl ------------------------------------------------------
1170 dnl Where we do we find zstd?
1172 AC_ARG_ENABLE(zstd,
1173       AS_HELP_STRING(--enable-zstd, [enable support for the Zstandard compression scheme.]),
1174       [case "${enableval}" in
1175         "yes") ;;
1176         "no")  ;;
1177         * ) AC_MSG_ERROR(bad value for --enable-zstd) ;;
1178       esac], [enable_zstd=auto])
1180 if test "x$enable_zstd" = "xno"; then
1181     have_zstd=no;
1182 else
1183     PKG_CHECK_MODULES([ZSTD],
1184                       [libzstd >= 1.1],
1185                       have_zstd=yes,
1186                       have_zstd=no)
1188     if test "x$have_zstd" = "xno" ; then
1189         AC_MSG_WARN([Unable to find libzstd, $pkg_config_user_action, or set ZSTD_CFLAGS and ZSTD_LIBS.])
1190     fi
1193 if test "x$have_zstd" = "xyes"; then
1194     AC_DEFINE(HAVE_ZSTD,1,[Have Zstd])
1195     TOR_ZSTD_CFLAGS="${ZSTD_CFLAGS}"
1196     TOR_ZSTD_LIBS="${ZSTD_LIBS}"
1198     dnl now check for zstd functions
1199     save_LIBS="$LIBS"
1200     save_CFLAGS="$CFLAGS"
1201     LIBS="$LIBS $ZSTD_LIBS"
1202     CFLAGS="$CFLAGS $ZSTD_CFLAGS"
1203     AC_CHECK_FUNCS(ZSTD_estimateCStreamSize \
1204                    ZSTD_estimateDCtxSize)
1205     LIBS="$save_LIBS"
1206     CFLAGS="$save_CFLAGS"
1208 AC_SUBST(TOR_ZSTD_CFLAGS)
1209 AC_SUBST(TOR_ZSTD_LIBS)
1211 dnl ----------------------------------------------------------------------
1212 dnl Check if libcap is available for capabilities.
1214 tor_cap_pkg_debian="libcap2"
1215 tor_cap_pkg_redhat="libcap"
1216 tor_cap_devpkg_debian="libcap-dev"
1217 tor_cap_devpkg_redhat="libcap-devel"
1219 AC_CHECK_LIB([cap], [cap_init], [],
1220   AC_MSG_NOTICE([Libcap was not found. Capabilities will not be usable.])
1222 AC_CHECK_FUNCS(cap_set_proc)
1224 dnl ---------------------------------------------------------------------
1225 dnl Now that we know about our major libraries, we can check for compiler
1226 dnl and linker hardening options.  We need to do this with the libraries known,
1227 dnl since sometimes the linker will like an option but not be willing to
1228 dnl use it with a build of a library.
1230 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
1231 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"
1233 CFLAGS_FTRAPV=
1234 CFLAGS_FWRAPV=
1235 CFLAGS_ASAN=
1236 CFLAGS_UBSAN=
1239 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1240 #if !defined(__clang__)
1241 #error
1242 #endif])], have_clang=yes, have_clang=no)
1244 if test "x$enable_pic" = "xyes"; then
1245     TOR_CHECK_CFLAGS(-fPIC)
1248 if test "x$enable_gcc_hardening" != "xno"; then
1249     CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
1250     if test "x$have_clang" = "xyes"; then
1251         TOR_CHECK_CFLAGS(-Qunused-arguments)
1252     fi
1253     TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
1254     AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
1255     AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
1256 m4_ifdef([AS_VAR_IF],[
1257     AS_VAR_IF(can_compile, [yes],
1258         AS_VAR_IF(can_link, [yes],
1259                   [],
1260                   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.)]))
1261         )])
1262     AS_VAR_POPDEF([can_link])
1263     AS_VAR_POPDEF([can_compile])
1264     TOR_CHECK_CFLAGS(-Wstack-protector)
1265     TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
1266     if test "$bwin32" = "false" && test "$enable_libfuzzer" != "yes" && test "$enable_oss_fuzz" != "yes"; then
1267        if test "$enable_pic" != "yes"; then
1268            # If we have already enabled -fPIC, then we don't also need to
1269            # compile with -fPIE...
1270            TOR_CHECK_CFLAGS(-fPIE)
1271        fi
1272        # ... but we want to link our executables with -pie in any case, since
1273        # they're executables, not a library.
1274        TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
1275     fi
1276     TOR_TRY_COMPILE_WITH_CFLAGS(-fwrapv, also_link, CFLAGS_FWRAPV="-fwrapv", true)
1278    AC_MSG_CHECKING([whether we can run hardened binaries])
1279    AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
1280         [AC_MSG_RESULT([yes])],
1281         [AC_MSG_RESULT([no])
1282          AC_MSG_ERROR([dnl
1283  We can link with compiler hardening options, but we can't run with them.
1284  That's a bad sign! If you must, you can pass --disable-gcc-hardening to
1285  configure, but it would be better to figure out what the underlying problem
1286  is.])],
1287         [AC_MSG_RESULT([cross])])
1290 if test "$fragile_hardening" = "yes"; then
1291     TOR_TRY_COMPILE_WITH_CFLAGS(-ftrapv, also_link, CFLAGS_FTRAPV="-ftrapv", true)
1292    if test "$tor_cv_cflags__ftrapv" = "yes" && test "$tor_can_link__ftrapv" != "yes"; then
1293       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.])
1294    fi
1296    if test "$tor_cv_cflags__ftrapv" != "yes"; then
1297      AC_MSG_ERROR([You requested fragile hardening, but the compiler does not seem to support -ftrapv.])
1298    fi
1300    TOR_TRY_COMPILE_WITH_CFLAGS([-fsanitize=address], also_link, CFLAGS_ASAN="-fsanitize=address", true)
1301     if test "$tor_cv_cflags__fsanitize_address" = "yes" && test "$tor_can_link__fsanitize_address" != "yes"; then
1302       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*])
1303     fi
1305    TOR_TRY_COMPILE_WITH_CFLAGS([-fsanitize=undefined], also_link, CFLAGS_UBSAN="-fsanitize=undefined", true)
1306     if test "$tor_cv_cflags__fsanitize_address" = "yes" && test "$tor_can_link__fsanitize_address" != "yes"; then
1307       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*])
1308     fi
1310    TOR_TRY_COMPILE_WITH_CFLAGS([-fno-sanitize=float-divide-by-zero], also_link, CFLAGS_UBSAN="-fno-sanitize=float-divide-by-zero", true)
1311     if test "$tor_cv_cflags__fno_sanitize_float_divide_by_zero" = "yes" && test "$tor_can_link__fno_sanitize_float_divide_by_zero" != "yes"; then
1312       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*])
1313     fi
1315 TOR_CHECK_CFLAGS([-fno-omit-frame-pointer])
1318 dnl Find the correct libraries to add in order to use the sanitizers.
1320 dnl When building Rust, Cargo will run the linker with the -nodefaultlibs
1321 dnl option, which will prevent the compiler from linking the sanitizer
1322 dnl libraries it needs.  We need to specify them manually.
1324 dnl What's more, we need to specify them in a linker script rather than
1325 dnl from build.rs: these options aren't allowed in the cargo:rustc-flags
1326 dnl variable.
1327 RUST_LINKER_OPTIONS=""
1328 if test "x$have_clang" = "xyes"; then
1329         if test "x$CFLAGS_ASAN" != "x"; then
1330                 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_ASAN -Cdefault-linker-libraries"
1331         fi
1332         if test "x$CFLAGS_UBSAN" != "x"; then
1333                 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_UBSAN -Cdefault-linker-libraries"
1334         fi
1335 else
1336         if test "x$CFLAGS_ASAN" != "x"; then
1337                 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=address -Cdefault-linker-libraries"
1338         fi
1339         if test "x$CFLAGS_UBSAN" != "x"; then
1340                 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=undefined -Cdefault-linker-libraries"
1341         fi
1343 AC_SUBST(RUST_LINKER_OPTIONS)
1345 CFLAGS_BUGTRAP="$CFLAGS_FTRAPV $CFLAGS_ASAN $CFLAGS_UBSAN"
1346 CFLAGS_CONSTTIME="$CFLAGS_FWRAPV"
1348 mulodi_fixes_ftrapv=no
1349 if test "$have_clang" = "yes"; then
1350   saved_CFLAGS="$CFLAGS"
1351   CFLAGS="$CFLAGS $CFLAGS_FTRAPV"
1352   AC_MSG_CHECKING([whether clang -ftrapv can link a 64-bit int multiply])
1353   AC_LINK_IFELSE([
1354       AC_LANG_SOURCE([[
1355           #include <stdint.h>
1356           #include <stdlib.h>
1357           int main(int argc, char **argv)
1358           {
1359             int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
1360                         * (int64_t)atoi(argv[3]);
1361             return x == 9;
1362           } ]])],
1363           [ftrapv_can_link=yes; AC_MSG_RESULT([yes])],
1364           [ftrapv_can_link=no; AC_MSG_RESULT([no])])
1365   if test "$ftrapv_can_link" = "no"; then
1366     AC_MSG_CHECKING([whether defining __mulodi4 fixes that])
1367     AC_LINK_IFELSE([
1368       AC_LANG_SOURCE([[
1369           #include <stdint.h>
1370           #include <stdlib.h>
1371           int64_t __mulodi4(int64_t a, int64_t b, int *overflow) {
1372              *overflow=0;
1373              return a;
1374           }
1375           int main(int argc, char **argv)
1376           {
1377             int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
1378                         * (int64_t)atoi(argv[3]);
1379             return x == 9;
1380           } ]])],
1381           [mulodi_fixes_ftrapv=yes; AC_MSG_RESULT([yes])],
1382           [mulodi_fixes_ftrapv=no; AC_MSG_RESULT([no])])
1383   fi
1384   CFLAGS="$saved_CFLAGS"
1387 AM_CONDITIONAL(ADD_MULODI4, test "$mulodi_fixes_ftrapv" = "yes")
1389 dnl These cflags add bunches of branches, and we haven't been able to
1390 dnl persuade ourselves that they're suitable for code that needs to be
1391 dnl constant time.
1392 AC_SUBST(CFLAGS_BUGTRAP)
1393 dnl These cflags are variant ones sutable for code that needs to be
1394 dnl constant-time.
1395 AC_SUBST(CFLAGS_CONSTTIME)
1397 if test "x$enable_linker_hardening" != "xno"; then
1398     TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
1401 # For backtrace support
1402 TOR_CHECK_LDFLAGS(-rdynamic)
1404 dnl ------------------------------------------------------
1405 dnl Now see if we have a -fomit-frame-pointer compiler option.
1407 saved_CFLAGS="$CFLAGS"
1408 TOR_CHECK_CFLAGS(-fomit-frame-pointer)
1409 F_OMIT_FRAME_POINTER=''
1410 if test "$saved_CFLAGS" != "$CFLAGS"; then
1411   if test "$fragile_hardening" = "yes"; then
1412     F_OMIT_FRAME_POINTER='-fomit-frame-pointer'
1413   fi
1415 CFLAGS="$saved_CFLAGS"
1416 AC_SUBST(F_OMIT_FRAME_POINTER)
1418 dnl ------------------------------------------------------
1419 dnl If we are adding -fomit-frame-pointer (or if the compiler's doing it
1420 dnl for us, as GCC 4.6 and later do at many optimization levels), then
1421 dnl we should try to add -fasynchronous-unwind-tables so that our backtrace
1422 dnl code will work.
1423 TOR_CHECK_CFLAGS(-fasynchronous-unwind-tables)
1425 dnl ============================================================
1426 dnl Check for libseccomp
1428 if test "x$enable_seccomp" != "xno"; then
1429   AC_CHECK_HEADERS([seccomp.h])
1430   AC_SEARCH_LIBS(seccomp_init, [seccomp])
1433 dnl ============================================================
1434 dnl Check for libscrypt
1436 if test "x$enable_libscrypt" != "xno"; then
1437   AC_CHECK_HEADERS([libscrypt.h])
1438   AC_SEARCH_LIBS(libscrypt_scrypt, [scrypt])
1439   AC_CHECK_FUNCS([libscrypt_scrypt])
1442 dnl ============================================================
1443 dnl We need an implementation of curve25519.
1445 dnl set these defaults.
1446 build_curve25519_donna=no
1447 build_curve25519_donna_c64=no
1448 use_curve25519_donna=no
1449 use_curve25519_nacl=no
1450 CURVE25519_LIBS=
1452 dnl The best choice is using curve25519-donna-c64, but that requires
1453 dnl that we
1454 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
1455   tor_cv_can_use_curve25519_donna_c64,
1456   [AC_RUN_IFELSE(
1457     [AC_LANG_PROGRAM([dnl
1458       #include <stdint.h>
1459       typedef unsigned uint128_t __attribute__((mode(TI)));
1460   int func(uint64_t a, uint64_t b) {
1461            uint128_t c = ((uint128_t)a) * b;
1462            int ok = ((uint64_t)(c>>96)) == 522859 &&
1463              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
1464                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
1465                  (((uint64_t)(c))&0xffffffffL) == 0;
1466            return ok;
1467       }
1468   ], [dnl
1469     int ok = func( ((uint64_t)2000000000) * 1000000000,
1470                    ((uint64_t)1234567890) << 24);
1471         return !ok;
1472       ])],
1473   [tor_cv_can_use_curve25519_donna_c64=yes],
1474       [tor_cv_can_use_curve25519_donna_c64=no],
1475   [AC_LINK_IFELSE(
1476         [AC_LANG_PROGRAM([dnl
1477       #include <stdint.h>
1478       typedef unsigned uint128_t __attribute__((mode(TI)));
1479   int func(uint64_t a, uint64_t b) {
1480            uint128_t c = ((uint128_t)a) * b;
1481            int ok = ((uint64_t)(c>>96)) == 522859 &&
1482              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
1483                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
1484                  (((uint64_t)(c))&0xffffffffL) == 0;
1485            return ok;
1486       }
1487   ], [dnl
1488     int ok = func( ((uint64_t)2000000000) * 1000000000,
1489                  ((uint64_t)1234567890) << 24);
1490         return !ok;
1491       ])],
1492           [tor_cv_can_use_curve25519_donna_c64=cross],
1493       [tor_cv_can_use_curve25519_donna_c64=no])])])
1495 AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
1496                   nacl/crypto_scalarmult_curve25519.h])
1498 AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
1499   tor_cv_can_use_curve25519_nacl,
1500   [tor_saved_LIBS="$LIBS"
1501    LIBS="$LIBS -lnacl"
1502    AC_LINK_IFELSE(
1503      [AC_LANG_PROGRAM([dnl
1504        #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
1505        #include <crypto_scalarmult_curve25519.h>
1506    #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
1507    #include <nacl/crypto_scalarmult_curve25519.h>
1508    #endif
1509        #ifdef crypto_scalarmult_curve25519_ref_BYTES
1510    #error Hey, this is the reference implementation! That's not fast.
1511    #endif
1512      ], [
1513    unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
1514      ])], [tor_cv_can_use_curve25519_nacl=yes],
1515      [tor_cv_can_use_curve25519_nacl=no])
1516    LIBS="$tor_saved_LIBS" ])
1518  dnl Okay, now we need to figure out which one to actually use. Fall back
1519  dnl to curve25519-donna.c
1521  if test "x$tor_cv_can_use_curve25519_donna_c64" != "xno"; then
1522    build_curve25519_donna_c64=yes
1523    use_curve25519_donna=yes
1524  elif test "x$tor_cv_can_use_curve25519_nacl" = "xyes"; then
1525    use_curve25519_nacl=yes
1526    CURVE25519_LIBS=-lnacl
1527  else
1528    build_curve25519_donna=yes
1529    use_curve25519_donna=yes
1530  fi
1532 if test "x$use_curve25519_donna" = "xyes"; then
1533   AC_DEFINE(USE_CURVE25519_DONNA, 1,
1534             [Defined if we should use an internal curve25519_donna{,_c64} implementation])
1536 if test "x$use_curve25519_nacl" = "xyes"; then
1537   AC_DEFINE(USE_CURVE25519_NACL, 1,
1538             [Defined if we should use a curve25519 from nacl])
1540 AM_CONDITIONAL(BUILD_CURVE25519_DONNA,
1541   test "x$build_curve25519_donna" = "xyes")
1542 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64,
1543   test "x$build_curve25519_donna_c64" = "xyes")
1544 AC_SUBST(CURVE25519_LIBS)
1546 dnl Make sure to enable support for large off_t if available.
1547 AC_SYS_LARGEFILE
1549 AC_CHECK_HEADERS([errno.h \
1550                   fcntl.h \
1551                   signal.h \
1552                   string.h \
1553                   sys/capability.h \
1554                   sys/fcntl.h \
1555                   sys/stat.h \
1556                   sys/time.h \
1557                   sys/types.h \
1558                   time.h \
1559                   unistd.h \
1560                   arpa/inet.h \
1561                   crt_externs.h \
1562                   execinfo.h \
1563                   gnu/libc-version.h \
1564                   grp.h \
1565                   ifaddrs.h \
1566                   inttypes.h \
1567                   limits.h \
1568                   linux/types.h \
1569                   mach/vm_inherit.h \
1570                   machine/limits.h \
1571                   malloc.h \
1572                   malloc/malloc.h \
1573                   malloc_np.h \
1574                   netdb.h \
1575                   netinet/in.h \
1576                   netinet/in6.h \
1577                   pwd.h \
1578                   readpassphrase.h \
1579                   stdatomic.h \
1580                   sys/eventfd.h \
1581                   sys/file.h \
1582                   sys/ioctl.h \
1583                   sys/limits.h \
1584                   sys/mman.h \
1585                   sys/param.h \
1586                   sys/prctl.h \
1587                   sys/random.h \
1588                   sys/resource.h \
1589                   sys/select.h \
1590                   sys/socket.h \
1591                   sys/statvfs.h \
1592                   sys/syscall.h \
1593                   sys/sysctl.h \
1594                   sys/syslimits.h \
1595                   sys/time.h \
1596                   sys/types.h \
1597                   sys/un.h \
1598                   sys/utime.h \
1599                   sys/wait.h \
1600                   syslog.h \
1601                   utime.h])
1603 AC_CHECK_HEADERS(sys/param.h)
1605 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
1606 [#ifdef HAVE_SYS_TYPES_H
1607 #include <sys/types.h>
1608 #endif
1609 #ifdef HAVE_SYS_SOCKET_H
1610 #include <sys/socket.h>
1611 #endif])
1612 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
1613 [#ifdef HAVE_SYS_TYPES_H
1614 #include <sys/types.h>
1615 #endif
1616 #ifdef HAVE_SYS_SOCKET_H
1617 #include <sys/socket.h>
1618 #endif
1619 #ifdef HAVE_NET_IF_H
1620 #include <net/if.h>
1621 #endif
1622 #ifdef HAVE_NETINET_IN_H
1623 #include <netinet/in.h>
1624 #endif])
1626 AC_CHECK_HEADERS(linux/if.h,[],[],
1628 #ifdef HAVE_SYS_SOCKET_H
1629 #include <sys/socket.h>
1630 #endif
1633 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
1634         linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
1635 [#ifdef HAVE_SYS_TYPES_H
1636 #include <sys/types.h>
1637 #endif
1638 #ifdef HAVE_SYS_SOCKET_H
1639 #include <sys/socket.h>
1640 #endif
1641 #ifdef HAVE_LIMITS_H
1642 #include <limits.h>
1643 #endif
1644 #ifdef HAVE_LINUX_TYPES_H
1645 #include <linux/types.h>
1646 #endif
1647 #ifdef HAVE_NETINET_IN6_H
1648 #include <netinet/in6.h>
1649 #endif
1650 #ifdef HAVE_NETINET_IN_H
1651 #include <netinet/in.h>
1652 #endif])
1654 AC_CHECK_HEADERS(linux/netfilter_ipv6/ip6_tables.h,
1655         linux_netfilter_ipv6_ip6_tables=1, linux_netfilter_ipv6_ip6_tables=0,
1656 [#ifdef HAVE_SYS_TYPES_H
1657 #include <sys/types.h>
1658 #endif
1659 #ifdef HAVE_SYS_SOCKET_H
1660 #include <sys/socket.h>
1661 #endif
1662 #ifdef HAVE_LIMITS_H
1663 #include <limits.h>
1664 #endif
1665 #ifdef HAVE_LINUX_TYPES_H
1666 #include <linux/types.h>
1667 #endif
1668 #ifdef HAVE_NETINET_IN6_H
1669 #include <netinet/in6.h>
1670 #endif
1671 #ifdef HAVE_NETINET_IN_H
1672 #include <netinet/in.h>
1673 #endif
1674 #ifdef HAVE_LINUX_IF_H
1675 #include <linux/if.h>
1676 #endif])
1678 transparent_ok=0
1679 if test "x$net_if_found" = "x1" && test "x$net_pfvar_found" = "x1"; then
1680   transparent_ok=1
1682 if test "x$linux_netfilter_ipv4" = "x1"; then
1683   transparent_ok=1
1685 if test "x$linux_netfilter_ipv6_ip6_tables" = "x1"; then
1686   transparent_ok=1
1688 if test "x$transparent_ok" = "x1"; then
1689   AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
1690 else
1691   AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
1694 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
1695 [#ifdef HAVE_SYS_TYPES_H
1696 #include <sys/types.h>
1697 #endif
1698 #ifdef HAVE_SYS_TIME_H
1699 #include <sys/time.h>
1700 #endif])
1702 AC_CHECK_SIZEOF(char)
1703 AC_CHECK_SIZEOF(short)
1704 AC_CHECK_SIZEOF(int)
1705 AC_CHECK_SIZEOF(unsigned int)
1706 AC_CHECK_SIZEOF(long)
1707 AC_CHECK_SIZEOF(long long)
1708 AC_CHECK_SIZEOF(__int64)
1709 AC_CHECK_SIZEOF(void *)
1710 AC_CHECK_SIZEOF(time_t)
1711 AC_CHECK_SIZEOF(size_t)
1712 AC_CHECK_SIZEOF(pid_t)
1714 AC_CHECK_TYPES([uint, u_char, ssize_t])
1716 AC_PC_FROM_UCONTEXT([:])
1718 dnl used to include sockaddr_storage, but everybody has that.
1719 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
1720 [#ifdef HAVE_SYS_TYPES_H
1721 #include <sys/types.h>
1722 #endif
1723 #ifdef HAVE_NETINET_IN_H
1724 #include <netinet/in.h>
1725 #endif
1726 #ifdef HAVE_NETINET_IN6_H
1727 #include <netinet/in6.h>
1728 #endif
1729 #ifdef HAVE_SYS_SOCKET_H
1730 #include <sys/socket.h>
1731 #endif
1732 #ifdef _WIN32
1733 #define _WIN32_WINNT 0x0501
1734 #define WIN32_LEAN_AND_MEAN
1735 #include <winsock2.h>
1736 #include <ws2tcpip.h>
1737 #endif
1739 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
1740 [#ifdef HAVE_SYS_TYPES_H
1741 #include <sys/types.h>
1742 #endif
1743 #ifdef HAVE_NETINET_IN_H
1744 #include <netinet/in.h>
1745 #endif
1746 #ifdef HAVE_NETINET_IN6_H
1747 #include <netinet/in6.h>
1748 #endif
1749 #ifdef HAVE_SYS_SOCKET_H
1750 #include <sys/socket.h>
1751 #endif
1752 #ifdef _WIN32
1753 #define _WIN32_WINNT 0x0501
1754 #define WIN32_LEAN_AND_MEAN
1755 #include <winsock2.h>
1756 #include <ws2tcpip.h>
1757 #endif
1760 AC_CHECK_TYPES([rlim_t], , ,
1761 [#ifdef HAVE_SYS_TYPES_H
1762 #include <sys/types.h>
1763 #endif
1764 #ifdef HAVE_SYS_TIME_H
1765 #include <sys/time.h>
1766 #endif
1767 #ifdef HAVE_SYS_RESOURCE_H
1768 #include <sys/resource.h>
1769 #endif
1772 AX_CHECK_SIGN([time_t],
1773        [ : ],
1774        [ : ], [
1775 #ifdef HAVE_SYS_TYPES_H
1776 #include <sys/types.h>
1777 #endif
1778 #ifdef HAVE_SYS_TIME_H
1779 #include <sys/time.h>
1780 #endif
1781 #ifdef HAVE_TIME_H
1782 #include <time.h>
1783 #endif
1786 if test "$ax_cv_decl_time_t_signed" = "no"; then
1787   AC_MSG_ERROR([You have an unsigned time_t; Tor does not support that. Please tell the Tor developers about your interesting platform.])
1790 AX_CHECK_SIGN([size_t],
1791        [ tor_cv_size_t_signed=yes ],
1792        [ tor_cv_size_t_signed=no ], [
1793 #ifdef HAVE_SYS_TYPES_H
1794 #include <sys/types.h>
1795 #endif
1798 if test "$ax_cv_decl_size_t_signed" = "yes"; then
1799   AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
1802 AX_CHECK_SIGN([enum always],
1803        [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
1804        [ : ], [
1805  enum always { AAA, BBB, CCC };
1808 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
1809 #ifdef HAVE_SYS_SOCKET_H
1810 #include <sys/socket.h>
1811 #endif
1814 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1816 AC_CHECK_SIZEOF(cell_t)
1818 # Let's see if stdatomic works. (There are some debian clangs that screw it
1819 # up; see Tor bug #26779 and debian bug 903709.)
1820 AC_CACHE_CHECK([whether C11 stdatomic.h actually works],
1821                tor_cv_stdatomic_works,
1822 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1823 #include <stdatomic.h>
1824 struct x { atomic_size_t y; };
1825 void try_atomic_init(struct x *xx)
1827   atomic_init(&xx->y, 99);
1828   atomic_fetch_add(&xx->y, 1);
1830 ]])], [tor_cv_stdatomic_works=yes], [tor_cv_stdatomic_works=no])])
1832 if test "$tor_cv_stdatomic_works" = "yes"; then
1833    AC_DEFINE(STDATOMIC_WORKS, 1, [Set to 1 if we can compile a simple stdatomic example.])
1834 elif test "$ac_cv_header_stdatomic_h" = "yes"; then
1835    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 ])
1838 # Now make sure that NULL can be represented as zero bytes.
1839 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1840 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1841 [[#include <stdlib.h>
1842 #include <string.h>
1843 #include <stdio.h>
1844 #ifdef HAVE_STDDEF_H
1845 #include <stddef.h>
1846 #endif
1847 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1848 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1849        [tor_cv_null_is_zero=yes],
1850        [tor_cv_null_is_zero=no],
1851        [tor_cv_null_is_zero=cross])])
1853 if test "$tor_cv_null_is_zero" = "cross"; then
1854   # Cross-compiling; let's hope that the target isn't raving mad.
1855   AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
1858 if test "$tor_cv_null_is_zero" != "no"; then
1859   AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1860             [Define to 1 iff memset(0) sets pointers to NULL])
1863 AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
1864 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1865 [[#include <stdlib.h>
1866 #include <string.h>
1867 #include <stdio.h>
1868 #ifdef HAVE_STDDEF_H
1869 #include <stddef.h>
1870 #endif
1871 int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
1872 return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
1873        [tor_cv_dbl0_is_zero=yes],
1874        [tor_cv_dbl0_is_zero=no],
1875        [tor_cv_dbl0_is_zero=cross])])
1877 if test "$tor_cv_dbl0_is_zero" = "cross"; then
1878   # Cross-compiling; let's hope that the target isn't raving mad.
1879   AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
1882 if test "$tor_cv_dbl0_is_zero" != "no"; then
1883   AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
1884             [Define to 1 iff memset(0) sets doubles to 0.0])
1887 # And what happens when we malloc zero?
1888 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
1889 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1890 [[#include <stdlib.h>
1891 #include <string.h>
1892 #include <stdio.h>
1893 #ifdef HAVE_STDDEF_H
1894 #include <stddef.h>
1895 #endif
1896 int main () { return malloc(0)?0:1; }]])],
1897        [tor_cv_malloc_zero_works=yes],
1898        [tor_cv_malloc_zero_works=no],
1899        [tor_cv_malloc_zero_works=cross])])
1901 if test "$tor_cv_malloc_zero_works" = "cross"; then
1902   # Cross-compiling; let's hope that the target isn't raving mad.
1903   AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
1906 if test "$tor_cv_malloc_zero_works" = "yes"; then
1907   AC_DEFINE([MALLOC_ZERO_WORKS], 1,
1908             [Define to 1 iff malloc(0) returns a pointer])
1911 # whether we seem to be in a 2s-complement world.
1912 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
1913 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1914 [[int main () { int problem = ((-99) != (~99)+1);
1915 return problem ? 1 : 0; }]])],
1916        [tor_cv_twos_complement=yes],
1917        [tor_cv_twos_complement=no],
1918        [tor_cv_twos_complement=cross])])
1920 if test "$tor_cv_twos_complement" = "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 negative integers are represented with two's complement.])
1925 if test "$tor_cv_twos_complement" != "no"; then
1926   AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
1927             [Define to 1 iff we represent negative integers with
1928              two's complement])
1931 # What does shifting a negative value do?
1932 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
1933 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1934 [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
1935        [tor_cv_sign_extend=yes],
1936        [tor_cv_sign_extend=no],
1937        [tor_cv_sign_extend=cross])])
1939 if test "$tor_cv_sign_extend" = "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 right-shifting negative integers causes sign-extension])
1944 if test "$tor_cv_sign_extend" != "no"; then
1945   AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
1946             [Define to 1 iff right-shifting a negative value performs sign-extension])
1949 # Is uint8_t the same type as unsigned char?
1950 AC_CACHE_CHECK([whether uint8_t is the same type as unsigned char], tor_cv_uint8_uchar,
1951 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1952 #include <stdint.h>
1953 extern uint8_t c;
1954 unsigned char c;]])],
1955        [tor_cv_uint8_uchar=yes],
1956        [tor_cv_uint8_uchar=no],
1957        [tor_cv_uint8_uchar=cross])])
1959 if test "$tor_cv_uint8_uchar" = "cross"; then
1960   AC_MSG_NOTICE([Cross-compiling: we'll assume that uint8_t is the same type as unsigned char])
1963 if test "$tor_cv_uint8_uchar" = "no"; then
1964   AC_MSG_ERROR([We assume that uint8_t is the same type as unsigned char, but your compiler disagrees.])
1967 AC_ARG_WITH(tcmalloc,
1968 AS_HELP_STRING(--with-tcmalloc, [use tcmalloc memory allocation library. Deprecated; see --with-malloc]))
1970 default_malloc=system
1972 if test "x$enable_openbsd_malloc" = "xyes" ; then
1973   AC_MSG_NOTICE([The --enable-openbsd-malloc argument is deprecated; use --with-malloc=openbsd instead.])
1974   default_malloc=openbsd
1977 if test "x$with_tcmalloc" = "xyes"; then
1978   AC_MSG_NOTICE([The --with-tcmalloc argument is deprecated; use --with-malloc=tcmalloc instead.])
1979   default_malloc=tcmalloc
1982 AC_ARG_WITH(malloc,
1983    AS_HELP_STRING([--with-malloc=[system,jemalloc,tcmalloc,openbsd]],
1984                   [select special malloc implementation [system]]),
1985    [ malloc="$with_malloc" ], [ malloc="$default_malloc" ])
1987 AS_CASE([$malloc],
1988   [tcmalloc], [
1989       PKG_CHECK_MODULES([TCMALLOC],
1990                         [libtcmalloc],
1991                         have_tcmalloc=yes,
1992                         have_tcmalloc=no)
1994       if test "x$have_tcmalloc" = "xno" ; then
1995           AC_MSG_ERROR([Unable to find tcmalloc requested by --with-malloc, $pkg_config_user_action, or set TCMALLOC_CFLAGS and TCMALLOC_LIBS.])
1996       fi
1998       CFLAGS="$CFLAGS $TCMALLOC_CFLAGS"
1999       LIBS="$TCMALLOC_LIBS $LIBS"
2000   ],
2002   [jemalloc], [
2003       PKG_CHECK_MODULES([JEMALLOC],
2004                         [jemalloc],
2005                         have_jemalloc=yes,
2006                         have_jemalloc=no)
2008       if test "x$have_jemalloc" = "xno" ; then
2009           AC_MSG_ERROR([Unable to find jemalloc requested by --with-malloc, $pkg_config_user_action, or set JEMALLOC_CFLAGS and JEMALLOC_LIBS.])
2010       fi
2012       CFLAGS="$CFLAGS $JEMALLOC_CFLAGS"
2013       LIBS="$JEMALLOC_LIBS $LIBS"
2014       using_custom_malloc=yes
2015   ],
2017   [openbsd], [
2018     AC_MSG_WARN([The openbsd malloc port is deprecated in Tor 0.3.5 and will be removed in a future version.])
2019     enable_openbsd_malloc=yes
2020   ],
2022   [system], [
2023      # handle this later, including the jemalloc fallback
2024     AC_CHECK_FUNCS(mallinfo)
2025   ],
2027   [AC_MSG_ERROR([--with-malloc=`$with_malloc' not supported, see --help])
2030 AM_CONDITIONAL(USE_OPENBSD_MALLOC, test "x$enable_openbsd_malloc" = "xyes")
2032 if test "$malloc" != "system"; then
2033   # Tell the C compiler not to use the system allocator functions.
2034   TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
2036 if test "$using_custom_malloc" = "yes"; then
2037   # Tell the C compiler not to use the system allocator functions.
2038   TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
2041 # By default, we're going to assume we don't have mlockall()
2042 # bionic and other platforms have various broken mlockall subsystems.
2043 # Some systems don't have a working mlockall, some aren't linkable,
2044 # and some have it but don't declare it.
2045 AC_CHECK_FUNCS(mlockall)
2046 AC_CHECK_DECLS([mlockall], , , [
2047 #ifdef HAVE_SYS_MMAN_H
2048 #include <sys/mman.h>
2049 #endif])
2051 # Allow user to specify an alternate syslog facility
2052 AC_ARG_WITH(syslog-facility,
2053 AS_HELP_STRING(--with-syslog-facility=LOG, [syslog facility to use (default=LOG_DAEMON)]),
2054 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
2055 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
2056 AC_SUBST(LOGFACILITY)
2058 # Check if we have getresuid and getresgid
2059 AC_CHECK_FUNCS(getresuid getresgid)
2061 # Check for gethostbyname_r in all its glorious incompatible versions.
2062 #   (This logic is based on that in Python's configure.in)
2063 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
2064   [Define this if you have any gethostbyname_r()])
2066 AC_CHECK_FUNC(gethostbyname_r, [
2067   AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
2068   OLD_CFLAGS=$CFLAGS
2069   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
2070   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2071 #include <netdb.h>
2072   ]], [[
2073     char *cp1, *cp2;
2074     struct hostent *h1, *h2;
2075     int i1, i2;
2076     (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
2077   ]])],[
2078     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2079     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2080      [Define this if gethostbyname_r takes 6 arguments])
2081     AC_MSG_RESULT(6)
2082   ], [
2083     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2084 #include <netdb.h>
2085     ]], [[
2086       char *cp1, *cp2;
2087       struct hostent *h1;
2088       int i1, i2;
2089       (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
2090     ]])], [
2091       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2092       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2093         [Define this if gethostbyname_r takes 5 arguments])
2094       AC_MSG_RESULT(5)
2095    ], [
2096       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2097 #include <netdb.h>
2098      ]], [[
2099        char *cp1;
2100        struct hostent *h1;
2101        struct hostent_data hd;
2102        (void) gethostbyname_r(cp1,h1,&hd);
2103      ]])], [
2104        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2105        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2106          [Define this if gethostbyname_r takes 3 arguments])
2107        AC_MSG_RESULT(3)
2108      ], [
2109        AC_MSG_RESULT(0)
2110      ])
2111   ])
2112  ])
2113  CFLAGS=$OLD_CFLAGS
2116 AC_CACHE_CHECK([whether the C compiler supports __func__],
2117   tor_cv_have_func_macro,
2118   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2119 #include <stdio.h>
2120 int main(int c, char **v) { puts(__func__); }])],
2121   tor_cv_have_func_macro=yes,
2122   tor_cv_have_func_macro=no))
2124 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
2125   tor_cv_have_FUNC_macro,
2126   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2127 #include <stdio.h>
2128 int main(int c, char **v) { puts(__FUNC__); }])],
2129   tor_cv_have_FUNC_macro=yes,
2130   tor_cv_have_FUNC_macro=no))
2132 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
2133   tor_cv_have_FUNCTION_macro,
2134   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2135 #include <stdio.h>
2136 int main(int c, char **v) { puts(__FUNCTION__); }])],
2137   tor_cv_have_FUNCTION_macro=yes,
2138   tor_cv_have_FUNCTION_macro=no))
2140 AC_CACHE_CHECK([whether we have extern char **environ already declared],
2141   tor_cv_have_environ_declared,
2142   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2143 #ifdef HAVE_UNISTD_H
2144 #include <unistd.h>
2145 #endif
2146 #include <stdlib.h>
2147 int main(int c, char **v) { char **t = environ; }])],
2148   tor_cv_have_environ_declared=yes,
2149   tor_cv_have_environ_declared=no))
2151 if test "$tor_cv_have_func_macro" = "yes"; then
2152   AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
2155 if test "$tor_cv_have_FUNC_macro" = "yes"; then
2156   AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
2159 if test "$tor_cv_have_FUNCTION_macro" = "yes"; then
2160   AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
2161            [Defined if the compiler supports __FUNCTION__])
2164 if test "$tor_cv_have_environ_declared" = "yes"; then
2165   AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
2166            [Defined if we have extern char **environ already declared])
2169 # $prefix stores the value of the --prefix command line option, or
2170 # NONE if the option wasn't set.  In the case that it wasn't set, make
2171 # it be the default, so that we can use it to expand directories now.
2172 if test "x$prefix" = "xNONE"; then
2173   prefix=$ac_default_prefix
2176 # and similarly for $exec_prefix
2177 if test "x$exec_prefix" = "xNONE"; then
2178   exec_prefix=$prefix
2181 if test "x$BUILDDIR" = "x"; then
2182   BUILDDIR=`pwd`
2184 AC_SUBST(BUILDDIR)
2185 AH_TEMPLATE([BUILDDIR],[tor's build directory])
2186 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
2188 if test "x$SRCDIR" = "x"; then
2189   SRCDIR=$(cd "$srcdir"; pwd)
2191 AH_TEMPLATE([SRCDIR],[tor's sourcedir directory])
2192 AC_DEFINE_UNQUOTED(SRCDIR,"$SRCDIR")
2194 if test "x$CONFDIR" = "x"; then
2195   CONFDIR=`eval echo $sysconfdir/tor`
2197 AC_SUBST(CONFDIR)
2198 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
2199 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
2201 BINDIR=`eval echo $bindir`
2202 AC_SUBST(BINDIR)
2203 LOCALSTATEDIR=`eval echo $localstatedir`
2204 AC_SUBST(LOCALSTATEDIR)
2206 if test "$bwin32" = "true"; then
2207   # Test if the linker supports the --nxcompat and --dynamicbase options
2208   # for Windows
2209   save_LDFLAGS="$LDFLAGS"
2210   LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
2211   AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
2212   AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
2213     [AC_MSG_RESULT([yes])]
2214     [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
2215     [AC_MSG_RESULT([no])]
2216   )
2217   LDFLAGS="$save_LDFLAGS"
2220 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
2221 # than autoconf's macros like.
2222 if test "$GCC" = "yes"; then
2223   # Disable GCC's strict aliasing checks.  They are an hours-to-debug
2224   # accident waiting to happen.
2225   CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
2226 else
2227   # Override optimization level for non-gcc compilers
2228   CFLAGS="$CFLAGS -O"
2229   enable_gcc_warnings=no
2230   enable_gcc_warnings_advisory=no
2233 # Warnings implies advisory-warnings and -Werror.
2234 if test "$enable_gcc_warnings" = "yes"; then
2235   enable_gcc_warnings_advisory=yes
2236   enable_fatal_warnings=yes
2239 # OS X Lion started deprecating the system openssl. Let's just disable
2240 # all deprecation warnings on OS X. Also, to potentially make the binary
2241 # a little smaller, let's enable dead_strip.
2242 case "$host_os" in
2244  darwin*)
2245     CFLAGS="$CFLAGS -Wno-deprecated-declarations"
2246     LDFLAGS="$LDFLAGS -dead_strip" ;;
2247 esac
2249 TOR_WARNING_FLAGS=""
2251 # Add some more warnings which we use in development but not in the
2252 # released versions.  (Some relevant gcc versions can't handle these.)
2254 # Note that we have to do this near the end  of the autoconf process, or
2255 # else we may run into problems when these warnings hit on the testing C
2256 # programs that autoconf wants to build.
2257 if test "x$enable_gcc_warnings_advisory" != "xno"; then
2259   case "$host" in
2260     *-*-openbsd* | *-*-bitrig*)
2261       # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
2262       # That's fine, except that the headers don't pass -Wredundant-decls.
2263       # Therefore, let's disable -Wsystem-headers when we're building
2264       # with maximal warnings on OpenBSD.
2265       CFLAGS="$CFLAGS -Wno-system-headers" ;;
2266   esac
2268   CFLAGS_NOWARNINGS="$CFLAGS"
2270   # GCC4.3 users once report trouble with -Wstrict-overflow=5.  GCC5 users
2271   # have it work better.
2272   # CFLAGS="$CFLAGS -Wstrict-overflow=1"
2274   # This warning was added in gcc 4.3, but it appears to generate
2275   # spurious warnings in gcc 4.4.  I don't know if it works in 4.5.
2276   #CFLAGS="$CFLAGS -Wlogical-op"
2278   m4_foreach_w([warning_flag], [
2279      -Waddress
2280      -Waddress-of-array-temporary
2281      -Waddress-of-temporary
2282      -Wambiguous-macro
2283      -Wanonymous-pack-parens
2284      -Warc
2285      -Warc-abi
2286      -Warc-bridge-casts-disallowed-in-nonarc
2287      -Warc-maybe-repeated-use-of-weak
2288      -Warc-performSelector-leaks
2289      -Warc-repeated-use-of-weak
2290      -Warray-bounds
2291      -Warray-bounds-pointer-arithmetic
2292      -Wasm
2293      -Wasm-operand-widths
2294      -Watomic-properties
2295      -Watomic-property-with-user-defined-accessor
2296      -Wauto-import
2297      -Wauto-storage-class
2298      -Wauto-var-id
2299      -Wavailability
2300      -Wbackslash-newline-escape
2301      -Wbad-array-new-length
2302      -Wbind-to-temporary-copy
2303      -Wbitfield-constant-conversion
2304      -Wbool-conversion
2305      -Wbool-conversions
2306      -Wbuiltin-requires-header
2307      -Wchar-align
2308      -Wcompare-distinct-pointer-types
2309      -Wcomplex-component-init
2310      -Wconditional-type-mismatch
2311      -Wconfig-macros
2312      -Wconstant-conversion
2313      -Wconstant-logical-operand
2314      -Wconstexpr-not-const
2315      -Wcustom-atomic-properties
2316      -Wdangling-field
2317      -Wdangling-initializer-list
2318      -Wdate-time
2319      -Wdelegating-ctor-cycles
2320      -Wdeprecated-implementations
2321      -Wdeprecated-register
2322      -Wdirect-ivar-access
2323      -Wdiscard-qual
2324      -Wdistributed-object-modifiers
2325      -Wdivision-by-zero
2326      -Wdollar-in-identifier-extension
2327      -Wdouble-promotion
2328      -Wduplicate-decl-specifier
2329      -Wduplicate-enum
2330      -Wduplicate-method-arg
2331      -Wduplicate-method-match
2332      -Wduplicated-cond
2333      -Wdynamic-class-memaccess
2334      -Wembedded-directive
2335      -Wempty-translation-unit
2336      -Wenum-conversion
2337      -Wexit-time-destructors
2338      -Wexplicit-ownership-type
2339      -Wextern-initializer
2340      -Wextra
2341      -Wextra-semi
2342      -Wextra-tokens
2343      -Wflexible-array-extensions
2344      -Wfloat-conversion
2345      -Wformat-non-iso
2346      -Wfour-char-constants
2347      -Wgcc-compat
2348      -Wglobal-constructors
2349      -Wgnu-array-member-paren-init
2350      -Wgnu-designator
2351      -Wgnu-static-float-init
2352      -Wheader-guard
2353      -Wheader-hygiene
2354      -Widiomatic-parentheses
2355      -Wignored-attributes
2356      -Wimplicit-atomic-properties
2357      -Wimplicit-conversion-floating-point-to-bool
2358      -Wimplicit-exception-spec-mismatch
2359      -Wimplicit-fallthrough
2360      -Wimplicit-fallthrough-per-function
2361      -Wimplicit-retain-self
2362      -Wimport-preprocessor-directive-pedantic
2363      -Wincompatible-library-redeclaration
2364      -Wincompatible-pointer-types-discards-qualifiers
2365      -Wincomplete-implementation
2366      -Wincomplete-module
2367      -Wincomplete-umbrella
2368      -Winit-self
2369      -Wint-conversions
2370      -Wint-to-void-pointer-cast
2371      -Winteger-overflow
2372      -Winvalid-constexpr
2373      -Winvalid-iboutlet
2374      -Winvalid-noreturn
2375      -Winvalid-pp-token
2376      -Winvalid-source-encoding
2377      -Winvalid-token-paste
2378      -Wknr-promoted-parameter
2379      -Wlarge-by-value-copy
2380      -Wliteral-conversion
2381      -Wliteral-range
2382      -Wlocal-type-template-args
2383      -Wlogical-op
2384      -Wloop-analysis
2385      -Wmain-return-type
2386      -Wmalformed-warning-check
2387      -Wmethod-signatures
2388      -Wmicrosoft
2389      -Wmicrosoft-exists
2390      -Wmismatched-parameter-types
2391      -Wmismatched-return-types
2392      -Wmissing-field-initializers
2393      -Wmissing-format-attribute
2394      -Wmissing-noreturn
2395      -Wmissing-selector-name
2396      -Wmissing-sysroot
2397      -Wmissing-variable-declarations
2398      -Wmodule-conflict
2399      -Wnested-anon-types
2400      -Wnewline-eof
2401      -Wnon-literal-null-conversion
2402      -Wnon-pod-varargs
2403      -Wnonportable-cfstrings
2404      -Wnormalized=nfkc
2405      -Wnull-arithmetic
2406      -Wnull-character
2407      -Wnull-conversion
2408      -Wnull-dereference
2409      -Wout-of-line-declaration
2410      -Wover-aligned
2411      -Woverlength-strings
2412      -Woverride-init
2413      -Woverriding-method-mismatch
2414      -Wpointer-type-mismatch
2415      -Wpredefined-identifier-outside-function
2416      -Wprotocol-property-synthesis-ambiguity
2417      -Wreadonly-iboutlet-property
2418      -Wreadonly-setter-attrs
2419      -Wreceiver-expr
2420      -Wreceiver-forward-class
2421      -Wreceiver-is-weak
2422      -Wreinterpret-base-class
2423      -Wrequires-super-attribute
2424      -Wreserved-user-defined-literal
2425      -Wreturn-stack-address
2426      -Wsection
2427      -Wselector-type-mismatch
2428      -Wsentinel
2429      -Wserialized-diagnostics
2430      -Wshadow
2431      -Wshift-count-negative
2432      -Wshift-count-overflow
2433      -Wshift-negative-value
2434      -Wshift-overflow=2
2435      -Wshift-sign-overflow
2436      -Wshorten-64-to-32
2437      -Wsizeof-array-argument
2438      -Wsource-uses-openmp
2439      -Wstatic-float-init
2440      -Wstatic-in-inline
2441      -Wstatic-local-in-inline
2442      -Wstrict-overflow=1
2443      -Wstring-compare
2444      -Wstring-conversion
2445      -Wstrlcpy-strlcat-size
2446      -Wstrncat-size
2447      -Wsuggest-attribute=format
2448      -Wsuggest-attribute=noreturn
2449      -Wsuper-class-method-mismatch
2450      -Wswitch-bool
2451      -Wsync-nand
2452      -Wtautological-constant-out-of-range-compare
2453      -Wtentative-definition-incomplete-type
2454      -Wtrampolines
2455      -Wtype-safety
2456      -Wtypedef-redefinition
2457      -Wtypename-missing
2458      -Wundefined-inline
2459      -Wundefined-internal
2460      -Wundefined-reinterpret-cast
2461      -Wunicode
2462      -Wunicode-whitespace
2463      -Wunknown-warning-option
2464      -Wunnamed-type-template-args
2465      -Wunneeded-member-function
2466      -Wunsequenced
2467      -Wunsupported-visibility
2468      -Wunused-but-set-parameter
2469      -Wunused-but-set-variable
2470      -Wunused-command-line-argument
2471      -Wunused-const-variable=2
2472      -Wunused-exception-parameter
2473      -Wunused-local-typedefs
2474      -Wunused-member-function
2475      -Wunused-sanitize-argument
2476      -Wunused-volatile-lvalue
2477      -Wuser-defined-literals
2478      -Wvariadic-macros
2479      -Wvector-conversion
2480      -Wvector-conversions
2481      -Wvexing-parse
2482      -Wvisibility
2483      -Wvla-extension
2484      -Wzero-length-array
2485   ], [ TOR_TRY_COMPILE_WITH_CFLAGS(warning_flag, [],
2486               [TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS warning_flag" CFLAGS="$CFLAGS warning_flag"], true)
2487      ])
2489 dnl    We should re-enable this in some later version.  Clang doesn't
2490 dnl    mind, but it causes trouble with GCC.
2491 dnl     -Wstrict-overflow=2
2493 dnl    These seem to require annotations that we don't currently use,
2494 dnl    and they give false positives in our pthreads wrappers. (Clang 4)
2495 dnl     -Wthread-safety
2496 dnl     -Wthread-safety-analysis
2497 dnl     -Wthread-safety-attributes
2498 dnl     -Wthread-safety-beta
2499 dnl     -Wthread-safety-precise
2501   W_FLAGS="$W_FLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
2502   W_FLAGS="$W_FLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
2503   W_FLAGS="$W_FLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
2504   W_FLAGS="$W_FLAGS -Wwrite-strings"
2505   W_FLAGS="$W_FLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
2506   W_FLAGS="$W_FLAGS -Waggregate-return -Wpacked -Wunused"
2507   W_FLAGS="$W_FLAGS -Wunused-parameter "
2508   # These interfere with building main() { return 0; }, which autoconf
2509   # likes to use as its default program.
2510   W_FLAGS="$W_FLAGS -Wold-style-definition -Wmissing-declarations"
2512   TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS $W_FLAGS"
2513   CFLAGS="$CFLAGS $W_FLAGS"
2515   if test "$tor_cv_cflags__Wnull_dereference" = "yes"; then
2516     AC_DEFINE([HAVE_CFLAG_WNULL_DEREFERENCE], 1, [True if we have -Wnull-dereference])
2517   fi
2518   if test "$tor_cv_cflags__Woverlength_strings" = "yes"; then
2519     AC_DEFINE([HAVE_CFLAG_WOVERLENGTH_STRINGS], 1, [True if we have -Woverlength-strings])
2520   fi
2521   if test "$tor_cv_cflags__warn_unused_const_variable_2" = "yes"; then
2522     AC_DEFINE([HAVE_CFLAG_WUNUSED_CONST_VARIABLE], 1, [True if we have -Wunused-const-variable])
2523   fi
2525   CFLAGS="$CFLAGS_NOWARNINGS"
2527   if test "x$enable_fatal_warnings" = "xyes"; then
2528     # I'd like to use TOR_CHECK_CFLAGS here, but I can't, since the
2529     # default autoconf programs are full of errors.
2530     CFLAGS="$CFLAGS -Werror"
2531   fi
2535 AC_SUBST(TOR_WARNING_FLAGS)
2537 echo "$TOR_WARNING_FLAGS">warning_flags
2539 TOR_TRY_COMPILE_WITH_CFLAGS([@warning_flags], [],
2540                             CFLAGS="$CFLAGS @warning_flags",
2541                             CFLAGS="$CFLAGS $TOR_WARNING_FLAGS")
2543 if test "$enable_coverage" = "yes" && test "$have_clang" = "no"; then
2544    case "$host_os" in
2545     darwin*)
2546       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.])
2547    esac
2550 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
2552 AC_CONFIG_FILES([
2553         Doxyfile
2554         Makefile
2555         config.rust
2556         contrib/operator-tools/tor.logrotate
2557         contrib/dist/tor.service
2558         src/config/torrc.sample
2559         src/config/torrc.minimal
2560         src/rust/.cargo/config
2561         scripts/maint/checkOptionDocs.pl
2562         warning_flags
2565 if test "x$asciidoc" = "xtrue" && test "$ASCIIDOC" = "none"; then
2566   regular_mans="doc/tor doc/tor-gencert doc/tor-resolve doc/torify"
2567   for file in $regular_mans ; do
2568     if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
2569       echo "==================================";
2570       echo;
2571       echo "Building Tor has failed since manpages cannot be built.";
2572       echo;
2573       echo "You need asciidoc installed to be able to build the manpages.";
2574       echo "To build without manpages, use the --disable-asciidoc argument";
2575       echo "when calling configure.";
2576       echo;
2577       echo "==================================";
2578       exit 1;
2579     fi
2580   done
2583 if test "$fragile_hardening" = "yes"; then
2584   AC_MSG_WARN([
2586 ============
2587 Warning!  Building Tor with --enable-fragile-hardening (also known as
2588 --enable-expensive-hardening) makes some kinds of attacks harder, but makes
2589 other kinds of attacks easier. A Tor instance build with this option will be
2590 somewhat less vulnerable to remote code execution, arithmetic overflow, or
2591 out-of-bounds read/writes... but at the cost of becoming more vulnerable to
2592 denial of service attacks. For more information, see
2593 https://trac.torproject.org/projects/tor/wiki/doc/TorFragileHardening
2594 ============
2595   ])
2598 AC_OUTPUT
2601 # Mini-report on what will be built.
2604 PPRINT_INIT
2605 PPRINT_SET_INDENT(1)
2606 PPRINT_SET_TS(65)
2608 AS_ECHO
2609 AS_ECHO("Tor Version: ${PPRINT_COLOR_BLDBLU}Tor $PACKAGE_VERSION $PPRINT_COLOR_RST")
2610 AS_ECHO
2612 PPRINT_SUBTITLE([Build Features])
2614 PPRINT_PROP_STRING([Compiler], [$CC])
2615 PPRINT_PROP_STRING([Host OS], [$host_os])
2616 AS_ECHO
2618 test "x$enable_fatal_warnings" = "xyes" && value=1 || value=0
2619 PPRINT_PROP_BOOL([Warnings are fatal (--enable-fatal-warnings)], $value)
2621 test "x$enable_rust" = "xyes" && value=1 || value=0
2622 PPRINT_PROP_BOOL([Rust support (--enable-rust)], $value)
2624 test "x$enable_cargo_online_mode" = "xyes" && value=1 || value=0
2625 PPRINT_PROP_BOOL([Cargo Online Fetch (--enable-cargo-online-mode)], $value)
2627 test "x$enable_android" = "xyes" && value=1 || value=0
2628 PPRINT_PROP_BOOL([Android support (--enable-android)], $value)
2630 AS_ECHO
2631 PPRINT_SUBTITLE([Static Build])
2633 test "x$enable_static_tor" = "xyes" && value=1 || value=0
2634 PPRINT_PROP_BOOL([tor (--enable-static-tor)], $value)
2636 if test "x$enable_static_libevent" = "xyes"; then
2637   PPRINT_PROP_STRING([libevent], [$TOR_LIBDIR_libevent])
2638 else
2639   PPRINT_PROP_BOOL([libevent (--enable-static-libevent)], $value)
2642 if test "x$enable_static_openssl" = "xyes"; then
2643   PPRINT_PROP_STRING([libssl], [$TOR_LIBDIR_openssl])
2644 else
2645   PPRINT_PROP_BOOL([libssl (--enable-static-openssl)], $value)
2648 if test "x$enable_static_zlib" = "xyes"; then
2649   PPRINT_PROP_STRING([zlib1g], [$TOR_LIBDIR_zlib])
2650 else
2651   PPRINT_PROP_BOOL([zlib1g (--enable-static-zlib)], $value)
2654 AS_ECHO
2655 PPRINT_SUBTITLE([Optional Libraries])
2657 test "x$enable_nss" = "xyes" && value=1 || value=0
2658 PPRINT_PROP_BOOL([libnss (--enable-nss)], $value)
2660 test "x$enable_seccomp" != "xno" && value=1 || value=0
2661 PPRINT_PROP_BOOL([libseccomp (--disable-seccomp)], $value)
2663 test "x$enable_libscrypt" != "xno" && value=1 || value=0
2664 PPRINT_PROP_BOOL([libscrypt (--disable-libscrypt)], $value)
2666 test "x$enable_systemd" = "xyes" && value=1 || value=0
2667 PPRINT_PROP_BOOL([Systemd support (--enable-systemd)], $value)
2669 test "x$enable_lzma" = "xyes" && value=1 || value=0
2670 PPRINT_PROP_BOOL([liblzma (--enable-lzma)], $value)
2672 test "x$enable_zstd" = "xyes" && value=1 || value=0
2673 PPRINT_PROP_BOOL([libzstd (--enable-zstd)], $value)
2675 AS_ECHO
2676 PPRINT_SUBTITLE([Hardening])
2678 test "x$enable_gcc_hardening" != "xno" && value=1 || value=0
2679 PPRINT_PROP_BOOL([Compiler Hardening (--disable-gcc-hardening)], $value)
2681 test "x$enable_linker_hardening" != "xno" && value=1 || value=0
2682 PPRINT_PROP_BOOL([Linker Hardening (--disable-linker-hardening)], $value)
2684 test "x$fragile_hardening" = "xyes" && value=1 || value=0
2685 PPRINT_PROP_BOOL([Fragile Hardening (--enable-fragile-hardening, dev only)], $value)
2687 AS_ECHO
2688 PPRINT_SUBTITLE([Modules])
2690 m4_foreach_w([mname], MODULES,
2691   [
2692     AM_COND_IF(m4_join([], [BUILD_MODULE_], m4_toupper([]mname[])), value=1, value=0)
2693     PPRINT_PROP_BOOL([mname (--disable-module-mname)], $value)
2694   ]
2697 AS_ECHO
2698 PPRINT_SUBTITLE([Documentation])
2700 test "x$enable_asciidoc" != "xno" && value=1 || value=0
2701 PPRINT_PROP_BOOL([AsciiDoc (--disable-asciidoc)], $value)
2703 test "x$enable_manpage" != "xno" && value=1 || value=0
2704 PPRINT_PROP_BOOL([Man Pages (--disable-manpage)], $value)
2706 test "x$enable_html_manual" != "xno" && value=1 || value=0
2707 PPRINT_PROP_BOOL([HTML Manual (--disable-html-manual)], $value)
2709 AS_ECHO
2710 PPRINT_SUBTITLE([Tests])
2712 test "x$enable_unittests" != "xno" && value=1 || value=0
2713 PPRINT_PROP_BOOL([Unit tests (--disable-unittests)], $value)
2715 test "x$enable_asserts_in_tests" = "xno" && value=1 || value=0
2716 PPRINT_PROP_BOOL([assert()s enabled (--enable-asserts-in-tests, dev only)], $value)
2718 test "x$enable_coverage" = "xyes" && value=1 || value=0
2719 PPRINT_PROP_BOOL([Code Coverage (--enable-coverage)], $value)
2721 test "x$enable_libfuzzer" = "xyes" && value=1 || value=0
2722 PPRINT_PROP_BOOL([libFuzzer support (--enable-libfuzzer)], $value)
2724 test "x$enable_oss_fuzz" = "xyes" && value=1 || value=0
2725 PPRINT_PROP_BOOL([OSS-Fuzz support (--enable-oss-fuzz)], $value)
2727 AS_ECHO
2728 PPRINT_SUBTITLE([Install Directories])
2730 report_mandir="`eval eval echo $mandir`"
2731 PPRINT_PROP_STRING([Binaries], [$BINDIR])
2732 PPRINT_PROP_STRING([Configuration], [$CONFDIR])
2733 PPRINT_PROP_STRING([Man Pages], [$report_mandir])
2735 AS_ECHO
2736 AS_ECHO(["Configure Line: ./configure $configure_flags"])