Makefile.am 8.0 KB

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