Makefile.am 23 KB

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