Merge branch 'maint-0.4.2' into maint-0.4.3
[tor.git] / configure.ac
blobe28f957d0370f19630b068ddce7741c6f14a6a65
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.3.6-dev])
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-07-09"], # for 0.4.3.6-dev
20           [Approximate date when this software was released. (Updated when the version changes.)])
22 # "foreign" means we don't follow GNU package layout standards
23 # "1.11" means we require automake version 1.11 or newer
24 # "subdir-objects" means put .o files in the same directory as the .c files
25 AM_INIT_AUTOMAKE([foreign 1.11 subdir-objects -Wall -Werror])
27 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
28 AC_CONFIG_HEADERS([orconfig.h])
30 AC_USE_SYSTEM_EXTENSIONS
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 dnl Linker hardening options
232 dnl Currently these options are ELF specific - you can't use this with MacOSX
233 AC_ARG_ENABLE(linker-hardening,
234     AS_HELP_STRING(--disable-linker-hardening, [disable linker security fixups]))
236 AC_ARG_ENABLE(local-appdata,
237    AS_HELP_STRING(--enable-local-appdata, [default to host local application data paths on Windows]))
238 if test "$enable_local_appdata" = "yes"; then
239   AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
240             [Defined if we default to host local appdata paths on Windows])
243 AC_ARG_ENABLE(tool-name-check,
244      AS_HELP_STRING(--disable-tool-name-check, [check for sanely named toolchain when cross-compiling]))
246 AC_ARG_ENABLE(seccomp,
247      AS_HELP_STRING(--disable-seccomp, [do not attempt to use libseccomp]))
249 AC_ARG_ENABLE(libscrypt,
250      AS_HELP_STRING(--disable-libscrypt, [do not attempt to use libscrypt]))
252 dnl Enable event tracing which are transformed to debug log statement.
253 AC_ARG_ENABLE(event-tracing-debug,
254      AS_HELP_STRING(--enable-event-tracing-debug, [build with event tracing to debug log]))
255 AM_CONDITIONAL([USE_EVENT_TRACING_DEBUG], [test "x$enable_event_tracing_debug" = "xyes"])
257 if test x$enable_event_tracing_debug = xyes; then
258   AC_DEFINE([USE_EVENT_TRACING_DEBUG], [1], [Tracing framework to log debug])
259   AC_DEFINE([TOR_EVENT_TRACING_ENABLED], [1], [Compile the event tracing instrumentation])
262 dnl Enable Android only features.
263 AC_ARG_ENABLE(android,
264      AS_HELP_STRING(--enable-android, [build with Android features enabled]))
265 AM_CONDITIONAL([USE_ANDROID], [test "x$enable_android" = "xyes"])
267 if test "x$enable_android" = "xyes"; then
268   AC_DEFINE([USE_ANDROID], [1], [Compile with Android specific features enabled])
270   dnl Check if the Android log library is available.
271   AC_CHECK_HEADERS([android/log.h])
272   AC_SEARCH_LIBS(__android_log_write, [log])
276 dnl ---
277 dnl Tor modules options. These options are namespaced with --disable-module-XXX
278 dnl ---
280 dnl All our modules.
281 m4_define(MODULES, relay dirauth dircache)
283 dnl Relay module.
284 AC_ARG_ENABLE([module-relay],
285               AS_HELP_STRING([--disable-module-relay],
286                              [Build tor without the Relay modules: tor can not run as a relay, bridge, or authority. Implies --disable-module-dirauth]))
287 AM_CONDITIONAL(BUILD_MODULE_RELAY, [test "x$enable_module_relay" != "xno"])
288 AM_COND_IF(BUILD_MODULE_RELAY,
289            AC_DEFINE([HAVE_MODULE_RELAY], [1],
290                      [Compile with Relay feature support]))
292 dnl Dircache module.  (This cannot be enabled or disabled independently of
293 dnl the relay module.  It is not listed by --list-modules for this reason.)
294 AM_CONDITIONAL(BUILD_MODULE_DIRCACHE,
295                [test "x$enable_module_relay" != "xno"])
296 AM_COND_IF(BUILD_MODULE_DIRCACHE,
297            AC_DEFINE([HAVE_MODULE_DIRCACHE], [1],
298                      [Compile with directory cache support]))
300 dnl Directory Authority module.
301 AC_ARG_ENABLE([module-dirauth],
302               AS_HELP_STRING([--disable-module-dirauth],
303                              [Build tor without the Directory Authority module: tor can not run as a directory authority or bridge authority]))
304 AM_CONDITIONAL(BUILD_MODULE_DIRAUTH,[test "x$enable_module_dirauth" != "xno" && test "x$enable_module_relay" != "xno"])
305 AM_COND_IF(BUILD_MODULE_DIRAUTH,
306            AC_DEFINE([HAVE_MODULE_DIRAUTH], [1],
307                      [Compile with Directory Authority feature support]))
309 dnl Helper variables.
310 TOR_MODULES_ALL_ENABLED=
311 AC_DEFUN([ADD_MODULE], [
312     MODULE=m4_toupper($1)
313     TOR_MODULES_ALL_ENABLED="${TOR_MODULES_ALL_ENABLED} -DHAVE_MODULE_${MODULE}=1"
315 m4_foreach_w([module], MODULES, [ADD_MODULE([module])])
316 AC_SUBST(TOR_MODULES_ALL_ENABLED)
318 dnl check for the correct "ar" when cross-compiling.
319 dnl   (AM_PROG_AR was new in automake 1.11.2, which we do not yet require,
320 dnl    so kludge up a replacement for the case where it isn't there yet.)
321 m4_ifdef([AM_PROG_AR],
322          [AM_PROG_AR],
323          [AN_MAKEVAR([AR], [AC_PROG_AR])
324           AN_PROGRAM([ar], [AC_PROG_AR])
325           AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [:])])
326           AC_PROG_AR])
328 dnl Check whether the above macro has settled for a simply named tool even
329 dnl though we're cross compiling. We must do this before running AC_PROG_CC,
330 dnl because that will find any cc on the system, not only the cross-compiler,
331 dnl and then verify that a binary built with this compiler runs on the
332 dnl build system. It will then come to the false conclusion that we're not
333 dnl cross-compiling.
334 if test "x$enable_tool_name_check" != "xno"; then
335     if test "x$ac_tool_warned" = "xyes"; then
336         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.)])
337         elif test "x$ac_ct_AR" != "x" -a "x$cross_compiling" = "xmaybe"; then
338                 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.)])
339         fi
342 AC_PROG_CC
343 AC_PROG_CPP
344 AC_PROG_MAKE_SET
345 AC_PROG_RANLIB
346 AC_PROG_SED
348 AC_ARG_VAR([PERL], [path to Perl binary])
349 AC_CHECK_PROGS([PERL], [perl])
350 AM_CONDITIONAL(USE_PERL, [test "x$ac_cv_prog_PERL" != "x"])
352 dnl check for asciidoc and a2x
353 AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
354 AC_PATH_PROGS([A2X], [a2x a2x.py], none)
356 AM_CONDITIONAL(USE_ASCIIDOC, test "x$asciidoc" = "xtrue")
357 AM_CONDITIONAL(BUILD_MANPAGE, [test "x$enable_manpage" != "xno"])
358 AM_CONDITIONAL(BUILD_HTML_DOCS, [test "x$enable_html_manual" != "xno"])
360 AM_PROG_CC_C_O
361 AC_PROG_CC_C99
363 AC_CACHE_CHECK([for Python 3], [tor_cv_PYTHON],
364    [AC_PATH_PROGS_FEATURE_CHECK([PYTHON], [ \
365         python3 \
366         python3.8 python3.7 python3.6 python3.5 python3.4 \
367         python ],
368    [["$ac_path_PYTHON" -c 'import sys; sys.exit(sys.version_info[0]<3)' && tor_cv_PYTHON="$ac_path_PYTHON" ac_path_PYTHON_found=:]] )])
369 AC_SUBST([PYTHON], [$tor_cv_PYTHON])
371 PYTHON="$tor_cv_PYTHON"
373 if test "x$PYTHON" = "x"; then
374   AC_MSG_WARN([Python 3 unavailable; some tests will not be run.])
377 AM_CONDITIONAL(USEPYTHON, [test "x$PYTHON" != "x"])
379 dnl List all external rust crates we depend on here. Include the version
380 rust_crates=" \
381     digest-0.7.2 \
382     libc-0.2.39 \
384 AC_SUBST(rust_crates)
386 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
387 AC_C_FLEXIBLE_ARRAY_MEMBER
388 ], [
389  dnl Maybe we've got an old autoconf...
390  AC_CACHE_CHECK([for flexible array members],
391      tor_cv_c_flexarray,
392      [AC_COMPILE_IFELSE(
393        AC_LANG_PROGRAM([
394  struct abc { int a; char b[]; };
395 ], [
396  struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
397  def->b[0] = 33;
399   [tor_cv_c_flexarray=yes],
400   [tor_cv_c_flexarray=no])])
401  if test "$tor_cv_flexarray" = "yes"; then
402    AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
403  else
404    AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
405  fi
408 AC_CACHE_CHECK([for working C99 mid-block declaration syntax],
409       tor_cv_c_c99_decl,
410       [AC_COMPILE_IFELSE(
411          [AC_LANG_PROGRAM([], [int x; x = 3; int y; y = 4 + x;])],
412          [tor_cv_c_c99_decl=yes],
413          [tor_cv_c_c99_decl=no] )])
414 if test "$tor_cv_c_c99_decl" != "yes"; then
415   AC_MSG_ERROR([Your compiler doesn't support c99 mid-block declarations. This is required as of Tor 0.2.6.x])
418 AC_CACHE_CHECK([for working C99 designated initializers],
419       tor_cv_c_c99_designated_init,
420       [AC_COMPILE_IFELSE(
421          [AC_LANG_PROGRAM([struct s { int a; int b; };],
422                [[ struct s ss = { .b = 5, .a = 6 }; ]])],
423          [tor_cv_c_c99_designated_init=yes],
424          [tor_cv_c_c99_designated_init=no] )])
426 if test "$tor_cv_c_c99_designated_init" != "yes"; then
427   AC_MSG_ERROR([Your compiler doesn't support c99 designated initializers. This is required as of Tor 0.2.6.x])
430 saved_CFLAGS="$CFLAGS"
431 CFLAGS="$CFLAGS -Werror"
432 AC_CACHE_CHECK([for __attribute__((fallthrough))],
433       tor_cv_c_attr_fallthrough,
434       [AC_COMPILE_IFELSE(
435          [AC_LANG_PROGRAM([extern int x; void fn(void) ;],
436                [[ switch (x) { case 1: fn(); __attribute__((fallthrough));
437                                case 2: fn(); break; } ]])],
438          [tor_cv_c_attr_fallthrough=yes],
439          [tor_cv_c_attr_fallthrough=no] )])
440 CFLAGS="$saved_CFLAGS"
442 if test "$tor_cv_c_attr_fallthrough" = "yes"; then
443   AC_DEFINE(HAVE_ATTR_FALLTHROUGH, [1], [defined if we have the fallthrough attribute.])
446 TORUSER=_tor
447 AC_ARG_WITH(tor-user,
448         AS_HELP_STRING(--with-tor-user=NAME, [specify username for tor daemon]),
449         [
450            TORUSER=$withval
451         ]
453 AC_SUBST(TORUSER)
455 TORGROUP=_tor
456 AC_ARG_WITH(tor-group,
457         AS_HELP_STRING(--with-tor-group=NAME, [specify group name for tor daemon]),
458         [
459            TORGROUP=$withval
460         ]
462 AC_SUBST(TORGROUP)
465 dnl If _WIN32 is defined and non-zero, we are building for win32
466 AC_MSG_CHECKING([for win32])
467 AC_RUN_IFELSE([AC_LANG_SOURCE([
468 int main(int c, char **v) {
469 #ifdef _WIN32
470 #if _WIN32
471   return 0;
472 #else
473   return 1;
474 #endif
475 #else
476   return 2;
477 #endif
478 }])],
479 bwin32=true; AC_MSG_RESULT([yes]),
480 bwin32=false; AC_MSG_RESULT([no]),
481 bwin32=cross; AC_MSG_RESULT([cross])
484 if test "$bwin32" = "cross"; then
485 AC_MSG_CHECKING([for win32 (cross)])
486 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
487 #ifdef _WIN32
488 int main(int c, char **v) {return 0;}
489 #else
490 #error
491 int main(int c, char **v) {return x(y);}
492 #endif
493 ])],
494 bwin32=true; AC_MSG_RESULT([yes]),
495 bwin32=false; AC_MSG_RESULT([no]))
498 AH_BOTTOM([
499 #ifdef _WIN32
500 /* Defined to access windows functions and definitions for >=WinXP */
501 # ifndef WINVER
502 #  define WINVER 0x0501
503 # endif
505 /* Defined to access _other_ windows functions and definitions for >=WinXP */
506 # ifndef _WIN32_WINNT
507 #  define _WIN32_WINNT 0x0501
508 # endif
510 /* Defined to avoid including some windows headers as part of Windows.h */
511 # ifndef WIN32_LEAN_AND_MEAN
512 #  define WIN32_LEAN_AND_MEAN 1
513 # endif
514 #endif
517 AM_CONDITIONAL(WIN32, test "x$bwin32" = "xtrue")
518 AM_CONDITIONAL(BUILD_NT_SERVICES, test "x$bwin32" = "xtrue")
519 AM_CONDITIONAL(BUILD_LIBTORRUNNER, test "x$bwin32" != "xtrue")
521 dnl Enable C99 when compiling with MIPSpro
522 AC_MSG_CHECKING([for MIPSpro compiler])
523 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
524 #if (defined(__sgi) && defined(_COMPILER_VERSION))
525 #error
526   return x(y);
527 #endif
528 ])],
529 bmipspro=false; AC_MSG_RESULT(no),
530 bmipspro=true; AC_MSG_RESULT(yes))
532 if test "$bmipspro" = "true"; then
533   CFLAGS="$CFLAGS -c99"
536 AC_C_BIGENDIAN
538 AC_ARG_VAR([TOR_RUST_TARGET], [Rust target, must be specified when cross-compiling (HOST != BUILD). example: i686-pc-windows-gnu])
540 if test "x$enable_rust" = "xyes"; then
541   AC_ARG_VAR([RUSTC], [path to the rustc binary])
542   AC_CHECK_PROG([RUSTC], [rustc], [rustc],[no])
543   if test "x$RUSTC" = "xno"; then
544     AC_MSG_ERROR([rustc unavailable but rust integration requested.])
545   fi
547   AC_ARG_VAR([CARGO], [path to the cargo binary])
548   AC_CHECK_PROG([CARGO], [cargo], [cargo],[no])
549   if test "x$CARGO" = "xno"; then
550     AC_MSG_ERROR([cargo unavailable but rust integration requested.])
551   fi
553   AC_DEFINE([HAVE_RUST], 1, [have Rust])
554   if test "x$enable_fatal_warnings" = "xyes"; then
555     RUST_WARN=
556   else
557     RUST_WARN=#
558   fi
559   if test "x$enable_cargo_online_mode" = "xyes"; then
560     CARGO_ONLINE=
561     RUST_DL=#
562   else
563     CARGO_ONLINE=--frozen
564     RUST_DL=
566     dnl When we're not allowed to touch the network, we need crate dependencies
567     dnl locally available.
568     AC_MSG_CHECKING([rust crate dependencies])
569     AC_ARG_VAR([TOR_RUST_DEPENDENCIES], [path to directory with local crate mirror])
570     if test "x$TOR_RUST_DEPENDENCIES" = "x"; then
571       TOR_RUST_DEPENDENCIES="${srcdir}/src/ext/rust/crates"
572     fi
573     dnl Check whether the path exists before we try to cd into it.
574     if test ! -d "$TOR_RUST_DEPENDENCIES"; then
575       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.])
576       ERRORED=1
577     fi
578     dnl Make the path absolute, since we'll be using it from within a
579     dnl subdirectory.
580     TOR_RUST_DEPENDENCIES=$(cd "$TOR_RUST_DEPENDENCIES" ; pwd)
582     for dep in $rust_crates; do
583       if test ! -d "$TOR_RUST_DEPENDENCIES"/"$dep"; then
584         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.])
585         ERRORED=1
586       fi
587     done
588     if test "x$ERRORED" = "x"; then
589       AC_MSG_RESULT([yes])
590     fi
591   fi
593   dnl For now both MSVC and MinGW rust libraries will output static libs with
594   dnl the MSVC naming convention.
595   if test "$bwin32" = "true"; then
596     tor_rust_static_name=tor_rust.lib
597   else
598     tor_rust_static_name=libtor_rust.a
599   fi
601   AC_CANONICAL_BUILD
603   if test -n "$TOR_RUST_TARGET"; then
604     if test "$host" = "$build"; then
605       AC_MSG_ERROR([HOST = BUILD is invalid if TOR_RUST_TARGET is specified, see configure --help for more information.])
606     fi
607     RUST_TARGET_PROP="target = '$TOR_RUST_TARGET'"
608     TOR_RUST_LIB_PATH="src/rust/target/$TOR_RUST_TARGET/release/$tor_rust_static_name"
609   else
610     if test "$host" != "$build"; then
611       AC_MSG_ERROR([TOR_RUST_TARGET must be specified when cross-compiling with Rust enabled.])
612     fi
613     RUST_TARGET_PROP=
614     TOR_RUST_LIB_PATH="src/rust/target/release/$tor_rust_static_name"
615   fi
617   AC_SUBST(RUST_TARGET_PROP)
618   AC_SUBST(TOR_RUST_LIB_PATH)
619   AC_SUBST(CARGO_ONLINE)
620   AC_SUBST(RUST_WARN)
621   AC_SUBST(RUST_DL)
623   dnl Let's check the rustc version, too
624   AC_MSG_CHECKING([rust version])
625   RUSTC_VERSION=`$RUSTC --version`
626   RUSTC_VERSION_MAJOR=`$RUSTC --version | cut -d ' ' -f 2 | cut -d '.' -f 1`
627   RUSTC_VERSION_MINOR=`$RUSTC --version | cut -d ' ' -f 2 | cut -d '.' -f 2`
628   if test "x$RUSTC_VERSION_MAJOR" = "x" -o "x$RUSTC_VERSION_MINOR" = "x"; then
629     AC_MSG_ERROR([rustc version couldn't be identified])
630   fi
631   if test "$RUSTC_VERSION_MAJOR" -lt 2 -a "$RUSTC_VERSION_MINOR" -lt 31; then
632     AC_MSG_ERROR([rustc must be at least version 1.31.0])
633   fi
634   AC_MSG_RESULT([$RUSTC_VERSION])
637 AC_SEARCH_LIBS(socket, [socket network])
638 AC_SEARCH_LIBS(gethostbyname, [nsl])
639 AC_SEARCH_LIBS(dlopen, [dl])
640 AC_SEARCH_LIBS(inet_aton, [resolv])
641 AC_SEARCH_LIBS(backtrace, [execinfo])
642 saved_LIBS="$LIBS"
643 AC_SEARCH_LIBS([clock_gettime], [rt])
644 if test "$LIBS" != "$saved_LIBS"; then
645    # Looks like we need -lrt for clock_gettime().
646    have_rt=yes
649 if test "$bwin32" = "false"; then
650   AC_SEARCH_LIBS(pthread_create, [pthread])
651   AC_SEARCH_LIBS(pthread_detach, [pthread])
654 AM_CONDITIONAL(THREADS_WIN32, test "$bwin32" = "true")
655 AM_CONDITIONAL(THREADS_PTHREADS, test "$bwin32" = "false")
657 AC_CHECK_FUNCS(
658         _NSGetEnviron \
659         RtlSecureZeroMemory \
660         SecureZeroMemory \
661         accept4 \
662         backtrace \
663         backtrace_symbols_fd \
664         eventfd \
665         explicit_bzero \
666         timingsafe_memcmp \
667         flock \
668         fsync \
669         ftime \
670         get_current_dir_name \
671         getaddrinfo \
672         getdelim \
673         getifaddrs \
674         getline \
675         getpass \
676         getrlimit \
677         gettimeofday \
678         gmtime_r \
679         gnu_get_libc_version \
680         htonll \
681         inet_aton \
682         ioctl \
683         issetugid \
684         llround \
685         localtime_r \
686         lround \
687         madvise \
688         memmem \
689         memset_s \
690         minherit \
691         mmap \
692         pipe \
693         pipe2 \
694         prctl \
695         readpassphrase \
696         rint \
697         sigaction \
698         socketpair \
699         statvfs \
700         strncasecmp \
701         strcasecmp \
702         strlcat \
703         strlcpy \
704         strnlen \
705         strptime \
706         strtok_r \
707         strtoull \
708         sysconf \
709         sysctl \
710         truncate \
711         uname \
712         usleep \
713         vasprintf \
714         _vscprintf
717 # Apple messed up when they added some functions: they
718 # forgot to decorate them with appropriate AVAILABLE_MAC_OS_VERSION
719 # checks.
721 # We should only probe for these functions if we are sure that we
722 # are not targeting OS X 10.9 or earlier.
723 AC_MSG_CHECKING([for a pre-Yosemite OS X build target])
724 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
725 #ifdef __APPLE__
726 #  include <AvailabilityMacros.h>
727 #  ifndef MAC_OS_X_VERSION_10_10
728 #    define MAC_OS_X_VERSION_10_10 101000
729 #  endif
730 #  if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
731 #    if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
732 #      error "Running on Mac OS X 10.9 or earlier"
733 #    endif
734 #  endif
735 #endif
736 ]], [[]])],
737    [on_macos_pre_10_10=no ; AC_MSG_RESULT([no])],
738    [on_macos_pre_10_10=yes; AC_MSG_RESULT([yes])])
740 if test "$on_macos_pre_10_10" = "no"; then
741   AC_CHECK_FUNCS(
742         mach_approximate_time \
743   )
746 # We should only probe for these functions if we are sure that we
747 # are not targeting OSX 10.11 or earlier.
748 AC_MSG_CHECKING([for a pre-Sierra OSX build target])
749 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
750 #ifdef __APPLE__
751 #  include <AvailabilityMacros.h>
752 #  ifndef MAC_OS_X_VERSION_10_12
753 #    define MAC_OS_X_VERSION_10_12 101200
754 #  endif
755 #  if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
756 #    if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
757 #      error "Running on Mac OSX 10.11 or earlier"
758 #    endif
759 #  endif
760 #endif
761 ]], [[]])],
762    [on_macos_pre_10_12=no ; AC_MSG_RESULT([no])],
763    [on_macos_pre_10_12=yes; AC_MSG_RESULT([yes])])
765 if test "$on_macos_pre_10_12" = "no"; then
766   AC_CHECK_FUNCS(
767         clock_gettime \
768         getentropy \
769   )
772 if test "$bwin32" != "true"; then
773   AC_CHECK_HEADERS(pthread.h)
774   AC_CHECK_FUNCS(pthread_create)
775   AC_CHECK_FUNCS(pthread_condattr_setclock)
778 if test "$bwin32" = "true"; then
779   AC_CHECK_DECLS([SecureZeroMemory, _getwch], , , [
780 #include <windows.h>
781 #include <conio.h>
782 #include <wchar.h>
783                  ])
786 AM_CONDITIONAL(BUILD_READPASSPHRASE_C,
787   test "x$ac_cv_func_readpassphrase" = "xno" && test "$bwin32" = "false")
789 AC_MSG_CHECKING([whether free(NULL) works])
790 AC_RUN_IFELSE([AC_LANG_PROGRAM([
791   #include <stdlib.h>
792 ], [
793 char *p = NULL;
794 free(p);
795 ])],
796 [free_null_ok=true; AC_MSG_RESULT(yes)],
797 [free_null_ok=false; AC_MSG_RESULT(no)],
798 [free_null_ok=cross; AC_MSG_RESULT(cross)])
800 if test "$free_null_ok" = "false"; then
801    AC_MSG_ERROR([Your libc implementation doesn't allow free(NULL), as required by C99.])
804 dnl ------------------------------------------------------
805 dnl Where do you live, libevent?  And how do we call you?
807 if test "$bwin32" = "true"; then
808   TOR_LIB_WS32=-lws2_32
809   TOR_LIB_IPHLPAPI=-liphlpapi
810   # Some of the cargo-cults recommend -lwsock32 as well, but I don't
811   # think it's actually necessary.
812   TOR_LIB_GDI=-lgdi32
813   TOR_LIB_USERENV=-luserenv
814 else
815   TOR_LIB_WS32=
816   TOR_LIB_GDI=
817   TOR_LIB_USERENV=
819 AC_SUBST(TOR_LIB_WS32)
820 AC_SUBST(TOR_LIB_GDI)
821 AC_SUBST(TOR_LIB_IPHLPAPI)
822 AC_SUBST(TOR_LIB_USERENV)
824 tor_libevent_pkg_redhat="libevent"
825 tor_libevent_pkg_debian="libevent-dev"
826 tor_libevent_devpkg_redhat="libevent-devel"
827 tor_libevent_devpkg_debian="libevent-dev"
829 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
830 dnl linking for static builds.
831 STATIC_LIBEVENT_FLAGS=""
832 if test "$enable_static_libevent" = "yes"; then
833     if test "$have_rt" = "yes"; then
834       STATIC_LIBEVENT_FLAGS=" -lrt "
835     fi
838 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
839 #ifdef _WIN32
840 #include <winsock2.h>
841 #endif
842 #include <sys/time.h>
843 #include <sys/types.h>
844 #include <event2/event.h>], [
845 #ifdef _WIN32
846 #include <winsock2.h>
847 #endif
848 struct event_base;
849 struct event_base *event_base_new(void);
850 void event_base_free(struct event_base *);],
851     [
852 #ifdef _WIN32
853 {WSADATA d; WSAStartup(0x101,&d); }
854 #endif
855 event_base_free(event_base_new());
856 ], [--with-libevent-dir], [/opt/libevent])
858 dnl Determine the incantation needed to link libevent.
859 save_LIBS="$LIBS"
860 save_LDFLAGS="$LDFLAGS"
861 save_CPPFLAGS="$CPPFLAGS"
863 LIBS="$STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $save_LIBS"
864 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
865 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
867 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
869 if test "$enable_static_libevent" = "yes"; then
870    if test "$tor_cv_library_libevent_dir" = "(system)"; then
871      AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
872    else
873      TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
874    fi
875 else
876      if test "x$ac_cv_header_event2_event_h" = "xyes"; then
877        AC_SEARCH_LIBS(event_new, [event event_core], , AC_MSG_ERROR("libevent2 is installed but linking it failed while searching for event_new"))
878        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"))
880        if test "$ac_cv_search_event_new" != "none required"; then
881          TOR_LIBEVENT_LIBS="$ac_cv_search_event_new"
882        fi
883        if test "$ac_cv_search_evdns_base_new" != "none required"; then
884          TOR_LIBEVENT_LIBS="$ac_cv_search_evdns_base_new $TOR_LIBEVENT_LIBS"
885        fi
886      else
887        AC_MSG_ERROR("libevent2 is required but the headers could not be found")
888      fi
891 dnl Now check for particular libevent functions.
892 AC_CHECK_FUNCS([evutil_secure_rng_set_urandom_device_file \
893                 evutil_secure_rng_add_bytes \
894                 evdns_base_get_nameserver_addr \
898 LIBS="$save_LIBS"
899 LDFLAGS="$save_LDFLAGS"
900 CPPFLAGS="$save_CPPFLAGS"
902 dnl Check that libevent is at least at version 2.0.10, the first stable
903 dnl release of its series
904 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
905 AC_MSG_CHECKING([whether Libevent is new enough])
906 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
907 #include <event2/event.h>
908 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000a00
909 #error
910 int x = y(zz);
911 #else
912 int x = 1;
913 #endif
914 ])], [ AC_MSG_RESULT([yes]) ],
915    [ AC_MSG_RESULT([no])
916      AC_MSG_ERROR([Libevent is not new enough.  We require 2.0.10-stable or later]) ] )
918 LIBS="$save_LIBS"
919 LDFLAGS="$save_LDFLAGS"
920 CPPFLAGS="$save_CPPFLAGS"
922 AC_SUBST(TOR_LIBEVENT_LIBS)
924 dnl ------------------------------------------------------
925 dnl Where do you live, libm?
927 dnl On some platforms (Haiku/BeOS) the math library is
928 dnl part of libroot. In which case don't link against lm
929 TOR_LIB_MATH=""
930 save_LIBS="$LIBS"
931 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
932 if test "$ac_cv_search_pow" != "none required"; then
933     TOR_LIB_MATH="$ac_cv_search_pow"
935 LIBS="$save_LIBS"
936 AC_SUBST(TOR_LIB_MATH)
938 dnl ------------------------------------------------------
939 dnl Hello, NSS.  You're new around here.
940 if test "x$enable_nss" = "xyes"; then
941   PKG_CHECK_MODULES(NSS,
942      [nss],
943      [have_nss=yes],
944      [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.])])
945   AC_SUBST(NSS_CFLAGS)
946   AC_SUBST(NSS_LIBS)
949 dnl ------------------------------------------------------
950 dnl Where do you live, openssl?  And how do we call you?
952 if test "x$enable_nss" != "xyes"; then
954 tor_openssl_pkg_redhat="openssl"
955 tor_openssl_pkg_debian="libssl-dev"
956 tor_openssl_devpkg_redhat="openssl-devel"
957 tor_openssl_devpkg_debian="libssl-dev"
959 ALT_openssl_WITHVAL=""
960 AC_ARG_WITH(ssl-dir,
961   AS_HELP_STRING(--with-ssl-dir=PATH, [obsolete alias for --with-openssl-dir]),
962   [
963       if test "x$withval" != "xno" && test "x$withval" != "x"; then
964          ALT_openssl_WITHVAL="$withval"
965       fi
966   ])
968 AC_MSG_NOTICE([Now, we'll look for OpenSSL >= 1.0.1])
969 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI $TOR_LIB_WS32],
970     [#include <openssl/ssl.h>
971      char *getenv(const char *);],
972     [struct ssl_cipher_st;
973      unsigned SSL_CIPHER_get_id(const struct ssl_cipher_st *);
974      char *getenv(const char *);],
975     dnl This funny-looking test program calls getenv, so that the compiler
976     dnl will neither make code that call SSL_CIPHER_get_id(NULL) [producing
977     dnl a crash], nor optimize out the call to SSL_CIPHER_get_id().
978     dnl We look for SSL_cipher_get_id() because it is present in
979     dnl OpenSSL >=1.0.1, because it is not deprecated, and because Tor
980     dnl depends on it.
981     [if (getenv("THIS_SHOULDNT_BE_SET_X201803")) SSL_CIPHER_get_id((void *)0);], [],
982     [/usr/local/opt/openssl /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /opt/openssl])
984 dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
986 if test "$enable_static_openssl" = "yes"; then
987    if test "$tor_cv_library_openssl_dir" = "(system)"; then
988      AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
989    else
990      TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
991    fi
992 else
993      TOR_OPENSSL_LIBS="-lssl -lcrypto"
995 AC_SUBST(TOR_OPENSSL_LIBS)
997 dnl Now check for particular openssl functions.
998 save_LIBS="$LIBS"
999 save_LDFLAGS="$LDFLAGS"
1000 save_CPPFLAGS="$CPPFLAGS"
1001 LIBS="$TOR_OPENSSL_LIBS $LIBS"
1002 LDFLAGS="$TOR_LDFLAGS_openssl $LDFLAGS"
1003 CPPFLAGS="$TOR_CPPFLAGS_openssl $CPPFLAGS"
1005 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1006 #include <openssl/opensslv.h>
1007 #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1000100fL
1008 #error "too old"
1009 #endif
1010    ]], [[]])],
1011    [ : ],
1012    [ 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.]) ])
1014 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1015 #include <openssl/opensslv.h>
1016 #include <openssl/evp.h>
1017 #if defined(OPENSSL_NO_EC) || defined(OPENSSL_NO_ECDH) || defined(OPENSSL_NO_ECDSA)
1018 #error "no ECC"
1019 #endif
1020 #if !defined(NID_X9_62_prime256v1) || !defined(NID_secp224r1)
1021 #error "curves unavailable"
1022 #endif
1023    ]], [[]])],
1024    [ : ],
1025    [ 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.]) ])
1027 AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , ,
1028 [#include <openssl/ssl.h>
1031 dnl OpenSSL functions which we might not have.  In theory, we could just
1032 dnl check the openssl version number, but in practice that gets pretty
1033 dnl confusing with LibreSSL, OpenSSL, and various distributions' patches
1034 dnl to them.
1035 AC_CHECK_FUNCS([ \
1036                 ERR_load_KDF_strings \
1037                 EVP_PBE_scrypt \
1038                 EVP_sha3_256 \
1039                 SSL_CIPHER_find \
1040                 SSL_CTX_set1_groups_list \
1041                 SSL_CTX_set_security_level \
1042                 SSL_SESSION_get_master_key \
1043                 SSL_get_client_ciphers \
1044                 SSL_get_client_random \
1045                 SSL_get_server_random \
1046                 TLS_method \
1047                ])
1049 dnl Check if OpenSSL structures are opaque
1050 AC_CHECK_MEMBERS([SSL.state], , ,
1051 [#include <openssl/ssl.h>
1054 AC_CHECK_SIZEOF(SHA_CTX, , [AC_INCLUDES_DEFAULT()
1055 #include <openssl/sha.h>
1058 fi # enable_nss
1060 dnl We will someday make KECCAK_TINY optional, but for now we still need
1061 dnl it for SHAKE, since OpenSSL's SHAKE can't be squeezed more than
1062 dnl once.  See comment in the definition of crypto_xof_t.
1064 dnl AM_CONDITIONAL(BUILD_KECCAK_TINY,
1065 dnl   test "x$ac_cv_func_EVP_sha3_256" != "xyes")
1067 AM_CONDITIONAL(BUILD_KECCAK_TINY, true)
1069 dnl ======================================================================
1070 dnl Can we use KIST?
1072 dnl Define the set of checks for KIST scheduler support.
1073 AC_DEFUN([CHECK_KIST_SUPPORT],[
1074   dnl KIST needs struct tcp_info and for certain members to exist.
1075   AC_CHECK_MEMBERS(
1076     [struct tcp_info.tcpi_unacked, struct tcp_info.tcpi_snd_mss],
1077     , ,[[#include <netinet/tcp.h>]])
1078   dnl KIST needs SIOCOUTQNSD to exist for an ioctl call.
1079   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1080                      #include <linux/sockios.h>
1081                      #ifndef SIOCOUTQNSD
1082                      #error
1083                      #endif
1084                      ])], have_siocoutqnsd=yes, have_siocoutqnsd=no)
1085   if test "x$have_siocoutqnsd" = "xyes"; then
1086     if test "x$ac_cv_member_struct_tcp_info_tcpi_unacked" = "xyes"; then
1087       if test "x$ac_cv_member_struct_tcp_info_tcpi_snd_mss" = "xyes"; then
1088         have_kist_support=yes
1089       fi
1090     fi
1091   fi
1093 dnl Now, trigger the check.
1094 CHECK_KIST_SUPPORT
1095 AS_IF([test "x$have_kist_support" = "xyes"],
1096       [AC_DEFINE(HAVE_KIST_SUPPORT, 1, [Defined if KIST scheduler is supported
1097                                         on this system])],
1098       [AC_MSG_NOTICE([KIST scheduler can't be used. Missing support.])])
1100 LIBS="$save_LIBS"
1101 LDFLAGS="$save_LDFLAGS"
1102 CPPFLAGS="$save_CPPFLAGS"
1104 dnl ------------------------------------------------------
1105 dnl Where do you live, zlib?  And how do we call you?
1107 tor_zlib_pkg_redhat="zlib"
1108 tor_zlib_pkg_debian="zlib1g"
1109 tor_zlib_devpkg_redhat="zlib-devel"
1110 tor_zlib_devpkg_debian="zlib1g-dev"
1112 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
1113     [#include <zlib.h>],
1114     [const char * zlibVersion(void);],
1115     [zlibVersion();], [--with-zlib-dir],
1116     [/opt/zlib])
1118 if test "$enable_static_zlib" = "yes"; then
1119    if test "$tor_cv_library_zlib_dir" = "(system)"; then
1120      AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
1121  using --enable-static-zlib")
1122    else
1123      TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
1124    fi
1125 else
1126      TOR_ZLIB_LIBS="-lz"
1128 AC_SUBST(TOR_ZLIB_LIBS)
1130 dnl ------------------------------------------------------
1131 dnl Where we do we find lzma?
1133 AC_ARG_ENABLE(lzma,
1134       AS_HELP_STRING(--enable-lzma, [enable support for the LZMA compression scheme.]),
1135       [case "${enableval}" in
1136         "yes") ;;
1137         "no")  ;;
1138         * ) AC_MSG_ERROR(bad value for --enable-lzma) ;;
1139       esac], [enable_lzma=auto])
1141 if test "x$enable_lzma" = "xno"; then
1142     have_lzma=no;
1143 else
1144     PKG_CHECK_MODULES([LZMA],
1145                       [liblzma],
1146                       have_lzma=yes,
1147                       have_lzma=no)
1149     if test "x$have_lzma" = "xno" ; then
1150         AC_MSG_WARN([Unable to find liblzma, $pkg_config_user_action, or set LZMA_CFLAGS and LZMA_LIBS.])
1151     fi
1154 if test "x$have_lzma" = "xyes"; then
1155     AC_DEFINE(HAVE_LZMA,1,[Have LZMA])
1156     TOR_LZMA_CFLAGS="${LZMA_CFLAGS}"
1157     TOR_LZMA_LIBS="${LZMA_LIBS}"
1159 AC_SUBST(TOR_LZMA_CFLAGS)
1160 AC_SUBST(TOR_LZMA_LIBS)
1162 dnl ------------------------------------------------------
1163 dnl Where we do we find zstd?
1165 AC_ARG_ENABLE(zstd,
1166       AS_HELP_STRING(--enable-zstd, [enable support for the Zstandard compression scheme.]),
1167       [case "${enableval}" in
1168         "yes") ;;
1169         "no")  ;;
1170         * ) AC_MSG_ERROR(bad value for --enable-zstd) ;;
1171       esac], [enable_zstd=auto])
1173 if test "x$enable_zstd" = "xno"; then
1174     have_zstd=no;
1175 else
1176     PKG_CHECK_MODULES([ZSTD],
1177                       [libzstd >= 1.1],
1178                       have_zstd=yes,
1179                       have_zstd=no)
1181     if test "x$have_zstd" = "xno" ; then
1182         AC_MSG_WARN([Unable to find libzstd, $pkg_config_user_action, or set ZSTD_CFLAGS and ZSTD_LIBS.])
1183     fi
1186 if test "x$have_zstd" = "xyes"; then
1187     AC_DEFINE(HAVE_ZSTD,1,[Have Zstd])
1188     TOR_ZSTD_CFLAGS="${ZSTD_CFLAGS}"
1189     TOR_ZSTD_LIBS="${ZSTD_LIBS}"
1191     dnl now check for zstd functions
1192     save_LIBS="$LIBS"
1193     save_CFLAGS="$CFLAGS"
1194     LIBS="$LIBS $ZSTD_LIBS"
1195     CFLAGS="$CFLAGS $ZSTD_CFLAGS"
1196     AC_CHECK_FUNCS(ZSTD_estimateCStreamSize \
1197                    ZSTD_estimateDCtxSize)
1198     LIBS="$save_LIBS"
1199     CFLAGS="$save_CFLAGS"
1201 AC_SUBST(TOR_ZSTD_CFLAGS)
1202 AC_SUBST(TOR_ZSTD_LIBS)
1204 dnl ----------------------------------------------------------------------
1205 dnl Check if libcap is available for capabilities.
1207 tor_cap_pkg_debian="libcap2"
1208 tor_cap_pkg_redhat="libcap"
1209 tor_cap_devpkg_debian="libcap-dev"
1210 tor_cap_devpkg_redhat="libcap-devel"
1212 AC_CHECK_LIB([cap], [cap_init], [],
1213   AC_MSG_NOTICE([Libcap was not found. Capabilities will not be usable.])
1215 AC_CHECK_FUNCS(cap_set_proc)
1217 dnl ---------------------------------------------------------------------
1218 dnl Now that we know about our major libraries, we can check for compiler
1219 dnl and linker hardening options.  We need to do this with the libraries known,
1220 dnl since sometimes the linker will like an option but not be willing to
1221 dnl use it with a build of a library.
1223 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
1224 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"
1226 CFLAGS_FTRAPV=
1227 CFLAGS_FWRAPV=
1228 CFLAGS_ASAN=
1229 CFLAGS_UBSAN=
1232 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1233 #if !defined(__clang__)
1234 #error
1235 #endif])], have_clang=yes, have_clang=no)
1237 if test "x$enable_pic" = "xyes"; then
1238     TOR_CHECK_CFLAGS(-fPIC)
1241 if test "x$enable_gcc_hardening" != "xno"; then
1242     CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
1243     if test "x$have_clang" = "xyes"; then
1244         TOR_CHECK_CFLAGS(-Qunused-arguments)
1245     fi
1246     TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
1247     AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
1248     AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
1249 m4_ifdef([AS_VAR_IF],[
1250     AS_VAR_IF(can_compile, [yes],
1251         AS_VAR_IF(can_link, [yes],
1252                   [],
1253                   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.)]))
1254         )])
1255     AS_VAR_POPDEF([can_link])
1256     AS_VAR_POPDEF([can_compile])
1257     TOR_CHECK_CFLAGS(-Wstack-protector)
1258     TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
1259     if test "$bwin32" = "false" && test "$enable_libfuzzer" != "yes" && test "$enable_oss_fuzz" != "yes"; then
1260        if test "$enable_pic" != "yes"; then
1261            # If we have already enabled -fPIC, then we don't also need to
1262            # compile with -fPIE...
1263            TOR_CHECK_CFLAGS(-fPIE)
1264        fi
1265        # ... but we want to link our executables with -pie in any case, since
1266        # they're executables, not a library.
1267        TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
1268     fi
1269     TOR_TRY_COMPILE_WITH_CFLAGS(-fwrapv, also_link, CFLAGS_FWRAPV="-fwrapv", true)
1271    AC_MSG_CHECKING([whether we can run hardened binaries])
1272    AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
1273         [AC_MSG_RESULT([yes])],
1274         [AC_MSG_RESULT([no])
1275          AC_MSG_ERROR([dnl
1276  We can link with compiler hardening options, but we can't run with them.
1277  That's a bad sign! If you must, you can pass --disable-gcc-hardening to
1278  configure, but it would be better to figure out what the underlying problem
1279  is.])],
1280         [AC_MSG_RESULT([cross])])
1283 if test "$fragile_hardening" = "yes"; then
1284     TOR_TRY_COMPILE_WITH_CFLAGS(-ftrapv, also_link, CFLAGS_FTRAPV="-ftrapv", true)
1285    if test "$tor_cv_cflags__ftrapv" = "yes" && test "$tor_can_link__ftrapv" != "yes"; then
1286       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.])
1287    fi
1289    if test "$tor_cv_cflags__ftrapv" != "yes"; then
1290      AC_MSG_ERROR([You requested fragile hardening, but the compiler does not seem to support -ftrapv.])
1291    fi
1293    TOR_TRY_COMPILE_WITH_CFLAGS([-fsanitize=address], also_link, CFLAGS_ASAN="-fsanitize=address", true)
1294     if test "$tor_cv_cflags__fsanitize_address" = "yes" && test "$tor_can_link__fsanitize_address" != "yes"; then
1295       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*])
1296     fi
1298    TOR_TRY_COMPILE_WITH_CFLAGS([-fsanitize=undefined], also_link, CFLAGS_UBSAN="-fsanitize=undefined", true)
1299     if test "$tor_cv_cflags__fsanitize_address" = "yes" && test "$tor_can_link__fsanitize_address" != "yes"; then
1300       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*])
1301     fi
1303    TOR_TRY_COMPILE_WITH_CFLAGS([-fno-sanitize=float-divide-by-zero], also_link, CFLAGS_UBSAN="-fno-sanitize=float-divide-by-zero", true)
1304     if test "$tor_cv_cflags__fno_sanitize_float_divide_by_zero" = "yes" && test "$tor_can_link__fno_sanitize_float_divide_by_zero" != "yes"; then
1305       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*])
1306     fi
1308 TOR_CHECK_CFLAGS([-fno-omit-frame-pointer])
1311 dnl Find the correct libraries to add in order to use the sanitizers.
1313 dnl When building Rust, Cargo will run the linker with the -nodefaultlibs
1314 dnl option, which will prevent the compiler from linking the sanitizer
1315 dnl libraries it needs.  We need to specify them manually.
1317 dnl What's more, we need to specify them in a linker script rather than
1318 dnl from build.rs: these options aren't allowed in the cargo:rustc-flags
1319 dnl variable.
1320 RUST_LINKER_OPTIONS=""
1321 if test "x$have_clang" = "xyes"; then
1322         if test "x$CFLAGS_ASAN" != "x"; then
1323                 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_ASAN -Cdefault-linker-libraries"
1324         fi
1325         if test "x$CFLAGS_UBSAN" != "x"; then
1326                 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_UBSAN -Cdefault-linker-libraries"
1327         fi
1328 else
1329         if test "x$CFLAGS_ASAN" != "x"; then
1330                 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=address -Cdefault-linker-libraries"
1331         fi
1332         if test "x$CFLAGS_UBSAN" != "x"; then
1333                 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=undefined -Cdefault-linker-libraries"
1334         fi
1336 AC_SUBST(RUST_LINKER_OPTIONS)
1338 CFLAGS_BUGTRAP="$CFLAGS_FTRAPV $CFLAGS_ASAN $CFLAGS_UBSAN"
1339 CFLAGS_CONSTTIME="$CFLAGS_FWRAPV"
1341 mulodi_fixes_ftrapv=no
1342 if test "$have_clang" = "yes"; then
1343   saved_CFLAGS="$CFLAGS"
1344   CFLAGS="$CFLAGS $CFLAGS_FTRAPV"
1345   AC_MSG_CHECKING([whether clang -ftrapv can link a 64-bit int multiply])
1346   AC_LINK_IFELSE([
1347       AC_LANG_SOURCE([[
1348           #include <stdint.h>
1349           #include <stdlib.h>
1350           int main(int argc, char **argv)
1351           {
1352             int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
1353                         * (int64_t)atoi(argv[3]);
1354             return x == 9;
1355           } ]])],
1356           [ftrapv_can_link=yes; AC_MSG_RESULT([yes])],
1357           [ftrapv_can_link=no; AC_MSG_RESULT([no])])
1358   if test "$ftrapv_can_link" = "no"; then
1359     AC_MSG_CHECKING([whether defining __mulodi4 fixes that])
1360     AC_LINK_IFELSE([
1361       AC_LANG_SOURCE([[
1362           #include <stdint.h>
1363           #include <stdlib.h>
1364           int64_t __mulodi4(int64_t a, int64_t b, int *overflow) {
1365              *overflow=0;
1366              return a;
1367           }
1368           int main(int argc, char **argv)
1369           {
1370             int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
1371                         * (int64_t)atoi(argv[3]);
1372             return x == 9;
1373           } ]])],
1374           [mulodi_fixes_ftrapv=yes; AC_MSG_RESULT([yes])],
1375           [mulodi_fixes_ftrapv=no; AC_MSG_RESULT([no])])
1376   fi
1377   CFLAGS="$saved_CFLAGS"
1380 AM_CONDITIONAL(ADD_MULODI4, test "$mulodi_fixes_ftrapv" = "yes")
1382 dnl These cflags add bunches of branches, and we haven't been able to
1383 dnl persuade ourselves that they're suitable for code that needs to be
1384 dnl constant time.
1385 AC_SUBST(CFLAGS_BUGTRAP)
1386 dnl These cflags are variant ones sutable for code that needs to be
1387 dnl constant-time.
1388 AC_SUBST(CFLAGS_CONSTTIME)
1390 if test "x$enable_linker_hardening" != "xno"; then
1391     TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
1394 # For backtrace support
1395 TOR_CHECK_LDFLAGS(-rdynamic)
1397 dnl ------------------------------------------------------
1398 dnl Now see if we have a -fomit-frame-pointer compiler option.
1400 saved_CFLAGS="$CFLAGS"
1401 TOR_CHECK_CFLAGS(-fomit-frame-pointer)
1402 F_OMIT_FRAME_POINTER=''
1403 if test "$saved_CFLAGS" != "$CFLAGS"; then
1404   if test "$fragile_hardening" = "yes"; then
1405     F_OMIT_FRAME_POINTER='-fomit-frame-pointer'
1406   fi
1408 CFLAGS="$saved_CFLAGS"
1409 AC_SUBST(F_OMIT_FRAME_POINTER)
1411 dnl ------------------------------------------------------
1412 dnl If we are adding -fomit-frame-pointer (or if the compiler's doing it
1413 dnl for us, as GCC 4.6 and later do at many optimization levels), then
1414 dnl we should try to add -fasynchronous-unwind-tables so that our backtrace
1415 dnl code will work.
1416 TOR_CHECK_CFLAGS(-fasynchronous-unwind-tables)
1418 dnl ============================================================
1419 dnl Check for libseccomp
1421 if test "x$enable_seccomp" != "xno"; then
1422   AC_CHECK_HEADERS([seccomp.h])
1423   AC_SEARCH_LIBS(seccomp_init, [seccomp])
1426 dnl ============================================================
1427 dnl Check for libscrypt
1429 if test "x$enable_libscrypt" != "xno"; then
1430   AC_CHECK_HEADERS([libscrypt.h])
1431   AC_SEARCH_LIBS(libscrypt_scrypt, [scrypt])
1432   AC_CHECK_FUNCS([libscrypt_scrypt])
1435 dnl ============================================================
1436 dnl We need an implementation of curve25519.
1438 dnl set these defaults.
1439 build_curve25519_donna=no
1440 build_curve25519_donna_c64=no
1441 use_curve25519_donna=no
1442 use_curve25519_nacl=no
1443 CURVE25519_LIBS=
1445 dnl The best choice is using curve25519-donna-c64, but that requires
1446 dnl that we
1447 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
1448   tor_cv_can_use_curve25519_donna_c64,
1449   [AC_RUN_IFELSE(
1450     [AC_LANG_PROGRAM([dnl
1451       #include <stdint.h>
1452       typedef unsigned uint128_t __attribute__((mode(TI)));
1453   int func(uint64_t a, uint64_t b) {
1454            uint128_t c = ((uint128_t)a) * b;
1455            int ok = ((uint64_t)(c>>96)) == 522859 &&
1456              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
1457                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
1458                  (((uint64_t)(c))&0xffffffffL) == 0;
1459            return ok;
1460       }
1461   ], [dnl
1462     int ok = func( ((uint64_t)2000000000) * 1000000000,
1463                    ((uint64_t)1234567890) << 24);
1464         return !ok;
1465       ])],
1466   [tor_cv_can_use_curve25519_donna_c64=yes],
1467       [tor_cv_can_use_curve25519_donna_c64=no],
1468   [AC_LINK_IFELSE(
1469         [AC_LANG_PROGRAM([dnl
1470       #include <stdint.h>
1471       typedef unsigned uint128_t __attribute__((mode(TI)));
1472   int func(uint64_t a, uint64_t b) {
1473            uint128_t c = ((uint128_t)a) * b;
1474            int ok = ((uint64_t)(c>>96)) == 522859 &&
1475              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
1476                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
1477                  (((uint64_t)(c))&0xffffffffL) == 0;
1478            return ok;
1479       }
1480   ], [dnl
1481     int ok = func( ((uint64_t)2000000000) * 1000000000,
1482                  ((uint64_t)1234567890) << 24);
1483         return !ok;
1484       ])],
1485           [tor_cv_can_use_curve25519_donna_c64=cross],
1486       [tor_cv_can_use_curve25519_donna_c64=no])])])
1488 AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
1489                   nacl/crypto_scalarmult_curve25519.h])
1491 AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
1492   tor_cv_can_use_curve25519_nacl,
1493   [tor_saved_LIBS="$LIBS"
1494    LIBS="$LIBS -lnacl"
1495    AC_LINK_IFELSE(
1496      [AC_LANG_PROGRAM([dnl
1497        #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
1498        #include <crypto_scalarmult_curve25519.h>
1499    #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
1500    #include <nacl/crypto_scalarmult_curve25519.h>
1501    #endif
1502        #ifdef crypto_scalarmult_curve25519_ref_BYTES
1503    #error Hey, this is the reference implementation! That's not fast.
1504    #endif
1505      ], [
1506    unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
1507      ])], [tor_cv_can_use_curve25519_nacl=yes],
1508      [tor_cv_can_use_curve25519_nacl=no])
1509    LIBS="$tor_saved_LIBS" ])
1511  dnl Okay, now we need to figure out which one to actually use. Fall back
1512  dnl to curve25519-donna.c
1514  if test "x$tor_cv_can_use_curve25519_donna_c64" != "xno"; then
1515    build_curve25519_donna_c64=yes
1516    use_curve25519_donna=yes
1517  elif test "x$tor_cv_can_use_curve25519_nacl" = "xyes"; then
1518    use_curve25519_nacl=yes
1519    CURVE25519_LIBS=-lnacl
1520  else
1521    build_curve25519_donna=yes
1522    use_curve25519_donna=yes
1523  fi
1525 if test "x$use_curve25519_donna" = "xyes"; then
1526   AC_DEFINE(USE_CURVE25519_DONNA, 1,
1527             [Defined if we should use an internal curve25519_donna{,_c64} implementation])
1529 if test "x$use_curve25519_nacl" = "xyes"; then
1530   AC_DEFINE(USE_CURVE25519_NACL, 1,
1531             [Defined if we should use a curve25519 from nacl])
1533 AM_CONDITIONAL(BUILD_CURVE25519_DONNA,
1534   test "x$build_curve25519_donna" = "xyes")
1535 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64,
1536   test "x$build_curve25519_donna_c64" = "xyes")
1537 AC_SUBST(CURVE25519_LIBS)
1539 dnl Make sure to enable support for large off_t if available.
1540 AC_SYS_LARGEFILE
1542 AC_CHECK_HEADERS([errno.h \
1543                   fcntl.h \
1544                   signal.h \
1545                   string.h \
1546                   sys/capability.h \
1547                   sys/fcntl.h \
1548                   sys/stat.h \
1549                   sys/time.h \
1550                   sys/types.h \
1551                   time.h \
1552                   unistd.h \
1553                   arpa/inet.h \
1554                   crt_externs.h \
1555                   execinfo.h \
1556                   gnu/libc-version.h \
1557                   grp.h \
1558                   ifaddrs.h \
1559                   inttypes.h \
1560                   limits.h \
1561                   linux/types.h \
1562                   mach/vm_inherit.h \
1563                   machine/limits.h \
1564                   malloc.h \
1565                   malloc/malloc.h \
1566                   malloc_np.h \
1567                   netdb.h \
1568                   netinet/in.h \
1569                   netinet/in6.h \
1570                   pwd.h \
1571                   readpassphrase.h \
1572                   stdatomic.h \
1573                   sys/eventfd.h \
1574                   sys/file.h \
1575                   sys/ioctl.h \
1576                   sys/limits.h \
1577                   sys/mman.h \
1578                   sys/param.h \
1579                   sys/prctl.h \
1580                   sys/random.h \
1581                   sys/resource.h \
1582                   sys/select.h \
1583                   sys/socket.h \
1584                   sys/statvfs.h \
1585                   sys/syscall.h \
1586                   sys/sysctl.h \
1587                   sys/syslimits.h \
1588                   sys/time.h \
1589                   sys/types.h \
1590                   sys/un.h \
1591                   sys/utime.h \
1592                   sys/wait.h \
1593                   syslog.h \
1594                   utime.h])
1596 AC_CHECK_HEADERS(sys/param.h)
1598 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
1599 [#ifdef HAVE_SYS_TYPES_H
1600 #include <sys/types.h>
1601 #endif
1602 #ifdef HAVE_SYS_SOCKET_H
1603 #include <sys/socket.h>
1604 #endif])
1605 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_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 #ifdef HAVE_NET_IF_H
1613 #include <net/if.h>
1614 #endif
1615 #ifdef HAVE_NETINET_IN_H
1616 #include <netinet/in.h>
1617 #endif])
1619 AC_CHECK_HEADERS(linux/if.h,[],[],
1621 #ifdef HAVE_SYS_SOCKET_H
1622 #include <sys/socket.h>
1623 #endif
1626 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
1627         linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
1628 [#ifdef HAVE_SYS_TYPES_H
1629 #include <sys/types.h>
1630 #endif
1631 #ifdef HAVE_SYS_SOCKET_H
1632 #include <sys/socket.h>
1633 #endif
1634 #ifdef HAVE_LIMITS_H
1635 #include <limits.h>
1636 #endif
1637 #ifdef HAVE_LINUX_TYPES_H
1638 #include <linux/types.h>
1639 #endif
1640 #ifdef HAVE_NETINET_IN6_H
1641 #include <netinet/in6.h>
1642 #endif
1643 #ifdef HAVE_NETINET_IN_H
1644 #include <netinet/in.h>
1645 #endif])
1647 AC_CHECK_HEADERS(linux/netfilter_ipv6/ip6_tables.h,
1648         linux_netfilter_ipv6_ip6_tables=1, linux_netfilter_ipv6_ip6_tables=0,
1649 [#ifdef HAVE_SYS_TYPES_H
1650 #include <sys/types.h>
1651 #endif
1652 #ifdef HAVE_SYS_SOCKET_H
1653 #include <sys/socket.h>
1654 #endif
1655 #ifdef HAVE_LIMITS_H
1656 #include <limits.h>
1657 #endif
1658 #ifdef HAVE_LINUX_TYPES_H
1659 #include <linux/types.h>
1660 #endif
1661 #ifdef HAVE_NETINET_IN6_H
1662 #include <netinet/in6.h>
1663 #endif
1664 #ifdef HAVE_NETINET_IN_H
1665 #include <netinet/in.h>
1666 #endif
1667 #ifdef HAVE_LINUX_IF_H
1668 #include <linux/if.h>
1669 #endif])
1671 transparent_ok=0
1672 if test "x$net_if_found" = "x1" && test "x$net_pfvar_found" = "x1"; then
1673   transparent_ok=1
1675 if test "x$linux_netfilter_ipv4" = "x1"; then
1676   transparent_ok=1
1678 if test "x$linux_netfilter_ipv6_ip6_tables" = "x1"; then
1679   transparent_ok=1
1681 if test "x$transparent_ok" = "x1"; then
1682   AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
1683 else
1684   AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
1687 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
1688 [#ifdef HAVE_SYS_TYPES_H
1689 #include <sys/types.h>
1690 #endif
1691 #ifdef HAVE_SYS_TIME_H
1692 #include <sys/time.h>
1693 #endif])
1695 AC_CHECK_SIZEOF(char)
1696 AC_CHECK_SIZEOF(short)
1697 AC_CHECK_SIZEOF(int)
1698 AC_CHECK_SIZEOF(unsigned int)
1699 AC_CHECK_SIZEOF(long)
1700 AC_CHECK_SIZEOF(long long)
1701 AC_CHECK_SIZEOF(__int64)
1702 AC_CHECK_SIZEOF(void *)
1703 AC_CHECK_SIZEOF(time_t)
1704 AC_CHECK_SIZEOF(size_t)
1705 AC_CHECK_SIZEOF(pid_t)
1707 AC_CHECK_TYPES([uint, u_char, ssize_t])
1709 AC_PC_FROM_UCONTEXT([:])
1711 dnl used to include sockaddr_storage, but everybody has that.
1712 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
1713 [#ifdef HAVE_SYS_TYPES_H
1714 #include <sys/types.h>
1715 #endif
1716 #ifdef HAVE_NETINET_IN_H
1717 #include <netinet/in.h>
1718 #endif
1719 #ifdef HAVE_NETINET_IN6_H
1720 #include <netinet/in6.h>
1721 #endif
1722 #ifdef HAVE_SYS_SOCKET_H
1723 #include <sys/socket.h>
1724 #endif
1725 #ifdef _WIN32
1726 #define _WIN32_WINNT 0x0501
1727 #define WIN32_LEAN_AND_MEAN
1728 #include <winsock2.h>
1729 #include <ws2tcpip.h>
1730 #endif
1732 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
1733 [#ifdef HAVE_SYS_TYPES_H
1734 #include <sys/types.h>
1735 #endif
1736 #ifdef HAVE_NETINET_IN_H
1737 #include <netinet/in.h>
1738 #endif
1739 #ifdef HAVE_NETINET_IN6_H
1740 #include <netinet/in6.h>
1741 #endif
1742 #ifdef HAVE_SYS_SOCKET_H
1743 #include <sys/socket.h>
1744 #endif
1745 #ifdef _WIN32
1746 #define _WIN32_WINNT 0x0501
1747 #define WIN32_LEAN_AND_MEAN
1748 #include <winsock2.h>
1749 #include <ws2tcpip.h>
1750 #endif
1753 AC_CHECK_TYPES([rlim_t], , ,
1754 [#ifdef HAVE_SYS_TYPES_H
1755 #include <sys/types.h>
1756 #endif
1757 #ifdef HAVE_SYS_TIME_H
1758 #include <sys/time.h>
1759 #endif
1760 #ifdef HAVE_SYS_RESOURCE_H
1761 #include <sys/resource.h>
1762 #endif
1765 AX_CHECK_SIGN([time_t],
1766        [ : ],
1767        [ : ], [
1768 #ifdef HAVE_SYS_TYPES_H
1769 #include <sys/types.h>
1770 #endif
1771 #ifdef HAVE_SYS_TIME_H
1772 #include <sys/time.h>
1773 #endif
1774 #ifdef HAVE_TIME_H
1775 #include <time.h>
1776 #endif
1779 if test "$ax_cv_decl_time_t_signed" = "no"; then
1780   AC_MSG_ERROR([You have an unsigned time_t; Tor does not support that. Please tell the Tor developers about your interesting platform.])
1783 AX_CHECK_SIGN([size_t],
1784        [ tor_cv_size_t_signed=yes ],
1785        [ tor_cv_size_t_signed=no ], [
1786 #ifdef HAVE_SYS_TYPES_H
1787 #include <sys/types.h>
1788 #endif
1791 if test "$ax_cv_decl_size_t_signed" = "yes"; then
1792   AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
1795 AX_CHECK_SIGN([enum always],
1796        [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
1797        [ : ], [
1798  enum always { AAA, BBB, CCC };
1801 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
1802 #ifdef HAVE_SYS_SOCKET_H
1803 #include <sys/socket.h>
1804 #endif
1807 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1809 AC_CHECK_SIZEOF(cell_t)
1811 # Let's see if stdatomic works. (There are some debian clangs that screw it
1812 # up; see Tor bug #26779 and debian bug 903709.)
1813 AC_CACHE_CHECK([whether C11 stdatomic.h actually works],
1814                tor_cv_stdatomic_works,
1815 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1816 #include <stdatomic.h>
1817 struct x { atomic_size_t y; };
1818 void try_atomic_init(struct x *xx)
1820   atomic_init(&xx->y, 99);
1821   atomic_fetch_add(&xx->y, 1);
1823 ]])], [tor_cv_stdatomic_works=yes], [tor_cv_stdatomic_works=no])])
1825 if test "$tor_cv_stdatomic_works" = "yes"; then
1826    AC_DEFINE(STDATOMIC_WORKS, 1, [Set to 1 if we can compile a simple stdatomic example.])
1827 elif test "$ac_cv_header_stdatomic_h" = "yes"; then
1828    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 ])
1831 # Now make sure that NULL can be represented as zero bytes.
1832 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1833 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1834 [[#include <stdlib.h>
1835 #include <string.h>
1836 #include <stdio.h>
1837 #ifdef HAVE_STDDEF_H
1838 #include <stddef.h>
1839 #endif
1840 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1841 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1842        [tor_cv_null_is_zero=yes],
1843        [tor_cv_null_is_zero=no],
1844        [tor_cv_null_is_zero=cross])])
1846 if test "$tor_cv_null_is_zero" = "cross"; then
1847   # Cross-compiling; let's hope that the target isn't raving mad.
1848   AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
1851 if test "$tor_cv_null_is_zero" != "no"; then
1852   AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1853             [Define to 1 iff memset(0) sets pointers to NULL])
1856 AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
1857 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1858 [[#include <stdlib.h>
1859 #include <string.h>
1860 #include <stdio.h>
1861 #ifdef HAVE_STDDEF_H
1862 #include <stddef.h>
1863 #endif
1864 int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
1865 return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
1866        [tor_cv_dbl0_is_zero=yes],
1867        [tor_cv_dbl0_is_zero=no],
1868        [tor_cv_dbl0_is_zero=cross])])
1870 if test "$tor_cv_dbl0_is_zero" = "cross"; then
1871   # Cross-compiling; let's hope that the target isn't raving mad.
1872   AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
1875 if test "$tor_cv_dbl0_is_zero" != "no"; then
1876   AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
1877             [Define to 1 iff memset(0) sets doubles to 0.0])
1880 # And what happens when we malloc zero?
1881 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
1882 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1883 [[#include <stdlib.h>
1884 #include <string.h>
1885 #include <stdio.h>
1886 #ifdef HAVE_STDDEF_H
1887 #include <stddef.h>
1888 #endif
1889 int main () { return malloc(0)?0:1; }]])],
1890        [tor_cv_malloc_zero_works=yes],
1891        [tor_cv_malloc_zero_works=no],
1892        [tor_cv_malloc_zero_works=cross])])
1894 if test "$tor_cv_malloc_zero_works" = "cross"; then
1895   # Cross-compiling; let's hope that the target isn't raving mad.
1896   AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
1899 if test "$tor_cv_malloc_zero_works" = "yes"; then
1900   AC_DEFINE([MALLOC_ZERO_WORKS], 1,
1901             [Define to 1 iff malloc(0) returns a pointer])
1904 # whether we seem to be in a 2s-complement world.
1905 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
1906 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1907 [[int main () { int problem = ((-99) != (~99)+1);
1908 return problem ? 1 : 0; }]])],
1909        [tor_cv_twos_complement=yes],
1910        [tor_cv_twos_complement=no],
1911        [tor_cv_twos_complement=cross])])
1913 if test "$tor_cv_twos_complement" = "cross"; then
1914   # Cross-compiling; let's hope that the target isn't raving mad.
1915   AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
1918 if test "$tor_cv_twos_complement" != "no"; then
1919   AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
1920             [Define to 1 iff we represent negative integers with
1921              two's complement])
1924 # What does shifting a negative value do?
1925 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
1926 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1927 [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
1928        [tor_cv_sign_extend=yes],
1929        [tor_cv_sign_extend=no],
1930        [tor_cv_sign_extend=cross])])
1932 if test "$tor_cv_sign_extend" = "cross"; then
1933   # Cross-compiling; let's hope that the target isn't raving mad.
1934   AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
1937 if test "$tor_cv_sign_extend" != "no"; then
1938   AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
1939             [Define to 1 iff right-shifting a negative value performs sign-extension])
1942 # Is uint8_t the same type as unsigned char?
1943 AC_CACHE_CHECK([whether uint8_t is the same type as unsigned char], tor_cv_uint8_uchar,
1944 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1945 #include <stdint.h>
1946 extern uint8_t c;
1947 unsigned char c;]])],
1948        [tor_cv_uint8_uchar=yes],
1949        [tor_cv_uint8_uchar=no],
1950        [tor_cv_uint8_uchar=cross])])
1952 if test "$tor_cv_uint8_uchar" = "cross"; then
1953   AC_MSG_NOTICE([Cross-compiling: we'll assume that uint8_t is the same type as unsigned char])
1956 if test "$tor_cv_uint8_uchar" = "no"; then
1957   AC_MSG_ERROR([We assume that uint8_t is the same type as unsigned char, but your compiler disagrees.])
1960 AC_ARG_WITH(tcmalloc,
1961 AS_HELP_STRING(--with-tcmalloc, [use tcmalloc memory allocation library. Deprecated; see --with-malloc]))
1963 default_malloc=system
1965 if test "x$enable_openbsd_malloc" = "xyes" ; then
1966   AC_MSG_NOTICE([The --enable-openbsd-malloc argument is deprecated; use --with-malloc=openbsd instead.])
1967   default_malloc=openbsd
1970 if test "x$with_tcmalloc" = "xyes"; then
1971   AC_MSG_NOTICE([The --with-tcmalloc argument is deprecated; use --with-malloc=tcmalloc instead.])
1972   default_malloc=tcmalloc
1975 AC_ARG_WITH(malloc,
1976    AS_HELP_STRING([--with-malloc=[system,jemalloc,tcmalloc,openbsd]],
1977                   [select special malloc implementation [system]]),
1978    [ malloc="$with_malloc" ], [ malloc="$default_malloc" ])
1980 AS_CASE([$malloc],
1981   [tcmalloc], [
1982       PKG_CHECK_MODULES([TCMALLOC],
1983                         [libtcmalloc],
1984                         have_tcmalloc=yes,
1985                         have_tcmalloc=no)
1987       if test "x$have_tcmalloc" = "xno" ; then
1988           AC_MSG_ERROR([Unable to find tcmalloc requested by --with-malloc, $pkg_config_user_action, or set TCMALLOC_CFLAGS and TCMALLOC_LIBS.])
1989       fi
1991       CFLAGS="$CFLAGS $TCMALLOC_CFLAGS"
1992       LIBS="$TCMALLOC_LIBS $LIBS"
1993   ],
1995   [jemalloc], [
1996       PKG_CHECK_MODULES([JEMALLOC],
1997                         [jemalloc],
1998                         have_jemalloc=yes,
1999                         have_jemalloc=no)
2001       if test "x$have_jemalloc" = "xno" ; then
2002           AC_MSG_ERROR([Unable to find jemalloc requested by --with-malloc, $pkg_config_user_action, or set JEMALLOC_CFLAGS and JEMALLOC_LIBS.])
2003       fi
2005       CFLAGS="$CFLAGS $JEMALLOC_CFLAGS"
2006       LIBS="$JEMALLOC_LIBS $LIBS"
2007       using_custom_malloc=yes
2008   ],
2010   [openbsd], [
2011     AC_MSG_WARN([The openbsd malloc port is deprecated in Tor 0.3.5 and will be removed in a future version.])
2012     enable_openbsd_malloc=yes
2013   ],
2015   [system], [
2016      # handle this later, including the jemalloc fallback
2017     AC_CHECK_FUNCS(mallinfo)
2018   ],
2020   [AC_MSG_ERROR([--with-malloc=`$with_malloc' not supported, see --help])
2023 AM_CONDITIONAL(USE_OPENBSD_MALLOC, test "x$enable_openbsd_malloc" = "xyes")
2025 if test "$malloc" != "system"; then
2026   # Tell the C compiler not to use the system allocator functions.
2027   TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
2029 if test "$using_custom_malloc" = "yes"; then
2030   # Tell the C compiler not to use the system allocator functions.
2031   TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
2034 # By default, we're going to assume we don't have mlockall()
2035 # bionic and other platforms have various broken mlockall subsystems.
2036 # Some systems don't have a working mlockall, some aren't linkable,
2037 # and some have it but don't declare it.
2038 AC_CHECK_FUNCS(mlockall)
2039 AC_CHECK_DECLS([mlockall], , , [
2040 #ifdef HAVE_SYS_MMAN_H
2041 #include <sys/mman.h>
2042 #endif])
2044 # Allow user to specify an alternate syslog facility
2045 AC_ARG_WITH(syslog-facility,
2046 AS_HELP_STRING(--with-syslog-facility=LOG, [syslog facility to use (default=LOG_DAEMON)]),
2047 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
2048 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
2049 AC_SUBST(LOGFACILITY)
2051 # Check if we have getresuid and getresgid
2052 AC_CHECK_FUNCS(getresuid getresgid)
2054 # Check for gethostbyname_r in all its glorious incompatible versions.
2055 #   (This logic is based on that in Python's configure.in)
2056 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
2057   [Define this if you have any gethostbyname_r()])
2059 AC_CHECK_FUNC(gethostbyname_r, [
2060   AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
2061   OLD_CFLAGS=$CFLAGS
2062   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
2063   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2064 #include <netdb.h>
2065   ]], [[
2066     char *cp1, *cp2;
2067     struct hostent *h1, *h2;
2068     int i1, i2;
2069     (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
2070   ]])],[
2071     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2072     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2073      [Define this if gethostbyname_r takes 6 arguments])
2074     AC_MSG_RESULT(6)
2075   ], [
2076     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2077 #include <netdb.h>
2078     ]], [[
2079       char *cp1, *cp2;
2080       struct hostent *h1;
2081       int i1, i2;
2082       (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
2083     ]])], [
2084       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2085       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2086         [Define this if gethostbyname_r takes 5 arguments])
2087       AC_MSG_RESULT(5)
2088    ], [
2089       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2090 #include <netdb.h>
2091      ]], [[
2092        char *cp1;
2093        struct hostent *h1;
2094        struct hostent_data hd;
2095        (void) gethostbyname_r(cp1,h1,&hd);
2096      ]])], [
2097        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2098        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2099          [Define this if gethostbyname_r takes 3 arguments])
2100        AC_MSG_RESULT(3)
2101      ], [
2102        AC_MSG_RESULT(0)
2103      ])
2104   ])
2105  ])
2106  CFLAGS=$OLD_CFLAGS
2109 AC_CACHE_CHECK([whether the C compiler supports __func__],
2110   tor_cv_have_func_macro,
2111   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2112 #include <stdio.h>
2113 int main(int c, char **v) { puts(__func__); }])],
2114   tor_cv_have_func_macro=yes,
2115   tor_cv_have_func_macro=no))
2117 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
2118   tor_cv_have_FUNC_macro,
2119   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2120 #include <stdio.h>
2121 int main(int c, char **v) { puts(__FUNC__); }])],
2122   tor_cv_have_FUNC_macro=yes,
2123   tor_cv_have_FUNC_macro=no))
2125 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
2126   tor_cv_have_FUNCTION_macro,
2127   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2128 #include <stdio.h>
2129 int main(int c, char **v) { puts(__FUNCTION__); }])],
2130   tor_cv_have_FUNCTION_macro=yes,
2131   tor_cv_have_FUNCTION_macro=no))
2133 AC_CACHE_CHECK([whether we have extern char **environ already declared],
2134   tor_cv_have_environ_declared,
2135   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2136 #ifdef HAVE_UNISTD_H
2137 #include <unistd.h>
2138 #endif
2139 #include <stdlib.h>
2140 int main(int c, char **v) { char **t = environ; }])],
2141   tor_cv_have_environ_declared=yes,
2142   tor_cv_have_environ_declared=no))
2144 if test "$tor_cv_have_func_macro" = "yes"; then
2145   AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
2148 if test "$tor_cv_have_FUNC_macro" = "yes"; then
2149   AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
2152 if test "$tor_cv_have_FUNCTION_macro" = "yes"; then
2153   AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
2154            [Defined if the compiler supports __FUNCTION__])
2157 if test "$tor_cv_have_environ_declared" = "yes"; then
2158   AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
2159            [Defined if we have extern char **environ already declared])
2162 # $prefix stores the value of the --prefix command line option, or
2163 # NONE if the option wasn't set.  In the case that it wasn't set, make
2164 # it be the default, so that we can use it to expand directories now.
2165 if test "x$prefix" = "xNONE"; then
2166   prefix=$ac_default_prefix
2169 # and similarly for $exec_prefix
2170 if test "x$exec_prefix" = "xNONE"; then
2171   exec_prefix=$prefix
2174 if test "x$BUILDDIR" = "x"; then
2175   BUILDDIR=`pwd`
2177 AC_SUBST(BUILDDIR)
2178 AH_TEMPLATE([BUILDDIR],[tor's build directory])
2179 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
2181 if test "x$SRCDIR" = "x"; then
2182   SRCDIR=$(cd "$srcdir"; pwd)
2184 AH_TEMPLATE([SRCDIR],[tor's sourcedir directory])
2185 AC_DEFINE_UNQUOTED(SRCDIR,"$SRCDIR")
2187 if test "x$CONFDIR" = "x"; then
2188   CONFDIR=`eval echo $sysconfdir/tor`
2190 AC_SUBST(CONFDIR)
2191 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
2192 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
2194 BINDIR=`eval echo $bindir`
2195 AC_SUBST(BINDIR)
2196 LOCALSTATEDIR=`eval echo $localstatedir`
2197 AC_SUBST(LOCALSTATEDIR)
2199 if test "$bwin32" = "true"; then
2200   # Test if the linker supports the --nxcompat and --dynamicbase options
2201   # for Windows
2202   save_LDFLAGS="$LDFLAGS"
2203   LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
2204   AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
2205   AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
2206     [AC_MSG_RESULT([yes])]
2207     [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
2208     [AC_MSG_RESULT([no])]
2209   )
2210   LDFLAGS="$save_LDFLAGS"
2213 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
2214 # than autoconf's macros like.
2215 if test "$GCC" = "yes"; then
2216   # Disable GCC's strict aliasing checks.  They are an hours-to-debug
2217   # accident waiting to happen.
2218   CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
2219 else
2220   # Override optimization level for non-gcc compilers
2221   CFLAGS="$CFLAGS -O"
2222   enable_gcc_warnings=no
2223   enable_gcc_warnings_advisory=no
2226 # Warnings implies advisory-warnings and -Werror.
2227 if test "$enable_gcc_warnings" = "yes"; then
2228   enable_gcc_warnings_advisory=yes
2229   enable_fatal_warnings=yes
2232 # OS X Lion started deprecating the system openssl. Let's just disable
2233 # all deprecation warnings on OS X. Also, to potentially make the binary
2234 # a little smaller, let's enable dead_strip.
2235 case "$host_os" in
2237  darwin*)
2238     CFLAGS="$CFLAGS -Wno-deprecated-declarations"
2239     LDFLAGS="$LDFLAGS -dead_strip" ;;
2240 esac
2242 TOR_WARNING_FLAGS=""
2244 # Add some more warnings which we use in development but not in the
2245 # released versions.  (Some relevant gcc versions can't handle these.)
2247 # Note that we have to do this near the end  of the autoconf process, or
2248 # else we may run into problems when these warnings hit on the testing C
2249 # programs that autoconf wants to build.
2250 if test "x$enable_gcc_warnings_advisory" != "xno"; then
2252   case "$host" in
2253     *-*-openbsd* | *-*-bitrig*)
2254       # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
2255       # That's fine, except that the headers don't pass -Wredundant-decls.
2256       # Therefore, let's disable -Wsystem-headers when we're building
2257       # with maximal warnings on OpenBSD.
2258       CFLAGS="$CFLAGS -Wno-system-headers" ;;
2259   esac
2261   CFLAGS_NOWARNINGS="$CFLAGS"
2263   # GCC4.3 users once report trouble with -Wstrict-overflow=5.  GCC5 users
2264   # have it work better.
2265   # CFLAGS="$CFLAGS -Wstrict-overflow=1"
2267   # This warning was added in gcc 4.3, but it appears to generate
2268   # spurious warnings in gcc 4.4.  I don't know if it works in 4.5.
2269   #CFLAGS="$CFLAGS -Wlogical-op"
2271   m4_foreach_w([warning_flag], [
2272      -Waddress
2273      -Waddress-of-array-temporary
2274      -Waddress-of-temporary
2275      -Wambiguous-macro
2276      -Wanonymous-pack-parens
2277      -Warc
2278      -Warc-abi
2279      -Warc-bridge-casts-disallowed-in-nonarc
2280      -Warc-maybe-repeated-use-of-weak
2281      -Warc-performSelector-leaks
2282      -Warc-repeated-use-of-weak
2283      -Warray-bounds
2284      -Warray-bounds-pointer-arithmetic
2285      -Wasm
2286      -Wasm-operand-widths
2287      -Watomic-properties
2288      -Watomic-property-with-user-defined-accessor
2289      -Wauto-import
2290      -Wauto-storage-class
2291      -Wauto-var-id
2292      -Wavailability
2293      -Wbackslash-newline-escape
2294      -Wbad-array-new-length
2295      -Wbind-to-temporary-copy
2296      -Wbitfield-constant-conversion
2297      -Wbool-conversion
2298      -Wbool-conversions
2299      -Wbuiltin-requires-header
2300      -Wchar-align
2301      -Wcompare-distinct-pointer-types
2302      -Wcomplex-component-init
2303      -Wconditional-type-mismatch
2304      -Wconfig-macros
2305      -Wconstant-conversion
2306      -Wconstant-logical-operand
2307      -Wconstexpr-not-const
2308      -Wcustom-atomic-properties
2309      -Wdangling-field
2310      -Wdangling-initializer-list
2311      -Wdate-time
2312      -Wdelegating-ctor-cycles
2313      -Wdeprecated-implementations
2314      -Wdeprecated-register
2315      -Wdirect-ivar-access
2316      -Wdiscard-qual
2317      -Wdistributed-object-modifiers
2318      -Wdivision-by-zero
2319      -Wdollar-in-identifier-extension
2320      -Wdouble-promotion
2321      -Wduplicate-decl-specifier
2322      -Wduplicate-enum
2323      -Wduplicate-method-arg
2324      -Wduplicate-method-match
2325      -Wduplicated-cond
2326      -Wdynamic-class-memaccess
2327      -Wembedded-directive
2328      -Wempty-translation-unit
2329      -Wenum-conversion
2330      -Wexit-time-destructors
2331      -Wexplicit-ownership-type
2332      -Wextern-initializer
2333      -Wextra
2334      -Wextra-semi
2335      -Wextra-tokens
2336      -Wflexible-array-extensions
2337      -Wfloat-conversion
2338      -Wformat-non-iso
2339      -Wfour-char-constants
2340      -Wgcc-compat
2341      -Wglobal-constructors
2342      -Wgnu-array-member-paren-init
2343      -Wgnu-designator
2344      -Wgnu-static-float-init
2345      -Wheader-guard
2346      -Wheader-hygiene
2347      -Widiomatic-parentheses
2348      -Wignored-attributes
2349      -Wimplicit-atomic-properties
2350      -Wimplicit-conversion-floating-point-to-bool
2351      -Wimplicit-exception-spec-mismatch
2352      -Wimplicit-fallthrough
2353      -Wimplicit-fallthrough-per-function
2354      -Wimplicit-retain-self
2355      -Wimport-preprocessor-directive-pedantic
2356      -Wincompatible-library-redeclaration
2357      -Wincompatible-pointer-types-discards-qualifiers
2358      -Wincomplete-implementation
2359      -Wincomplete-module
2360      -Wincomplete-umbrella
2361      -Winit-self
2362      -Wint-conversions
2363      -Wint-to-void-pointer-cast
2364      -Winteger-overflow
2365      -Winvalid-constexpr
2366      -Winvalid-iboutlet
2367      -Winvalid-noreturn
2368      -Winvalid-pp-token
2369      -Winvalid-source-encoding
2370      -Winvalid-token-paste
2371      -Wknr-promoted-parameter
2372      -Wlarge-by-value-copy
2373      -Wliteral-conversion
2374      -Wliteral-range
2375      -Wlocal-type-template-args
2376      -Wlogical-op
2377      -Wloop-analysis
2378      -Wmain-return-type
2379      -Wmalformed-warning-check
2380      -Wmethod-signatures
2381      -Wmicrosoft
2382      -Wmicrosoft-exists
2383      -Wmismatched-parameter-types
2384      -Wmismatched-return-types
2385      -Wmissing-field-initializers
2386      -Wmissing-format-attribute
2387      -Wmissing-noreturn
2388      -Wmissing-selector-name
2389      -Wmissing-sysroot
2390      -Wmissing-variable-declarations
2391      -Wmodule-conflict
2392      -Wnested-anon-types
2393      -Wnewline-eof
2394      -Wnon-literal-null-conversion
2395      -Wnon-pod-varargs
2396      -Wnonportable-cfstrings
2397      -Wnormalized=nfkc
2398      -Wnull-arithmetic
2399      -Wnull-character
2400      -Wnull-conversion
2401      -Wnull-dereference
2402      -Wout-of-line-declaration
2403      -Wover-aligned
2404      -Woverlength-strings
2405      -Woverride-init
2406      -Woverriding-method-mismatch
2407      -Wpointer-type-mismatch
2408      -Wpredefined-identifier-outside-function
2409      -Wprotocol-property-synthesis-ambiguity
2410      -Wreadonly-iboutlet-property
2411      -Wreadonly-setter-attrs
2412      -Wreceiver-expr
2413      -Wreceiver-forward-class
2414      -Wreceiver-is-weak
2415      -Wreinterpret-base-class
2416      -Wrequires-super-attribute
2417      -Wreserved-user-defined-literal
2418      -Wreturn-stack-address
2419      -Wsection
2420      -Wselector-type-mismatch
2421      -Wsentinel
2422      -Wserialized-diagnostics
2423      -Wshadow
2424      -Wshift-count-negative
2425      -Wshift-count-overflow
2426      -Wshift-negative-value
2427      -Wshift-overflow=2
2428      -Wshift-sign-overflow
2429      -Wshorten-64-to-32
2430      -Wsizeof-array-argument
2431      -Wsource-uses-openmp
2432      -Wstatic-float-init
2433      -Wstatic-in-inline
2434      -Wstatic-local-in-inline
2435      -Wstrict-overflow=1
2436      -Wstring-compare
2437      -Wstring-conversion
2438      -Wstrlcpy-strlcat-size
2439      -Wstrncat-size
2440      -Wsuggest-attribute=format
2441      -Wsuggest-attribute=noreturn
2442      -Wsuper-class-method-mismatch
2443      -Wswitch-bool
2444      -Wsync-nand
2445      -Wtautological-constant-out-of-range-compare
2446      -Wtentative-definition-incomplete-type
2447      -Wtrampolines
2448      -Wtype-safety
2449      -Wtypedef-redefinition
2450      -Wtypename-missing
2451      -Wundefined-inline
2452      -Wundefined-internal
2453      -Wundefined-reinterpret-cast
2454      -Wunicode
2455      -Wunicode-whitespace
2456      -Wunknown-warning-option
2457      -Wunnamed-type-template-args
2458      -Wunneeded-member-function
2459      -Wunsequenced
2460      -Wunsupported-visibility
2461      -Wunused-but-set-parameter
2462      -Wunused-but-set-variable
2463      -Wunused-command-line-argument
2464      -Wunused-const-variable=2
2465      -Wunused-exception-parameter
2466      -Wunused-local-typedefs
2467      -Wunused-member-function
2468      -Wunused-sanitize-argument
2469      -Wunused-volatile-lvalue
2470      -Wuser-defined-literals
2471      -Wvariadic-macros
2472      -Wvector-conversion
2473      -Wvector-conversions
2474      -Wvexing-parse
2475      -Wvisibility
2476      -Wvla-extension
2477      -Wzero-length-array
2478   ], [ TOR_TRY_COMPILE_WITH_CFLAGS(warning_flag, [],
2479               [TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS warning_flag" CFLAGS="$CFLAGS warning_flag"], true)
2480      ])
2482 dnl    We should re-enable this in some later version.  Clang doesn't
2483 dnl    mind, but it causes trouble with GCC.
2484 dnl     -Wstrict-overflow=2
2486 dnl    These seem to require annotations that we don't currently use,
2487 dnl    and they give false positives in our pthreads wrappers. (Clang 4)
2488 dnl     -Wthread-safety
2489 dnl     -Wthread-safety-analysis
2490 dnl     -Wthread-safety-attributes
2491 dnl     -Wthread-safety-beta
2492 dnl     -Wthread-safety-precise
2494   W_FLAGS="$W_FLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
2495   W_FLAGS="$W_FLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
2496   W_FLAGS="$W_FLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
2497   W_FLAGS="$W_FLAGS -Wwrite-strings"
2498   W_FLAGS="$W_FLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
2499   W_FLAGS="$W_FLAGS -Waggregate-return -Wpacked -Wunused"
2500   W_FLAGS="$W_FLAGS -Wunused-parameter "
2501   # These interfere with building main() { return 0; }, which autoconf
2502   # likes to use as its default program.
2503   W_FLAGS="$W_FLAGS -Wold-style-definition -Wmissing-declarations"
2505   TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS $W_FLAGS"
2506   CFLAGS="$CFLAGS $W_FLAGS"
2508   if test "$tor_cv_cflags__Wnull_dereference" = "yes"; then
2509     AC_DEFINE([HAVE_CFLAG_WNULL_DEREFERENCE], 1, [True if we have -Wnull-dereference])
2510   fi
2511   if test "$tor_cv_cflags__Woverlength_strings" = "yes"; then
2512     AC_DEFINE([HAVE_CFLAG_WOVERLENGTH_STRINGS], 1, [True if we have -Woverlength-strings])
2513   fi
2514   if test "$tor_cv_cflags__warn_unused_const_variable_2" = "yes"; then
2515     AC_DEFINE([HAVE_CFLAG_WUNUSED_CONST_VARIABLE], 1, [True if we have -Wunused-const-variable])
2516   fi
2518   CFLAGS="$CFLAGS_NOWARNINGS"
2520   if test "x$enable_fatal_warnings" = "xyes"; then
2521     # I'd like to use TOR_CHECK_CFLAGS here, but I can't, since the
2522     # default autoconf programs are full of errors.
2523     CFLAGS="$CFLAGS -Werror"
2524   fi
2528 AC_SUBST(TOR_WARNING_FLAGS)
2530 echo "$TOR_WARNING_FLAGS">warning_flags
2532 TOR_TRY_COMPILE_WITH_CFLAGS([@warning_flags], [],
2533                             CFLAGS="$CFLAGS @warning_flags",
2534                             CFLAGS="$CFLAGS $TOR_WARNING_FLAGS")
2536 if test "$enable_coverage" = "yes" && test "$have_clang" = "no"; then
2537    case "$host_os" in
2538     darwin*)
2539       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.])
2540    esac
2543 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
2545 AC_CONFIG_FILES([
2546         Doxyfile
2547         Makefile
2548         config.rust
2549         contrib/operator-tools/tor.logrotate
2550         contrib/dist/tor.service
2551         src/config/torrc.sample
2552         src/config/torrc.minimal
2553         src/rust/.cargo/config
2554         scripts/maint/checkOptionDocs.pl
2555         warning_flags
2558 if test "x$asciidoc" = "xtrue" && test "$ASCIIDOC" = "none"; then
2559   regular_mans="doc/tor doc/tor-gencert doc/tor-resolve doc/torify"
2560   for file in $regular_mans ; do
2561     if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
2562       echo "==================================";
2563       echo;
2564       echo "Building Tor has failed since manpages cannot be built.";
2565       echo;
2566       echo "You need asciidoc installed to be able to build the manpages.";
2567       echo "To build without manpages, use the --disable-asciidoc argument";
2568       echo "when calling configure.";
2569       echo;
2570       echo "==================================";
2571       exit 1;
2572     fi
2573   done
2576 if test "$fragile_hardening" = "yes"; then
2577   AC_MSG_WARN([
2579 ============
2580 Warning!  Building Tor with --enable-fragile-hardening (also known as
2581 --enable-expensive-hardening) makes some kinds of attacks harder, but makes
2582 other kinds of attacks easier. A Tor instance build with this option will be
2583 somewhat less vulnerable to remote code execution, arithmetic overflow, or
2584 out-of-bounds read/writes... but at the cost of becoming more vulnerable to
2585 denial of service attacks. For more information, see
2586 https://trac.torproject.org/projects/tor/wiki/doc/TorFragileHardening
2587 ============
2588   ])
2591 AC_OUTPUT
2594 # Mini-report on what will be built.
2597 PPRINT_INIT
2598 PPRINT_SET_INDENT(1)
2599 PPRINT_SET_TS(65)
2601 AS_ECHO
2602 AS_ECHO("Tor Version: ${PPRINT_COLOR_BLDBLU}Tor $PACKAGE_VERSION $PPRINT_COLOR_RST")
2603 AS_ECHO
2605 PPRINT_SUBTITLE([Build Features])
2607 PPRINT_PROP_STRING([Compiler], [$CC])
2608 PPRINT_PROP_STRING([Host OS], [$host_os])
2609 AS_ECHO
2611 test "x$enable_fatal_warnings" = "xyes" && value=1 || value=0
2612 PPRINT_PROP_BOOL([Warnings are fatal (--enable-fatal-warnings)], $value)
2614 test "x$enable_rust" = "xyes" && value=1 || value=0
2615 PPRINT_PROP_BOOL([Rust support (--enable-rust)], $value)
2617 test "x$enable_cargo_online_mode" = "xyes" && value=1 || value=0
2618 PPRINT_PROP_BOOL([Cargo Online Fetch (--enable-cargo-online-mode)], $value)
2620 test "x$enable_android" = "xyes" && value=1 || value=0
2621 PPRINT_PROP_BOOL([Android support (--enable-android)], $value)
2623 AS_ECHO
2624 PPRINT_SUBTITLE([Static Build])
2626 test "x$enable_static_tor" = "xyes" && value=1 || value=0
2627 PPRINT_PROP_BOOL([tor (--enable-static-tor)], $value)
2629 if test "x$enable_static_libevent" = "xyes"; then
2630   PPRINT_PROP_STRING([libevent], [$TOR_LIBDIR_libevent])
2631 else
2632   PPRINT_PROP_BOOL([libevent (--enable-static-libevent)], $value)
2635 if test "x$enable_static_openssl" = "xyes"; then
2636   PPRINT_PROP_STRING([libssl], [$TOR_LIBDIR_openssl])
2637 else
2638   PPRINT_PROP_BOOL([libssl (--enable-static-openssl)], $value)
2641 if test "x$enable_static_zlib" = "xyes"; then
2642   PPRINT_PROP_STRING([zlib1g], [$TOR_LIBDIR_zlib])
2643 else
2644   PPRINT_PROP_BOOL([zlib1g (--enable-static-zlib)], $value)
2647 AS_ECHO
2648 PPRINT_SUBTITLE([Optional Libraries])
2650 test "x$enable_nss" = "xyes" && value=1 || value=0
2651 PPRINT_PROP_BOOL([libnss (--enable-nss)], $value)
2653 test "x$enable_seccomp" != "xno" && value=1 || value=0
2654 PPRINT_PROP_BOOL([libseccomp (--disable-seccomp)], $value)
2656 test "x$enable_libscrypt" != "xno" && value=1 || value=0
2657 PPRINT_PROP_BOOL([libscrypt (--disable-libscrypt)], $value)
2659 test "x$enable_systemd" = "xyes" && value=1 || value=0
2660 PPRINT_PROP_BOOL([Systemd support (--enable-systemd)], $value)
2662 test "x$enable_lzma" = "xyes" && value=1 || value=0
2663 PPRINT_PROP_BOOL([liblzma (--enable-lzma)], $value)
2665 test "x$enable_zstd" = "xyes" && value=1 || value=0
2666 PPRINT_PROP_BOOL([libzstd (--enable-zstd)], $value)
2668 AS_ECHO
2669 PPRINT_SUBTITLE([Hardening])
2671 test "x$enable_gcc_hardening" != "xno" && value=1 || value=0
2672 PPRINT_PROP_BOOL([Compiler Hardening (--disable-gcc-hardening)], $value)
2674 test "x$enable_linker_hardening" != "xno" && value=1 || value=0
2675 PPRINT_PROP_BOOL([Linker Hardening (--disable-linker-hardening)], $value)
2677 test "x$fragile_hardening" = "xyes" && value=1 || value=0
2678 PPRINT_PROP_BOOL([Fragile Hardening (--enable-fragile-hardening, dev only)], $value)
2680 AS_ECHO
2681 PPRINT_SUBTITLE([Modules])
2683 m4_foreach_w([mname], MODULES,
2684   [
2685     AM_COND_IF(m4_join([], [BUILD_MODULE_], m4_toupper([]mname[])), value=1, value=0)
2686     PPRINT_PROP_BOOL([mname (--disable-module-mname)], $value)
2687   ]
2690 AS_ECHO
2691 PPRINT_SUBTITLE([Documentation])
2693 test "x$enable_asciidoc" != "xno" && value=1 || value=0
2694 PPRINT_PROP_BOOL([AsciiDoc (--disable-asciidoc)], $value)
2696 test "x$enable_manpage" != "xno" && value=1 || value=0
2697 PPRINT_PROP_BOOL([Man Pages (--disable-manpage)], $value)
2699 test "x$enable_html_manual" != "xno" && value=1 || value=0
2700 PPRINT_PROP_BOOL([HTML Manual (--disable-html-manual)], $value)
2702 AS_ECHO
2703 PPRINT_SUBTITLE([Tests])
2705 test "x$enable_unittests" != "xno" && value=1 || value=0
2706 PPRINT_PROP_BOOL([Unit tests (--disable-unittests)], $value)
2708 test "x$enable_asserts_in_tests" = "xno" && value=1 || value=0
2709 PPRINT_PROP_BOOL([assert()s enabled (--enable-asserts-in-tests, dev only)], $value)
2711 test "x$enable_coverage" = "xyes" && value=1 || value=0
2712 PPRINT_PROP_BOOL([Code Coverage (--enable-coverage)], $value)
2714 test "x$enable_libfuzzer" = "xyes" && value=1 || value=0
2715 PPRINT_PROP_BOOL([libFuzzer support (--enable-libfuzzer)], $value)
2717 test "x$enable_oss_fuzz" = "xyes" && value=1 || value=0
2718 PPRINT_PROP_BOOL([OSS-Fuzz support (--enable-oss-fuzz)], $value)
2720 AS_ECHO
2721 PPRINT_SUBTITLE([Install Directories])
2723 report_mandir="`eval eval echo $mandir`"
2724 PPRINT_PROP_STRING([Binaries], [$BINDIR])
2725 PPRINT_PROP_STRING([Configuration], [$CONFDIR])
2726 PPRINT_PROP_STRING([Man Pages], [$report_mandir])
2728 AS_ECHO
2729 AS_ECHO(["Configure Line: ./configure $configure_flags"])