configure.ac 94 KB

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