Makefile.am 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. # Copyright (c) 2001-2004, Roger Dingledine
  2. # Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
  3. # Copyright (c) 2007-2015, The Tor Project, Inc.
  4. # See LICENSE for licensing information
  5. # "foreign" means we don't follow GNU package layout standards
  6. # 1.9 means we require automake vesion 1.9
  7. AUTOMAKE_OPTIONS = foreign 1.9 subdir-objects
  8. ACLOCAL_AMFLAGS = -I m4
  9. noinst_LIBRARIES=
  10. EXTRA_DIST=
  11. noinst_HEADERS=
  12. bin_PROGRAMS=
  13. CLEANFILES=
  14. TESTS=
  15. noinst_PROGRAMS=
  16. DISTCLEANFILES=
  17. bin_SCRIPTS=
  18. AM_CPPFLAGS=
  19. AM_CFLAGS = @TOR_SYSTEMD_CFLAGS@
  20. SHELL = @SHELL@
  21. include src/include.am
  22. include doc/include.am
  23. include contrib/include.am
  24. EXTRA_DIST+= \
  25. ChangeLog \
  26. INSTALL \
  27. LICENSE \
  28. Makefile.nmake \
  29. README \
  30. ReleaseNotes
  31. if COVERAGE_ENABLED
  32. TEST_CFLAGS=-fno-inline -fprofile-arcs -ftest-coverage
  33. TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE
  34. TEST_NETWORK_FLAGS=--coverage --hs-multi-client 1
  35. else
  36. TEST_CFLAGS=
  37. TEST_CPPFLAGS=-DTOR_UNIT_TESTS
  38. TEST_NETWORK_FLAGS=--hs-multi-client 1
  39. endif
  40. TEST_NETWORK_ALL_LOG_DIR=$(top_builddir)/test_network_log
  41. TEST_NETWORK_ALL_DRIVER_FLAGS=--color-tests yes
  42. #install-data-local:
  43. # $(INSTALL) -m 755 -d $(LOCALSTATEDIR)/lib/tor
  44. # Allows to override rpmbuild with rpmbuild-md5 from fedora-packager so that
  45. # building for EL5 won't fail on https://bugzilla.redhat.com/show_bug.cgi?id=490613
  46. RPMBUILD ?= rpmbuild
  47. # Use automake's dist-gzip target to build the tarball
  48. dist-rpm: dist-gzip
  49. TIMESTAMP=$$(date +"%Y-%m-%d_%H.%M.%S"); \
  50. RPM_BUILD_DIR=$$(mktemp -d "/tmp/tor-rpm-build-$$TIMESTAMP-XXXX"); \
  51. mkdir -p "$$RPM_BUILD_DIR"/{BUILD,RPMS,SOURCES/"tor-$(VERSION)",SPECS,SRPMS}; \
  52. cp -fa "$(distdir).tar.gz" "$$RPM_BUILD_DIR"/SOURCES/; \
  53. LIBS=-lrt $(RPMBUILD) -ba --define "_topdir $$RPM_BUILD_DIR" tor.spec; \
  54. cp -fa "$$RPM_BUILD_DIR"/SRPMS/* .; \
  55. cp -fa "$$RPM_BUILD_DIR"/RPMS/* .; \
  56. rm -rf "$$RPM_BUILD_DIR"; \
  57. echo "RPM build finished"; \
  58. #end of dist-rpm
  59. dist: check
  60. doxygen:
  61. doxygen && cd doc/doxygen/latex && make
  62. test: all
  63. $(top_builddir)/src/test/test
  64. need-chutney-path:
  65. @if test ! -d "$$CHUTNEY_PATH"; then \
  66. echo '$$CHUTNEY_PATH was not set.'; \
  67. if test -d $(top_srcdir)/../chutney -a -x $(top_srcdir)/../chutney/chutney; then \
  68. echo "Assuming test-network.sh will find" $(top_srcdir)/../chutney; \
  69. else \
  70. echo; \
  71. echo "To run these tests, git clone https://git.torproject.org/chutney.git ; export CHUTNEY_PATH=\`pwd\`/chutney"; \
  72. exit 1; \
  73. fi \
  74. fi
  75. # Note that test-network requires a copy of Chutney in $CHUTNEY_PATH.
  76. # Chutney can be cloned from https://git.torproject.org/chutney.git .
  77. test-network: need-chutney-path all
  78. $(top_srcdir)/src/test/test-network.sh $(TEST_NETWORK_FLAGS)
  79. # Run all available tests using automake's test-driver
  80. # only run IPv6 tests if we can ping6 ::1 (localhost)
  81. # some IPv6 tests will fail without an IPv6 DNS server (see #16971 and #17011)
  82. # only run mixed tests if we have a tor-stable binary
  83. # see #17015 for autodetection of different tor versions
  84. test-network-all: need-chutney-path all test-driver
  85. mkdir -p $(TEST_NETWORK_ALL_LOG_DIR)
  86. @flavors="$(TEST_CHUTNEY_FLAVORS)"; \
  87. if ping6 -q -o ::1 >/dev/null 2>&1; then \
  88. echo "ping6 ::1 succeeded, running IPv6 flavors: $(TEST_CHUTNEY_FLAVORS_IPV6)."; \
  89. flavors="$$flavors $(TEST_CHUTNEY_FLAVORS_IPV6)"; \
  90. else \
  91. echo "ping6 ::1 failed, skipping IPv6 flavors: $(TEST_CHUTNEY_FLAVORS_IPV6)."; \
  92. skip_flavors="$$skip_flavors $(TEST_CHUTNEY_FLAVORS_IPV6)"; \
  93. fi; \
  94. if command -v tor-stable >/dev/null 2>&1; then \
  95. echo "tor-stable found, running mixed flavors: $(TEST_CHUTNEY_FLAVORS_MIXED)."; \
  96. flavors="$$flavors $(TEST_CHUTNEY_FLAVORS_MIXED)"; \
  97. else \
  98. echo "tor-stable not found, skipping mixed flavors: $(TEST_CHUTNEY_FLAVORS_MIXED)."; \
  99. skip_flavors="$$skip_flavors $(TEST_CHUTNEY_FLAVORS_MIXED)"; \
  100. fi; \
  101. for f in $$skip_flavors; do \
  102. echo "SKIP: $$f"; \
  103. done; \
  104. for f in $$flavors; do \
  105. ./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); \
  106. done; \
  107. echo "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)."; \
  108. ! grep -q FAIL test_network_log/*.trs
  109. need-stem-path:
  110. @if test ! -d "$$STEM_SOURCE_DIR"; then \
  111. echo '$$STEM_SOURCE_DIR was not set.'; echo; \
  112. echo "To run these tests, git clone https://git.torproject.org/stem.git/ ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \
  113. exit 1; \
  114. fi
  115. test-stem: need-stem-path $(TESTING_TOR_BINARY)
  116. @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor $(TESTING_TOR_BINARY) --all --log notice --target RUN_ALL;
  117. test-stem-full: need-stem-path $(TESTING_TOR_BINARY)
  118. @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor $(TESTING_TOR_BINARY) --all --log notice --target RUN_ALL,ONLINE -v;
  119. test-full: need-stem-path need-chutney-path check test-network test-stem
  120. test-full-online: need-stem-path need-chutney-path check test-network test-stem-full
  121. reset-gcov:
  122. rm -f $(top_builddir)/src/*/*.gcda $(top_builddir)/src/*/*/*.gcda
  123. HTML_COVER_DIR=$(top_builddir)/coverage_html
  124. coverage-html: all
  125. if COVERAGE_ENABLED
  126. test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
  127. test -d "$(HTML_COVER_DIR)" || $(MKDIR_P) "$(HTML_COVER_DIR)"
  128. lcov --rc lcov_branch_coverage=1 --directory $(top_builddir)/src --zerocounters
  129. $(MAKE) reset-gcov
  130. $(MAKE) check
  131. lcov --capture --rc lcov_branch_coverage=1 --no-external --directory $(top_builddir) --base-directory $(top_srcdir) --output-file "$(HTML_COVER_DIR)/lcov.tmp"
  132. lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
  133. genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
  134. else
  135. @printf "Not configured with --enable-coverage, run ./configure --enable-coverage\n"
  136. endif
  137. coverage-html-full: all
  138. test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
  139. test -d "$(HTML_COVER_DIR)" || mkdir -p "$(HTML_COVER_DIR)"
  140. lcov --rc lcov_branch_coverage=1 --directory ./src --zerocounters
  141. $(MAKE) reset-gcov
  142. $(MAKE) check
  143. $(MAKE) test-stem-full
  144. CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh
  145. CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh --flavor hs
  146. lcov --capture --rc lcov_branch_coverage=1 --no-external --directory . --output-file "$(HTML_COVER_DIR)/lcov.tmp"
  147. lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
  148. genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
  149. # Avoid strlcpy.c, strlcat.c, aes.c, OpenBSD_malloc_Linux.c, sha256.c,
  150. # eventdns.[hc], tinytest*.[ch]
  151. check-spaces:
  152. $(top_srcdir)/scripts/maint/checkSpace.pl -C \
  153. $(top_srcdir)/src/common/*.[ch] \
  154. $(top_srcdir)/src/or/*.[ch] \
  155. $(top_srcdir)/src/test/*.[ch] \
  156. $(top_srcdir)/src/tools/*.[ch]
  157. check-docs: all
  158. $(PERL) $(top_builddir)/scripts/maint/checkOptionDocs.pl
  159. check-logs:
  160. $(top_srcdir)/scripts/maint/checkLogs.pl \
  161. $(top_srcdir)/src/*/*.[ch] | sort -n
  162. .PHONY: check-changes
  163. check-changes:
  164. @if test -d "$(top_srcdir)/changes"; then \
  165. $(PYTHON) $(top_srcdir)/scripts/maint/lintChanges.py $(top_srcdir)/changes/*; \
  166. fi
  167. .PHONY: update-versions
  168. update-versions:
  169. $(PERL) $(top_builddir)/scripts/maint/updateVersions.pl
  170. version:
  171. @echo "Tor @VERSION@"
  172. @if test -d "$(top_srcdir)/.git" && test -x "`which git 2>&1;true`"; then \
  173. echo -n "git: " ;\
  174. (cd "$(top_srcdir)" && git rev-parse --short=16 HEAD); \
  175. fi
  176. mostlyclean-local:
  177. rm -f $(top_builddir)/src/*/*.gc{da,no} $(top_builddir)/src/*/*/*.gc{da,no}
  178. rm -rf $(HTML_COVER_DIR)
  179. rm -rf $(top_builddir)/doc/doxygen
  180. rm -rf $(TEST_NETWORK_ALL_LOG_DIR)