Space out the line.key/line.value in test_policy_summary_helper_family_flags()
[tor.git] / configure.ac
blobaa511a39110f971632714dd4552fd2a53f898013
1 dnl Copyright (c) 2001-2004, Roger Dingledine
2 dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
3 dnl Copyright (c) 2007-2019, The Tor Project, Inc.
4 dnl See LICENSE for licensing information
6 AC_PREREQ([2.63])
7 AC_INIT([tor],[0.4.4.0-alpha-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-02-11"], # for 0.4.4.0-alpha-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 TORUSER=_tor
431 AC_ARG_WITH(tor-user,
432         AS_HELP_STRING(--with-tor-user=NAME, [specify username for tor daemon]),
433         [
434            TORUSER=$withval
435         ]
437 AC_SUBST(TORUSER)
439 TORGROUP=_tor
440 AC_ARG_WITH(tor-group,
441         AS_HELP_STRING(--with-tor-group=NAME, [specify group name for tor daemon]),
442         [
443            TORGROUP=$withval
444         ]
446 AC_SUBST(TORGROUP)
449 dnl If _WIN32 is defined and non-zero, we are building for win32
450 AC_MSG_CHECKING([for win32])
451 AC_RUN_IFELSE([AC_LANG_SOURCE([
452 int main(int c, char **v) {
453 #ifdef _WIN32
454 #if _WIN32
455   return 0;
456 #else
457   return 1;
458 #endif
459 #else
460   return 2;
461 #endif
462 }])],
463 bwin32=true; AC_MSG_RESULT([yes]),
464 bwin32=false; AC_MSG_RESULT([no]),
465 bwin32=cross; AC_MSG_RESULT([cross])
468 if test "$bwin32" = "cross"; then
469 AC_MSG_CHECKING([for win32 (cross)])
470 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
471 #ifdef _WIN32
472 int main(int c, char **v) {return 0;}
473 #else
474 #error
475 int main(int c, char **v) {return x(y);}
476 #endif
477 ])],
478 bwin32=true; AC_MSG_RESULT([yes]),
479 bwin32=false; AC_MSG_RESULT([no]))
482 AH_BOTTOM([
483 #ifdef _WIN32
484 /* Defined to access windows functions and definitions for >=WinXP */
485 # ifndef WINVER
486 #  define WINVER 0x0501
487 # endif
489 /* Defined to access _other_ windows functions and definitions for >=WinXP */
490 # ifndef _WIN32_WINNT
491 #  define _WIN32_WINNT 0x0501
492 # endif
494 /* Defined to avoid including some windows headers as part of Windows.h */
495 # ifndef WIN32_LEAN_AND_MEAN
496 #  define WIN32_LEAN_AND_MEAN 1
497 # endif
498 #endif
501 AM_CONDITIONAL(WIN32, test "x$bwin32" = "xtrue")
502 AM_CONDITIONAL(BUILD_NT_SERVICES, test "x$bwin32" = "xtrue")
503 AM_CONDITIONAL(BUILD_LIBTORRUNNER, test "x$bwin32" != "xtrue")
505 dnl Enable C99 when compiling with MIPSpro
506 AC_MSG_CHECKING([for MIPSpro compiler])
507 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
508 #if (defined(__sgi) && defined(_COMPILER_VERSION))
509 #error
510   return x(y);
511 #endif
512 ])],
513 bmipspro=false; AC_MSG_RESULT(no),
514 bmipspro=true; AC_MSG_RESULT(yes))
516 if test "$bmipspro" = "true"; then
517   CFLAGS="$CFLAGS -c99"
520 AC_C_BIGENDIAN
522 AC_ARG_VAR([TOR_RUST_TARGET], [Rust target, must be specified when cross-compiling (HOST != BUILD). example: i686-pc-windows-gnu])
524 if test "x$enable_rust" = "xyes"; then
525   AC_ARG_VAR([RUSTC], [path to the rustc binary])
526   AC_CHECK_PROG([RUSTC], [rustc], [rustc],[no])
527   if test "x$RUSTC" = "xno"; then
528     AC_MSG_ERROR([rustc unavailable but rust integration requested.])
529   fi
531   AC_ARG_VAR([CARGO], [path to the cargo binary])
532   AC_CHECK_PROG([CARGO], [cargo], [cargo],[no])
533   if test "x$CARGO" = "xno"; then
534     AC_MSG_ERROR([cargo unavailable but rust integration requested.])
535   fi
537   AC_DEFINE([HAVE_RUST], 1, [have Rust])
538   if test "x$enable_fatal_warnings" = "xyes"; then
539     RUST_WARN=
540   else
541     RUST_WARN=#
542   fi
543   if test "x$enable_cargo_online_mode" = "xyes"; then
544     CARGO_ONLINE=
545     RUST_DL=#
546   else
547     CARGO_ONLINE=--frozen
548     RUST_DL=
550     dnl When we're not allowed to touch the network, we need crate dependencies
551     dnl locally available.
552     AC_MSG_CHECKING([rust crate dependencies])
553     AC_ARG_VAR([TOR_RUST_DEPENDENCIES], [path to directory with local crate mirror])
554     if test "x$TOR_RUST_DEPENDENCIES" = "x"; then
555       TOR_RUST_DEPENDENCIES="${srcdir}/src/ext/rust/crates"
556     fi
557     dnl Check whether the path exists before we try to cd into it.
558     if test ! -d "$TOR_RUST_DEPENDENCIES"; then
559       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.])
560       ERRORED=1
561     fi
562     dnl Make the path absolute, since we'll be using it from within a
563     dnl subdirectory.
564     TOR_RUST_DEPENDENCIES=$(cd "$TOR_RUST_DEPENDENCIES" ; pwd)
566     for dep in $rust_crates; do
567       if test ! -d "$TOR_RUST_DEPENDENCIES"/"$dep"; then
568         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.])
569         ERRORED=1
570       fi
571     done
572     if test "x$ERRORED" = "x"; then
573       AC_MSG_RESULT([yes])
574     fi
575   fi
577   dnl For now both MSVC and MinGW rust libraries will output static libs with
578   dnl the MSVC naming convention.
579   if test "$bwin32" = "true"; then
580     tor_rust_static_name=tor_rust.lib
581   else
582     tor_rust_static_name=libtor_rust.a
583   fi
585   AC_CANONICAL_BUILD
587   if test -n "$TOR_RUST_TARGET"; then
588     if test "$host" = "$build"; then
589       AC_MSG_ERROR([HOST = BUILD is invalid if TOR_RUST_TARGET is specified, see configure --help for more information.])
590     fi
591     RUST_TARGET_PROP="target = '$TOR_RUST_TARGET'"
592     TOR_RUST_LIB_PATH="src/rust/target/$TOR_RUST_TARGET/release/$tor_rust_static_name"
593   else
594     if test "$host" != "$build"; then
595       AC_MSG_ERROR([TOR_RUST_TARGET must be specified when cross-compiling with Rust enabled.])
596     fi
597     RUST_TARGET_PROP=
598     TOR_RUST_LIB_PATH="src/rust/target/release/$tor_rust_static_name"
599   fi
601   AC_SUBST(RUST_TARGET_PROP)
602   AC_SUBST(TOR_RUST_LIB_PATH)
603   AC_SUBST(CARGO_ONLINE)
604   AC_SUBST(RUST_WARN)
605   AC_SUBST(RUST_DL)
607   dnl Let's check the rustc version, too
608   AC_MSG_CHECKING([rust version])
609   RUSTC_VERSION=`$RUSTC --version`
610   RUSTC_VERSION_MAJOR=`$RUSTC --version | cut -d ' ' -f 2 | cut -d '.' -f 1`
611   RUSTC_VERSION_MINOR=`$RUSTC --version | cut -d ' ' -f 2 | cut -d '.' -f 2`
612   if test "x$RUSTC_VERSION_MAJOR" = "x" -o "x$RUSTC_VERSION_MINOR" = "x"; then
613     AC_MSG_ERROR([rustc version couldn't be identified])
614   fi
615   if test "$RUSTC_VERSION_MAJOR" -lt 2 -a "$RUSTC_VERSION_MINOR" -lt 31; then
616     AC_MSG_ERROR([rustc must be at least version 1.31.0])
617   fi
618   AC_MSG_RESULT([$RUSTC_VERSION])
621 AC_SEARCH_LIBS(socket, [socket network])
622 AC_SEARCH_LIBS(gethostbyname, [nsl])
623 AC_SEARCH_LIBS(dlopen, [dl])
624 AC_SEARCH_LIBS(inet_aton, [resolv])
625 AC_SEARCH_LIBS(backtrace, [execinfo])
626 saved_LIBS="$LIBS"
627 AC_SEARCH_LIBS([clock_gettime], [rt])
628 if test "$LIBS" != "$saved_LIBS"; then
629    # Looks like we need -lrt for clock_gettime().
630    have_rt=yes
633 if test "$bwin32" = "false"; then
634   AC_SEARCH_LIBS(pthread_create, [pthread])
635   AC_SEARCH_LIBS(pthread_detach, [pthread])
638 AM_CONDITIONAL(THREADS_WIN32, test "$bwin32" = "true")
639 AM_CONDITIONAL(THREADS_PTHREADS, test "$bwin32" = "false")
641 AC_CHECK_FUNCS(
642         _NSGetEnviron \
643         RtlSecureZeroMemory \
644         SecureZeroMemory \
645         accept4 \
646         backtrace \
647         backtrace_symbols_fd \
648         eventfd \
649         explicit_bzero \
650         timingsafe_memcmp \
651         flock \
652         ftime \
653         get_current_dir_name \
654         getaddrinfo \
655         getdelim \
656         getifaddrs \
657         getline \
658         getpass \
659         getrlimit \
660         gettimeofday \
661         gmtime_r \
662         gnu_get_libc_version \
663         htonll \
664         inet_aton \
665         ioctl \
666         issetugid \
667         llround \
668         localtime_r \
669         lround \
670         madvise \
671         memmem \
672         memset_s \
673         minherit \
674         mmap \
675         pipe \
676         pipe2 \
677         prctl \
678         readpassphrase \
679         rint \
680         sigaction \
681         socketpair \
682         statvfs \
683         strncasecmp \
684         strcasecmp \
685         strlcat \
686         strlcpy \
687         strnlen \
688         strptime \
689         strtok_r \
690         strtoull \
691         sysconf \
692         sysctl \
693         truncate \
694         uname \
695         usleep \
696         vasprintf \
697         _vscprintf
700 # Apple messed up when they added some functions: they
701 # forgot to decorate them with appropriate AVAILABLE_MAC_OS_VERSION
702 # checks.
704 # We should only probe for these functions if we are sure that we
705 # are not targeting OS X 10.9 or earlier.
706 AC_MSG_CHECKING([for a pre-Yosemite OS X build target])
707 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
708 #ifdef __APPLE__
709 #  include <AvailabilityMacros.h>
710 #  ifndef MAC_OS_X_VERSION_10_10
711 #    define MAC_OS_X_VERSION_10_10 101000
712 #  endif
713 #  if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
714 #    if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
715 #      error "Running on Mac OS X 10.9 or earlier"
716 #    endif
717 #  endif
718 #endif
719 ]], [[]])],
720    [on_macos_pre_10_10=no ; AC_MSG_RESULT([no])],
721    [on_macos_pre_10_10=yes; AC_MSG_RESULT([yes])])
723 if test "$on_macos_pre_10_10" = "no"; then
724   AC_CHECK_FUNCS(
725         mach_approximate_time \
726   )
729 # We should only probe for these functions if we are sure that we
730 # are not targeting OSX 10.11 or earlier.
731 AC_MSG_CHECKING([for a pre-Sierra OSX build target])
732 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
733 #ifdef __APPLE__
734 #  include <AvailabilityMacros.h>
735 #  ifndef MAC_OS_X_VERSION_10_12
736 #    define MAC_OS_X_VERSION_10_12 101200
737 #  endif
738 #  if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
739 #    if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
740 #      error "Running on Mac OSX 10.11 or earlier"
741 #    endif
742 #  endif
743 #endif
744 ]], [[]])],
745    [on_macos_pre_10_12=no ; AC_MSG_RESULT([no])],
746    [on_macos_pre_10_12=yes; AC_MSG_RESULT([yes])])
748 if test "$on_macos_pre_10_12" = "no"; then
749   AC_CHECK_FUNCS(
750         clock_gettime \
751         getentropy \
752   )
755 if test "$bwin32" != "true"; then
756   AC_CHECK_HEADERS(pthread.h)
757   AC_CHECK_FUNCS(pthread_create)
758   AC_CHECK_FUNCS(pthread_condattr_setclock)
761 if test "$bwin32" = "true"; then
762   AC_CHECK_DECLS([SecureZeroMemory, _getwch], , , [
763 #include <windows.h>
764 #include <conio.h>
765 #include <wchar.h>
766                  ])
769 AM_CONDITIONAL(BUILD_READPASSPHRASE_C,
770   test "x$ac_cv_func_readpassphrase" = "xno" && test "$bwin32" = "false")
772 AC_MSG_CHECKING([whether free(NULL) works])
773 AC_RUN_IFELSE([AC_LANG_PROGRAM([
774   #include <stdlib.h>
775 ], [
776 char *p = NULL;
777 free(p);
778 ])],
779 [free_null_ok=true; AC_MSG_RESULT(yes)],
780 [free_null_ok=false; AC_MSG_RESULT(no)],
781 [free_null_ok=cross; AC_MSG_RESULT(cross)])
783 if test "$free_null_ok" = "false"; then
784    AC_MSG_ERROR([Your libc implementation doesn't allow free(NULL), as required by C99.])
787 dnl ------------------------------------------------------
788 dnl Where do you live, libevent?  And how do we call you?
790 if test "$bwin32" = "true"; then
791   TOR_LIB_WS32=-lws2_32
792   TOR_LIB_IPHLPAPI=-liphlpapi
793   # Some of the cargo-cults recommend -lwsock32 as well, but I don't
794   # think it's actually necessary.
795   TOR_LIB_GDI=-lgdi32
796   TOR_LIB_USERENV=-luserenv
797 else
798   TOR_LIB_WS32=
799   TOR_LIB_GDI=
800   TOR_LIB_USERENV=
802 AC_SUBST(TOR_LIB_WS32)
803 AC_SUBST(TOR_LIB_GDI)
804 AC_SUBST(TOR_LIB_IPHLPAPI)
805 AC_SUBST(TOR_LIB_USERENV)
807 tor_libevent_pkg_redhat="libevent"
808 tor_libevent_pkg_debian="libevent-dev"
809 tor_libevent_devpkg_redhat="libevent-devel"
810 tor_libevent_devpkg_debian="libevent-dev"
812 dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
813 dnl linking for static builds.
814 STATIC_LIBEVENT_FLAGS=""
815 if test "$enable_static_libevent" = "yes"; then
816     if test "$have_rt" = "yes"; then
817       STATIC_LIBEVENT_FLAGS=" -lrt "
818     fi
821 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
822 #ifdef _WIN32
823 #include <winsock2.h>
824 #endif
825 #include <sys/time.h>
826 #include <sys/types.h>
827 #include <event2/event.h>], [
828 #ifdef _WIN32
829 #include <winsock2.h>
830 #endif
831 struct event_base;
832 struct event_base *event_base_new(void);
833 void event_base_free(struct event_base *);],
834     [
835 #ifdef _WIN32
836 {WSADATA d; WSAStartup(0x101,&d); }
837 #endif
838 event_base_free(event_base_new());
839 ], [--with-libevent-dir], [/opt/libevent])
841 dnl Determine the incantation needed to link libevent.
842 save_LIBS="$LIBS"
843 save_LDFLAGS="$LDFLAGS"
844 save_CPPFLAGS="$CPPFLAGS"
846 LIBS="$STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $save_LIBS"
847 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
848 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
850 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
852 if test "$enable_static_libevent" = "yes"; then
853    if test "$tor_cv_library_libevent_dir" = "(system)"; then
854      AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
855    else
856      TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
857    fi
858 else
859      if test "x$ac_cv_header_event2_event_h" = "xyes"; then
860        AC_SEARCH_LIBS(event_new, [event event_core], , AC_MSG_ERROR("libevent2 is installed but linking it failed while searching for event_new"))
861        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"))
863        if test "$ac_cv_search_event_new" != "none required"; then
864          TOR_LIBEVENT_LIBS="$ac_cv_search_event_new"
865        fi
866        if test "$ac_cv_search_evdns_base_new" != "none required"; then
867          TOR_LIBEVENT_LIBS="$ac_cv_search_evdns_base_new $TOR_LIBEVENT_LIBS"
868        fi
869      else
870        AC_MSG_ERROR("libevent2 is required but the headers could not be found")
871      fi
874 dnl Now check for particular libevent functions.
875 AC_CHECK_FUNCS([evutil_secure_rng_set_urandom_device_file \
876                 evutil_secure_rng_add_bytes \
877                 evdns_base_get_nameserver_addr \
881 LIBS="$save_LIBS"
882 LDFLAGS="$save_LDFLAGS"
883 CPPFLAGS="$save_CPPFLAGS"
885 dnl Check that libevent is at least at version 2.0.10, the first stable
886 dnl release of its series
887 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
888 AC_MSG_CHECKING([whether Libevent is new enough])
889 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
890 #include <event2/event.h>
891 #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000a00
892 #error
893 int x = y(zz);
894 #else
895 int x = 1;
896 #endif
897 ])], [ AC_MSG_RESULT([yes]) ],
898    [ AC_MSG_RESULT([no])
899      AC_MSG_ERROR([Libevent is not new enough.  We require 2.0.10-stable or later]) ] )
901 LIBS="$save_LIBS"
902 LDFLAGS="$save_LDFLAGS"
903 CPPFLAGS="$save_CPPFLAGS"
905 AC_SUBST(TOR_LIBEVENT_LIBS)
907 dnl ------------------------------------------------------
908 dnl Where do you live, libm?
910 dnl On some platforms (Haiku/BeOS) the math library is
911 dnl part of libroot. In which case don't link against lm
912 TOR_LIB_MATH=""
913 save_LIBS="$LIBS"
914 AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
915 if test "$ac_cv_search_pow" != "none required"; then
916     TOR_LIB_MATH="$ac_cv_search_pow"
918 LIBS="$save_LIBS"
919 AC_SUBST(TOR_LIB_MATH)
921 dnl ------------------------------------------------------
922 dnl Hello, NSS.  You're new around here.
923 if test "x$enable_nss" = "xyes"; then
924   PKG_CHECK_MODULES(NSS,
925      [nss],
926      [have_nss=yes],
927      [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.])])
928   AC_SUBST(NSS_CFLAGS)
929   AC_SUBST(NSS_LIBS)
932 dnl ------------------------------------------------------
933 dnl Where do you live, openssl?  And how do we call you?
935 if test "x$enable_nss" != "xyes"; then
937 tor_openssl_pkg_redhat="openssl"
938 tor_openssl_pkg_debian="libssl-dev"
939 tor_openssl_devpkg_redhat="openssl-devel"
940 tor_openssl_devpkg_debian="libssl-dev"
942 ALT_openssl_WITHVAL=""
943 AC_ARG_WITH(ssl-dir,
944   AS_HELP_STRING(--with-ssl-dir=PATH, [obsolete alias for --with-openssl-dir]),
945   [
946       if test "x$withval" != "xno" && test "x$withval" != "x"; then
947          ALT_openssl_WITHVAL="$withval"
948       fi
949   ])
951 AC_MSG_NOTICE([Now, we'll look for OpenSSL >= 1.0.1])
952 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI $TOR_LIB_WS32],
953     [#include <openssl/ssl.h>
954      char *getenv(const char *);],
955     [struct ssl_cipher_st;
956      unsigned SSL_CIPHER_get_id(const struct ssl_cipher_st *);
957      char *getenv(const char *);],
958     dnl This funny-looking test program calls getenv, so that the compiler
959     dnl will neither make code that call SSL_CIPHER_get_id(NULL) [producing
960     dnl a crash], nor optimize out the call to SSL_CIPHER_get_id().
961     dnl We look for SSL_cipher_get_id() because it is present in
962     dnl OpenSSL >=1.0.1, because it is not deprecated, and because Tor
963     dnl depends on it.
964     [if (getenv("THIS_SHOULDNT_BE_SET_X201803")) SSL_CIPHER_get_id((void *)0);], [],
965     [/usr/local/opt/openssl /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /opt/openssl])
967 dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
969 if test "$enable_static_openssl" = "yes"; then
970    if test "$tor_cv_library_openssl_dir" = "(system)"; then
971      AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
972    else
973      TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
974    fi
975 else
976      TOR_OPENSSL_LIBS="-lssl -lcrypto"
978 AC_SUBST(TOR_OPENSSL_LIBS)
980 dnl Now check for particular openssl functions.
981 save_LIBS="$LIBS"
982 save_LDFLAGS="$LDFLAGS"
983 save_CPPFLAGS="$CPPFLAGS"
984 LIBS="$TOR_OPENSSL_LIBS $LIBS"
985 LDFLAGS="$TOR_LDFLAGS_openssl $LDFLAGS"
986 CPPFLAGS="$TOR_CPPFLAGS_openssl $CPPFLAGS"
988 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
989 #include <openssl/opensslv.h>
990 #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1000100fL
991 #error "too old"
992 #endif
993    ]], [[]])],
994    [ : ],
995    [ 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.]) ])
997 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
998 #include <openssl/opensslv.h>
999 #include <openssl/evp.h>
1000 #if defined(OPENSSL_NO_EC) || defined(OPENSSL_NO_ECDH) || defined(OPENSSL_NO_ECDSA)
1001 #error "no ECC"
1002 #endif
1003 #if !defined(NID_X9_62_prime256v1) || !defined(NID_secp224r1)
1004 #error "curves unavailable"
1005 #endif
1006    ]], [[]])],
1007    [ : ],
1008    [ 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.]) ])
1010 AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , ,
1011 [#include <openssl/ssl.h>
1014 dnl OpenSSL functions which we might not have.  In theory, we could just
1015 dnl check the openssl version number, but in practice that gets pretty
1016 dnl confusing with LibreSSL, OpenSSL, and various distributions' patches
1017 dnl to them.
1018 AC_CHECK_FUNCS([ \
1019                 ERR_load_KDF_strings \
1020                 EVP_PBE_scrypt \
1021                 EVP_sha3_256 \
1022                 SSL_CIPHER_find \
1023                 SSL_CTX_set1_groups_list \
1024                 SSL_CTX_set_security_level \
1025                 SSL_SESSION_get_master_key \
1026                 SSL_get_client_ciphers \
1027                 SSL_get_client_random \
1028                 SSL_get_server_random \
1029                 TLS_method \
1030                ])
1032 dnl Check if OpenSSL structures are opaque
1033 AC_CHECK_MEMBERS([SSL.state], , ,
1034 [#include <openssl/ssl.h>
1037 AC_CHECK_SIZEOF(SHA_CTX, , [AC_INCLUDES_DEFAULT()
1038 #include <openssl/sha.h>
1041 fi # enable_nss
1043 dnl We will someday make KECCAK_TINY optional, but for now we still need
1044 dnl it for SHAKE, since OpenSSL's SHAKE can't be squeezed more than
1045 dnl once.  See comment in the definition of crypto_xof_t.
1047 dnl AM_CONDITIONAL(BUILD_KECCAK_TINY,
1048 dnl   test "x$ac_cv_func_EVP_sha3_256" != "xyes")
1050 AM_CONDITIONAL(BUILD_KECCAK_TINY, true)
1052 dnl ======================================================================
1053 dnl Can we use KIST?
1055 dnl Define the set of checks for KIST scheduler support.
1056 AC_DEFUN([CHECK_KIST_SUPPORT],[
1057   dnl KIST needs struct tcp_info and for certain members to exist.
1058   AC_CHECK_MEMBERS(
1059     [struct tcp_info.tcpi_unacked, struct tcp_info.tcpi_snd_mss],
1060     , ,[[#include <netinet/tcp.h>]])
1061   dnl KIST needs SIOCOUTQNSD to exist for an ioctl call.
1062   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1063                      #include <linux/sockios.h>
1064                      #ifndef SIOCOUTQNSD
1065                      #error
1066                      #endif
1067                      ])], have_siocoutqnsd=yes, have_siocoutqnsd=no)
1068   if test "x$have_siocoutqnsd" = "xyes"; then
1069     if test "x$ac_cv_member_struct_tcp_info_tcpi_unacked" = "xyes"; then
1070       if test "x$ac_cv_member_struct_tcp_info_tcpi_snd_mss" = "xyes"; then
1071         have_kist_support=yes
1072       fi
1073     fi
1074   fi
1076 dnl Now, trigger the check.
1077 CHECK_KIST_SUPPORT
1078 AS_IF([test "x$have_kist_support" = "xyes"],
1079       [AC_DEFINE(HAVE_KIST_SUPPORT, 1, [Defined if KIST scheduler is supported
1080                                         on this system])],
1081       [AC_MSG_NOTICE([KIST scheduler can't be used. Missing support.])])
1083 LIBS="$save_LIBS"
1084 LDFLAGS="$save_LDFLAGS"
1085 CPPFLAGS="$save_CPPFLAGS"
1087 dnl ------------------------------------------------------
1088 dnl Where do you live, zlib?  And how do we call you?
1090 tor_zlib_pkg_redhat="zlib"
1091 tor_zlib_pkg_debian="zlib1g"
1092 tor_zlib_devpkg_redhat="zlib-devel"
1093 tor_zlib_devpkg_debian="zlib1g-dev"
1095 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
1096     [#include <zlib.h>],
1097     [const char * zlibVersion(void);],
1098     [zlibVersion();], [--with-zlib-dir],
1099     [/opt/zlib])
1101 if test "$enable_static_zlib" = "yes"; then
1102    if test "$tor_cv_library_zlib_dir" = "(system)"; then
1103      AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
1104  using --enable-static-zlib")
1105    else
1106      TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
1107    fi
1108 else
1109      TOR_ZLIB_LIBS="-lz"
1111 AC_SUBST(TOR_ZLIB_LIBS)
1113 dnl ------------------------------------------------------
1114 dnl Where we do we find lzma?
1116 AC_ARG_ENABLE(lzma,
1117       AS_HELP_STRING(--enable-lzma, [enable support for the LZMA compression scheme.]),
1118       [case "${enableval}" in
1119         "yes") ;;
1120         "no")  ;;
1121         * ) AC_MSG_ERROR(bad value for --enable-lzma) ;;
1122       esac], [enable_lzma=auto])
1124 if test "x$enable_lzma" = "xno"; then
1125     have_lzma=no;
1126 else
1127     PKG_CHECK_MODULES([LZMA],
1128                       [liblzma],
1129                       have_lzma=yes,
1130                       have_lzma=no)
1132     if test "x$have_lzma" = "xno" ; then
1133         AC_MSG_WARN([Unable to find liblzma, $pkg_config_user_action, or set LZMA_CFLAGS and LZMA_LIBS.])
1134     fi
1137 if test "x$have_lzma" = "xyes"; then
1138     AC_DEFINE(HAVE_LZMA,1,[Have LZMA])
1139     TOR_LZMA_CFLAGS="${LZMA_CFLAGS}"
1140     TOR_LZMA_LIBS="${LZMA_LIBS}"
1142 AC_SUBST(TOR_LZMA_CFLAGS)
1143 AC_SUBST(TOR_LZMA_LIBS)
1145 dnl ------------------------------------------------------
1146 dnl Where we do we find zstd?
1148 AC_ARG_ENABLE(zstd,
1149       AS_HELP_STRING(--enable-zstd, [enable support for the Zstandard compression scheme.]),
1150       [case "${enableval}" in
1151         "yes") ;;
1152         "no")  ;;
1153         * ) AC_MSG_ERROR(bad value for --enable-zstd) ;;
1154       esac], [enable_zstd=auto])
1156 if test "x$enable_zstd" = "xno"; then
1157     have_zstd=no;
1158 else
1159     PKG_CHECK_MODULES([ZSTD],
1160                       [libzstd >= 1.1],
1161                       have_zstd=yes,
1162                       have_zstd=no)
1164     if test "x$have_zstd" = "xno" ; then
1165         AC_MSG_WARN([Unable to find libzstd, $pkg_config_user_action, or set ZSTD_CFLAGS and ZSTD_LIBS.])
1166     fi
1169 if test "x$have_zstd" = "xyes"; then
1170     AC_DEFINE(HAVE_ZSTD,1,[Have Zstd])
1171     TOR_ZSTD_CFLAGS="${ZSTD_CFLAGS}"
1172     TOR_ZSTD_LIBS="${ZSTD_LIBS}"
1174     dnl now check for zstd functions
1175     save_LIBS="$LIBS"
1176     save_CFLAGS="$CFLAGS"
1177     LIBS="$LIBS $ZSTD_LIBS"
1178     CFLAGS="$CFLAGS $ZSTD_CFLAGS"
1179     AC_CHECK_FUNCS(ZSTD_estimateCStreamSize \
1180                    ZSTD_estimateDCtxSize)
1181     LIBS="$save_LIBS"
1182     CFLAGS="$save_CFLAGS"
1184 AC_SUBST(TOR_ZSTD_CFLAGS)
1185 AC_SUBST(TOR_ZSTD_LIBS)
1187 dnl ----------------------------------------------------------------------
1188 dnl Check if libcap is available for capabilities.
1190 tor_cap_pkg_debian="libcap2"
1191 tor_cap_pkg_redhat="libcap"
1192 tor_cap_devpkg_debian="libcap-dev"
1193 tor_cap_devpkg_redhat="libcap-devel"
1195 AC_CHECK_LIB([cap], [cap_init], [],
1196   AC_MSG_NOTICE([Libcap was not found. Capabilities will not be usable.])
1198 AC_CHECK_FUNCS(cap_set_proc)
1200 dnl ---------------------------------------------------------------------
1201 dnl Now that we know about our major libraries, we can check for compiler
1202 dnl and linker hardening options.  We need to do this with the libraries known,
1203 dnl since sometimes the linker will like an option but not be willing to
1204 dnl use it with a build of a library.
1206 all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
1207 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"
1209 CFLAGS_FTRAPV=
1210 CFLAGS_FWRAPV=
1211 CFLAGS_ASAN=
1212 CFLAGS_UBSAN=
1215 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1216 #if !defined(__clang__)
1217 #error
1218 #endif])], have_clang=yes, have_clang=no)
1220 if test "x$enable_pic" = "xyes"; then
1221     TOR_CHECK_CFLAGS(-fPIC)
1224 if test "x$enable_gcc_hardening" != "xno"; then
1225     CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
1226     if test "x$have_clang" = "xyes"; then
1227         TOR_CHECK_CFLAGS(-Qunused-arguments)
1228     fi
1229     TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
1230     AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
1231     AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
1232 m4_ifdef([AS_VAR_IF],[
1233     AS_VAR_IF(can_compile, [yes],
1234         AS_VAR_IF(can_link, [yes],
1235                   [],
1236                   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.)]))
1237         )])
1238     AS_VAR_POPDEF([can_link])
1239     AS_VAR_POPDEF([can_compile])
1240     TOR_CHECK_CFLAGS(-Wstack-protector)
1241     TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
1242     if test "$bwin32" = "false" && test "$enable_libfuzzer" != "yes" && test "$enable_oss_fuzz" != "yes"; then
1243        if test "$enable_pic" != "yes"; then
1244            # If we have already enabled -fPIC, then we don't also need to
1245            # compile with -fPIE...
1246            TOR_CHECK_CFLAGS(-fPIE)
1247        fi
1248        # ... but we want to link our executables with -pie in any case, since
1249        # they're executables, not a library.
1250        TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
1251     fi
1252     TOR_TRY_COMPILE_WITH_CFLAGS(-fwrapv, also_link, CFLAGS_FWRAPV="-fwrapv", true)
1254    AC_MSG_CHECKING([whether we can run hardened binaries])
1255    AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
1256         [AC_MSG_RESULT([yes])],
1257         [AC_MSG_RESULT([no])
1258          AC_MSG_ERROR([dnl
1259  We can link with compiler hardening options, but we can't run with them.
1260  That's a bad sign! If you must, you can pass --disable-gcc-hardening to
1261  configure, but it would be better to figure out what the underlying problem
1262  is.])],
1263         [AC_MSG_RESULT([cross])])
1266 if test "$fragile_hardening" = "yes"; then
1267     TOR_TRY_COMPILE_WITH_CFLAGS(-ftrapv, also_link, CFLAGS_FTRAPV="-ftrapv", true)
1268    if test "$tor_cv_cflags__ftrapv" = "yes" && test "$tor_can_link__ftrapv" != "yes"; then
1269       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.])
1270    fi
1272    if test "$tor_cv_cflags__ftrapv" != "yes"; then
1273      AC_MSG_ERROR([You requested fragile hardening, but the compiler does not seem to support -ftrapv.])
1274    fi
1276    TOR_TRY_COMPILE_WITH_CFLAGS([-fsanitize=address], also_link, CFLAGS_ASAN="-fsanitize=address", true)
1277     if test "$tor_cv_cflags__fsanitize_address" = "yes" && test "$tor_can_link__fsanitize_address" != "yes"; then
1278       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*])
1279     fi
1281    TOR_TRY_COMPILE_WITH_CFLAGS([-fsanitize=undefined], also_link, CFLAGS_UBSAN="-fsanitize=undefined", true)
1282     if test "$tor_cv_cflags__fsanitize_address" = "yes" && test "$tor_can_link__fsanitize_address" != "yes"; then
1283       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*])
1284     fi
1286    TOR_TRY_COMPILE_WITH_CFLAGS([-fno-sanitize=float-divide-by-zero], also_link, CFLAGS_UBSAN="-fno-sanitize=float-divide-by-zero", true)
1287     if test "$tor_cv_cflags__fno_sanitize_float_divide_by_zero" = "yes" && test "$tor_can_link__fno_sanitize_float_divide_by_zero" != "yes"; then
1288       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*])
1289     fi
1291 TOR_CHECK_CFLAGS([-fno-omit-frame-pointer])
1294 dnl Find the correct libraries to add in order to use the sanitizers.
1296 dnl When building Rust, Cargo will run the linker with the -nodefaultlibs
1297 dnl option, which will prevent the compiler from linking the sanitizer
1298 dnl libraries it needs.  We need to specify them manually.
1300 dnl What's more, we need to specify them in a linker script rather than
1301 dnl from build.rs: these options aren't allowed in the cargo:rustc-flags
1302 dnl variable.
1303 RUST_LINKER_OPTIONS=""
1304 if test "x$have_clang" = "xyes"; then
1305         if test "x$CFLAGS_ASAN" != "x"; then
1306                 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_ASAN -Cdefault-linker-libraries"
1307         fi
1308         if test "x$CFLAGS_UBSAN" != "x"; then
1309                 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_UBSAN -Cdefault-linker-libraries"
1310         fi
1311 else
1312         if test "x$CFLAGS_ASAN" != "x"; then
1313                 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=address -Cdefault-linker-libraries"
1314         fi
1315         if test "x$CFLAGS_UBSAN" != "x"; then
1316                 RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=undefined -Cdefault-linker-libraries"
1317         fi
1319 AC_SUBST(RUST_LINKER_OPTIONS)
1321 CFLAGS_BUGTRAP="$CFLAGS_FTRAPV $CFLAGS_ASAN $CFLAGS_UBSAN"
1322 CFLAGS_CONSTTIME="$CFLAGS_FWRAPV"
1324 mulodi_fixes_ftrapv=no
1325 if test "$have_clang" = "yes"; then
1326   saved_CFLAGS="$CFLAGS"
1327   CFLAGS="$CFLAGS $CFLAGS_FTRAPV"
1328   AC_MSG_CHECKING([whether clang -ftrapv can link a 64-bit int multiply])
1329   AC_LINK_IFELSE([
1330       AC_LANG_SOURCE([[
1331           #include <stdint.h>
1332           #include <stdlib.h>
1333           int main(int argc, char **argv)
1334           {
1335             int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
1336                         * (int64_t)atoi(argv[3]);
1337             return x == 9;
1338           } ]])],
1339           [ftrapv_can_link=yes; AC_MSG_RESULT([yes])],
1340           [ftrapv_can_link=no; AC_MSG_RESULT([no])])
1341   if test "$ftrapv_can_link" = "no"; then
1342     AC_MSG_CHECKING([whether defining __mulodi4 fixes that])
1343     AC_LINK_IFELSE([
1344       AC_LANG_SOURCE([[
1345           #include <stdint.h>
1346           #include <stdlib.h>
1347           int64_t __mulodi4(int64_t a, int64_t b, int *overflow) {
1348              *overflow=0;
1349              return a;
1350           }
1351           int main(int argc, char **argv)
1352           {
1353             int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
1354                         * (int64_t)atoi(argv[3]);
1355             return x == 9;
1356           } ]])],
1357           [mulodi_fixes_ftrapv=yes; AC_MSG_RESULT([yes])],
1358           [mulodi_fixes_ftrapv=no; AC_MSG_RESULT([no])])
1359   fi
1360   CFLAGS="$saved_CFLAGS"
1363 AM_CONDITIONAL(ADD_MULODI4, test "$mulodi_fixes_ftrapv" = "yes")
1365 dnl These cflags add bunches of branches, and we haven't been able to
1366 dnl persuade ourselves that they're suitable for code that needs to be
1367 dnl constant time.
1368 AC_SUBST(CFLAGS_BUGTRAP)
1369 dnl These cflags are variant ones sutable for code that needs to be
1370 dnl constant-time.
1371 AC_SUBST(CFLAGS_CONSTTIME)
1373 if test "x$enable_linker_hardening" != "xno"; then
1374     TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
1377 # For backtrace support
1378 TOR_CHECK_LDFLAGS(-rdynamic)
1380 dnl ------------------------------------------------------
1381 dnl Now see if we have a -fomit-frame-pointer compiler option.
1383 saved_CFLAGS="$CFLAGS"
1384 TOR_CHECK_CFLAGS(-fomit-frame-pointer)
1385 F_OMIT_FRAME_POINTER=''
1386 if test "$saved_CFLAGS" != "$CFLAGS"; then
1387   if test "$fragile_hardening" = "yes"; then
1388     F_OMIT_FRAME_POINTER='-fomit-frame-pointer'
1389   fi
1391 CFLAGS="$saved_CFLAGS"
1392 AC_SUBST(F_OMIT_FRAME_POINTER)
1394 dnl ------------------------------------------------------
1395 dnl If we are adding -fomit-frame-pointer (or if the compiler's doing it
1396 dnl for us, as GCC 4.6 and later do at many optimization levels), then
1397 dnl we should try to add -fasynchronous-unwind-tables so that our backtrace
1398 dnl code will work.
1399 TOR_CHECK_CFLAGS(-fasynchronous-unwind-tables)
1401 dnl ============================================================
1402 dnl Check for libseccomp
1404 if test "x$enable_seccomp" != "xno"; then
1405   AC_CHECK_HEADERS([seccomp.h])
1406   AC_SEARCH_LIBS(seccomp_init, [seccomp])
1409 dnl ============================================================
1410 dnl Check for libscrypt
1412 if test "x$enable_libscrypt" != "xno"; then
1413   AC_CHECK_HEADERS([libscrypt.h])
1414   AC_SEARCH_LIBS(libscrypt_scrypt, [scrypt])
1415   AC_CHECK_FUNCS([libscrypt_scrypt])
1418 dnl ============================================================
1419 dnl We need an implementation of curve25519.
1421 dnl set these defaults.
1422 build_curve25519_donna=no
1423 build_curve25519_donna_c64=no
1424 use_curve25519_donna=no
1425 use_curve25519_nacl=no
1426 CURVE25519_LIBS=
1428 dnl The best choice is using curve25519-donna-c64, but that requires
1429 dnl that we
1430 AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
1431   tor_cv_can_use_curve25519_donna_c64,
1432   [AC_RUN_IFELSE(
1433     [AC_LANG_PROGRAM([dnl
1434       #include <stdint.h>
1435       typedef unsigned uint128_t __attribute__((mode(TI)));
1436   int func(uint64_t a, uint64_t b) {
1437            uint128_t c = ((uint128_t)a) * b;
1438            int ok = ((uint64_t)(c>>96)) == 522859 &&
1439              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
1440                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
1441                  (((uint64_t)(c))&0xffffffffL) == 0;
1442            return ok;
1443       }
1444   ], [dnl
1445     int ok = func( ((uint64_t)2000000000) * 1000000000,
1446                    ((uint64_t)1234567890) << 24);
1447         return !ok;
1448       ])],
1449   [tor_cv_can_use_curve25519_donna_c64=yes],
1450       [tor_cv_can_use_curve25519_donna_c64=no],
1451   [AC_LINK_IFELSE(
1452         [AC_LANG_PROGRAM([dnl
1453       #include <stdint.h>
1454       typedef unsigned uint128_t __attribute__((mode(TI)));
1455   int func(uint64_t a, uint64_t b) {
1456            uint128_t c = ((uint128_t)a) * b;
1457            int ok = ((uint64_t)(c>>96)) == 522859 &&
1458              (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
1459                  (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
1460                  (((uint64_t)(c))&0xffffffffL) == 0;
1461            return ok;
1462       }
1463   ], [dnl
1464     int ok = func( ((uint64_t)2000000000) * 1000000000,
1465                  ((uint64_t)1234567890) << 24);
1466         return !ok;
1467       ])],
1468           [tor_cv_can_use_curve25519_donna_c64=cross],
1469       [tor_cv_can_use_curve25519_donna_c64=no])])])
1471 AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
1472                   nacl/crypto_scalarmult_curve25519.h])
1474 AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
1475   tor_cv_can_use_curve25519_nacl,
1476   [tor_saved_LIBS="$LIBS"
1477    LIBS="$LIBS -lnacl"
1478    AC_LINK_IFELSE(
1479      [AC_LANG_PROGRAM([dnl
1480        #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
1481        #include <crypto_scalarmult_curve25519.h>
1482    #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
1483    #include <nacl/crypto_scalarmult_curve25519.h>
1484    #endif
1485        #ifdef crypto_scalarmult_curve25519_ref_BYTES
1486    #error Hey, this is the reference implementation! That's not fast.
1487    #endif
1488      ], [
1489    unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
1490      ])], [tor_cv_can_use_curve25519_nacl=yes],
1491      [tor_cv_can_use_curve25519_nacl=no])
1492    LIBS="$tor_saved_LIBS" ])
1494  dnl Okay, now we need to figure out which one to actually use. Fall back
1495  dnl to curve25519-donna.c
1497  if test "x$tor_cv_can_use_curve25519_donna_c64" != "xno"; then
1498    build_curve25519_donna_c64=yes
1499    use_curve25519_donna=yes
1500  elif test "x$tor_cv_can_use_curve25519_nacl" = "xyes"; then
1501    use_curve25519_nacl=yes
1502    CURVE25519_LIBS=-lnacl
1503  else
1504    build_curve25519_donna=yes
1505    use_curve25519_donna=yes
1506  fi
1508 if test "x$use_curve25519_donna" = "xyes"; then
1509   AC_DEFINE(USE_CURVE25519_DONNA, 1,
1510             [Defined if we should use an internal curve25519_donna{,_c64} implementation])
1512 if test "x$use_curve25519_nacl" = "xyes"; then
1513   AC_DEFINE(USE_CURVE25519_NACL, 1,
1514             [Defined if we should use a curve25519 from nacl])
1516 AM_CONDITIONAL(BUILD_CURVE25519_DONNA,
1517   test "x$build_curve25519_donna" = "xyes")
1518 AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64,
1519   test "x$build_curve25519_donna_c64" = "xyes")
1520 AC_SUBST(CURVE25519_LIBS)
1522 dnl Make sure to enable support for large off_t if available.
1523 AC_SYS_LARGEFILE
1525 AC_CHECK_HEADERS([errno.h \
1526                   fcntl.h \
1527                   signal.h \
1528                   string.h \
1529                   sys/capability.h \
1530                   sys/fcntl.h \
1531                   sys/stat.h \
1532                   sys/time.h \
1533                   sys/types.h \
1534                   time.h \
1535                   unistd.h \
1536                   arpa/inet.h \
1537                   crt_externs.h \
1538                   execinfo.h \
1539                   gnu/libc-version.h \
1540                   grp.h \
1541                   ifaddrs.h \
1542                   inttypes.h \
1543                   limits.h \
1544                   linux/types.h \
1545                   mach/vm_inherit.h \
1546                   machine/limits.h \
1547                   malloc.h \
1548                   malloc/malloc.h \
1549                   malloc_np.h \
1550                   netdb.h \
1551                   netinet/in.h \
1552                   netinet/in6.h \
1553                   pwd.h \
1554                   readpassphrase.h \
1555                   stdatomic.h \
1556                   sys/eventfd.h \
1557                   sys/file.h \
1558                   sys/ioctl.h \
1559                   sys/limits.h \
1560                   sys/mman.h \
1561                   sys/param.h \
1562                   sys/prctl.h \
1563                   sys/random.h \
1564                   sys/resource.h \
1565                   sys/select.h \
1566                   sys/socket.h \
1567                   sys/statvfs.h \
1568                   sys/syscall.h \
1569                   sys/sysctl.h \
1570                   sys/syslimits.h \
1571                   sys/time.h \
1572                   sys/types.h \
1573                   sys/un.h \
1574                   sys/utime.h \
1575                   sys/wait.h \
1576                   syslog.h \
1577                   utime.h])
1579 AC_CHECK_HEADERS(sys/param.h)
1581 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
1582 [#ifdef HAVE_SYS_TYPES_H
1583 #include <sys/types.h>
1584 #endif
1585 #ifdef HAVE_SYS_SOCKET_H
1586 #include <sys/socket.h>
1587 #endif])
1588 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
1589 [#ifdef HAVE_SYS_TYPES_H
1590 #include <sys/types.h>
1591 #endif
1592 #ifdef HAVE_SYS_SOCKET_H
1593 #include <sys/socket.h>
1594 #endif
1595 #ifdef HAVE_NET_IF_H
1596 #include <net/if.h>
1597 #endif
1598 #ifdef HAVE_NETINET_IN_H
1599 #include <netinet/in.h>
1600 #endif])
1602 AC_CHECK_HEADERS(linux/if.h,[],[],
1604 #ifdef HAVE_SYS_SOCKET_H
1605 #include <sys/socket.h>
1606 #endif
1609 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
1610         linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
1611 [#ifdef HAVE_SYS_TYPES_H
1612 #include <sys/types.h>
1613 #endif
1614 #ifdef HAVE_SYS_SOCKET_H
1615 #include <sys/socket.h>
1616 #endif
1617 #ifdef HAVE_LIMITS_H
1618 #include <limits.h>
1619 #endif
1620 #ifdef HAVE_LINUX_TYPES_H
1621 #include <linux/types.h>
1622 #endif
1623 #ifdef HAVE_NETINET_IN6_H
1624 #include <netinet/in6.h>
1625 #endif
1626 #ifdef HAVE_NETINET_IN_H
1627 #include <netinet/in.h>
1628 #endif])
1630 AC_CHECK_HEADERS(linux/netfilter_ipv6/ip6_tables.h,
1631         linux_netfilter_ipv6_ip6_tables=1, linux_netfilter_ipv6_ip6_tables=0,
1632 [#ifdef HAVE_SYS_TYPES_H
1633 #include <sys/types.h>
1634 #endif
1635 #ifdef HAVE_SYS_SOCKET_H
1636 #include <sys/socket.h>
1637 #endif
1638 #ifdef HAVE_LIMITS_H
1639 #include <limits.h>
1640 #endif
1641 #ifdef HAVE_LINUX_TYPES_H
1642 #include <linux/types.h>
1643 #endif
1644 #ifdef HAVE_NETINET_IN6_H
1645 #include <netinet/in6.h>
1646 #endif
1647 #ifdef HAVE_NETINET_IN_H
1648 #include <netinet/in.h>
1649 #endif
1650 #ifdef HAVE_LINUX_IF_H
1651 #include <linux/if.h>
1652 #endif])
1654 transparent_ok=0
1655 if test "x$net_if_found" = "x1" && test "x$net_pfvar_found" = "x1"; then
1656   transparent_ok=1
1658 if test "x$linux_netfilter_ipv4" = "x1"; then
1659   transparent_ok=1
1661 if test "x$linux_netfilter_ipv6_ip6_tables" = "x1"; then
1662   transparent_ok=1
1664 if test "x$transparent_ok" = "x1"; then
1665   AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
1666 else
1667   AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
1670 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
1671 [#ifdef HAVE_SYS_TYPES_H
1672 #include <sys/types.h>
1673 #endif
1674 #ifdef HAVE_SYS_TIME_H
1675 #include <sys/time.h>
1676 #endif])
1678 AC_CHECK_SIZEOF(char)
1679 AC_CHECK_SIZEOF(short)
1680 AC_CHECK_SIZEOF(int)
1681 AC_CHECK_SIZEOF(unsigned int)
1682 AC_CHECK_SIZEOF(long)
1683 AC_CHECK_SIZEOF(long long)
1684 AC_CHECK_SIZEOF(__int64)
1685 AC_CHECK_SIZEOF(void *)
1686 AC_CHECK_SIZEOF(time_t)
1687 AC_CHECK_SIZEOF(size_t)
1688 AC_CHECK_SIZEOF(pid_t)
1690 AC_CHECK_TYPES([uint, u_char, ssize_t])
1692 AC_PC_FROM_UCONTEXT([:])
1694 dnl used to include sockaddr_storage, but everybody has that.
1695 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
1696 [#ifdef HAVE_SYS_TYPES_H
1697 #include <sys/types.h>
1698 #endif
1699 #ifdef HAVE_NETINET_IN_H
1700 #include <netinet/in.h>
1701 #endif
1702 #ifdef HAVE_NETINET_IN6_H
1703 #include <netinet/in6.h>
1704 #endif
1705 #ifdef HAVE_SYS_SOCKET_H
1706 #include <sys/socket.h>
1707 #endif
1708 #ifdef _WIN32
1709 #define _WIN32_WINNT 0x0501
1710 #define WIN32_LEAN_AND_MEAN
1711 #include <winsock2.h>
1712 #include <ws2tcpip.h>
1713 #endif
1715 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
1716 [#ifdef HAVE_SYS_TYPES_H
1717 #include <sys/types.h>
1718 #endif
1719 #ifdef HAVE_NETINET_IN_H
1720 #include <netinet/in.h>
1721 #endif
1722 #ifdef HAVE_NETINET_IN6_H
1723 #include <netinet/in6.h>
1724 #endif
1725 #ifdef HAVE_SYS_SOCKET_H
1726 #include <sys/socket.h>
1727 #endif
1728 #ifdef _WIN32
1729 #define _WIN32_WINNT 0x0501
1730 #define WIN32_LEAN_AND_MEAN
1731 #include <winsock2.h>
1732 #include <ws2tcpip.h>
1733 #endif
1736 AC_CHECK_TYPES([rlim_t], , ,
1737 [#ifdef HAVE_SYS_TYPES_H
1738 #include <sys/types.h>
1739 #endif
1740 #ifdef HAVE_SYS_TIME_H
1741 #include <sys/time.h>
1742 #endif
1743 #ifdef HAVE_SYS_RESOURCE_H
1744 #include <sys/resource.h>
1745 #endif
1748 AX_CHECK_SIGN([time_t],
1749        [ : ],
1750        [ : ], [
1751 #ifdef HAVE_SYS_TYPES_H
1752 #include <sys/types.h>
1753 #endif
1754 #ifdef HAVE_SYS_TIME_H
1755 #include <sys/time.h>
1756 #endif
1757 #ifdef HAVE_TIME_H
1758 #include <time.h>
1759 #endif
1762 if test "$ax_cv_decl_time_t_signed" = "no"; then
1763   AC_MSG_ERROR([You have an unsigned time_t; Tor does not support that. Please tell the Tor developers about your interesting platform.])
1766 AX_CHECK_SIGN([size_t],
1767        [ tor_cv_size_t_signed=yes ],
1768        [ tor_cv_size_t_signed=no ], [
1769 #ifdef HAVE_SYS_TYPES_H
1770 #include <sys/types.h>
1771 #endif
1774 if test "$ax_cv_decl_size_t_signed" = "yes"; then
1775   AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
1778 AX_CHECK_SIGN([enum always],
1779        [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
1780        [ : ], [
1781  enum always { AAA, BBB, CCC };
1784 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
1785 #ifdef HAVE_SYS_SOCKET_H
1786 #include <sys/socket.h>
1787 #endif
1790 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
1792 AC_CHECK_SIZEOF(cell_t)
1794 # Let's see if stdatomic works. (There are some debian clangs that screw it
1795 # up; see Tor bug #26779 and debian bug 903709.)
1796 AC_CACHE_CHECK([whether C11 stdatomic.h actually works],
1797                tor_cv_stdatomic_works,
1798 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1799 #include <stdatomic.h>
1800 struct x { atomic_size_t y; };
1801 void try_atomic_init(struct x *xx)
1803   atomic_init(&xx->y, 99);
1804   atomic_fetch_add(&xx->y, 1);
1806 ]])], [tor_cv_stdatomic_works=yes], [tor_cv_stdatomic_works=no])])
1808 if test "$tor_cv_stdatomic_works" = "yes"; then
1809    AC_DEFINE(STDATOMIC_WORKS, 1, [Set to 1 if we can compile a simple stdatomic example.])
1810 elif test "$ac_cv_header_stdatomic_h" = "yes"; then
1811    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 ])
1814 # Now make sure that NULL can be represented as zero bytes.
1815 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
1816 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1817 [[#include <stdlib.h>
1818 #include <string.h>
1819 #include <stdio.h>
1820 #ifdef HAVE_STDDEF_H
1821 #include <stddef.h>
1822 #endif
1823 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
1824 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
1825        [tor_cv_null_is_zero=yes],
1826        [tor_cv_null_is_zero=no],
1827        [tor_cv_null_is_zero=cross])])
1829 if test "$tor_cv_null_is_zero" = "cross"; then
1830   # Cross-compiling; let's hope that the target isn't raving mad.
1831   AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
1834 if test "$tor_cv_null_is_zero" != "no"; then
1835   AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
1836             [Define to 1 iff memset(0) sets pointers to NULL])
1839 AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
1840 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1841 [[#include <stdlib.h>
1842 #include <string.h>
1843 #include <stdio.h>
1844 #ifdef HAVE_STDDEF_H
1845 #include <stddef.h>
1846 #endif
1847 int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
1848 return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
1849        [tor_cv_dbl0_is_zero=yes],
1850        [tor_cv_dbl0_is_zero=no],
1851        [tor_cv_dbl0_is_zero=cross])])
1853 if test "$tor_cv_dbl0_is_zero" = "cross"; then
1854   # Cross-compiling; let's hope that the target isn't raving mad.
1855   AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
1858 if test "$tor_cv_dbl0_is_zero" != "no"; then
1859   AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
1860             [Define to 1 iff memset(0) sets doubles to 0.0])
1863 # And what happens when we malloc zero?
1864 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
1865 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1866 [[#include <stdlib.h>
1867 #include <string.h>
1868 #include <stdio.h>
1869 #ifdef HAVE_STDDEF_H
1870 #include <stddef.h>
1871 #endif
1872 int main () { return malloc(0)?0:1; }]])],
1873        [tor_cv_malloc_zero_works=yes],
1874        [tor_cv_malloc_zero_works=no],
1875        [tor_cv_malloc_zero_works=cross])])
1877 if test "$tor_cv_malloc_zero_works" = "cross"; then
1878   # Cross-compiling; let's hope that the target isn't raving mad.
1879   AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
1882 if test "$tor_cv_malloc_zero_works" = "yes"; then
1883   AC_DEFINE([MALLOC_ZERO_WORKS], 1,
1884             [Define to 1 iff malloc(0) returns a pointer])
1887 # whether we seem to be in a 2s-complement world.
1888 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
1889 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1890 [[int main () { int problem = ((-99) != (~99)+1);
1891 return problem ? 1 : 0; }]])],
1892        [tor_cv_twos_complement=yes],
1893        [tor_cv_twos_complement=no],
1894        [tor_cv_twos_complement=cross])])
1896 if test "$tor_cv_twos_complement" = "cross"; then
1897   # Cross-compiling; let's hope that the target isn't raving mad.
1898   AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
1901 if test "$tor_cv_twos_complement" != "no"; then
1902   AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
1903             [Define to 1 iff we represent negative integers with
1904              two's complement])
1907 # What does shifting a negative value do?
1908 AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
1909 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1910 [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
1911        [tor_cv_sign_extend=yes],
1912        [tor_cv_sign_extend=no],
1913        [tor_cv_sign_extend=cross])])
1915 if test "$tor_cv_sign_extend" = "cross"; then
1916   # Cross-compiling; let's hope that the target isn't raving mad.
1917   AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
1920 if test "$tor_cv_sign_extend" != "no"; then
1921   AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
1922             [Define to 1 iff right-shifting a negative value performs sign-extension])
1925 # Is uint8_t the same type as unsigned char?
1926 AC_CACHE_CHECK([whether uint8_t is the same type as unsigned char], tor_cv_uint8_uchar,
1927 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1928 #include <stdint.h>
1929 extern uint8_t c;
1930 unsigned char c;]])],
1931        [tor_cv_uint8_uchar=yes],
1932        [tor_cv_uint8_uchar=no],
1933        [tor_cv_uint8_uchar=cross])])
1935 if test "$tor_cv_uint8_uchar" = "cross"; then
1936   AC_MSG_NOTICE([Cross-compiling: we'll assume that uint8_t is the same type as unsigned char])
1939 if test "$tor_cv_uint8_uchar" = "no"; then
1940   AC_MSG_ERROR([We assume that uint8_t is the same type as unsigned char, but your compiler disagrees.])
1943 AC_ARG_WITH(tcmalloc,
1944 AS_HELP_STRING(--with-tcmalloc, [use tcmalloc memory allocation library. Deprecated; see --with-malloc]))
1946 default_malloc=system
1948 if test "x$enable_openbsd_malloc" = "xyes" ; then
1949   AC_MSG_NOTICE([The --enable-openbsd-malloc argument is deprecated; use --with-malloc=openbsd instead.])
1950   default_malloc=openbsd
1953 if test "x$with_tcmalloc" = "xyes"; then
1954   AC_MSG_NOTICE([The --with-tcmalloc argument is deprecated; use --with-malloc=tcmalloc instead.])
1955   default_malloc=tcmalloc
1958 AC_ARG_WITH(malloc,
1959    AS_HELP_STRING([--with-malloc=[system,jemalloc,tcmalloc,openbsd]],
1960                   [select special malloc implementation [system]]),
1961    [ malloc="$with_malloc" ], [ malloc="$default_malloc" ])
1963 AS_CASE([$malloc],
1964   [tcmalloc], [
1965       PKG_CHECK_MODULES([TCMALLOC],
1966                         [libtcmalloc],
1967                         have_tcmalloc=yes,
1968                         have_tcmalloc=no)
1970       if test "x$have_tcmalloc" = "xno" ; then
1971           AC_MSG_ERROR([Unable to find tcmalloc requested by --with-malloc, $pkg_config_user_action, or set TCMALLOC_CFLAGS and TCMALLOC_LIBS.])
1972       fi
1974       CFLAGS="$CFLAGS $TCMALLOC_CFLAGS"
1975       LIBS="$TCMALLOC_LIBS $LIBS"
1976   ],
1978   [jemalloc], [
1979       PKG_CHECK_MODULES([JEMALLOC],
1980                         [jemalloc],
1981                         have_jemalloc=yes,
1982                         have_jemalloc=no)
1984       if test "x$have_jemalloc" = "xno" ; then
1985           AC_MSG_ERROR([Unable to find jemalloc requested by --with-malloc, $pkg_config_user_action, or set JEMALLOC_CFLAGS and JEMALLOC_LIBS.])
1986       fi
1988       CFLAGS="$CFLAGS $JEMALLOC_CFLAGS"
1989       LIBS="$JEMALLOC_LIBS $LIBS"
1990       using_custom_malloc=yes
1991   ],
1993   [openbsd], [
1994     AC_MSG_WARN([The openbsd malloc port is deprecated in Tor 0.3.5 and will be removed in a future version.])
1995     enable_openbsd_malloc=yes
1996   ],
1998   [system], [
1999      # handle this later, including the jemalloc fallback
2000     AC_CHECK_FUNCS(mallinfo)
2001   ],
2003   [AC_MSG_ERROR([--with-malloc=`$with_malloc' not supported, see --help])
2006 AM_CONDITIONAL(USE_OPENBSD_MALLOC, test "x$enable_openbsd_malloc" = "xyes")
2008 if test "$malloc" != "system"; then
2009   # Tell the C compiler not to use the system allocator functions.
2010   TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
2012 if test "$using_custom_malloc" = "yes"; then
2013   # Tell the C compiler not to use the system allocator functions.
2014   TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
2017 # By default, we're going to assume we don't have mlockall()
2018 # bionic and other platforms have various broken mlockall subsystems.
2019 # Some systems don't have a working mlockall, some aren't linkable,
2020 # and some have it but don't declare it.
2021 AC_CHECK_FUNCS(mlockall)
2022 AC_CHECK_DECLS([mlockall], , , [
2023 #ifdef HAVE_SYS_MMAN_H
2024 #include <sys/mman.h>
2025 #endif])
2027 # Allow user to specify an alternate syslog facility
2028 AC_ARG_WITH(syslog-facility,
2029 AS_HELP_STRING(--with-syslog-facility=LOG, [syslog facility to use (default=LOG_DAEMON)]),
2030 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
2031 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
2032 AC_SUBST(LOGFACILITY)
2034 # Check if we have getresuid and getresgid
2035 AC_CHECK_FUNCS(getresuid getresgid)
2037 # Check for gethostbyname_r in all its glorious incompatible versions.
2038 #   (This logic is based on that in Python's configure.in)
2039 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
2040   [Define this if you have any gethostbyname_r()])
2042 AC_CHECK_FUNC(gethostbyname_r, [
2043   AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
2044   OLD_CFLAGS=$CFLAGS
2045   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
2046   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2047 #include <netdb.h>
2048   ]], [[
2049     char *cp1, *cp2;
2050     struct hostent *h1, *h2;
2051     int i1, i2;
2052     (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
2053   ]])],[
2054     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2055     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2056      [Define this if gethostbyname_r takes 6 arguments])
2057     AC_MSG_RESULT(6)
2058   ], [
2059     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2060 #include <netdb.h>
2061     ]], [[
2062       char *cp1, *cp2;
2063       struct hostent *h1;
2064       int i1, i2;
2065       (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
2066     ]])], [
2067       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2068       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2069         [Define this if gethostbyname_r takes 5 arguments])
2070       AC_MSG_RESULT(5)
2071    ], [
2072       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2073 #include <netdb.h>
2074      ]], [[
2075        char *cp1;
2076        struct hostent *h1;
2077        struct hostent_data hd;
2078        (void) gethostbyname_r(cp1,h1,&hd);
2079      ]])], [
2080        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2081        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2082          [Define this if gethostbyname_r takes 3 arguments])
2083        AC_MSG_RESULT(3)
2084      ], [
2085        AC_MSG_RESULT(0)
2086      ])
2087   ])
2088  ])
2089  CFLAGS=$OLD_CFLAGS
2092 AC_CACHE_CHECK([whether the C compiler supports __func__],
2093   tor_cv_have_func_macro,
2094   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2095 #include <stdio.h>
2096 int main(int c, char **v) { puts(__func__); }])],
2097   tor_cv_have_func_macro=yes,
2098   tor_cv_have_func_macro=no))
2100 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
2101   tor_cv_have_FUNC_macro,
2102   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2103 #include <stdio.h>
2104 int main(int c, char **v) { puts(__FUNC__); }])],
2105   tor_cv_have_FUNC_macro=yes,
2106   tor_cv_have_FUNC_macro=no))
2108 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
2109   tor_cv_have_FUNCTION_macro,
2110   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2111 #include <stdio.h>
2112 int main(int c, char **v) { puts(__FUNCTION__); }])],
2113   tor_cv_have_FUNCTION_macro=yes,
2114   tor_cv_have_FUNCTION_macro=no))
2116 AC_CACHE_CHECK([whether we have extern char **environ already declared],
2117   tor_cv_have_environ_declared,
2118   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2119 #ifdef HAVE_UNISTD_H
2120 #include <unistd.h>
2121 #endif
2122 #include <stdlib.h>
2123 int main(int c, char **v) { char **t = environ; }])],
2124   tor_cv_have_environ_declared=yes,
2125   tor_cv_have_environ_declared=no))
2127 if test "$tor_cv_have_func_macro" = "yes"; then
2128   AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
2131 if test "$tor_cv_have_FUNC_macro" = "yes"; then
2132   AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
2135 if test "$tor_cv_have_FUNCTION_macro" = "yes"; then
2136   AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
2137            [Defined if the compiler supports __FUNCTION__])
2140 if test "$tor_cv_have_environ_declared" = "yes"; then
2141   AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
2142            [Defined if we have extern char **environ already declared])
2145 # $prefix stores the value of the --prefix command line option, or
2146 # NONE if the option wasn't set.  In the case that it wasn't set, make
2147 # it be the default, so that we can use it to expand directories now.
2148 if test "x$prefix" = "xNONE"; then
2149   prefix=$ac_default_prefix
2152 # and similarly for $exec_prefix
2153 if test "x$exec_prefix" = "xNONE"; then
2154   exec_prefix=$prefix
2157 if test "x$BUILDDIR" = "x"; then
2158   BUILDDIR=`pwd`
2160 AC_SUBST(BUILDDIR)
2161 AH_TEMPLATE([BUILDDIR],[tor's build directory])
2162 AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
2164 if test "x$SRCDIR" = "x"; then
2165   SRCDIR=$(cd "$srcdir"; pwd)
2167 AH_TEMPLATE([SRCDIR],[tor's sourcedir directory])
2168 AC_DEFINE_UNQUOTED(SRCDIR,"$SRCDIR")
2170 if test "x$CONFDIR" = "x"; then
2171   CONFDIR=`eval echo $sysconfdir/tor`
2173 AC_SUBST(CONFDIR)
2174 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
2175 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
2177 BINDIR=`eval echo $bindir`
2178 AC_SUBST(BINDIR)
2179 LOCALSTATEDIR=`eval echo $localstatedir`
2180 AC_SUBST(LOCALSTATEDIR)
2182 if test "$bwin32" = "true"; then
2183   # Test if the linker supports the --nxcompat and --dynamicbase options
2184   # for Windows
2185   save_LDFLAGS="$LDFLAGS"
2186   LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
2187   AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
2188   AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
2189     [AC_MSG_RESULT([yes])]
2190     [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
2191     [AC_MSG_RESULT([no])]
2192   )
2193   LDFLAGS="$save_LDFLAGS"
2196 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
2197 # than autoconf's macros like.
2198 if test "$GCC" = "yes"; then
2199   # Disable GCC's strict aliasing checks.  They are an hours-to-debug
2200   # accident waiting to happen.
2201   CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
2202 else
2203   # Override optimization level for non-gcc compilers
2204   CFLAGS="$CFLAGS -O"
2205   enable_gcc_warnings=no
2206   enable_gcc_warnings_advisory=no
2209 # Warnings implies advisory-warnings and -Werror.
2210 if test "$enable_gcc_warnings" = "yes"; then
2211   enable_gcc_warnings_advisory=yes
2212   enable_fatal_warnings=yes
2215 # OS X Lion started deprecating the system openssl. Let's just disable
2216 # all deprecation warnings on OS X. Also, to potentially make the binary
2217 # a little smaller, let's enable dead_strip.
2218 case "$host_os" in
2220  darwin*)
2221     CFLAGS="$CFLAGS -Wno-deprecated-declarations"
2222     LDFLAGS="$LDFLAGS -dead_strip" ;;
2223 esac
2225 TOR_WARNING_FLAGS=""
2227 # Add some more warnings which we use in development but not in the
2228 # released versions.  (Some relevant gcc versions can't handle these.)
2230 # Note that we have to do this near the end  of the autoconf process, or
2231 # else we may run into problems when these warnings hit on the testing C
2232 # programs that autoconf wants to build.
2233 if test "x$enable_gcc_warnings_advisory" != "xno"; then
2235   case "$host" in
2236     *-*-openbsd* | *-*-bitrig*)
2237       # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
2238       # That's fine, except that the headers don't pass -Wredundant-decls.
2239       # Therefore, let's disable -Wsystem-headers when we're building
2240       # with maximal warnings on OpenBSD.
2241       CFLAGS="$CFLAGS -Wno-system-headers" ;;
2242   esac
2244   CFLAGS_NOWARNINGS="$CFLAGS"
2246   # GCC4.3 users once report trouble with -Wstrict-overflow=5.  GCC5 users
2247   # have it work better.
2248   # CFLAGS="$CFLAGS -Wstrict-overflow=1"
2250   # This warning was added in gcc 4.3, but it appears to generate
2251   # spurious warnings in gcc 4.4.  I don't know if it works in 4.5.
2252   #CFLAGS="$CFLAGS -Wlogical-op"
2254   m4_foreach_w([warning_flag], [
2255      -Waddress
2256      -Waddress-of-array-temporary
2257      -Waddress-of-temporary
2258      -Wambiguous-macro
2259      -Wanonymous-pack-parens
2260      -Warc
2261      -Warc-abi
2262      -Warc-bridge-casts-disallowed-in-nonarc
2263      -Warc-maybe-repeated-use-of-weak
2264      -Warc-performSelector-leaks
2265      -Warc-repeated-use-of-weak
2266      -Warray-bounds
2267      -Warray-bounds-pointer-arithmetic
2268      -Wasm
2269      -Wasm-operand-widths
2270      -Watomic-properties
2271      -Watomic-property-with-user-defined-accessor
2272      -Wauto-import
2273      -Wauto-storage-class
2274      -Wauto-var-id
2275      -Wavailability
2276      -Wbackslash-newline-escape
2277      -Wbad-array-new-length
2278      -Wbind-to-temporary-copy
2279      -Wbitfield-constant-conversion
2280      -Wbool-conversion
2281      -Wbool-conversions
2282      -Wbuiltin-requires-header
2283      -Wchar-align
2284      -Wcompare-distinct-pointer-types
2285      -Wcomplex-component-init
2286      -Wconditional-type-mismatch
2287      -Wconfig-macros
2288      -Wconstant-conversion
2289      -Wconstant-logical-operand
2290      -Wconstexpr-not-const
2291      -Wcustom-atomic-properties
2292      -Wdangling-field
2293      -Wdangling-initializer-list
2294      -Wdate-time
2295      -Wdelegating-ctor-cycles
2296      -Wdeprecated-implementations
2297      -Wdeprecated-register
2298      -Wdirect-ivar-access
2299      -Wdiscard-qual
2300      -Wdistributed-object-modifiers
2301      -Wdivision-by-zero
2302      -Wdollar-in-identifier-extension
2303      -Wdouble-promotion
2304      -Wduplicate-decl-specifier
2305      -Wduplicate-enum
2306      -Wduplicate-method-arg
2307      -Wduplicate-method-match
2308      -Wduplicated-cond
2309      -Wdynamic-class-memaccess
2310      -Wembedded-directive
2311      -Wempty-translation-unit
2312      -Wenum-conversion
2313      -Wexit-time-destructors
2314      -Wexplicit-ownership-type
2315      -Wextern-initializer
2316      -Wextra
2317      -Wextra-semi
2318      -Wextra-tokens
2319      -Wflexible-array-extensions
2320      -Wfloat-conversion
2321      -Wformat-non-iso
2322      -Wfour-char-constants
2323      -Wgcc-compat
2324      -Wglobal-constructors
2325      -Wgnu-array-member-paren-init
2326      -Wgnu-designator
2327      -Wgnu-static-float-init
2328      -Wheader-guard
2329      -Wheader-hygiene
2330      -Widiomatic-parentheses
2331      -Wignored-attributes
2332      -Wimplicit-atomic-properties
2333      -Wimplicit-conversion-floating-point-to-bool
2334      -Wimplicit-exception-spec-mismatch
2335      -Wimplicit-fallthrough
2336      -Wimplicit-fallthrough-per-function
2337      -Wimplicit-retain-self
2338      -Wimport-preprocessor-directive-pedantic
2339      -Wincompatible-library-redeclaration
2340      -Wincompatible-pointer-types-discards-qualifiers
2341      -Wincomplete-implementation
2342      -Wincomplete-module
2343      -Wincomplete-umbrella
2344      -Winit-self
2345      -Wint-conversions
2346      -Wint-to-void-pointer-cast
2347      -Winteger-overflow
2348      -Winvalid-constexpr
2349      -Winvalid-iboutlet
2350      -Winvalid-noreturn
2351      -Winvalid-pp-token
2352      -Winvalid-source-encoding
2353      -Winvalid-token-paste
2354      -Wknr-promoted-parameter
2355      -Wlarge-by-value-copy
2356      -Wliteral-conversion
2357      -Wliteral-range
2358      -Wlocal-type-template-args
2359      -Wlogical-op
2360      -Wloop-analysis
2361      -Wmain-return-type
2362      -Wmalformed-warning-check
2363      -Wmethod-signatures
2364      -Wmicrosoft
2365      -Wmicrosoft-exists
2366      -Wmismatched-parameter-types
2367      -Wmismatched-return-types
2368      -Wmissing-field-initializers
2369      -Wmissing-format-attribute
2370      -Wmissing-noreturn
2371      -Wmissing-selector-name
2372      -Wmissing-sysroot
2373      -Wmissing-variable-declarations
2374      -Wmodule-conflict
2375      -Wnested-anon-types
2376      -Wnewline-eof
2377      -Wnon-literal-null-conversion
2378      -Wnon-pod-varargs
2379      -Wnonportable-cfstrings
2380      -Wnormalized=nfkc
2381      -Wnull-arithmetic
2382      -Wnull-character
2383      -Wnull-conversion
2384      -Wnull-dereference
2385      -Wout-of-line-declaration
2386      -Wover-aligned
2387      -Woverlength-strings
2388      -Woverride-init
2389      -Woverriding-method-mismatch
2390      -Wpointer-type-mismatch
2391      -Wpredefined-identifier-outside-function
2392      -Wprotocol-property-synthesis-ambiguity
2393      -Wreadonly-iboutlet-property
2394      -Wreadonly-setter-attrs
2395      -Wreceiver-expr
2396      -Wreceiver-forward-class
2397      -Wreceiver-is-weak
2398      -Wreinterpret-base-class
2399      -Wrequires-super-attribute
2400      -Wreserved-user-defined-literal
2401      -Wreturn-stack-address
2402      -Wsection
2403      -Wselector-type-mismatch
2404      -Wsentinel
2405      -Wserialized-diagnostics
2406      -Wshadow
2407      -Wshift-count-negative
2408      -Wshift-count-overflow
2409      -Wshift-negative-value
2410      -Wshift-overflow=2
2411      -Wshift-sign-overflow
2412      -Wshorten-64-to-32
2413      -Wsizeof-array-argument
2414      -Wsource-uses-openmp
2415      -Wstatic-float-init
2416      -Wstatic-in-inline
2417      -Wstatic-local-in-inline
2418      -Wstrict-overflow=1
2419      -Wstring-compare
2420      -Wstring-conversion
2421      -Wstrlcpy-strlcat-size
2422      -Wstrncat-size
2423      -Wsuggest-attribute=format
2424      -Wsuggest-attribute=noreturn
2425      -Wsuper-class-method-mismatch
2426      -Wswitch-bool
2427      -Wsync-nand
2428      -Wtautological-constant-out-of-range-compare
2429      -Wtentative-definition-incomplete-type
2430      -Wtrampolines
2431      -Wtype-safety
2432      -Wtypedef-redefinition
2433      -Wtypename-missing
2434      -Wundefined-inline
2435      -Wundefined-internal
2436      -Wundefined-reinterpret-cast
2437      -Wunicode
2438      -Wunicode-whitespace
2439      -Wunknown-warning-option
2440      -Wunnamed-type-template-args
2441      -Wunneeded-member-function
2442      -Wunsequenced
2443      -Wunsupported-visibility
2444      -Wunused-but-set-parameter
2445      -Wunused-but-set-variable
2446      -Wunused-command-line-argument
2447      -Wunused-const-variable=2
2448      -Wunused-exception-parameter
2449      -Wunused-local-typedefs
2450      -Wunused-member-function
2451      -Wunused-sanitize-argument
2452      -Wunused-volatile-lvalue
2453      -Wuser-defined-literals
2454      -Wvariadic-macros
2455      -Wvector-conversion
2456      -Wvector-conversions
2457      -Wvexing-parse
2458      -Wvisibility
2459      -Wvla-extension
2460      -Wzero-length-array
2461   ], [ TOR_TRY_COMPILE_WITH_CFLAGS(warning_flag, [],
2462               [TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS warning_flag" CFLAGS="$CFLAGS warning_flag"], true)
2463      ])
2465 dnl    We should re-enable this in some later version.  Clang doesn't
2466 dnl    mind, but it causes trouble with GCC.
2467 dnl     -Wstrict-overflow=2
2469 dnl    These seem to require annotations that we don't currently use,
2470 dnl    and they give false positives in our pthreads wrappers. (Clang 4)
2471 dnl     -Wthread-safety
2472 dnl     -Wthread-safety-analysis
2473 dnl     -Wthread-safety-attributes
2474 dnl     -Wthread-safety-beta
2475 dnl     -Wthread-safety-precise
2477   W_FLAGS="$W_FLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
2478   W_FLAGS="$W_FLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
2479   W_FLAGS="$W_FLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
2480   W_FLAGS="$W_FLAGS -Wwrite-strings"
2481   W_FLAGS="$W_FLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
2482   W_FLAGS="$W_FLAGS -Waggregate-return -Wpacked -Wunused"
2483   W_FLAGS="$W_FLAGS -Wunused-parameter "
2484   # These interfere with building main() { return 0; }, which autoconf
2485   # likes to use as its default program.
2486   W_FLAGS="$W_FLAGS -Wold-style-definition -Wmissing-declarations"
2488   TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS $W_FLAGS"
2489   CFLAGS="$CFLAGS $W_FLAGS"
2491   if test "$tor_cv_cflags__Wnull_dereference" = "yes"; then
2492     AC_DEFINE([HAVE_CFLAG_WNULL_DEREFERENCE], 1, [True if we have -Wnull-dereference])
2493   fi
2494   if test "$tor_cv_cflags__Woverlength_strings" = "yes"; then
2495     AC_DEFINE([HAVE_CFLAG_WOVERLENGTH_STRINGS], 1, [True if we have -Woverlength-strings])
2496   fi
2497   if test "$tor_cv_cflags__warn_unused_const_variable_2" = "yes"; then
2498     AC_DEFINE([HAVE_CFLAG_WUNUSED_CONST_VARIABLE], 1, [True if we have -Wunused-const-variable])
2499   fi
2501   CFLAGS="$CFLAGS_NOWARNINGS"
2503   if test "x$enable_fatal_warnings" = "xyes"; then
2504     # I'd like to use TOR_CHECK_CFLAGS here, but I can't, since the
2505     # default autoconf programs are full of errors.
2506     CFLAGS="$CFLAGS -Werror"
2507   fi
2511 AC_SUBST(TOR_WARNING_FLAGS)
2513 echo "$TOR_WARNING_FLAGS">warning_flags
2515 TOR_TRY_COMPILE_WITH_CFLAGS([@warning_flags], [],
2516                             CFLAGS="$CFLAGS @warning_flags",
2517                             CFLAGS="$CFLAGS $TOR_WARNING_FLAGS")
2519 if test "$enable_coverage" = "yes" && test "$have_clang" = "no"; then
2520    case "$host_os" in
2521     darwin*)
2522       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.])
2523    esac
2526 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
2528 AC_CONFIG_FILES([
2529         Doxyfile
2530         Makefile
2531         config.rust
2532         contrib/operator-tools/tor.logrotate
2533         contrib/dist/tor.service
2534         src/config/torrc.sample
2535         src/config/torrc.minimal
2536         src/rust/.cargo/config
2537         scripts/maint/checkOptionDocs.pl
2538         warning_flags
2541 if test "x$asciidoc" = "xtrue" && test "$ASCIIDOC" = "none"; then
2542   regular_mans="doc/tor doc/tor-gencert doc/tor-resolve doc/torify"
2543   for file in $regular_mans ; do
2544     if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
2545       echo "==================================";
2546       echo;
2547       echo "Building Tor has failed since manpages cannot be built.";
2548       echo;
2549       echo "You need asciidoc installed to be able to build the manpages.";
2550       echo "To build without manpages, use the --disable-asciidoc argument";
2551       echo "when calling configure.";
2552       echo;
2553       echo "==================================";
2554       exit 1;
2555     fi
2556   done
2559 if test "$fragile_hardening" = "yes"; then
2560   AC_MSG_WARN([
2562 ============
2563 Warning!  Building Tor with --enable-fragile-hardening (also known as
2564 --enable-expensive-hardening) makes some kinds of attacks harder, but makes
2565 other kinds of attacks easier. A Tor instance build with this option will be
2566 somewhat less vulnerable to remote code execution, arithmetic overflow, or
2567 out-of-bounds read/writes... but at the cost of becoming more vulnerable to
2568 denial of service attacks. For more information, see
2569 https://trac.torproject.org/projects/tor/wiki/doc/TorFragileHardening
2570 ============
2571   ])
2574 AC_OUTPUT
2577 # Mini-report on what will be built.
2580 PPRINT_INIT
2581 PPRINT_SET_INDENT(1)
2582 PPRINT_SET_TS(65)
2584 AS_ECHO
2585 AS_ECHO("Tor Version: ${PPRINT_COLOR_BLDBLU}Tor $PACKAGE_VERSION $PPRINT_COLOR_RST")
2586 AS_ECHO
2588 PPRINT_SUBTITLE([Build Features])
2590 PPRINT_PROP_STRING([Compiler], [$CC])
2591 PPRINT_PROP_STRING([Host OS], [$host_os])
2592 AS_ECHO
2594 test "x$enable_fatal_warnings" = "xyes" && value=1 || value=0
2595 PPRINT_PROP_BOOL([Warnings are fatal (--enable-fatal-warnings)], $value)
2597 test "x$enable_rust" = "xyes" && value=1 || value=0
2598 PPRINT_PROP_BOOL([Rust support (--enable-rust)], $value)
2600 test "x$enable_cargo_online_mode" = "xyes" && value=1 || value=0
2601 PPRINT_PROP_BOOL([Cargo Online Fetch (--enable-cargo-online-mode)], $value)
2603 test "x$enable_android" = "xyes" && value=1 || value=0
2604 PPRINT_PROP_BOOL([Android support (--enable-android)], $value)
2606 AS_ECHO
2607 PPRINT_SUBTITLE([Static Build])
2609 test "x$enable_static_tor" = "xyes" && value=1 || value=0
2610 PPRINT_PROP_BOOL([tor (--enable-static-tor)], $value)
2612 if test "x$enable_static_libevent" = "xyes"; then
2613   PPRINT_PROP_STRING([libevent], [$TOR_LIBDIR_libevent])
2614 else
2615   PPRINT_PROP_BOOL([libevent (--enable-static-libevent)], $value)
2618 if test "x$enable_static_openssl" = "xyes"; then
2619   PPRINT_PROP_STRING([libssl], [$TOR_LIBDIR_openssl])
2620 else
2621   PPRINT_PROP_BOOL([libssl (--enable-static-openssl)], $value)
2624 if test "x$enable_static_zlib" = "xyes"; then
2625   PPRINT_PROP_STRING([zlib1g], [$TOR_LIBDIR_zlib])
2626 else
2627   PPRINT_PROP_BOOL([zlib1g (--enable-static-zlib)], $value)
2630 AS_ECHO
2631 PPRINT_SUBTITLE([Optional Libraries])
2633 test "x$enable_nss" = "xyes" && value=1 || value=0
2634 PPRINT_PROP_BOOL([libnss (--enable-nss)], $value)
2636 test "x$enable_seccomp" != "xno" && value=1 || value=0
2637 PPRINT_PROP_BOOL([libseccomp (--disable-seccomp)], $value)
2639 test "x$enable_libscrypt" != "xno" && value=1 || value=0
2640 PPRINT_PROP_BOOL([libscrypt (--disable-libscrypt)], $value)
2642 test "x$enable_systemd" = "xyes" && value=1 || value=0
2643 PPRINT_PROP_BOOL([Systemd support (--enable-systemd)], $value)
2645 test "x$enable_lzma" = "xyes" && value=1 || value=0
2646 PPRINT_PROP_BOOL([liblzma (--enable-lzma)], $value)
2648 test "x$enable_zstd" = "xyes" && value=1 || value=0
2649 PPRINT_PROP_BOOL([libzstd (--enable-zstd)], $value)
2651 AS_ECHO
2652 PPRINT_SUBTITLE([Hardening])
2654 test "x$enable_gcc_hardening" != "xno" && value=1 || value=0
2655 PPRINT_PROP_BOOL([Compiler Hardening (--disable-gcc-hardening)], $value)
2657 test "x$enable_linker_hardening" != "xno" && value=1 || value=0
2658 PPRINT_PROP_BOOL([Linker Hardening (--disable-linker-hardening)], $value)
2660 test "x$fragile_hardening" = "xyes" && value=1 || value=0
2661 PPRINT_PROP_BOOL([Fragile Hardening (--enable-fragile-hardening, dev only)], $value)
2663 AS_ECHO
2664 PPRINT_SUBTITLE([Modules])
2666 m4_foreach_w([mname], MODULES,
2667   [
2668     test "xenable_module_mname" != "xno" && value=1 || value=0
2669     PPRINT_PROP_BOOL([mname (--disable-module-mname)], $value)
2670   ]
2673 AS_ECHO
2674 PPRINT_SUBTITLE([Documentation])
2676 test "x$enable_asciidoc" != "xno" && value=1 || value=0
2677 PPRINT_PROP_BOOL([AsciiDoc (--disable-asciidoc)], $value)
2679 test "x$enable_manpage" != "xno" && value=1 || value=0
2680 PPRINT_PROP_BOOL([Man Pages (--disable-manpage)], $value)
2682 test "x$enable_html_manual" != "xno" && value=1 || value=0
2683 PPRINT_PROP_BOOL([HTML Manual (--disable-html-manual)], $value)
2685 AS_ECHO
2686 PPRINT_SUBTITLE([Tests])
2688 test "x$enable_unittests" != "xno" && value=1 || value=0
2689 PPRINT_PROP_BOOL([Unit tests (--disable-unittests)], $value)
2691 test "x$enable_asserts_in_tests" = "xno" && value=1 || value=0
2692 PPRINT_PROP_BOOL([assert()s enabled (--enable-asserts-in-tests, dev only)], $value)
2694 test "x$enable_coverage" = "xyes" && value=1 || value=0
2695 PPRINT_PROP_BOOL([Code Coverage (--enable-coverage)], $value)
2697 test "x$enable_libfuzzer" = "xyes" && value=1 || value=0
2698 PPRINT_PROP_BOOL([libFuzzer support (--enable-libfuzzer)], $value)
2700 test "x$enable_oss_fuzz" = "xyes" && value=1 || value=0
2701 PPRINT_PROP_BOOL([OSS-Fuzz support (--enable-oss-fuzz)], $value)
2703 AS_ECHO
2704 PPRINT_SUBTITLE([Install Directories])
2706 report_mandir="`eval eval echo $mandir`"
2707 PPRINT_PROP_STRING([Binaries], [$BINDIR])
2708 PPRINT_PROP_STRING([Configuration], [$CONFDIR])
2709 PPRINT_PROP_STRING([Man Pages], [$report_mandir])
2711 AS_ECHO
2712 AS_ECHO(["Configure Line: ./configure $configure_flags"])