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