Makefile.am 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. # Copyright (c) 2001-2004, Roger Dingledine
  2. # Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
  3. # Copyright (c) 2007-2018, 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=@TOR_SYSTEMD_CFLAGS@ @CFLAGS_BUGTRAP@ @TOR_LZMA_CFLAGS@ @TOR_ZSTD_CFLAGS@
  22. SHELL=@SHELL@
  23. if COVERAGE_ENABLED
  24. TESTING_TOR_BINARY=$(top_builddir)/src/or/tor-cov$(EXEEXT)
  25. else
  26. TESTING_TOR_BINARY=$(top_builddir)/src/or/tor$(EXEEXT)
  27. endif
  28. if USE_RUST
  29. rust_ldadd=$(top_builddir)/src/rust/target/release/@TOR_RUST_STATIC_NAME@ \
  30. @TOR_RUST_EXTRA_LIBS@
  31. else
  32. rust_ldadd=
  33. endif
  34. # "Common" libraries used to link tor's utility code.
  35. TOR_UTIL_LIBS = \
  36. src/common/libor.a \
  37. src/common/libor-ctime.a
  38. # Variants of the above for linking the testing variant of tor (for coverage
  39. # and tests)
  40. TOR_UTIL_TESTING_LIBS = \
  41. src/common/libor-testing.a \
  42. src/common/libor-ctime-testing.a
  43. # Internal crypto libraries used in Tor
  44. TOR_CRYPTO_LIBS = \
  45. src/common/libor-crypto.a \
  46. $(LIBKECCAK_TINY) \
  47. $(LIBDONNA)
  48. # Variants of the above for linking the testing variant of tor (for coverage
  49. # and tests)
  50. TOR_CRYPTO_TESTING_LIBS = \
  51. src/common/libor-crypto-testing.a \
  52. $(LIBKECCAK_TINY) \
  53. $(LIBDONNA)
  54. # All static libraries used to link tor.
  55. TOR_INTERNAL_LIBS = \
  56. src/or/libtor.a \
  57. $(TOR_CRYPTO_LIBS) \
  58. $(TOR_UTIL_LIBS) \
  59. src/common/libor-event.a \
  60. src/trunnel/libor-trunnel.a \
  61. src/trace/libor-trace.a
  62. # Variants of the above for linking the testing variant of tor (for coverage
  63. # and tests)
  64. TOR_INTERNAL_TESTING_LIBS = \
  65. src/or/libtor-testing.a \
  66. $(TOR_CRYPTO_TESTING_LIBS) \
  67. $(TOR_UTIL_TESTING_LIBS) \
  68. $(LIBKECCAK_TINY) \
  69. $(LIBDONNA) \
  70. src/common/libor-event-testing.a \
  71. src/trunnel/libor-trunnel-testing.a \
  72. src/trace/libor-trace.a
  73. # All libraries used to link tor-cov
  74. include src/include.am
  75. include doc/include.am
  76. include contrib/include.am
  77. EXTRA_DIST+= \
  78. ChangeLog \
  79. CONTRIBUTING \
  80. INSTALL \
  81. LICENSE \
  82. Makefile.nmake \
  83. README \
  84. ReleaseNotes \
  85. scripts/maint/checkSpace.pl
  86. ## This tells etags how to find mockable function definitions.
  87. AM_ETAGSFLAGS=--regex='{c}/MOCK_IMPL([^,]+,\W*\([a-zA-Z0-9_]+\)\W*,/\1/s'
  88. if COVERAGE_ENABLED
  89. TEST_CFLAGS=-fno-inline -fprofile-arcs -ftest-coverage
  90. if DISABLE_ASSERTS_IN_UNIT_TESTS
  91. TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE -DDISABLE_ASSERTS_IN_UNIT_TESTS @TOR_MODULES_ALL_ENABLED@
  92. else
  93. TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE @TOR_MODULES_ALL_ENABLED@
  94. endif
  95. TEST_NETWORK_FLAGS=--coverage --hs-multi-client 1
  96. else
  97. TEST_CFLAGS=
  98. TEST_CPPFLAGS=-DTOR_UNIT_TESTS @TOR_MODULES_ALL_ENABLED@
  99. TEST_NETWORK_FLAGS=--hs-multi-client 1
  100. endif
  101. TEST_NETWORK_WARNING_FLAGS=--quiet --only-warnings
  102. if LIBFUZZER_ENABLED
  103. TEST_CFLAGS += -fsanitize-coverage=trace-pc-guard,trace-cmp,trace-div
  104. # not "edge"
  105. endif
  106. TEST_NETWORK_ALL_LOG_DIR=$(top_builddir)/test_network_log
  107. TEST_NETWORK_ALL_DRIVER_FLAGS=--color-tests yes
  108. #install-data-local:
  109. # $(INSTALL) -m 755 -d $(LOCALSTATEDIR)/lib/tor
  110. # Allows to override rpmbuild with rpmbuild-md5 from fedora-packager so that
  111. # building for EL5 won't fail on https://bugzilla.redhat.com/show_bug.cgi?id=490613
  112. RPMBUILD ?= rpmbuild
  113. # Use automake's dist-gzip target to build the tarball
  114. dist-rpm: dist-gzip
  115. TIMESTAMP=$$(date +"%Y-%m-%d_%H.%M.%S"); \
  116. RPM_BUILD_DIR=$$(mktemp -d "/tmp/tor-rpm-build-$$TIMESTAMP-XXXX"); \
  117. mkdir -p "$$RPM_BUILD_DIR"/{BUILD,RPMS,SOURCES/"tor-$(VERSION)",SPECS,SRPMS}; \
  118. cp -fa "$(distdir).tar.gz" "$$RPM_BUILD_DIR"/SOURCES/; \
  119. LIBS=-lrt $(RPMBUILD) -ba --define "_topdir $$RPM_BUILD_DIR" tor.spec; \
  120. cp -fa "$$RPM_BUILD_DIR"/SRPMS/* .; \
  121. cp -fa "$$RPM_BUILD_DIR"/RPMS/* .; \
  122. rm -rf "$$RPM_BUILD_DIR"; \
  123. echo "RPM build finished"; \
  124. #end of dist-rpm
  125. doxygen:
  126. doxygen && cd doc/doxygen/latex && make
  127. test: all
  128. $(top_builddir)/src/test/test
  129. check-local: check-spaces check-changes
  130. need-chutney-path:
  131. @if test ! -d "$$CHUTNEY_PATH"; then \
  132. echo '$$CHUTNEY_PATH was not set.'; \
  133. if test -d $(top_srcdir)/../chutney -a -x $(top_srcdir)/../chutney/chutney; then \
  134. echo "Assuming test-network.sh will find" $(top_srcdir)/../chutney; \
  135. else \
  136. echo; \
  137. echo "To run these tests, git clone https://git.torproject.org/chutney.git ; export CHUTNEY_PATH=\`pwd\`/chutney"; \
  138. exit 1; \
  139. fi \
  140. fi
  141. # Note that test-network requires a copy of Chutney in $CHUTNEY_PATH.
  142. # Chutney can be cloned from https://git.torproject.org/chutney.git .
  143. test-network: need-chutney-path $(TESTING_TOR_BINARY) src/tools/tor-gencert
  144. $(top_srcdir)/src/test/test-network.sh $(TEST_NETWORK_FLAGS)
  145. # Run all available tests using automake's test-driver
  146. # only run IPv6 tests if we can ping6 ::1 (localhost)
  147. # only run IPv6 tests if we can ping ::1 (localhost)
  148. # some IPv6 tests will fail without an IPv6 DNS server (see #16971 and #17011)
  149. # only run mixed tests if we have a tor-stable binary
  150. # Try the syntax for BSD ping6, Linux ping6, and Linux ping -6,
  151. # because they're incompatible
  152. test-network-all: need-chutney-path test-driver $(TESTING_TOR_BINARY) src/tools/tor-gencert
  153. mkdir -p $(TEST_NETWORK_ALL_LOG_DIR)
  154. @flavors="$(TEST_CHUTNEY_FLAVORS)"; \
  155. if ping6 -q -c 1 -o ::1 >/dev/null 2>&1 || ping6 -q -c 1 -W 1 ::1 >/dev/null 2>&1 || ping -6 -c 1 -W 1 ::1 >/dev/null 2>&1; then \
  156. echo "ping6 ::1 or ping ::1 succeeded, running IPv6 flavors: $(TEST_CHUTNEY_FLAVORS_IPV6)."; \
  157. flavors="$$flavors $(TEST_CHUTNEY_FLAVORS_IPV6)"; \
  158. else \
  159. echo "ping6 ::1 and ping ::1 failed, skipping IPv6 flavors: $(TEST_CHUTNEY_FLAVORS_IPV6)."; \
  160. skip_flavors="$$skip_flavors $(TEST_CHUTNEY_FLAVORS_IPV6)"; \
  161. fi; \
  162. if command -v tor-stable >/dev/null 2>&1; then \
  163. echo "tor-stable found, running mixed flavors: $(TEST_CHUTNEY_FLAVORS_MIXED)."; \
  164. flavors="$$flavors $(TEST_CHUTNEY_FLAVORS_MIXED)"; \
  165. else \
  166. echo "tor-stable not found, skipping mixed flavors: $(TEST_CHUTNEY_FLAVORS_MIXED)."; \
  167. skip_flavors="$$skip_flavors $(TEST_CHUTNEY_FLAVORS_MIXED)"; \
  168. fi; \
  169. for f in $$skip_flavors; do \
  170. echo "SKIP: $$f"; \
  171. done; \
  172. for f in $$flavors; do \
  173. $(SHELL) $(top_srcdir)/test-driver --test-name $$f --log-file $(TEST_NETWORK_ALL_LOG_DIR)/$$f.log --trs-file $(TEST_NETWORK_ALL_LOG_DIR)/$$f.trs $(TEST_NETWORK_ALL_DRIVER_FLAGS) $(top_srcdir)/src/test/test-network.sh --flavor $$f $(TEST_NETWORK_FLAGS); \
  174. $(top_srcdir)/src/test/test-network.sh $(TEST_NETWORK_WARNING_FLAGS); \
  175. done; \
  176. echo "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)."; \
  177. ! grep -q FAIL test_network_log/*.trs
  178. need-stem-path:
  179. @if test ! -d "$$STEM_SOURCE_DIR"; then \
  180. echo '$$STEM_SOURCE_DIR was not set.'; echo; \
  181. echo "To run these tests, git clone https://git.torproject.org/stem.git/ ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \
  182. exit 1; \
  183. fi
  184. test-stem: need-stem-path $(TESTING_TOR_BINARY)
  185. @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --all --log notice --target RUN_ALL;
  186. test-stem-full: need-stem-path $(TESTING_TOR_BINARY)
  187. @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --all --log notice --target RUN_ALL,ONLINE -v;
  188. test-full: need-stem-path need-chutney-path check test-network test-stem
  189. test-full-online: need-stem-path need-chutney-path check test-network test-stem-full
  190. reset-gcov:
  191. rm -f $(top_builddir)/src/*/*.gcda $(top_builddir)/src/*/*/*.gcda
  192. HTML_COVER_DIR=$(top_builddir)/coverage_html
  193. coverage-html: all
  194. if COVERAGE_ENABLED
  195. test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
  196. test -d "$(HTML_COVER_DIR)" || $(MKDIR_P) "$(HTML_COVER_DIR)"
  197. lcov --rc lcov_branch_coverage=1 --directory $(top_builddir)/src --zerocounters
  198. $(MAKE) reset-gcov
  199. $(MAKE) check
  200. lcov --capture --rc lcov_branch_coverage=1 --no-external --directory $(top_builddir) --base-directory $(top_srcdir) --output-file "$(HTML_COVER_DIR)/lcov.tmp"
  201. lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
  202. genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
  203. else
  204. @printf "Not configured with --enable-coverage, run ./configure --enable-coverage\n"
  205. endif
  206. coverage-html-full: all
  207. test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
  208. test -d "$(HTML_COVER_DIR)" || mkdir -p "$(HTML_COVER_DIR)"
  209. lcov --rc lcov_branch_coverage=1 --directory ./src --zerocounters
  210. $(MAKE) reset-gcov
  211. $(MAKE) check
  212. $(MAKE) test-stem-full
  213. CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh
  214. CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh --flavor hs
  215. lcov --capture --rc lcov_branch_coverage=1 --no-external --directory . --output-file "$(HTML_COVER_DIR)/lcov.tmp"
  216. lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
  217. genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
  218. # Avoid strlcpy.c, strlcat.c, aes.c, OpenBSD_malloc_Linux.c, sha256.c,
  219. # tinytest*.[ch]
  220. check-spaces:
  221. if USE_PERL
  222. $(PERL) $(top_srcdir)/scripts/maint/checkSpace.pl -C \
  223. $(top_srcdir)/src/common/*.[ch] \
  224. $(top_srcdir)/src/or/*.[ch] \
  225. $(top_srcdir)/src/test/*.[ch] \
  226. $(top_srcdir)/src/test/*/*.[ch] \
  227. $(top_srcdir)/src/tools/*.[ch]
  228. endif
  229. check-docs: all
  230. $(PERL) $(top_builddir)/scripts/maint/checkOptionDocs.pl
  231. check-logs:
  232. $(top_srcdir)/scripts/maint/checkLogs.pl \
  233. $(top_srcdir)/src/*/*.[ch] | sort -n
  234. .PHONY: check-typos
  235. check-typos:
  236. @if test -x "`which misspell 2>&1;true`"; then \
  237. echo "Checking for Typos ..."; \
  238. (misspell \
  239. $(top_srcdir)/src/[^e]*/*.[ch] \
  240. $(top_srcdir)/doc \
  241. $(top_srcdir)/contrib \
  242. $(top_srcdir)/scripts \
  243. $(top_srcdir)/README \
  244. $(top_srcdir)/ChangeLog \
  245. $(top_srcdir)/INSTALL \
  246. $(top_srcdir)/ReleaseNotes \
  247. $(top_srcdir)/LICENSE); \
  248. else \
  249. echo "Tor can use misspell to check for typos."; \
  250. echo "It seems that you don't have misspell installed."; \
  251. echo "You can install the latest version of misspell here: https://github.com/client9/misspell#install"; \
  252. fi
  253. .PHONY: clippy
  254. clippy:
  255. if USE_RUST
  256. @if test -x "`which cargo-clippy 2>&1;true`"; then \
  257. echo "Running cargo clippy ..."; \
  258. echo "Prepare yourself for the onslaught of suggestions ..."; \
  259. (cd "$(top_srcdir)/src/rust" && cargo clippy); \
  260. else \
  261. echo "Tor can use clippy to lint Rust code."; \
  262. echo "However, it seems that you don't have clippy installed."; \
  263. echo "You can install the latest version of clippy by following the directions here: https://github.com/rust-lang-nursery/rust-clippy"; \
  264. fi
  265. endif
  266. .PHONY: check-changes
  267. check-changes:
  268. if USEPYTHON
  269. @if test -d "$(top_srcdir)/changes"; then \
  270. $(PYTHON) $(top_srcdir)/scripts/maint/lintChanges.py $(top_srcdir)/changes; \
  271. fi
  272. endif
  273. .PHONY: update-versions
  274. update-versions:
  275. $(PERL) $(top_builddir)/scripts/maint/updateVersions.pl
  276. .PHONY: callgraph
  277. callgraph:
  278. $(top_builddir)/scripts/maint/run_calltool.sh
  279. version:
  280. @echo "Tor @VERSION@"
  281. @if test -d "$(top_srcdir)/.git" && test -x "`which git 2>&1;true`"; then \
  282. echo -n "git: " ;\
  283. (cd "$(top_srcdir)" && git rev-parse --short=16 HEAD); \
  284. fi
  285. mostlyclean-local:
  286. rm -f $(top_builddir)/src/*/*.gc{da,no} $(top_builddir)/src/*/*/*.gc{da,no}
  287. rm -rf $(HTML_COVER_DIR)
  288. rm -rf $(top_builddir)/doc/doxygen
  289. rm -rf $(TEST_NETWORK_ALL_LOG_DIR)
  290. clean-local:
  291. rm -rf $(top_builddir)/src/rust/target
  292. rm -rf $(top_builddir)/src/rust/.cargo/registry
  293. if USE_RUST
  294. distclean-local: distclean-rust
  295. endif
  296. # This relies on some internal details of how automake implements
  297. # distcheck. We check two directories because automake-1.15 changed
  298. # from $(distdir)/_build to $(distdir)/_build/sub.
  299. show-distdir-testlog:
  300. @if test -d "$(distdir)/_build/sub"; then \
  301. cat $(distdir)/_build/sub/$(TEST_SUITE_LOG); \
  302. else \
  303. cat $(distdir)/_build/$(TEST_SUITE_LOG); fi