configure.ac 95 KB

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