Makefile.am 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. # Copyright (c) 2001-2004, Roger Dingledine
  2. # Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
  3. # Copyright (c) 2007-2017, 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. AM_CFLAGS=@TOR_SYSTEMD_CFLAGS@ @CFLAGS_BUGTRAP@ @TOR_LZMA_CFLAGS@ @TOR_ZSTD_CFLAGS@
  18. SHELL=@SHELL@
  19. if COVERAGE_ENABLED
  20. TESTING_TOR_BINARY=$(top_builddir)/src/or/tor-cov$(EXEEXT)
  21. else
  22. TESTING_TOR_BINARY=$(top_builddir)/src/or/tor$(EXEEXT)
  23. endif
  24. if USE_RUST
  25. rust_ldadd=$(top_builddir)/src/rust/target/release/@TOR_RUST_STATIC_NAME@
  26. else
  27. rust_ldadd=
  28. endif
  29. include src/include.am
  30. include doc/include.am
  31. include contrib/include.am
  32. EXTRA_DIST+= \
  33. ChangeLog \
  34. INSTALL \
  35. LICENSE \
  36. Makefile.nmake \
  37. README \
  38. ReleaseNotes \
  39. scripts/maint/checkSpace.pl
  40. ## This tells etags how to find mockable function definitions.
  41. AM_ETAGSFLAGS=--regex='{c}/MOCK_IMPL([^,]+,\W*\([a-zA-Z0-9_]+\)\W*,/\1/s'
  42. if COVERAGE_ENABLED
  43. TEST_CFLAGS=-fno-inline -fprofile-arcs -ftest-coverage
  44. if DISABLE_ASSERTS_IN_UNIT_TESTS
  45. TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE -DDISABLE_ASSERTS_IN_UNIT_TESTS
  46. else
  47. TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE
  48. endif
  49. TEST_NETWORK_FLAGS=--coverage --hs-multi-client 1
  50. else
  51. TEST_CFLAGS=
  52. TEST_CPPFLAGS=-DTOR_UNIT_TESTS
  53. TEST_NETWORK_FLAGS=--hs-multi-client 1
  54. endif
  55. TEST_NETWORK_WARNING_FLAGS=--quiet --only-warnings
  56. if LIBFUZZER_ENABLED
  57. TEST_CFLAGS += -fsanitize-coverage=trace-pc-guard,trace-cmp,trace-div
  58. # not "edge"
  59. endif
  60. TEST_NETWORK_ALL_LOG_DIR=$(top_builddir)/test_network_log
  61. TEST_NETWORK_ALL_DRIVER_FLAGS=--color-tests yes
  62. #install-data-local:
  63. # $(INSTALL) -m 755 -d $(LOCALSTATEDIR)/lib/tor
  64. # Allows to override rpmbuild with rpmbuild-md5 from fedora-packager so that
  65. # building for EL5 won't fail on https://bugzilla.redhat.com/show_bug.cgi?id=490613
  66. RPMBUILD ?= rpmbuild
  67. # Use automake's dist-gzip target to build the tarball
  68. dist-rpm: dist-gzip
  69. TIMESTAMP=$$(date +"%Y-%m-%d_%H.%M.%S"); \
  70. RPM_BUILD_DIR=$$(mktemp -d "/tmp/tor-rpm-build-$$TIMESTAMP-XXXX"); \
  71. mkdir -p "$$RPM_BUILD_DIR"/{BUILD,RPMS,SOURCES/"tor-$(VERSION)",SPECS,SRPMS}; \
  72. cp -fa "$(distdir).tar.gz" "$$RPM_BUILD_DIR"/SOURCES/; \
  73. LIBS=-lrt $(RPMBUILD) -ba --define "_topdir $$RPM_BUILD_DIR" tor.spec; \
  74. cp -fa "$$RPM_BUILD_DIR"/SRPMS/* .; \
  75. cp -fa "$$RPM_BUILD_DIR"/RPMS/* .; \
  76. rm -rf "$$RPM_BUILD_DIR"; \
  77. echo "RPM build finished"; \
  78. #end of dist-rpm
  79. doxygen:
  80. doxygen && cd doc/doxygen/latex && make
  81. test: all
  82. $(top_builddir)/src/test/test
  83. check-local: check-spaces check-changes
  84. need-chutney-path:
  85. @if test ! -d "$$CHUTNEY_PATH"; then \
  86. echo '$$CHUTNEY_PATH was not set.'; \
  87. if test -d $(top_srcdir)/../chutney -a -x $(top_srcdir)/../chutney/chutney; then \
  88. echo "Assuming test-network.sh will find" $(top_srcdir)/../chutney; \
  89. else \
  90. echo; \
  91. echo "To run these tests, git clone https://git.torproject.org/chutney.git ; export CHUTNEY_PATH=\`pwd\`/chutney"; \
  92. exit 1; \
  93. fi \
  94. fi
  95. # Note that test-network requires a copy of Chutney in $CHUTNEY_PATH.
  96. # Chutney can be cloned from https://git.torproject.org/chutney.git .
  97. test-network: need-chutney-path $(TESTING_TOR_BINARY) src/tools/tor-gencert
  98. $(top_srcdir)/src/test/test-network.sh $(TEST_NETWORK_FLAGS)
  99. # Run all available tests using automake's test-driver
  100. # only run IPv6 tests if we can ping6 ::1 (localhost)
  101. # some IPv6 tests will fail without an IPv6 DNS server (see #16971 and #17011)
  102. # only run mixed tests if we have a tor-stable binary
  103. # Try both the BSD and the Linux ping6 syntax, because they're incompatible
  104. test-network-all: need-chutney-path test-driver $(TESTING_TOR_BINARY) src/tools/tor-gencert
  105. mkdir -p $(TEST_NETWORK_ALL_LOG_DIR)
  106. @flavors="$(TEST_CHUTNEY_FLAVORS)"; \
  107. if ping6 -q -c 1 -o ::1 >/dev/null 2>&1 || ping6 -q -c 1 -W 1 ::1 >/dev/null 2>&1; then \
  108. echo "ping6 ::1 succeeded, running IPv6 flavors: $(TEST_CHUTNEY_FLAVORS_IPV6)."; \
  109. flavors="$$flavors $(TEST_CHUTNEY_FLAVORS_IPV6)"; \
  110. else \
  111. echo "ping6 ::1 failed, skipping IPv6 flavors: $(TEST_CHUTNEY_FLAVORS_IPV6)."; \
  112. skip_flavors="$$skip_flavors $(TEST_CHUTNEY_FLAVORS_IPV6)"; \
  113. fi; \
  114. if command -v tor-stable >/dev/null 2>&1; then \
  115. echo "tor-stable found, running mixed flavors: $(TEST_CHUTNEY_FLAVORS_MIXED)."; \
  116. flavors="$$flavors $(TEST_CHUTNEY_FLAVORS_MIXED)"; \
  117. else \
  118. echo "tor-stable not found, skipping mixed flavors: $(TEST_CHUTNEY_FLAVORS_MIXED)."; \
  119. skip_flavors="$$skip_flavors $(TEST_CHUTNEY_FLAVORS_MIXED)"; \
  120. fi; \
  121. for f in $$skip_flavors; do \
  122. echo "SKIP: $$f"; \
  123. done; \
  124. for f in $$flavors; do \
  125. $(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); \
  126. $(top_srcdir)/src/test/test-network.sh $(TEST_NETWORK_WARNING_FLAGS); \
  127. done; \
  128. echo "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)."; \
  129. ! grep -q FAIL test_network_log/*.trs
  130. need-stem-path:
  131. @if test ! -d "$$STEM_SOURCE_DIR"; then \
  132. echo '$$STEM_SOURCE_DIR was not set.'; echo; \
  133. echo "To run these tests, git clone https://git.torproject.org/stem.git/ ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \
  134. exit 1; \
  135. fi
  136. test-stem: need-stem-path $(TESTING_TOR_BINARY)
  137. @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --all --log notice --target RUN_ALL;
  138. test-stem-full: need-stem-path $(TESTING_TOR_BINARY)
  139. @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --all --log notice --target RUN_ALL,ONLINE -v;
  140. test-full: need-stem-path need-chutney-path check test-network test-stem
  141. test-full-online: need-stem-path need-chutney-path check test-network test-stem-full
  142. reset-gcov:
  143. rm -f $(top_builddir)/src/*/*.gcda $(top_builddir)/src/*/*/*.gcda
  144. HTML_COVER_DIR=$(top_builddir)/coverage_html
  145. coverage-html: all
  146. if COVERAGE_ENABLED
  147. test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
  148. test -d "$(HTML_COVER_DIR)" || $(MKDIR_P) "$(HTML_COVER_DIR)"
  149. lcov --rc lcov_branch_coverage=1 --directory $(top_builddir)/src --zerocounters
  150. $(MAKE) reset-gcov
  151. $(MAKE) check
  152. lcov --capture --rc lcov_branch_coverage=1 --no-external --directory $(top_builddir) --base-directory $(top_srcdir) --output-file "$(HTML_COVER_DIR)/lcov.tmp"
  153. lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
  154. genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
  155. else
  156. @printf "Not configured with --enable-coverage, run ./configure --enable-coverage\n"
  157. endif
  158. coverage-html-full: all
  159. test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
  160. test -d "$(HTML_COVER_DIR)" || mkdir -p "$(HTML_COVER_DIR)"
  161. lcov --rc lcov_branch_coverage=1 --directory ./src --zerocounters
  162. $(MAKE) reset-gcov
  163. $(MAKE) check
  164. $(MAKE) test-stem-full
  165. CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh
  166. CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh --flavor hs
  167. lcov --capture --rc lcov_branch_coverage=1 --no-external --directory . --output-file "$(HTML_COVER_DIR)/lcov.tmp"
  168. lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
  169. genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
  170. # Avoid strlcpy.c, strlcat.c, aes.c, OpenBSD_malloc_Linux.c, sha256.c,
  171. # tinytest*.[ch]
  172. check-spaces:
  173. if USE_PERL
  174. $(PERL) $(top_srcdir)/scripts/maint/checkSpace.pl -C \
  175. $(top_srcdir)/src/common/*.[ch] \
  176. $(top_srcdir)/src/or/*.[ch] \
  177. $(top_srcdir)/src/test/*.[ch] \
  178. $(top_srcdir)/src/test/*/*.[ch] \
  179. $(top_srcdir)/src/tools/*.[ch]
  180. endif
  181. check-docs: all
  182. $(PERL) $(top_builddir)/scripts/maint/checkOptionDocs.pl
  183. check-logs:
  184. $(top_srcdir)/scripts/maint/checkLogs.pl \
  185. $(top_srcdir)/src/*/*.[ch] | sort -n
  186. .PHONY: check-changes
  187. check-changes:
  188. if USEPYTHON
  189. @if test -d "$(top_srcdir)/changes"; then \
  190. $(PYTHON) $(top_srcdir)/scripts/maint/lintChanges.py $(top_srcdir)/changes; \
  191. fi
  192. endif
  193. .PHONY: update-versions
  194. update-versions:
  195. $(PERL) $(top_builddir)/scripts/maint/updateVersions.pl
  196. .PHONY: callgraph
  197. callgraph:
  198. $(top_builddir)/scripts/maint/run_calltool.sh
  199. version:
  200. @echo "Tor @VERSION@"
  201. @if test -d "$(top_srcdir)/.git" && test -x "`which git 2>&1;true`"; then \
  202. echo -n "git: " ;\
  203. (cd "$(top_srcdir)" && git rev-parse --short=16 HEAD); \
  204. fi
  205. mostlyclean-local:
  206. rm -f $(top_builddir)/src/*/*.gc{da,no} $(top_builddir)/src/*/*/*.gc{da,no}
  207. rm -rf $(HTML_COVER_DIR)
  208. rm -rf $(top_builddir)/doc/doxygen
  209. rm -rf $(TEST_NETWORK_ALL_LOG_DIR)
  210. clean-local:
  211. rm -rf $(top_builddir)/src/rust/target
  212. rm -rf $(top_builddir)/src/rust/.cargo/registry
  213. if USE_RUST
  214. distclean-local: distclean-rust
  215. endif