control: With GETINFO, don't trigger an address resolve
[tor.git] / Makefile.am
blob4b708af9e505f9d4e4dcea230ae91a999822f5f2
1 # Copyright (c) 2001-2004, Roger Dingledine
2 # Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
3 # Copyright (c) 2007-2019, The Tor Project, Inc.
4 # See LICENSE for licensing information
6 ACLOCAL_AMFLAGS = -I m4
8 noinst_LIBRARIES=
9 EXTRA_DIST=
10 noinst_HEADERS=
11 bin_PROGRAMS=
12 EXTRA_PROGRAMS=
13 CLEANFILES=
14 TESTS=
15 noinst_PROGRAMS=
16 DISTCLEANFILES=
17 bin_SCRIPTS=
18 AM_CPPFLAGS=\
19         -I$(top_srcdir)/src \
20         -I$(top_srcdir)/src/ext \
21         -I$(top_srcdir)/src/ext/trunnel \
22         -I$(top_srcdir)/src/trunnel
24 AM_CFLAGS=                                      \
25         @TOR_SYSTEMD_CFLAGS@                    \
26         @CFLAGS_BUGTRAP@                        \
27         @TOR_LZMA_CFLAGS@                       \
28         @TOR_ZSTD_CFLAGS@
30 SHELL=@SHELL@
32 if COVERAGE_ENABLED
33 TESTING_TOR_BINARY=$(top_builddir)/src/app/tor-cov$(EXEEXT)
34 else
35 TESTING_TOR_BINARY=$(top_builddir)/src/app/tor$(EXEEXT)
36 endif
38 if USE_RUST
39 rust_ldadd=$(top_builddir)/$(TOR_RUST_LIB_PATH)
40 else
41 rust_ldadd=
42 endif
44 # "Common" libraries used to link tor's utility code.
45 TOR_UTIL_LIBS = \
46         src/lib/libtor-geoip.a \
47         src/lib/libtor-process.a \
48         src/lib/libtor-buf.a \
49         src/lib/libtor-confmgt.a \
50         src/lib/libtor-pubsub.a \
51         src/lib/libtor-dispatch.a \
52         src/lib/libtor-time.a \
53         src/lib/libtor-fs.a \
54         src/lib/libtor-encoding.a \
55         src/lib/libtor-sandbox.a \
56         src/lib/libtor-container.a \
57         src/lib/libtor-net.a \
58         src/lib/libtor-thread.a \
59         src/lib/libtor-memarea.a \
60         src/lib/libtor-math.a \
61         src/lib/libtor-meminfo.a \
62         src/lib/libtor-osinfo.a \
63         src/lib/libtor-log.a \
64         src/lib/libtor-lock.a \
65         src/lib/libtor-fdio.a \
66         src/lib/libtor-string.a \
67         src/lib/libtor-term.a \
68         src/lib/libtor-smartlist-core.a \
69         src/lib/libtor-malloc.a \
70         src/lib/libtor-wallclock.a \
71         src/lib/libtor-err.a \
72         src/lib/libtor-version.a \
73         src/lib/libtor-llharden.a \
74         src/lib/libtor-intmath.a \
75         src/lib/libtor-ctime.a
77 # Variants of the above for linking the testing variant of tor (for coverage
78 # and tests)
79 if UNITTESTS_ENABLED
80 TOR_UTIL_TESTING_LIBS = \
81         src/lib/libtor-geoip-testing.a \
82         src/lib/libtor-process-testing.a \
83         src/lib/libtor-buf-testing.a \
84         src/lib/libtor-confmgt-testing.a \
85         src/lib/libtor-pubsub-testing.a \
86         src/lib/libtor-dispatch-testing.a \
87         src/lib/libtor-time-testing.a \
88         src/lib/libtor-fs-testing.a \
89         src/lib/libtor-encoding-testing.a \
90         src/lib/libtor-sandbox-testing.a \
91         src/lib/libtor-container-testing.a \
92         src/lib/libtor-net-testing.a \
93         src/lib/libtor-thread-testing.a \
94         src/lib/libtor-memarea-testing.a \
95         src/lib/libtor-math-testing.a \
96         src/lib/libtor-meminfo-testing.a \
97         src/lib/libtor-osinfo-testing.a \
98         src/lib/libtor-term-testing.a \
99         src/lib/libtor-log-testing.a \
100         src/lib/libtor-lock-testing.a \
101         src/lib/libtor-fdio-testing.a \
102         src/lib/libtor-string-testing.a \
103         src/lib/libtor-smartlist-core-testing.a \
104         src/lib/libtor-malloc-testing.a \
105         src/lib/libtor-wallclock-testing.a \
106         src/lib/libtor-err-testing.a \
107         src/lib/libtor-version-testing.a \
108         src/lib/libtor-llharden-testing.a \
109         src/lib/libtor-intmath.a \
110         src/lib/libtor-ctime-testing.a
111 endif
113 # Internal crypto libraries used in Tor
114 TOR_CRYPTO_LIBS = \
115         src/lib/libtor-tls.a \
116         src/lib/libtor-crypt-ops.a \
117         $(LIBKECCAK_TINY) \
118         $(LIBDONNA)
120 # Variants of the above for linking the testing variant of tor (for coverage
121 # and tests)
122 if UNITTESTS_ENABLED
123 TOR_CRYPTO_TESTING_LIBS = \
124         src/lib/libtor-tls-testing.a \
125         src/lib/libtor-crypt-ops-testing.a \
126         $(LIBKECCAK_TINY) \
127         $(LIBDONNA)
128 endif
130 # All static libraries used to link tor.
131 TOR_INTERNAL_LIBS = \
132         src/core/libtor-app.a \
133         src/lib/libtor-compress.a \
134         src/lib/libtor-evloop.a \
135         $(TOR_CRYPTO_LIBS) \
136         $(TOR_UTIL_LIBS) \
137         src/trunnel/libor-trunnel.a \
138         src/lib/libtor-trace.a
140 # Variants of the above for linking the testing variant of tor (for coverage
141 # and tests)
142 if UNITTESTS_ENABLED
143 TOR_INTERNAL_TESTING_LIBS = \
144         src/core/libtor-app-testing.a \
145         src/lib/libtor-compress-testing.a \
146         src/lib/libtor-evloop-testing.a \
147         $(TOR_CRYPTO_TESTING_LIBS) \
148         $(TOR_UTIL_TESTING_LIBS) \
149         src/trunnel/libor-trunnel-testing.a \
150         src/lib/libtor-trace.a
151 endif
153 TOR_LDFLAGS_CRYPTLIB=@TOR_LDFLAGS_openssl@
154 TOR_LIBS_CRYPTLIB=@TOR_OPENSSL_LIBS@
155 TOR_CFLAGS_CRYPTLIB=
156 if USE_NSS
157 TOR_CFLAGS_CRYPTLIB+=@NSS_CFLAGS@
158 TOR_LIBS_CRYPTLIB+=@NSS_LIBS@
159 endif
161 # All libraries used to link tor-cov
163 include src/include.am
164 include doc/include.am
165 include contrib/include.am
167 EXTRA_DIST+= \
168         ChangeLog                                                       \
169         CONTRIBUTING                                                    \
170         CODE_OF_CONDUCT                                                 \
171         INSTALL                                                         \
172         LICENSE                                                         \
173         Makefile.nmake                                                  \
174         README                                                          \
175         ReleaseNotes                                                    \
176         scripts/maint/checkIncludes.py                                  \
177         scripts/maint/checkSpace.pl                                     \
178         scripts/maint/checkSpaceTest.sh                                 \
179         scripts/maint/checkspace_tests/dubious.c                        \
180         scripts/maint/checkspace_tests/dubious.h                        \
181         scripts/maint/checkspace_tests/expected.txt                     \
182         scripts/maint/checkspace_tests/good_guard.h                     \
183         scripts/maint/checkspace_tests/same_guard.h                     \
184         scripts/maint/checkspace_tests/subdir/dubious.c                 \
185         scripts/maint/checkShellScripts.sh                              \
186         scripts/maint/practracker/README                                \
187         scripts/maint/practracker/exceptions.txt                        \
188         scripts/maint/practracker/includes.py                           \
189         scripts/maint/practracker/metrics.py                            \
190         scripts/maint/practracker/practracker.py                        \
191         scripts/maint/practracker/practracker_tests.py                  \
192         scripts/maint/practracker/problem.py                            \
193         scripts/maint/practracker/testdata/.may_include                 \
194         scripts/maint/practracker/testdata/a.c                          \
195         scripts/maint/practracker/testdata/b.c                          \
196         scripts/maint/practracker/testdata/ex0-expected.txt             \
197         scripts/maint/practracker/testdata/ex0.txt                      \
198         scripts/maint/practracker/testdata/ex1-expected.txt             \
199         scripts/maint/practracker/testdata/ex1.txt                      \
200         scripts/maint/practracker/testdata/ex1-overbroad-expected.txt   \
201         scripts/maint/practracker/testdata/ex1-regen-expected.txt       \
202         scripts/maint/practracker/testdata/ex1-regen-overbroad-expected.txt \
203         scripts/maint/practracker/testdata/ex.txt                       \
204         scripts/maint/practracker/testdata/header.h                     \
205         scripts/maint/practracker/testdata/not_c_file                   \
206         scripts/maint/practracker/test_practracker.sh                   \
207         scripts/maint/practracker/util.py                               \
208         scripts/coccinelle/apply.sh                                     \
209         scripts/coccinelle/check_cocci_parse.sh                         \
210         scripts/coccinelle/exceptions.txt                               \
211         scripts/coccinelle/test-operator-cleanup                        \
212         scripts/coccinelle/tor-coccinelle.h                             \
213         scripts/coccinelle/try_parse.sh
215 ## This tells etags how to find mockable function definitions.
216 AM_ETAGSFLAGS=--regex='{c}/MOCK_IMPL([^,]+,\W*\([a-zA-Z0-9_]+\)\W*,/\1/s'
218 if COVERAGE_ENABLED
219 TEST_CFLAGS=-fno-inline -fprofile-arcs -ftest-coverage
220 if DISABLE_ASSERTS_IN_UNIT_TESTS
221 TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE -DDISABLE_ASSERTS_IN_UNIT_TESTS @TOR_MODULES_ALL_ENABLED@
222 else
223 TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE @TOR_MODULES_ALL_ENABLED@
224 endif
225 TEST_NETWORK_FLAGS=--coverage --hs-multi-client 1
226 else
227 TEST_CFLAGS=
228 TEST_CPPFLAGS=-DTOR_UNIT_TESTS @TOR_MODULES_ALL_ENABLED@
229 TEST_NETWORK_FLAGS=--hs-multi-client 1
230 endif
231 TEST_NETWORK_SHOW_WARNINGS_FOR_LAST_RUN_FLAGS=--quiet --only-warnings
233 if LIBFUZZER_ENABLED
234 TEST_CFLAGS += -fsanitize-coverage=trace-pc-guard,trace-cmp,trace-div
235 # not "edge"
236 endif
238 TEST_NETWORK_ALL_LOG_DIR=$(top_builddir)/test_network_log
239 TEST_NETWORK_ALL_DRIVER_FLAGS=--color-tests yes
241 #install-data-local:
242 #       $(INSTALL) -m 755 -d $(LOCALSTATEDIR)/lib/tor
244 # Allows to override rpmbuild with rpmbuild-md5 from fedora-packager so that
245 # building for EL5 won't fail on https://bugzilla.redhat.com/show_bug.cgi?id=490613
246 RPMBUILD ?= rpmbuild
248 # Use automake's dist-gzip target to build the tarball
249 dist-rpm: dist-gzip
250         TIMESTAMP=$$(date +"%Y-%m-%d_%H.%M.%S");                                \
251         RPM_BUILD_DIR=$$(mktemp -d "/tmp/tor-rpm-build-$$TIMESTAMP-XXXX");      \
252         mkdir -p "$$RPM_BUILD_DIR"/{BUILD,RPMS,SOURCES/"tor-$(VERSION)",SPECS,SRPMS}; \
253         cp -fa "$(distdir).tar.gz" "$$RPM_BUILD_DIR"/SOURCES/;                  \
254         LIBS=-lrt $(RPMBUILD) -ba --define "_topdir $$RPM_BUILD_DIR" tor.spec;  \
255         cp -fa "$$RPM_BUILD_DIR"/SRPMS/* .;                                     \
256         cp -fa "$$RPM_BUILD_DIR"/RPMS/* .;                                      \
257         rm -rf "$$RPM_BUILD_DIR";                                               \
258         echo "RPM build finished";                                              \
259         #end of dist-rpm
261 .PHONY: doxygen
262 doxygen: Doxyfile
263         mkdir -p doc/doxygen
264         (cd "$(top_srcdir)" && doxygen "$(abs_top_builddir)/Doxyfile")
266 test: all
267         $(top_builddir)/src/test/test
269 shellcheck:
270         $(top_srcdir)/scripts/maint/checkShellScripts.sh
272 check-local:                                    \
273         check-spaces                            \
274         check-changes                           \
275         check-includes                          \
276         shellcheck
278 # test-network requires a copy of Chutney in $CHUTNEY_PATH.
279 # Chutney can be cloned from https://git.torproject.org/chutney.git .
280 .PHONY: need-chutney-path
281 need-chutney-path:
282         @if test ! -d "$$CHUTNEY_PATH"; then \
283                 echo '$$CHUTNEY_PATH was not set.'; \
284                 if test -d "$(top_srcdir)/../chutney" && \
285                    test -x "$(top_srcdir)/../chutney/chutney"; then \
286                         echo "Assuming test-network.sh will find" \
287                           "$(top_srcdir)/../chutney"; \
288                 else \
289                         echo; \
290                         echo "To run these tests," \
291                           "git clone" \
292                           "https://git.torproject.org/chutney.git ;" \
293                           "export CHUTNEY_PATH=\`pwd\`/chutney"; \
294                         exit 1; \
295                 fi \
296         fi
298 # Run some basic tests using automake's test-driver
299 .PHONY: test-network
300 # Hide directory path logs from submakes using $(MAKE) -s
301 test-network:
302         @$(MAKE) -s test-network-mkdir
303         @$(MAKE) -s test-network-clean
304         @$(MAKE) -s test-network-run \
305           ipv4_flavors="$(TEST_CHUTNEY_FLAVOR_QUICK)" \
306           ipv6_flavors="$(TEST_CHUTNEY_FLAVOR_QUICK_IPV6)"
307         @$(MAKE) -s test-network-results
309 # Run all available tests using automake's test-driver
310 .PHONY: test-network-all
311 # Hide directory path logs from submakes using $(MAKE) -s
312 test-network-all:
313         @$(MAKE) -s test-network-mkdir
314         @$(MAKE) -s test-network-clean
315         @$(MAKE) -s test-network-run \
316           ipv4_flavors="$(TEST_CHUTNEY_FLAVORS)" \
317           mixed_flavors="$(TEST_CHUTNEY_FLAVORS_MIXED)" \
318           ipv6_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6)" \
319           ipv6_mixed_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6_MIXED)"
320         @$(MAKE) -s test-network-results
322 # Run IPv4 and mixed tests using automake's test-driver
323 .PHONY: test-network-ipv4
324 # Hide directory path logs from submakes using $(MAKE) -s
325 test-network-ipv4:
326         @$(MAKE) -s test-network-mkdir
327         @$(MAKE) -s test-network-clean
328         @$(MAKE) -s test-network-run \
329           ipv4_flavors="$(TEST_CHUTNEY_FLAVORS)" \
330           mixed_flavors="$(TEST_CHUTNEY_FLAVORS_MIXED)"
331         @$(MAKE) -s test-network-results
333 # Run IPv6 tests using automake's test-driver
334 .PHONY: test-network-ipv6
335 # Hide directory path logs from submakes using $(MAKE) -s
336 test-network-ipv6:
337         @$(MAKE) -s test-network-mkdir
338         @$(MAKE) -s test-network-clean
339         @$(MAKE) -s test-network-run \
340           ipv6_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6)" \
341           ipv6_mixed_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6_MIXED)"
342         @$(MAKE) -s test-network-results
344 # Make the test network log directory, if it does not exist
345 .PHONY: test-network-mkdir
346 test-network-mkdir:
347         @mkdir -p "$(TEST_NETWORK_ALL_LOG_DIR)"
349 # Clean the test network log directory
350 .PHONY: test-network-clean
351 # We need to remove all matching files, so we can't quote the glob part of the
352 # rm arguments
353 test-network-clean:
354         rm -f "$(TEST_NETWORK_ALL_LOG_DIR)"/*.log \
355               "$(TEST_NETWORK_ALL_LOG_DIR)"/*.trs
357 # Run tests using automake's test-driver
358 # When checking if a set of test can be run, log the type of test, and the
359 # list of tests that will be run (or skipped).
361 # Run the IPv4 tests in $(ipv4_flavors), unconditionally
362 #   - tor relays and directory authorities require IPv4.
363 # Run the IPv6 tests in $(ipv6_flavors), if IPv6 is available
364 #   - only run IPv6 tests if we can ping6 or ping -6 ::1 (localhost)
365 #     we try the syntax for BSD ping6, Linux ping6, and Linux ping -6,
366 #     because they're incompatible
367 #   - some IPv6 tests may fail without an IPv6 DNS server
368 #     (see #16971 and #17011)
369 # Run the mixed tests in $(mixed_flavors), if a tor-stable binary is available
370 #   - only run mixed tests if we have a tor-stable binary
371 # Run the IPv6 mixed tests in $(ipv6_mixed_flavors), if IPv6 and mixed are run
372 #   - see above for details about IPv6 and mixed
373 .PHONY: test-network-run
374 # We need the word splitting in the "for" lines, so we can't quote
375 # $(skip_flavors) or $(flavors)
376 test-network-run: need-chutney-path test-driver $(TESTING_TOR_BINARY) src/tools/tor-gencert
377         @flavors=""; \
378         skip_flavors=""; \
379         if test -n "$(ipv4_flavors)"; then \
380                 echo "Running IPv4 flavors: $(ipv4_flavors)."; \
381                 flavors="$$flavors $(ipv4_flavors)"; \
382         fi; \
383         test_network_ipv6=false; \
384         if test -n "$(ipv6_flavors)" || \
385            test -n "$(ipv6_mixed_flavors)"; then \
386                 if ping6 -q -c 1 -o   ::1 >/dev/null 2>&1 || \
387                    ping6 -q -c 1 -W 1 ::1 >/dev/null 2>&1 || \
388                    ping  -6 -c 1 -W 1 ::1 >/dev/null 2>&1; then \
389                         test_network_ipv6=true; \
390                 fi; \
391         fi; \
392         if test -n "$(ipv6_flavors)"; then \
393                 if test "$$test_network_ipv6" = "true"; then \
394                         echo "ping6 ::1 or ping ::1 succeeded, running IPv6" \
395                           "flavors: $(ipv6_flavors)."; \
396                         flavors="$$flavors $(ipv6_flavors)"; \
397                 else \
398                         echo "ping6 ::1 and ping ::1 failed, skipping IPv6" \
399                           "flavors: $(ipv6_flavors)."; \
400                         skip_flavors="$$skip_flavors $(ipv6_flavors)"; \
401                 fi; \
402         fi; \
403         test_network_mixed=false; \
404         if test -n "$(mixed_flavors)" || \
405            test -n "$(ipv6_mixed_flavors)"; then \
406                 if command -v tor-stable >/dev/null 2>&1; then \
407                         test_network_mixed=true; \
408                 fi; \
409         fi; \
410         if test -n "$(mixed_flavors)"; then \
411                 if test "$$test_network_mixed" = "true"; then \
412                         echo "tor-stable found, running mixed flavors:" \
413                           "$(mixed_flavors)."; \
414                         flavors="$$flavors $(mixed_flavors)"; \
415                 else \
416                         echo "tor-stable not found, skipping mixed flavors:" \
417                           "$(mixed_flavors)."; \
418                         skip_flavors="$$skip_flavors $(mixed_flavors)"; \
419                 fi; \
420         fi; \
421         if test -n "$(ipv6_mixed_flavors)"; then \
422                 if test "$$test_network_ipv6" = "true" && \
423                    test "$$test_network_mixed" = "true"; then \
424                         echo "Running IPv6 mixed flavors:" \
425                           "$(ipv6_mixed_flavors)."; \
426                         flavors="$$flavors $(ipv6_mixed_flavors)"; \
427                 else \
428                         echo "Skipping IPv6 mixed flavors:" \
429                           "$(ipv6_mixed_flavors)."; \
430                         skip_flavors="$$skip_flavors $(ipv6_mixed_flavors)"; \
431                 fi; \
432         fi; \
433         for f in $$skip_flavors; do \
434                 echo "SKIP: $$f"; \
435         done; \
436         for f in $$flavors; do \
437                 $(SHELL) "$(top_srcdir)/test-driver" --test-name "$$f" \
438                   --log-file "$(TEST_NETWORK_ALL_LOG_DIR)/$$f.log" \
439                   --trs-file "$(TEST_NETWORK_ALL_LOG_DIR)/$$f.trs" \
440                   $(TEST_NETWORK_ALL_DRIVER_FLAGS) \
441                   "$(top_srcdir)/src/test/test-network.sh" \
442                     --flavor "$$f" $(TEST_NETWORK_FLAGS); \
443                 "$(top_srcdir)/src/test/test-network.sh" \
444                   $(TEST_NETWORK_SHOW_WARNINGS_FOR_LAST_RUN_FLAGS); \
445         done
447 # Print the results from automake's test-driver
448 #   - show tor warnings on the console after each network run
449 #     (otherwise, warnings go to the logs, and people don't see them unless
450 #     there is a network failure)
451 .PHONY: test-network-results
452 # We need to grep all matching files, so we can't quote the glob part of the
453 # grep arguments
454 test-network-results:
455         @echo \
456           "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)."
457         @! grep -q FAIL "$(TEST_NETWORK_ALL_LOG_DIR)"/*.trs
459 need-stem-path:
460         @if test ! -d "$$STEM_SOURCE_DIR"; then \
461                 echo '$$STEM_SOURCE_DIR was not set.'; echo; \
462                 echo "To run these tests, git clone https://git.torproject.org/stem.git/ ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \
463                 exit 1; \
464         fi
466 test-stem: need-stem-path $(TESTING_TOR_BINARY)
467         @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --integ --test control.controller --test control.base_controller --test process --log notice;
469 test-stem-full: need-stem-path $(TESTING_TOR_BINARY)
470         @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --all --log notice --target RUN_ALL,ONLINE -v;
472 test-full:                                      \
473         need-stem-path                          \
474         need-chutney-path                       \
475         check                                   \
476         test-network                            \
477         test-stem
479 test-full-online:                               \
480         need-stem-path                          \
481         need-chutney-path                       \
482         check                                   \
483         test-network                            \
484         test-stem-full
486 # We can't delete the gcno files, because they are created when tor is compiled
487 reset-gcov:
488         rm -f $(top_builddir)/src/*/*.gcda $(top_builddir)/src/*/*/*.gcda \
489               $(top_builddir)/src/*/*.gcov $(top_builddir)/src/*/*/*.gcov
491 HTML_COVER_DIR=$(top_builddir)/coverage_html
492 coverage-html: all
493 if COVERAGE_ENABLED
494         test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
495         test -d "$(HTML_COVER_DIR)" || $(MKDIR_P) "$(HTML_COVER_DIR)"
496         lcov --rc lcov_branch_coverage=1 --directory $(top_builddir)/src --zerocounters
497         $(MAKE) reset-gcov
498         $(MAKE) check
499         lcov --capture --rc lcov_branch_coverage=1 --no-external --directory $(top_builddir) --base-directory $(top_srcdir) --output-file "$(HTML_COVER_DIR)/lcov.tmp"
500         lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
501         genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
502 else
503         @printf "Not configured with --enable-coverage, run ./configure --enable-coverage\n"
504 endif
506 coverage-html-full: all
507         test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
508         test -d "$(HTML_COVER_DIR)" || mkdir -p "$(HTML_COVER_DIR)"
509         lcov --rc lcov_branch_coverage=1 --directory ./src --zerocounters
510         $(MAKE) reset-gcov
511         $(MAKE) check
512         $(MAKE) test-stem-full
513         CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh
514         CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh --flavor hs
515         lcov --capture --rc lcov_branch_coverage=1 --no-external --directory . --output-file "$(HTML_COVER_DIR)/lcov.tmp"
516         lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
517         genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
519 # For scripts: avoid src/ext and src/trunnel.
520 # Keep these lists consistent:
521 #   - OWNED_TOR_C_FILES in Makefile.am
522 #   - CHECK_FILES in pre-commit.git-hook and pre-push.git-hook
523 #   - try_parse in check_cocci_parse.sh
524 OWNED_TOR_C_FILES=\
525                 $(top_srcdir)/src/lib/*/*.[ch] \
526                 $(top_srcdir)/src/core/*/*.[ch] \
527                 $(top_srcdir)/src/feature/*/*.[ch] \
528                 $(top_srcdir)/src/app/*/*.[ch] \
529                 $(top_srcdir)/src/test/*.[ch] \
530                 $(top_srcdir)/src/test/*/*.[ch] \
531                 $(top_srcdir)/src/tools/*.[ch]
533 check-spaces:
534 if USE_PERL
535         $(PERL) $(top_srcdir)/scripts/maint/checkSpace.pl -C \
536                 $(OWNED_TOR_C_FILES)
537 endif
539 check-includes:
540 if USEPYTHON
541         $(PYTHON) $(top_srcdir)/scripts/maint/practracker/includes.py $(top_srcdir)
542 endif
544 check-best-practices:
545 if USEPYTHON
546         @$(PYTHON) $(top_srcdir)/scripts/maint/practracker/practracker.py $(top_srcdir) $(TOR_PRACTRACKER_OPTIONS)
547 endif
549 check-cocci:
550         VERBOSE=1 $(top_srcdir)/scripts/coccinelle/check_cocci_parse.sh $(OWNED_TOR_C_FILES)
552 practracker-regen:
553         $(PYTHON) $(top_srcdir)/scripts/maint/practracker/practracker.py --regen $(top_srcdir)
555 check-docs: all
556         $(PERL) $(top_builddir)/scripts/maint/checkOptionDocs.pl
558 check-logs:
559         $(top_srcdir)/scripts/maint/checkLogs.pl \
560                 $(top_srcdir)/src/*/*.[ch] | sort -n
562 .PHONY: check-typos
563 check-typos:
564         @if test -x "`which misspell 2>&1;true`"; then \
565                 echo "Checking for Typos ..."; \
566                 (misspell \
567                         $(top_srcdir)/src/[^e]*/*.[ch] \
568                         $(top_srcdir)/doc \
569                         $(top_srcdir)/contrib \
570                         $(top_srcdir)/scripts \
571                         $(top_srcdir)/README \
572                         $(top_srcdir)/ChangeLog \
573                         $(top_srcdir)/INSTALL \
574                         $(top_srcdir)/ReleaseNotes \
575                         $(top_srcdir)/LICENSE); \
576         else \
577                 echo "Tor can use misspell to check for typos."; \
578                 echo "It seems that you don't have misspell installed."; \
579                 echo "You can install the latest version of misspell here: https://github.com/client9/misspell#install"; \
580         fi
582 .PHONY: rustfmt
583 rustfmt:
584 if USE_RUST
585         @if test -x "`which cargo-fmt 2>&1;true`"; then \
586                 echo "Formatting Rust code ..."; \
587                 (cd "$(top_srcdir)/src/rust" && cargo fmt --all --); \
588         else \
589                 echo "Tor uses rustfmt (via cargo-fmt) to format Rust code."; \
590                 echo "However, it seems that you don't have rustfmt installed."; \
591                 printf "You can install rustfmt by following the directions here:"; \
592                 echo " https://github.com/rust-lang-nursery/rustfmt"; \
593         fi
594 endif
596 .PHONY: check-rustfmt
597 check-rustfmt:
598 if USE_RUST
599         @if test -x "`which cargo-fmt 2>&1;true`"; then \
600                 printf "Running rustfmt..."; \
601                 (cd "$(top_srcdir)/src/rust" && cargo fmt --all -- --check && echo "done.") || \
602                 (echo "**************** check-rustfmt failed. ****************"; \
603                  echo "   Run \`make rustfmt\` to apply the above changes."; \
604                  exit 1); \
605         else \
606                 echo "Tor uses rustfmt (via cargo-fmt) to format Rust code."; \
607                 echo "However, it seems that you don't have rustfmt installed."; \
608                 printf "You can install rustfmt by following the directions here:"; \
609                 echo " https://github.com/rust-lang-nursery/rustfmt"; \
610         fi
611 endif
613 .PHONY: clippy
614 clippy:
615 if USE_RUST
616         @if test -x "`which cargo-clippy 2>&1;true`"; then \
617                 echo "Running cargo clippy ..."; \
618                 echo "Prepare yourself for the onslaught of suggestions ..."; \
619                 (cd "$(top_srcdir)/src/rust" && cargo clippy); \
620         else \
621                 echo "Tor can use clippy to lint Rust code."; \
622                 echo "However, it seems that you don't have clippy installed."; \
623                 echo "You can install the latest version of clippy by following the directions here: https://github.com/rust-lang-nursery/rust-clippy"; \
624         fi
625 endif
627 .PHONY: check-changes
628 check-changes:
629 if USEPYTHON
630         @if test -d "$(top_srcdir)/changes"; then \
631                 PACKAGE_VERSION=$(PACKAGE_VERSION) $(PYTHON) $(top_srcdir)/scripts/maint/lintChanges.py $(top_srcdir)/changes; \
632                 fi
633 endif
635 .PHONY: update-versions
636 update-versions:
637         abs_top_srcdir="$(abs_top_srcdir)" $(PYTHON) $(top_srcdir)/scripts/maint/update_versions.py
639 .PHONY: callgraph
640 callgraph:
641         cd $(top_builddir); $(abs_top_srcdir)/scripts/maint/run_calltool.sh
643 version:
644         @echo "Tor @VERSION@"
645         @if test -d "$(top_srcdir)/.git" && test -x "`which git 2>&1;true`"; then \
646            echo -n "git: " ;\
647            (cd "$(top_srcdir)" && git rev-parse --short=16 HEAD); \
648         fi
650 .PHONY: autostyle-ifdefs
651 autostyle-ifdefs:
652         $(PYTHON) $(top_srcdir)/scripts/maint/annotate_ifdef_directives.py $(OWNED_TOR_C_FILES)
654 .PHONY: autostyle-ifdefs
655 autostyle-operators:
656         $(PERL) $(top_srcdir)/scripts/coccinelle/test-operator-cleanup $(OWNED_TOR_C_FILES)
658 .PHONY: rectify-includes
659 rectify-includes:
660         cd $(top_srcdir); $(PYTHON) $(abs_top_srcdir)/scripts/maint/rectify_include_paths.py
662 .PHONY: update-copyright
663 update-copyright:
664         $(PERL) $(top_srcdir)/scripts/maint/updateCopyright.pl $(OWNED_TOR_C_FILES)
666 .PHONY: autostyle
667 autostyle: update-versions rustfmt autostyle-ifdefs rectify-includes
669 mostlyclean-local:
670         rm -f $(top_builddir)/src/*/*.gc{da,no} $(top_builddir)/src/*/*/*.gc{da,no}
671         rm -rf $(HTML_COVER_DIR)
672         rm -rf $(top_builddir)/doc/doxygen
673         rm -rf $(TEST_NETWORK_ALL_LOG_DIR)
675 clean-local:
676         rm -rf $(top_builddir)/src/rust/target
677         rm -rf $(top_builddir)/src/rust/.cargo/registry
679 if USE_RUST
680 distclean-local: distclean-rust
681 endif
683 # This relies on some internal details of how automake implements
684 # distcheck.  We check two directories because automake-1.15 changed
685 # from $(distdir)/_build to $(distdir)/_build/sub.
686 show-distdir-testlog:
687         @if test -d "$(distdir)/_build/sub"; then \
688           cat $(distdir)/_build/sub/$(TEST_SUITE_LOG); \
689         else \
690           cat $(distdir)/_build/$(TEST_SUITE_LOG); fi
692 # Similarly, this relies on automake internals to run file on an
693 # intermittent core file whose provenance is not known to us.  See
694 # ticket 26787.
695 show-distdir-core:
696         @if test -d "$(distdir)/_build/sub"; then \
697           file $(distdir)/_build/sub/core ; \
698         else \
699           file $(distdir)/_build/core; fi
701 show-libs:
702         @echo $(TOR_INTERNAL_LIBS)
704 show-testing-libs:
705         @echo $(TOR_INTERNAL_TESTING_LIBS)