Makefile.am 23 KB

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