Makefile.am 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. # Copyright (c) 2001-2004, Roger Dingledine
  2. # Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
  3. # Copyright (c) 2007-2019, The Tor Project, Inc.
  4. # See LICENSE for licensing information
  5. ACLOCAL_AMFLAGS = -I m4
  6. noinst_LIBRARIES=
  7. EXTRA_DIST=
  8. noinst_HEADERS=
  9. bin_PROGRAMS=
  10. EXTRA_PROGRAMS=
  11. CLEANFILES=
  12. TESTS=
  13. noinst_PROGRAMS=
  14. DISTCLEANFILES=
  15. MOSTLYCLEANFILES=
  16. bin_SCRIPTS=
  17. AM_CPPFLAGS=\
  18. -I$(top_srcdir)/src \
  19. -I$(top_srcdir)/src/ext \
  20. -I$(top_srcdir)/src/ext/trunnel \
  21. -I$(top_srcdir)/src/trunnel
  22. AM_CFLAGS= \
  23. @TOR_SYSTEMD_CFLAGS@ \
  24. @CFLAGS_BUGTRAP@ \
  25. @TOR_LZMA_CFLAGS@ \
  26. @TOR_ZSTD_CFLAGS@
  27. SHELL=@SHELL@
  28. if COVERAGE_ENABLED
  29. TESTING_TOR_BINARY=$(top_builddir)/src/app/tor-cov$(EXEEXT)
  30. else
  31. TESTING_TOR_BINARY=$(top_builddir)/src/app/tor$(EXEEXT)
  32. endif
  33. if USE_RUST
  34. rust_ldadd=$(top_builddir)/$(TOR_RUST_LIB_PATH)
  35. else
  36. rust_ldadd=
  37. endif
  38. # "Common" libraries used to link tor's utility code.
  39. TOR_UTIL_LIBS = \
  40. src/lib/libtor-geoip.a \
  41. src/lib/libtor-process.a \
  42. src/lib/libtor-buf.a \
  43. src/lib/libtor-confmgt.a \
  44. src/lib/libtor-pubsub.a \
  45. src/lib/libtor-dispatch.a \
  46. src/lib/libtor-time.a \
  47. src/lib/libtor-fs.a \
  48. src/lib/libtor-encoding.a \
  49. src/lib/libtor-sandbox.a \
  50. src/lib/libtor-container.a \
  51. src/lib/libtor-net.a \
  52. src/lib/libtor-thread.a \
  53. src/lib/libtor-memarea.a \
  54. src/lib/libtor-math.a \
  55. src/lib/libtor-meminfo.a \
  56. src/lib/libtor-osinfo.a \
  57. src/lib/libtor-log.a \
  58. src/lib/libtor-lock.a \
  59. src/lib/libtor-fdio.a \
  60. src/lib/libtor-string.a \
  61. src/lib/libtor-term.a \
  62. src/lib/libtor-smartlist-core.a \
  63. src/lib/libtor-malloc.a \
  64. src/lib/libtor-wallclock.a \
  65. src/lib/libtor-err.a \
  66. src/lib/libtor-version.a \
  67. src/lib/libtor-llharden.a \
  68. src/lib/libtor-intmath.a \
  69. src/lib/libtor-ctime.a \
  70. src/lib/libtor-metrics.a
  71. # Variants of the above for linking the testing variant of tor (for coverage
  72. # and tests)
  73. if UNITTESTS_ENABLED
  74. TOR_UTIL_TESTING_LIBS = \
  75. src/lib/libtor-geoip-testing.a \
  76. src/lib/libtor-process-testing.a \
  77. src/lib/libtor-buf-testing.a \
  78. src/lib/libtor-confmgt-testing.a \
  79. src/lib/libtor-pubsub-testing.a \
  80. src/lib/libtor-dispatch-testing.a \
  81. src/lib/libtor-time-testing.a \
  82. src/lib/libtor-fs-testing.a \
  83. src/lib/libtor-encoding-testing.a \
  84. src/lib/libtor-sandbox-testing.a \
  85. src/lib/libtor-container-testing.a \
  86. src/lib/libtor-net-testing.a \
  87. src/lib/libtor-thread-testing.a \
  88. src/lib/libtor-memarea-testing.a \
  89. src/lib/libtor-math-testing.a \
  90. src/lib/libtor-meminfo-testing.a \
  91. src/lib/libtor-osinfo-testing.a \
  92. src/lib/libtor-term-testing.a \
  93. src/lib/libtor-log-testing.a \
  94. src/lib/libtor-lock-testing.a \
  95. src/lib/libtor-fdio-testing.a \
  96. src/lib/libtor-string-testing.a \
  97. src/lib/libtor-smartlist-core-testing.a \
  98. src/lib/libtor-malloc-testing.a \
  99. src/lib/libtor-wallclock-testing.a \
  100. src/lib/libtor-err-testing.a \
  101. src/lib/libtor-version-testing.a \
  102. src/lib/libtor-llharden-testing.a \
  103. src/lib/libtor-intmath.a \
  104. src/lib/libtor-ctime-testing.a \
  105. src/lib/libtor-metrics-testing.a
  106. endif
  107. # Internal crypto libraries used in Tor
  108. TOR_CRYPTO_LIBS = \
  109. src/lib/libtor-tls.a \
  110. src/lib/libtor-crypt-ops.a \
  111. $(LIBKECCAK_TINY) \
  112. $(LIBDONNA)
  113. # Variants of the above for linking the testing variant of tor (for coverage
  114. # and tests)
  115. if UNITTESTS_ENABLED
  116. TOR_CRYPTO_TESTING_LIBS = \
  117. src/lib/libtor-tls-testing.a \
  118. src/lib/libtor-crypt-ops-testing.a \
  119. $(LIBKECCAK_TINY) \
  120. $(LIBDONNA)
  121. endif
  122. # All static libraries used to link tor.
  123. TOR_INTERNAL_LIBS = \
  124. src/core/libtor-app.a \
  125. src/lib/libtor-compress.a \
  126. src/lib/libtor-evloop.a \
  127. $(TOR_CRYPTO_LIBS) \
  128. $(TOR_UTIL_LIBS) \
  129. src/trunnel/libor-trunnel.a \
  130. src/lib/libtor-trace.a
  131. libtor.a: $(TOR_INTERNAL_LIBS)
  132. $(AM_V_AR) export AR="$(AR)"; \
  133. export ARFLAGS="$(ARFLAGS)"; \
  134. export RANLIB="$(RANLIB)"; \
  135. $(top_srcdir)/scripts/build/combine_libs libtor.a $(TOR_INTERNAL_LIBS)
  136. MOSTLYCLEANFILES += libtor.a
  137. # Variants of the above for linking the testing variant of tor (for coverage
  138. # and tests)
  139. if UNITTESTS_ENABLED
  140. TOR_INTERNAL_TESTING_LIBS = \
  141. src/core/libtor-app-testing.a \
  142. src/lib/libtor-compress-testing.a \
  143. src/lib/libtor-evloop-testing.a \
  144. $(TOR_CRYPTO_TESTING_LIBS) \
  145. $(TOR_UTIL_TESTING_LIBS) \
  146. src/trunnel/libor-trunnel-testing.a \
  147. src/lib/libtor-trace.a
  148. src/test/libtor-testing.a: $(TOR_INTERNAL_TESTING_LIBS)
  149. $(AM_V_AR) export AR="$(AR)"; \
  150. export ARFLAGS="$(ARFLAGS)"; \
  151. export RANLIB="$(RANLIB)"; \
  152. $(top_srcdir)/scripts/build/combine_libs src/test/libtor-testing.a $(TOR_INTERNAL_TESTING_LIBS)
  153. MOSTLYCLEANFILES += src/test/libtor-testing.a
  154. endif
  155. TOR_LDFLAGS_CRYPTLIB=@TOR_LDFLAGS_openssl@
  156. TOR_LIBS_CRYPTLIB=@TOR_OPENSSL_LIBS@
  157. TOR_CFLAGS_CRYPTLIB=
  158. if USE_NSS
  159. TOR_CFLAGS_CRYPTLIB+=@NSS_CFLAGS@
  160. TOR_LIBS_CRYPTLIB+=@NSS_LIBS@
  161. endif
  162. # All libraries used to link tor-cov
  163. include src/include.am
  164. include doc/include.am
  165. include contrib/include.am
  166. manpages: $(nodist_man1_MANS)
  167. EXTRA_DIST+= \
  168. ChangeLog \
  169. CONTRIBUTING \
  170. CODE_OF_CONDUCT \
  171. INSTALL \
  172. LICENSE \
  173. Makefile.nmake \
  174. README \
  175. ReleaseNotes \
  176. scripts/build/combine_libs \
  177. scripts/maint/checkIncludes.py \
  178. scripts/maint/checkSpace.pl \
  179. scripts/maint/checkSpaceTest.sh \
  180. scripts/maint/checkspace_tests/dubious.c \
  181. scripts/maint/checkspace_tests/dubious.h \
  182. scripts/maint/checkspace_tests/expected.txt \
  183. scripts/maint/checkspace_tests/good_guard.h \
  184. scripts/maint/checkspace_tests/same_guard.h \
  185. scripts/maint/checkspace_tests/subdir/dubious.c \
  186. scripts/maint/checkShellScripts.sh \
  187. scripts/maint/practracker/README \
  188. scripts/maint/practracker/exceptions.txt \
  189. scripts/maint/practracker/includes.py \
  190. scripts/maint/practracker/metrics.py \
  191. scripts/maint/practracker/practracker.py \
  192. scripts/maint/practracker/practracker_tests.py \
  193. scripts/maint/practracker/problem.py \
  194. scripts/maint/practracker/testdata/.may_include \
  195. scripts/maint/practracker/testdata/a.c \
  196. scripts/maint/practracker/testdata/b.c \
  197. scripts/maint/practracker/testdata/ex0-expected.txt \
  198. scripts/maint/practracker/testdata/ex0.txt \
  199. scripts/maint/practracker/testdata/ex1-expected.txt \
  200. scripts/maint/practracker/testdata/ex1.txt \
  201. scripts/maint/practracker/testdata/ex1-overbroad-expected.txt \
  202. scripts/maint/practracker/testdata/ex1-regen-expected.txt \
  203. scripts/maint/practracker/testdata/ex1-regen-overbroad-expected.txt \
  204. scripts/maint/practracker/testdata/ex.txt \
  205. scripts/maint/practracker/testdata/header.h \
  206. scripts/maint/practracker/testdata/not_c_file \
  207. scripts/maint/practracker/test_practracker.sh \
  208. scripts/maint/practracker/util.py \
  209. scripts/coccinelle/apply.sh \
  210. scripts/coccinelle/check_cocci_parse.sh \
  211. scripts/coccinelle/exceptions.txt \
  212. scripts/coccinelle/test-operator-cleanup \
  213. scripts/coccinelle/tor-coccinelle.h \
  214. scripts/coccinelle/try_parse.sh
  215. ## This tells etags how to find mockable function definitions.
  216. AM_ETAGSFLAGS=--regex='{c}/MOCK_IMPL([^,]+,\W*\([a-zA-Z0-9_]+\)\W*,/\1/s'
  217. if COVERAGE_ENABLED
  218. TEST_CFLAGS=-fno-inline -fprofile-arcs -ftest-coverage
  219. if DISABLE_ASSERTS_IN_UNIT_TESTS
  220. TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE -DDISABLE_ASSERTS_IN_UNIT_TESTS @TOR_MODULES_ALL_ENABLED@
  221. else
  222. TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE @TOR_MODULES_ALL_ENABLED@
  223. endif
  224. TEST_NETWORK_FLAGS=--coverage --hs-multi-client 1
  225. else
  226. TEST_CFLAGS=
  227. TEST_CPPFLAGS=-DTOR_UNIT_TESTS @TOR_MODULES_ALL_ENABLED@
  228. TEST_NETWORK_FLAGS=--hs-multi-client 1
  229. endif
  230. TEST_NETWORK_SHOW_WARNINGS_FOR_LAST_RUN_FLAGS=--quiet --only-warnings
  231. if LIBFUZZER_ENABLED
  232. TEST_CFLAGS += -fsanitize-coverage=trace-pc-guard,trace-cmp,trace-div
  233. # not "edge"
  234. endif
  235. TEST_NETWORK_ALL_LOG_DIR=$(top_builddir)/test_network_log
  236. TEST_NETWORK_ALL_DRIVER_FLAGS=--color-tests yes
  237. #install-data-local:
  238. # $(INSTALL) -m 755 -d $(LOCALSTATEDIR)/lib/tor
  239. # Allows to override rpmbuild with rpmbuild-md5 from fedora-packager so that
  240. # building for EL5 won't fail on https://bugzilla.redhat.com/show_bug.cgi?id=490613
  241. RPMBUILD ?= rpmbuild
  242. # Use automake's dist-gzip target to build the tarball
  243. dist-rpm: dist-gzip
  244. TIMESTAMP=$$(date +"%Y-%m-%d_%H.%M.%S"); \
  245. RPM_BUILD_DIR=$$(mktemp -d "/tmp/tor-rpm-build-$$TIMESTAMP-XXXX"); \
  246. mkdir -p "$$RPM_BUILD_DIR"/{BUILD,RPMS,SOURCES/"tor-$(VERSION)",SPECS,SRPMS}; \
  247. cp -fa "$(distdir).tar.gz" "$$RPM_BUILD_DIR"/SOURCES/; \
  248. LIBS=-lrt $(RPMBUILD) -ba --define "_topdir $$RPM_BUILD_DIR" tor.spec; \
  249. cp -fa "$$RPM_BUILD_DIR"/SRPMS/* .; \
  250. cp -fa "$$RPM_BUILD_DIR"/RPMS/* .; \
  251. rm -rf "$$RPM_BUILD_DIR"; \
  252. echo "RPM build finished"; \
  253. #end of dist-rpm
  254. .PHONY: doxygen
  255. doxygen: Doxyfile
  256. mkdir -p doc/doxygen
  257. (cd "$(top_srcdir)" && doxygen "$(abs_top_builddir)/Doxyfile")
  258. test: all
  259. $(top_builddir)/src/test/test
  260. shellcheck:
  261. $(top_srcdir)/scripts/maint/checkShellScripts.sh
  262. check-local: \
  263. check-spaces \
  264. check-changes \
  265. check-includes \
  266. shellcheck
  267. # test-network requires a copy of Chutney in $CHUTNEY_PATH.
  268. # Chutney can be cloned from https://git.torproject.org/chutney.git .
  269. .PHONY: need-chutney-path
  270. need-chutney-path:
  271. @if test ! -d "$$CHUTNEY_PATH"; then \
  272. echo '$$CHUTNEY_PATH was not set.'; \
  273. if test -d "$(top_srcdir)/../chutney" && \
  274. test -x "$(top_srcdir)/../chutney/chutney"; then \
  275. echo "Assuming test-network.sh will find" \
  276. "$(top_srcdir)/../chutney"; \
  277. else \
  278. echo; \
  279. echo "To run these tests," \
  280. "git clone" \
  281. "https://git.torproject.org/chutney.git ;" \
  282. "export CHUTNEY_PATH=\`pwd\`/chutney"; \
  283. exit 1; \
  284. fi \
  285. fi
  286. # Run some basic tests using automake's test-driver
  287. .PHONY: test-network
  288. # Hide directory path logs from submakes using $(MAKE) -s
  289. test-network:
  290. @$(MAKE) -s test-network-mkdir
  291. @$(MAKE) -s test-network-clean
  292. @$(MAKE) -s test-network-run \
  293. ipv4_flavors="$(TEST_CHUTNEY_FLAVOR_QUICK)" \
  294. ipv6_flavors="$(TEST_CHUTNEY_FLAVOR_QUICK_IPV6)"
  295. @$(MAKE) -s test-network-results
  296. # Run all available tests using automake's test-driver
  297. .PHONY: test-network-all
  298. # Hide directory path logs from submakes using $(MAKE) -s
  299. test-network-all:
  300. @$(MAKE) -s test-network-mkdir
  301. @$(MAKE) -s test-network-clean
  302. @$(MAKE) -s test-network-run \
  303. ipv4_flavors="$(TEST_CHUTNEY_FLAVORS)" \
  304. mixed_flavors="$(TEST_CHUTNEY_FLAVORS_MIXED)" \
  305. ipv6_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6)" \
  306. ipv6_mixed_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6_MIXED)"
  307. @$(MAKE) -s test-network-results
  308. # Run IPv4 and mixed tests using automake's test-driver
  309. .PHONY: test-network-ipv4
  310. # Hide directory path logs from submakes using $(MAKE) -s
  311. test-network-ipv4:
  312. @$(MAKE) -s test-network-mkdir
  313. @$(MAKE) -s test-network-clean
  314. @$(MAKE) -s test-network-run \
  315. ipv4_flavors="$(TEST_CHUTNEY_FLAVORS)" \
  316. mixed_flavors="$(TEST_CHUTNEY_FLAVORS_MIXED)"
  317. @$(MAKE) -s test-network-results
  318. # Run IPv6 tests using automake's test-driver
  319. .PHONY: test-network-ipv6
  320. # Hide directory path logs from submakes using $(MAKE) -s
  321. test-network-ipv6:
  322. @$(MAKE) -s test-network-mkdir
  323. @$(MAKE) -s test-network-clean
  324. @$(MAKE) -s test-network-run \
  325. ipv6_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6)" \
  326. ipv6_mixed_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6_MIXED)"
  327. @$(MAKE) -s test-network-results
  328. # Make the test network log directory, if it does not exist
  329. .PHONY: test-network-mkdir
  330. test-network-mkdir:
  331. @mkdir -p "$(TEST_NETWORK_ALL_LOG_DIR)"
  332. # Clean the test network log directory
  333. .PHONY: test-network-clean
  334. # We need to remove all matching files, so we can't quote the glob part of the
  335. # rm arguments
  336. test-network-clean:
  337. rm -f "$(TEST_NETWORK_ALL_LOG_DIR)"/*.log \
  338. "$(TEST_NETWORK_ALL_LOG_DIR)"/*.trs
  339. # Run tests using automake's test-driver
  340. # When checking if a set of test can be run, log the type of test, and the
  341. # list of tests that will be run (or skipped).
  342. #
  343. # Run the IPv4 tests in $(ipv4_flavors), unconditionally
  344. # - tor relays and directory authorities require IPv4.
  345. # Run the IPv6 tests in $(ipv6_flavors), if IPv6 is available
  346. # - only run IPv6 tests if we can ping6 or ping -6 ::1 (localhost)
  347. # we try the syntax for BSD ping6, Linux ping6, and Linux ping -6,
  348. # because they're incompatible
  349. # - some IPv6 tests may fail without an IPv6 DNS server
  350. # (see #16971 and #17011)
  351. # Run the mixed tests in $(mixed_flavors), if a tor-stable binary is available
  352. # - only run mixed tests if we have a tor-stable binary
  353. # Run the IPv6 mixed tests in $(ipv6_mixed_flavors), if IPv6 and mixed are run
  354. # - see above for details about IPv6 and mixed
  355. .PHONY: test-network-run
  356. # We need the word splitting in the "for" lines, so we can't quote
  357. # $(skip_flavors) or $(flavors)
  358. test-network-run: need-chutney-path test-driver $(TESTING_TOR_BINARY) src/tools/tor-gencert
  359. @flavors=""; \
  360. skip_flavors=""; \
  361. if test -n "$(ipv4_flavors)"; then \
  362. echo "Running IPv4 flavors: $(ipv4_flavors)."; \
  363. flavors="$$flavors $(ipv4_flavors)"; \
  364. fi; \
  365. test_network_ipv6=false; \
  366. if test -n "$(ipv6_flavors)" || \
  367. test -n "$(ipv6_mixed_flavors)"; then \
  368. if ping6 -q -c 1 -o ::1 >/dev/null 2>&1 || \
  369. ping6 -q -c 1 -W 1 ::1 >/dev/null 2>&1 || \
  370. ping -6 -c 1 -W 1 ::1 >/dev/null 2>&1; then \
  371. test_network_ipv6=true; \
  372. fi; \
  373. fi; \
  374. if test -n "$(ipv6_flavors)"; then \
  375. if test "$$test_network_ipv6" = "true"; then \
  376. echo "ping6 ::1 or ping ::1 succeeded, running IPv6" \
  377. "flavors: $(ipv6_flavors)."; \
  378. flavors="$$flavors $(ipv6_flavors)"; \
  379. else \
  380. echo "ping6 ::1 and ping ::1 failed, skipping IPv6" \
  381. "flavors: $(ipv6_flavors)."; \
  382. skip_flavors="$$skip_flavors $(ipv6_flavors)"; \
  383. fi; \
  384. fi; \
  385. test_network_mixed=false; \
  386. if test -n "$(mixed_flavors)" || \
  387. test -n "$(ipv6_mixed_flavors)"; then \
  388. if command -v tor-stable >/dev/null 2>&1; then \
  389. test_network_mixed=true; \
  390. fi; \
  391. fi; \
  392. if test -n "$(mixed_flavors)"; then \
  393. if test "$$test_network_mixed" = "true"; then \
  394. echo "tor-stable found, running mixed flavors:" \
  395. "$(mixed_flavors)."; \
  396. flavors="$$flavors $(mixed_flavors)"; \
  397. else \
  398. echo "tor-stable not found, skipping mixed flavors:" \
  399. "$(mixed_flavors)."; \
  400. skip_flavors="$$skip_flavors $(mixed_flavors)"; \
  401. fi; \
  402. fi; \
  403. if test -n "$(ipv6_mixed_flavors)"; then \
  404. if test "$$test_network_ipv6" = "true" && \
  405. test "$$test_network_mixed" = "true"; then \
  406. echo "Running IPv6 mixed flavors:" \
  407. "$(ipv6_mixed_flavors)."; \
  408. flavors="$$flavors $(ipv6_mixed_flavors)"; \
  409. else \
  410. echo "Skipping IPv6 mixed flavors:" \
  411. "$(ipv6_mixed_flavors)."; \
  412. skip_flavors="$$skip_flavors $(ipv6_mixed_flavors)"; \
  413. fi; \
  414. fi; \
  415. for f in $$skip_flavors; do \
  416. echo "SKIP: $$f"; \
  417. done; \
  418. for f in $$flavors; do \
  419. $(SHELL) "$(top_srcdir)/test-driver" --test-name "$$f" \
  420. --log-file "$(TEST_NETWORK_ALL_LOG_DIR)/$$f.log" \
  421. --trs-file "$(TEST_NETWORK_ALL_LOG_DIR)/$$f.trs" \
  422. $(TEST_NETWORK_ALL_DRIVER_FLAGS) \
  423. "$(top_srcdir)/src/test/test-network.sh" \
  424. --flavor "$$f" $(TEST_NETWORK_FLAGS); \
  425. "$(top_srcdir)/src/test/test-network.sh" \
  426. $(TEST_NETWORK_SHOW_WARNINGS_FOR_LAST_RUN_FLAGS); \
  427. done
  428. # Print the results from automake's test-driver
  429. # - show tor warnings on the console after each network run
  430. # (otherwise, warnings go to the logs, and people don't see them unless
  431. # there is a network failure)
  432. .PHONY: test-network-results
  433. # We need to grep all matching files, so we can't quote the glob part of the
  434. # grep arguments
  435. test-network-results:
  436. @echo \
  437. "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)."
  438. @! grep -q FAIL "$(TEST_NETWORK_ALL_LOG_DIR)"/*.trs
  439. need-stem-path:
  440. @if test ! -d "$$STEM_SOURCE_DIR"; then \
  441. echo '$$STEM_SOURCE_DIR was not set.'; echo; \
  442. echo "To run these tests, git clone https://git.torproject.org/stem.git/ ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \
  443. exit 1; \
  444. fi
  445. test-stem: need-stem-path $(TESTING_TOR_BINARY)
  446. @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --integ --test control.controller --test control.base_controller --test process --log notice;
  447. test-stem-full: need-stem-path $(TESTING_TOR_BINARY)
  448. @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --all --log notice --target RUN_ALL,ONLINE -v;
  449. test-full: \
  450. need-stem-path \
  451. need-chutney-path \
  452. check \
  453. test-network \
  454. test-stem
  455. test-full-online: \
  456. need-stem-path \
  457. need-chutney-path \
  458. check \
  459. test-network \
  460. test-stem-full
  461. # We can't delete the gcno files, because they are created when tor is compiled
  462. reset-gcov:
  463. rm -f $(top_builddir)/src/*/*.gcda $(top_builddir)/src/*/*/*.gcda \
  464. $(top_builddir)/src/*/*.gcov $(top_builddir)/src/*/*/*.gcov
  465. HTML_COVER_DIR=$(top_builddir)/coverage_html
  466. coverage-html: all
  467. if COVERAGE_ENABLED
  468. test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
  469. test -d "$(HTML_COVER_DIR)" || $(MKDIR_P) "$(HTML_COVER_DIR)"
  470. lcov --rc lcov_branch_coverage=1 --directory $(top_builddir)/src --zerocounters
  471. $(MAKE) reset-gcov
  472. $(MAKE) check
  473. lcov --capture --rc lcov_branch_coverage=1 --no-external --directory $(top_builddir) --base-directory $(top_srcdir) --output-file "$(HTML_COVER_DIR)/lcov.tmp"
  474. lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
  475. genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
  476. else
  477. @printf "Not configured with --enable-coverage, run ./configure --enable-coverage\n"
  478. endif
  479. coverage-html-full: all
  480. test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
  481. test -d "$(HTML_COVER_DIR)" || mkdir -p "$(HTML_COVER_DIR)"
  482. lcov --rc lcov_branch_coverage=1 --directory ./src --zerocounters
  483. $(MAKE) reset-gcov
  484. $(MAKE) check
  485. $(MAKE) test-stem-full
  486. CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh
  487. CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh --flavor hs
  488. lcov --capture --rc lcov_branch_coverage=1 --no-external --directory . --output-file "$(HTML_COVER_DIR)/lcov.tmp"
  489. lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
  490. genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
  491. # For scripts: avoid src/ext and src/trunnel.
  492. # Keep these lists consistent:
  493. # - OWNED_TOR_C_FILES in Makefile.am
  494. # - CHECK_FILES in pre-commit.git-hook and pre-push.git-hook
  495. # - try_parse in check_cocci_parse.sh
  496. OWNED_TOR_C_FILES=\
  497. $(top_srcdir)/src/lib/*/*.[ch] \
  498. $(top_srcdir)/src/core/*/*.[ch] \
  499. $(top_srcdir)/src/feature/*/*.[ch] \
  500. $(top_srcdir)/src/app/*/*.[ch] \
  501. $(top_srcdir)/src/test/*.[ch] \
  502. $(top_srcdir)/src/test/*/*.[ch] \
  503. $(top_srcdir)/src/tools/*.[ch]
  504. check-spaces:
  505. if USE_PERL
  506. $(PERL) $(top_srcdir)/scripts/maint/checkSpace.pl -C \
  507. $(OWNED_TOR_C_FILES)
  508. endif
  509. check-includes:
  510. if USEPYTHON
  511. $(PYTHON) $(top_srcdir)/scripts/maint/practracker/includes.py $(top_srcdir)
  512. endif
  513. check-best-practices:
  514. if USEPYTHON
  515. @$(PYTHON) $(top_srcdir)/scripts/maint/practracker/practracker.py $(top_srcdir) $(TOR_PRACTRACKER_OPTIONS)
  516. endif
  517. check-cocci:
  518. VERBOSE=1 $(top_srcdir)/scripts/coccinelle/check_cocci_parse.sh $(OWNED_TOR_C_FILES)
  519. practracker-regen:
  520. $(PYTHON) $(top_srcdir)/scripts/maint/practracker/practracker.py --regen $(top_srcdir)
  521. check-docs: all
  522. $(PERL) $(top_builddir)/scripts/maint/checkOptionDocs.pl
  523. check-logs:
  524. $(top_srcdir)/scripts/maint/checkLogs.pl \
  525. $(top_srcdir)/src/*/*.[ch] | sort -n
  526. .PHONY: check-typos
  527. check-typos:
  528. @if test -x "`which misspell 2>&1;true`"; then \
  529. echo "Checking for Typos ..."; \
  530. (misspell \
  531. $(top_srcdir)/src/[^e]*/*.[ch] \
  532. $(top_srcdir)/doc \
  533. $(top_srcdir)/contrib \
  534. $(top_srcdir)/scripts \
  535. $(top_srcdir)/README \
  536. $(top_srcdir)/ChangeLog \
  537. $(top_srcdir)/INSTALL \
  538. $(top_srcdir)/ReleaseNotes \
  539. $(top_srcdir)/LICENSE); \
  540. else \
  541. echo "Tor can use misspell to check for typos."; \
  542. echo "It seems that you don't have misspell installed."; \
  543. echo "You can install the latest version of misspell here: https://github.com/client9/misspell#install"; \
  544. fi
  545. .PHONY: rustfmt
  546. rustfmt:
  547. if USE_RUST
  548. @if test -x "`which cargo-fmt 2>&1;true`"; then \
  549. echo "Formatting Rust code ..."; \
  550. (cd "$(top_srcdir)/src/rust" && cargo fmt --all --); \
  551. else \
  552. echo "Tor uses rustfmt (via cargo-fmt) to format Rust code."; \
  553. echo "However, it seems that you don't have rustfmt installed."; \
  554. printf "You can install rustfmt by following the directions here:"; \
  555. echo " https://github.com/rust-lang-nursery/rustfmt"; \
  556. fi
  557. endif
  558. .PHONY: check-rustfmt
  559. check-rustfmt:
  560. if USE_RUST
  561. @if test -x "`which cargo-fmt 2>&1;true`"; then \
  562. printf "Running rustfmt..."; \
  563. (cd "$(top_srcdir)/src/rust" && cargo fmt --all -- --check && echo "done.") || \
  564. (echo "**************** check-rustfmt failed. ****************"; \
  565. echo " Run \`make rustfmt\` to apply the above changes."; \
  566. exit 1); \
  567. else \
  568. echo "Tor uses rustfmt (via cargo-fmt) to format Rust code."; \
  569. echo "However, it seems that you don't have rustfmt installed."; \
  570. printf "You can install rustfmt by following the directions here:"; \
  571. echo " https://github.com/rust-lang-nursery/rustfmt"; \
  572. fi
  573. endif
  574. .PHONY: clippy
  575. clippy:
  576. if USE_RUST
  577. @if test -x "`which cargo-clippy 2>&1;true`"; then \
  578. echo "Running cargo clippy ..."; \
  579. echo "Prepare yourself for the onslaught of suggestions ..."; \
  580. (cd "$(top_srcdir)/src/rust" && cargo clippy); \
  581. else \
  582. echo "Tor can use clippy to lint Rust code."; \
  583. echo "However, it seems that you don't have clippy installed."; \
  584. echo "You can install the latest version of clippy by following the directions here: https://github.com/rust-lang-nursery/rust-clippy"; \
  585. fi
  586. endif
  587. .PHONY: check-changes
  588. check-changes:
  589. if USEPYTHON
  590. @if test -d "$(top_srcdir)/changes"; then \
  591. PACKAGE_VERSION=$(PACKAGE_VERSION) $(PYTHON) $(top_srcdir)/scripts/maint/lintChanges.py $(top_srcdir)/changes; \
  592. fi
  593. endif
  594. .PHONY: update-versions
  595. update-versions:
  596. abs_top_srcdir="$(abs_top_srcdir)" $(PYTHON) $(top_srcdir)/scripts/maint/update_versions.py
  597. .PHONY: callgraph
  598. callgraph:
  599. cd $(top_builddir); $(abs_top_srcdir)/scripts/maint/run_calltool.sh
  600. version:
  601. @echo "Tor @VERSION@"
  602. @if test -d "$(top_srcdir)/.git" && test -x "`which git 2>&1;true`"; then \
  603. echo -n "git: " ;\
  604. (cd "$(top_srcdir)" && git rev-parse --short=16 HEAD); \
  605. fi
  606. .PHONY: autostyle-ifdefs
  607. autostyle-ifdefs:
  608. $(PYTHON) $(top_srcdir)/scripts/maint/annotate_ifdef_directives.py $(OWNED_TOR_C_FILES)
  609. .PHONY: autostyle-ifdefs
  610. autostyle-operators:
  611. $(PERL) $(top_srcdir)/scripts/coccinelle/test-operator-cleanup $(OWNED_TOR_C_FILES)
  612. .PHONY: rectify-includes
  613. rectify-includes:
  614. cd $(top_srcdir); $(PYTHON) $(abs_top_srcdir)/scripts/maint/rectify_include_paths.py
  615. .PHONY: update-copyright
  616. update-copyright:
  617. $(PERL) $(top_srcdir)/scripts/maint/updateCopyright.pl $(OWNED_TOR_C_FILES)
  618. .PHONY: autostyle
  619. autostyle: update-versions rustfmt autostyle-ifdefs rectify-includes
  620. mostlyclean-local:
  621. rm -f $(top_builddir)/src/*/*.gc{da,no} $(top_builddir)/src/*/*/*.gc{da,no}
  622. rm -rf $(HTML_COVER_DIR)
  623. rm -rf $(top_builddir)/doc/doxygen
  624. rm -rf $(TEST_NETWORK_ALL_LOG_DIR)
  625. clean-local:
  626. rm -rf $(top_builddir)/src/rust/target
  627. rm -rf $(top_builddir)/src/rust/.cargo/registry
  628. if USE_RUST
  629. distclean-local: distclean-rust
  630. endif
  631. # This relies on some internal details of how automake implements
  632. # distcheck. We check two directories because automake-1.15 changed
  633. # from $(distdir)/_build to $(distdir)/_build/sub.
  634. show-distdir-testlog:
  635. @if test -d "$(distdir)/_build/sub"; then \
  636. cat $(distdir)/_build/sub/$(TEST_SUITE_LOG); \
  637. else \
  638. cat $(distdir)/_build/$(TEST_SUITE_LOG); fi
  639. # Similarly, this relies on automake internals to run file on an
  640. # intermittent core file whose provenance is not known to us. See
  641. # ticket 26787.
  642. show-distdir-core:
  643. @if test -d "$(distdir)/_build/sub"; then \
  644. file $(distdir)/_build/sub/core ; \
  645. else \
  646. file $(distdir)/_build/core; fi
  647. show-libs:
  648. @echo libtor.a
  649. show-testing-libs:
  650. @echo src/test/libtor-testing.a
  651. # Note here that we hardcode this -j2 because if the user would pass too many
  652. # cores, bear actually chockes and dies :S. For this to work, a make clean
  653. # needs to be done else bear will miss some compile flags.
  654. lsp:
  655. @if test -x "`which bear 2>&1;true`"; then \
  656. echo "Generating LSP compile_commands.json. Might take few minutes..."; \
  657. $(MAKE) clean 2>&1 >/dev/null; \
  658. bear >/dev/null 2>&1 -- $(MAKE) -j2 2>&1 >/dev/null; \
  659. echo "Generating .ccls file..."; \
  660. ./scripts/maint/gen_ccls_file.sh \
  661. else \
  662. echo "No bear command found. On debian, apt install bear"; \
  663. fi
  664. # Reproducible tarball. We change the tar options for this.
  665. dist-reprod:
  666. $(MAKE) dist am__tar="$${TAR-tar} --format=gnu --owner=root --group=root --sort=name --mtime=\"`git show --no-patch --format='%ci'`\" -chof - $(distdir)"