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
6 ACLOCAL_AMFLAGS = -I m4
20 -I$(top_srcdir)/src/ext \
21 -I$(top_srcdir)/src/ext/trunnel \
22 -I$(top_srcdir)/src/trunnel
24 AM_CFLAGS=@TOR_SYSTEMD_CFLAGS@ @CFLAGS_BUGTRAP@ @TOR_LZMA_CFLAGS@ @TOR_ZSTD_CFLAGS@
28 TESTING_TOR_BINARY=$(top_builddir)/src/app/tor-cov$(EXEEXT)
30 TESTING_TOR_BINARY=$(top_builddir)/src/app/tor$(EXEEXT)
34 ## this MUST be $(), otherwise am__DEPENDENCIES will not track it
35 rust_ldadd=$(top_builddir)/$(TOR_RUST_LIB_PATH) \
36 $(TOR_RUST_EXTRA_LIBS)
41 # "Common" libraries used to link tor's utility code.
43 src/lib/libtor-process.a \
44 src/lib/libtor-time.a \
46 src/lib/libtor-encoding.a \
47 src/lib/libtor-sandbox.a \
48 src/lib/libtor-container.a \
49 src/lib/libtor-net.a \
50 src/lib/libtor-thread.a \
51 src/lib/libtor-memarea.a \
52 src/lib/libtor-math.a \
53 src/lib/libtor-meminfo.a \
54 src/lib/libtor-osinfo.a \
55 src/lib/libtor-log.a \
56 src/lib/libtor-lock.a \
57 src/lib/libtor-fdio.a \
58 src/lib/libtor-string.a \
59 src/lib/libtor-term.a \
60 src/lib/libtor-smartlist-core.a \
61 src/lib/libtor-malloc.a \
62 src/lib/libtor-wallclock.a \
63 src/lib/libtor-err.a \
64 src/lib/libtor-intmath.a \
65 src/lib/libtor-ctime.a
67 # Variants of the above for linking the testing variant of tor (for coverage
69 TOR_UTIL_TESTING_LIBS = \
70 src/lib/libtor-process-testing.a \
71 src/lib/libtor-time-testing.a \
72 src/lib/libtor-fs-testing.a \
73 src/lib/libtor-encoding-testing.a \
74 src/lib/libtor-sandbox-testing.a \
75 src/lib/libtor-container-testing.a \
76 src/lib/libtor-net-testing.a \
77 src/lib/libtor-thread-testing.a \
78 src/lib/libtor-memarea-testing.a \
79 src/lib/libtor-math-testing.a \
80 src/lib/libtor-meminfo-testing.a \
81 src/lib/libtor-osinfo-testing.a \
82 src/lib/libtor-term-testing.a \
83 src/lib/libtor-log-testing.a \
84 src/lib/libtor-lock-testing.a \
85 src/lib/libtor-fdio-testing.a \
86 src/lib/libtor-string-testing.a \
87 src/lib/libtor-smartlist-core-testing.a \
88 src/lib/libtor-malloc-testing.a \
89 src/lib/libtor-wallclock-testing.a \
90 src/lib/libtor-err-testing.a \
91 src/lib/libtor-intmath.a \
92 src/lib/libtor-ctime-testing.a
94 # Internal crypto libraries used in Tor
96 src/lib/libtor-tls.a \
97 src/lib/libtor-crypt-ops.a \
101 # Variants of the above for linking the testing variant of tor (for coverage
103 TOR_CRYPTO_TESTING_LIBS = \
104 src/lib/libtor-tls-testing.a \
105 src/lib/libtor-crypt-ops-testing.a \
109 # All static libraries used to link tor.
110 TOR_INTERNAL_LIBS = \
111 src/core/libtor-app.a \
112 src/lib/libtor-compress.a \
113 src/lib/libtor-evloop.a \
116 src/trunnel/libor-trunnel.a \
117 src/lib/libtor-trace.a
119 # Variants of the above for linking the testing variant of tor (for coverage
121 TOR_INTERNAL_TESTING_LIBS = \
122 src/core/libtor-app-testing.a \
123 src/lib/libtor-compress-testing.a \
124 src/lib/libtor-evloop-testing.a \
125 $(TOR_CRYPTO_TESTING_LIBS) \
126 $(TOR_UTIL_TESTING_LIBS) \
127 src/trunnel/libor-trunnel-testing.a \
128 src/lib/libtor-trace.a
130 # All libraries used to link tor-cov
132 include src/include.am
133 include doc/include.am
134 include contrib/include.am
145 scripts/maint/checkIncludes.py \
146 scripts/maint/checkSpace.pl
148 ## This tells etags how to find mockable function definitions.
149 AM_ETAGSFLAGS=--regex='{c}/MOCK_IMPL([^,]+,\W*\([a-zA-Z0-9_]+\)\W*,/\1/s'
152 TEST_CFLAGS=-fno-inline -fprofile-arcs -ftest-coverage
153 if DISABLE_ASSERTS_IN_UNIT_TESTS
154 TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE -DDISABLE_ASSERTS_IN_UNIT_TESTS @TOR_MODULES_ALL_ENABLED@
156 TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE @TOR_MODULES_ALL_ENABLED@
158 TEST_NETWORK_FLAGS=--coverage --hs-multi-client 1
161 TEST_CPPFLAGS=-DTOR_UNIT_TESTS @TOR_MODULES_ALL_ENABLED@
162 TEST_NETWORK_FLAGS=--hs-multi-client 1
164 TEST_NETWORK_WARNING_FLAGS=--quiet --only-warnings
167 TEST_CFLAGS += -fsanitize-coverage=trace-pc-guard,trace-cmp,trace-div
171 TEST_NETWORK_ALL_LOG_DIR=$(top_builddir)/test_network_log
172 TEST_NETWORK_ALL_DRIVER_FLAGS=--color-tests yes
175 # $(INSTALL) -m 755 -d $(LOCALSTATEDIR)/lib/tor
177 # Allows to override rpmbuild with rpmbuild-md5 from fedora-packager so that
178 # building for EL5 won't fail on https://bugzilla.redhat.com/show_bug.cgi?id=490613
181 # Use automake's dist-gzip target to build the tarball
183 TIMESTAMP=$$(date +"%Y-%m-%d_%H.%M.%S"); \
184 RPM_BUILD_DIR=$$(mktemp -d "/tmp/tor-rpm-build-$$TIMESTAMP-XXXX"); \
185 mkdir -p "$$RPM_BUILD_DIR"/{BUILD,RPMS,SOURCES/"tor-$(VERSION)",SPECS,SRPMS}; \
186 cp -fa "$(distdir).tar.gz" "$$RPM_BUILD_DIR"/SOURCES/; \
187 LIBS=-lrt $(RPMBUILD) -ba --define "_topdir $$RPM_BUILD_DIR" tor.spec; \
188 cp -fa "$$RPM_BUILD_DIR"/SRPMS/* .; \
189 cp -fa "$$RPM_BUILD_DIR"/RPMS/* .; \
190 rm -rf "$$RPM_BUILD_DIR"; \
191 echo "RPM build finished"; \
195 doxygen && cd doc/doxygen/latex && make
198 $(top_builddir)/src/test/test
200 check-local: check-spaces check-changes
203 @if test ! -d "$$CHUTNEY_PATH"; then \
204 echo '$$CHUTNEY_PATH was not set.'; \
205 if test -d $(top_srcdir)/../chutney -a -x $(top_srcdir)/../chutney/chutney; then \
206 echo "Assuming test-network.sh will find" $(top_srcdir)/../chutney; \
209 echo "To run these tests, git clone https://git.torproject.org/chutney.git ; export CHUTNEY_PATH=\`pwd\`/chutney"; \
214 # Note that test-network requires a copy of Chutney in $CHUTNEY_PATH.
215 # Chutney can be cloned from https://git.torproject.org/chutney.git .
216 test-network: need-chutney-path $(TESTING_TOR_BINARY) src/tools/tor-gencert
217 $(top_srcdir)/src/test/test-network.sh $(TEST_NETWORK_FLAGS)
219 # Run all available tests using automake's test-driver
220 # only run IPv6 tests if we can ping6 ::1 (localhost)
221 # only run IPv6 tests if we can ping ::1 (localhost)
222 # some IPv6 tests will fail without an IPv6 DNS server (see #16971 and #17011)
223 # only run mixed tests if we have a tor-stable binary
224 # Try the syntax for BSD ping6, Linux ping6, and Linux ping -6,
225 # because they're incompatible
226 test-network-all: need-chutney-path test-driver $(TESTING_TOR_BINARY) src/tools/tor-gencert
227 mkdir -p $(TEST_NETWORK_ALL_LOG_DIR)
228 @flavors="$(TEST_CHUTNEY_FLAVORS)"; \
229 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 \
230 echo "ping6 ::1 or ping ::1 succeeded, running IPv6 flavors: $(TEST_CHUTNEY_FLAVORS_IPV6)."; \
231 flavors="$$flavors $(TEST_CHUTNEY_FLAVORS_IPV6)"; \
233 echo "ping6 ::1 and ping ::1 failed, skipping IPv6 flavors: $(TEST_CHUTNEY_FLAVORS_IPV6)."; \
234 skip_flavors="$$skip_flavors $(TEST_CHUTNEY_FLAVORS_IPV6)"; \
236 if command -v tor-stable >/dev/null 2>&1; then \
237 echo "tor-stable found, running mixed flavors: $(TEST_CHUTNEY_FLAVORS_MIXED)."; \
238 flavors="$$flavors $(TEST_CHUTNEY_FLAVORS_MIXED)"; \
240 echo "tor-stable not found, skipping mixed flavors: $(TEST_CHUTNEY_FLAVORS_MIXED)."; \
241 skip_flavors="$$skip_flavors $(TEST_CHUTNEY_FLAVORS_MIXED)"; \
243 for f in $$skip_flavors; do \
246 for f in $$flavors; do \
247 $(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); \
248 $(top_srcdir)/src/test/test-network.sh $(TEST_NETWORK_WARNING_FLAGS); \
250 echo "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)."; \
251 ! grep -q FAIL test_network_log/*.trs
254 @if test ! -d "$$STEM_SOURCE_DIR"; then \
255 echo '$$STEM_SOURCE_DIR was not set.'; echo; \
256 echo "To run these tests, git clone https://git.torproject.org/stem.git/ ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \
260 test-stem: need-stem-path $(TESTING_TOR_BINARY)
261 @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --all --log notice --target RUN_ALL;
263 test-stem-full: need-stem-path $(TESTING_TOR_BINARY)
264 @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --all --log notice --target RUN_ALL,ONLINE -v;
266 test-full: need-stem-path need-chutney-path check test-network test-stem
268 test-full-online: need-stem-path need-chutney-path check test-network test-stem-full
271 rm -f $(top_builddir)/src/*/*.gcda $(top_builddir)/src/*/*/*.gcda
273 HTML_COVER_DIR=$(top_builddir)/coverage_html
276 test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
277 test -d "$(HTML_COVER_DIR)" || $(MKDIR_P) "$(HTML_COVER_DIR)"
278 lcov --rc lcov_branch_coverage=1 --directory $(top_builddir)/src --zerocounters
281 lcov --capture --rc lcov_branch_coverage=1 --no-external --directory $(top_builddir) --base-directory $(top_srcdir) --output-file "$(HTML_COVER_DIR)/lcov.tmp"
282 lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
283 genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
285 @printf "Not configured with --enable-coverage, run ./configure --enable-coverage\n"
288 coverage-html-full: all
289 test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
290 test -d "$(HTML_COVER_DIR)" || mkdir -p "$(HTML_COVER_DIR)"
291 lcov --rc lcov_branch_coverage=1 --directory ./src --zerocounters
294 $(MAKE) test-stem-full
295 CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh
296 CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh --flavor hs
297 lcov --capture --rc lcov_branch_coverage=1 --no-external --directory . --output-file "$(HTML_COVER_DIR)/lcov.tmp"
298 lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
299 genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
301 # Avoid strlcpy.c, strlcat.c, aes.c, OpenBSD_malloc_Linux.c, sha256.c,
305 $(PERL) $(top_srcdir)/scripts/maint/checkSpace.pl -C \
306 $(top_srcdir)/src/lib/*/*.[ch] \
307 $(top_srcdir)/src/core/*/*.[ch] \
308 $(top_srcdir)/src/feature/*/*.[ch] \
309 $(top_srcdir)/src/app/*/*.[ch] \
310 $(top_srcdir)/src/test/*.[ch] \
311 $(top_srcdir)/src/test/*/*.[ch] \
312 $(top_srcdir)/src/tools/*.[ch]
317 $(top_srcdir)/scripts/maint/checkIncludes.py
321 $(PERL) $(top_builddir)/scripts/maint/checkOptionDocs.pl
324 $(top_srcdir)/scripts/maint/checkLogs.pl \
325 $(top_srcdir)/src/*/*.[ch] | sort -n
329 @if test -x "`which misspell 2>&1;true`"; then \
330 echo "Checking for Typos ..."; \
332 $(top_srcdir)/src/[^e]*/*.[ch] \
334 $(top_srcdir)/contrib \
335 $(top_srcdir)/scripts \
336 $(top_srcdir)/README \
337 $(top_srcdir)/ChangeLog \
338 $(top_srcdir)/INSTALL \
339 $(top_srcdir)/ReleaseNotes \
340 $(top_srcdir)/LICENSE); \
342 echo "Tor can use misspell to check for typos."; \
343 echo "It seems that you don't have misspell installed."; \
344 echo "You can install the latest version of misspell here: https://github.com/client9/misspell#install"; \
350 @if test -x "`which cargo-clippy 2>&1;true`"; then \
351 echo "Running cargo clippy ..."; \
352 echo "Prepare yourself for the onslaught of suggestions ..."; \
353 (cd "$(top_srcdir)/src/rust" && cargo clippy); \
355 echo "Tor can use clippy to lint Rust code."; \
356 echo "However, it seems that you don't have clippy installed."; \
357 echo "You can install the latest version of clippy by following the directions here: https://github.com/rust-lang-nursery/rust-clippy"; \
361 .PHONY: check-changes
364 @if test -d "$(top_srcdir)/changes"; then \
365 $(PYTHON) $(top_srcdir)/scripts/maint/lintChanges.py $(top_srcdir)/changes; \
369 .PHONY: update-versions
371 $(PERL) $(top_builddir)/scripts/maint/updateVersions.pl
375 $(top_builddir)/scripts/maint/run_calltool.sh
378 @echo "Tor @VERSION@"
379 @if test -d "$(top_srcdir)/.git" && test -x "`which git 2>&1;true`"; then \
381 (cd "$(top_srcdir)" && git rev-parse --short=16 HEAD); \
385 rm -f $(top_builddir)/src/*/*.gc{da,no} $(top_builddir)/src/*/*/*.gc{da,no}
386 rm -rf $(HTML_COVER_DIR)
387 rm -rf $(top_builddir)/doc/doxygen
388 rm -rf $(TEST_NETWORK_ALL_LOG_DIR)
391 rm -rf $(top_builddir)/src/rust/target
392 rm -rf $(top_builddir)/src/rust/.cargo/registry
395 distclean-local: distclean-rust
398 # This relies on some internal details of how automake implements
399 # distcheck. We check two directories because automake-1.15 changed
400 # from $(distdir)/_build to $(distdir)/_build/sub.
401 show-distdir-testlog:
402 @if test -d "$(distdir)/_build/sub"; then \
403 cat $(distdir)/_build/sub/$(TEST_SUITE_LOG); \
405 cat $(distdir)/_build/$(TEST_SUITE_LOG); fi
408 @echo $(TOR_INTERNAL_LIBS)
411 @echo $(TOR_INTERNAL_TESTING_LIBS)