Makefile.am 24 KB

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