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
20 -I$(top_srcdir)/src/ext \
21 -I$(top_srcdir)/src/ext/trunnel \
22 -I$(top_srcdir)/src/trunnel
25 @TOR_SYSTEMD_CFLAGS@ \
33 TESTING_TOR_BINARY=$(top_builddir)/src/app/tor-cov$(EXEEXT)
35 TESTING_TOR_BINARY=$(top_builddir)/src/app/tor$(EXEEXT)
39 rust_ldadd=$(top_builddir)/$(TOR_RUST_LIB_PATH)
44 # "Common" libraries used to link tor's utility code.
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 \
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
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
113 # Internal crypto libraries used in Tor
115 src/lib/libtor-tls.a \
116 src/lib/libtor-crypt-ops.a \
120 # Variants of the above for linking the testing variant of tor (for coverage
123 TOR_CRYPTO_TESTING_LIBS = \
124 src/lib/libtor-tls-testing.a \
125 src/lib/libtor-crypt-ops-testing.a \
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 \
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
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
153 TOR_LDFLAGS_CRYPTLIB=@TOR_LDFLAGS_openssl@
154 TOR_LIBS_CRYPTLIB=@TOR_OPENSSL_LIBS@
157 TOR_CFLAGS_CRYPTLIB+=@NSS_CFLAGS@
158 TOR_LIBS_CRYPTLIB+=@NSS_LIBS@
161 # All libraries used to link tor-cov
163 include src/include.am
164 include doc/include.am
165 include contrib/include.am
167 manpages: $(nodist_man1_MANS)
178 scripts/maint/checkIncludes.py \
179 scripts/maint/checkSpace.pl \
180 scripts/maint/checkSpaceTest.sh \
181 scripts/maint/checkspace_tests/dubious.c \
182 scripts/maint/checkspace_tests/dubious.h \
183 scripts/maint/checkspace_tests/expected.txt \
184 scripts/maint/checkspace_tests/good_guard.h \
185 scripts/maint/checkspace_tests/same_guard.h \
186 scripts/maint/checkspace_tests/subdir/dubious.c \
187 scripts/maint/checkShellScripts.sh \
188 scripts/maint/practracker/README \
189 scripts/maint/practracker/exceptions.txt \
190 scripts/maint/practracker/includes.py \
191 scripts/maint/practracker/metrics.py \
192 scripts/maint/practracker/practracker.py \
193 scripts/maint/practracker/practracker_tests.py \
194 scripts/maint/practracker/problem.py \
195 scripts/maint/practracker/testdata/.may_include \
196 scripts/maint/practracker/testdata/a.c \
197 scripts/maint/practracker/testdata/b.c \
198 scripts/maint/practracker/testdata/ex0-expected.txt \
199 scripts/maint/practracker/testdata/ex0.txt \
200 scripts/maint/practracker/testdata/ex1-expected.txt \
201 scripts/maint/practracker/testdata/ex1.txt \
202 scripts/maint/practracker/testdata/ex1-overbroad-expected.txt \
203 scripts/maint/practracker/testdata/ex1-regen-expected.txt \
204 scripts/maint/practracker/testdata/ex1-regen-overbroad-expected.txt \
205 scripts/maint/practracker/testdata/ex.txt \
206 scripts/maint/practracker/testdata/header.h \
207 scripts/maint/practracker/testdata/not_c_file \
208 scripts/maint/practracker/test_practracker.sh \
209 scripts/maint/practracker/util.py \
210 scripts/coccinelle/apply.sh \
211 scripts/coccinelle/check_cocci_parse.sh \
212 scripts/coccinelle/exceptions.txt \
213 scripts/coccinelle/test-operator-cleanup \
214 scripts/coccinelle/tor-coccinelle.h \
215 scripts/coccinelle/try_parse.sh
217 ## This tells etags how to find mockable function definitions.
218 AM_ETAGSFLAGS=--regex='{c}/MOCK_IMPL([^,]+,\W*\([a-zA-Z0-9_]+\)\W*,/\1/s'
221 TEST_CFLAGS=-fno-inline -fprofile-arcs -ftest-coverage
222 if DISABLE_ASSERTS_IN_UNIT_TESTS
223 TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE -DDISABLE_ASSERTS_IN_UNIT_TESTS @TOR_MODULES_ALL_ENABLED@
225 TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE @TOR_MODULES_ALL_ENABLED@
227 TEST_NETWORK_FLAGS=--coverage --hs-multi-client 1
230 TEST_CPPFLAGS=-DTOR_UNIT_TESTS @TOR_MODULES_ALL_ENABLED@
231 TEST_NETWORK_FLAGS=--hs-multi-client 1
233 TEST_NETWORK_SHOW_WARNINGS_FOR_LAST_RUN_FLAGS=--quiet --only-warnings
236 TEST_CFLAGS += -fsanitize-coverage=trace-pc-guard,trace-cmp,trace-div
240 TEST_NETWORK_ALL_LOG_DIR=$(top_builddir)/test_network_log
241 TEST_NETWORK_ALL_DRIVER_FLAGS=--color-tests yes
244 # $(INSTALL) -m 755 -d $(LOCALSTATEDIR)/lib/tor
246 # Allows to override rpmbuild with rpmbuild-md5 from fedora-packager so that
247 # building for EL5 won't fail on https://bugzilla.redhat.com/show_bug.cgi?id=490613
250 # Use automake's dist-gzip target to build the tarball
252 TIMESTAMP=$$(date +"%Y-%m-%d_%H.%M.%S"); \
253 RPM_BUILD_DIR=$$(mktemp -d "/tmp/tor-rpm-build-$$TIMESTAMP-XXXX"); \
254 mkdir -p "$$RPM_BUILD_DIR"/{BUILD,RPMS,SOURCES/"tor-$(VERSION)",SPECS,SRPMS}; \
255 cp -fa "$(distdir).tar.gz" "$$RPM_BUILD_DIR"/SOURCES/; \
256 LIBS=-lrt $(RPMBUILD) -ba --define "_topdir $$RPM_BUILD_DIR" tor.spec; \
257 cp -fa "$$RPM_BUILD_DIR"/SRPMS/* .; \
258 cp -fa "$$RPM_BUILD_DIR"/RPMS/* .; \
259 rm -rf "$$RPM_BUILD_DIR"; \
260 echo "RPM build finished"; \
266 (cd "$(top_srcdir)" && doxygen "$(abs_top_builddir)/Doxyfile")
269 $(top_builddir)/src/test/test
272 $(top_srcdir)/scripts/maint/checkShellScripts.sh
278 check-best-practices \
281 # test-network requires a copy of Chutney in $CHUTNEY_PATH.
282 # Chutney can be cloned from https://git.torproject.org/chutney.git .
283 .PHONY: need-chutney-path
285 @if test ! -d "$$CHUTNEY_PATH"; then \
286 echo '$$CHUTNEY_PATH was not set.'; \
287 if test -d "$(top_srcdir)/../chutney" && \
288 test -x "$(top_srcdir)/../chutney/chutney"; then \
289 echo "Assuming test-network.sh will find" \
290 "$(top_srcdir)/../chutney"; \
293 echo "To run these tests," \
295 "https://git.torproject.org/chutney.git ;" \
296 "export CHUTNEY_PATH=\`pwd\`/chutney"; \
301 # Run some basic tests using automake's test-driver
303 # Hide directory path logs from submakes using $(MAKE) -s
305 @$(MAKE) -s test-network-mkdir
306 @$(MAKE) -s test-network-clean
307 @$(MAKE) -s test-network-run \
308 ipv4_flavors="$(TEST_CHUTNEY_FLAVOR_QUICK)" \
309 ipv6_flavors="$(TEST_CHUTNEY_FLAVOR_QUICK_IPV6)"
310 @$(MAKE) -s test-network-results
312 # Run all available tests using automake's test-driver
313 .PHONY: test-network-all
314 # Hide directory path logs from submakes using $(MAKE) -s
316 @$(MAKE) -s test-network-mkdir
317 @$(MAKE) -s test-network-clean
318 @$(MAKE) -s test-network-run \
319 ipv4_flavors="$(TEST_CHUTNEY_FLAVORS)" \
320 mixed_flavors="$(TEST_CHUTNEY_FLAVORS_MIXED)" \
321 ipv6_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6)" \
322 ipv6_mixed_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6_MIXED)"
323 @$(MAKE) -s test-network-results
325 # Run IPv4 and mixed tests using automake's test-driver
326 .PHONY: test-network-ipv4
327 # Hide directory path logs from submakes using $(MAKE) -s
329 @$(MAKE) -s test-network-mkdir
330 @$(MAKE) -s test-network-clean
331 @$(MAKE) -s test-network-run \
332 ipv4_flavors="$(TEST_CHUTNEY_FLAVORS)" \
333 mixed_flavors="$(TEST_CHUTNEY_FLAVORS_MIXED)"
334 @$(MAKE) -s test-network-results
336 # Run IPv6 tests using automake's test-driver
337 .PHONY: test-network-ipv6
338 # Hide directory path logs from submakes using $(MAKE) -s
340 @$(MAKE) -s test-network-mkdir
341 @$(MAKE) -s test-network-clean
342 @$(MAKE) -s test-network-run \
343 ipv6_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6)" \
344 ipv6_mixed_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6_MIXED)"
345 @$(MAKE) -s test-network-results
347 # Make the test network log directory, if it does not exist
348 .PHONY: test-network-mkdir
350 @mkdir -p "$(TEST_NETWORK_ALL_LOG_DIR)"
352 # Clean the test network log directory
353 .PHONY: test-network-clean
354 # We need to remove all matching files, so we can't quote the glob part of the
357 rm -f "$(TEST_NETWORK_ALL_LOG_DIR)"/*.log \
358 "$(TEST_NETWORK_ALL_LOG_DIR)"/*.trs
360 # Run tests using automake's test-driver
361 # When checking if a set of test can be run, log the type of test, and the
362 # list of tests that will be run (or skipped).
364 # Run the IPv4 tests in $(ipv4_flavors), unconditionally
365 # - tor relays and directory authorities require IPv4.
366 # Run the IPv6 tests in $(ipv6_flavors), if IPv6 is available
367 # - only run IPv6 tests if we can ping6 or ping -6 ::1 (localhost)
368 # we try the syntax for BSD ping6, Linux ping6, and Linux ping -6,
369 # because they're incompatible
370 # - some IPv6 tests may fail without an IPv6 DNS server
371 # (see #16971 and #17011)
372 # Run the mixed tests in $(mixed_flavors), if a tor-stable binary is available
373 # - only run mixed tests if we have a tor-stable binary
374 # Run the IPv6 mixed tests in $(ipv6_mixed_flavors), if IPv6 and mixed are run
375 # - see above for details about IPv6 and mixed
376 .PHONY: test-network-run
377 # We need the word splitting in the "for" lines, so we can't quote
378 # $(skip_flavors) or $(flavors)
379 test-network-run: need-chutney-path test-driver $(TESTING_TOR_BINARY) src/tools/tor-gencert
382 if test -n "$(ipv4_flavors)"; then \
383 echo "Running IPv4 flavors: $(ipv4_flavors)."; \
384 flavors="$$flavors $(ipv4_flavors)"; \
386 test_network_ipv6=false; \
387 if test -n "$(ipv6_flavors)" || \
388 test -n "$(ipv6_mixed_flavors)"; then \
389 if ping6 -q -c 1 -o ::1 >/dev/null 2>&1 || \
390 ping6 -q -c 1 -W 1 ::1 >/dev/null 2>&1 || \
391 ping -6 -c 1 -W 1 ::1 >/dev/null 2>&1; then \
392 test_network_ipv6=true; \
395 if test -n "$(ipv6_flavors)"; then \
396 if test "$$test_network_ipv6" = "true"; then \
397 echo "ping6 ::1 or ping ::1 succeeded, running IPv6" \
398 "flavors: $(ipv6_flavors)."; \
399 flavors="$$flavors $(ipv6_flavors)"; \
401 echo "ping6 ::1 and ping ::1 failed, skipping IPv6" \
402 "flavors: $(ipv6_flavors)."; \
403 skip_flavors="$$skip_flavors $(ipv6_flavors)"; \
406 test_network_mixed=false; \
407 if test -n "$(mixed_flavors)" || \
408 test -n "$(ipv6_mixed_flavors)"; then \
409 if command -v tor-stable >/dev/null 2>&1; then \
410 test_network_mixed=true; \
413 if test -n "$(mixed_flavors)"; then \
414 if test "$$test_network_mixed" = "true"; then \
415 echo "tor-stable found, running mixed flavors:" \
416 "$(mixed_flavors)."; \
417 flavors="$$flavors $(mixed_flavors)"; \
419 echo "tor-stable not found, skipping mixed flavors:" \
420 "$(mixed_flavors)."; \
421 skip_flavors="$$skip_flavors $(mixed_flavors)"; \
424 if test -n "$(ipv6_mixed_flavors)"; then \
425 if test "$$test_network_ipv6" = "true" && \
426 test "$$test_network_mixed" = "true"; then \
427 echo "Running IPv6 mixed flavors:" \
428 "$(ipv6_mixed_flavors)."; \
429 flavors="$$flavors $(ipv6_mixed_flavors)"; \
431 echo "Skipping IPv6 mixed flavors:" \
432 "$(ipv6_mixed_flavors)."; \
433 skip_flavors="$$skip_flavors $(ipv6_mixed_flavors)"; \
436 for f in $$skip_flavors; do \
439 for f in $$flavors; do \
440 $(SHELL) "$(top_srcdir)/test-driver" --test-name "$$f" \
441 --log-file "$(TEST_NETWORK_ALL_LOG_DIR)/$$f.log" \
442 --trs-file "$(TEST_NETWORK_ALL_LOG_DIR)/$$f.trs" \
443 $(TEST_NETWORK_ALL_DRIVER_FLAGS) \
444 "$(top_srcdir)/src/test/test-network.sh" \
445 --flavor "$$f" $(TEST_NETWORK_FLAGS); \
446 "$(top_srcdir)/src/test/test-network.sh" \
447 $(TEST_NETWORK_SHOW_WARNINGS_FOR_LAST_RUN_FLAGS); \
450 # Print the results from automake's test-driver
451 # - show tor warnings on the console after each network run
452 # (otherwise, warnings go to the logs, and people don't see them unless
453 # there is a network failure)
454 .PHONY: test-network-results
455 # We need to grep all matching files, so we can't quote the glob part of the
457 test-network-results:
459 "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)."
460 @! grep -q FAIL "$(TEST_NETWORK_ALL_LOG_DIR)"/*.trs
463 @if test ! -d "$$STEM_SOURCE_DIR"; then \
464 echo '$$STEM_SOURCE_DIR was not set.'; echo; \
465 echo "To run these tests, git clone https://git.torproject.org/stem.git/ ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \
469 test-stem: need-stem-path $(TESTING_TOR_BINARY)
470 @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --integ --test control.controller --test control.base_controller --test process --log notice;
472 test-stem-full: need-stem-path $(TESTING_TOR_BINARY)
473 @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --all --log notice --target RUN_ALL,ONLINE -v;
489 # We can't delete the gcno files, because they are created when tor is compiled
491 rm -f $(top_builddir)/src/*/*.gcda $(top_builddir)/src/*/*/*.gcda \
492 $(top_builddir)/src/*/*.gcov $(top_builddir)/src/*/*/*.gcov
494 HTML_COVER_DIR=$(top_builddir)/coverage_html
497 test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
498 test -d "$(HTML_COVER_DIR)" || $(MKDIR_P) "$(HTML_COVER_DIR)"
499 lcov --rc lcov_branch_coverage=1 --directory $(top_builddir)/src --zerocounters
502 lcov --capture --rc lcov_branch_coverage=1 --no-external --directory $(top_builddir) --base-directory $(top_srcdir) --output-file "$(HTML_COVER_DIR)/lcov.tmp"
503 lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
504 genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
506 @printf "Not configured with --enable-coverage, run ./configure --enable-coverage\n"
509 coverage-html-full: all
510 test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
511 test -d "$(HTML_COVER_DIR)" || mkdir -p "$(HTML_COVER_DIR)"
512 lcov --rc lcov_branch_coverage=1 --directory ./src --zerocounters
515 $(MAKE) test-stem-full
516 CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh
517 CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh --flavor hs
518 lcov --capture --rc lcov_branch_coverage=1 --no-external --directory . --output-file "$(HTML_COVER_DIR)/lcov.tmp"
519 lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
520 genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
522 # For scripts: avoid src/ext and src/trunnel.
523 # Keep these lists consistent:
524 # - OWNED_TOR_C_FILES in Makefile.am
525 # - CHECK_FILES in pre-commit.git-hook and pre-push.git-hook
526 # - try_parse in check_cocci_parse.sh
528 $(top_srcdir)/src/lib/*/*.[ch] \
529 $(top_srcdir)/src/core/*/*.[ch] \
530 $(top_srcdir)/src/feature/*/*.[ch] \
531 $(top_srcdir)/src/app/*/*.[ch] \
532 $(top_srcdir)/src/test/*.[ch] \
533 $(top_srcdir)/src/test/*/*.[ch] \
534 $(top_srcdir)/src/tools/*.[ch]
538 $(PERL) $(top_srcdir)/scripts/maint/checkSpace.pl -C \
544 $(PYTHON) $(top_srcdir)/scripts/maint/practracker/includes.py $(top_srcdir)
547 check-best-practices:
549 @$(PYTHON) $(top_srcdir)/scripts/maint/practracker/practracker.py $(top_srcdir) $(TOR_PRACTRACKER_OPTIONS)
553 VERBOSE=1 $(top_srcdir)/scripts/coccinelle/check_cocci_parse.sh $(OWNED_TOR_C_FILES)
556 $(PYTHON) $(top_srcdir)/scripts/maint/practracker/practracker.py --regen $(top_srcdir)
559 $(PERL) $(top_builddir)/scripts/maint/checkOptionDocs.pl
562 $(top_srcdir)/scripts/maint/checkLogs.pl \
563 $(top_srcdir)/src/*/*.[ch] | sort -n
567 @if test -x "`which misspell 2>&1;true`"; then \
568 echo "Checking for Typos ..."; \
570 $(top_srcdir)/src/[^e]*/*.[ch] \
572 $(top_srcdir)/contrib \
573 $(top_srcdir)/scripts \
574 $(top_srcdir)/README \
575 $(top_srcdir)/ChangeLog \
576 $(top_srcdir)/INSTALL \
577 $(top_srcdir)/ReleaseNotes \
578 $(top_srcdir)/LICENSE); \
580 echo "Tor can use misspell to check for typos."; \
581 echo "It seems that you don't have misspell installed."; \
582 echo "You can install the latest version of misspell here: https://github.com/client9/misspell#install"; \
588 @if test -x "`which cargo-fmt 2>&1;true`"; then \
589 echo "Formatting Rust code ..."; \
590 (cd "$(top_srcdir)/src/rust" && cargo fmt --all --); \
592 echo "Tor uses rustfmt (via cargo-fmt) to format Rust code."; \
593 echo "However, it seems that you don't have rustfmt installed."; \
594 printf "You can install rustfmt by following the directions here:"; \
595 echo " https://github.com/rust-lang-nursery/rustfmt"; \
599 .PHONY: check-rustfmt
602 @if test -x "`which cargo-fmt 2>&1;true`"; then \
603 printf "Running rustfmt..."; \
604 (cd "$(top_srcdir)/src/rust" && cargo fmt --all -- --check && echo "done.") || \
605 (echo "**************** check-rustfmt failed. ****************"; \
606 echo " Run \`make rustfmt\` to apply the above changes."; \
609 echo "Tor uses rustfmt (via cargo-fmt) to format Rust code."; \
610 echo "However, it seems that you don't have rustfmt installed."; \
611 printf "You can install rustfmt by following the directions here:"; \
612 echo " https://github.com/rust-lang-nursery/rustfmt"; \
619 @if test -x "`which cargo-clippy 2>&1;true`"; then \
620 echo "Running cargo clippy ..."; \
621 echo "Prepare yourself for the onslaught of suggestions ..."; \
622 (cd "$(top_srcdir)/src/rust" && cargo clippy); \
624 echo "Tor can use clippy to lint Rust code."; \
625 echo "However, it seems that you don't have clippy installed."; \
626 echo "You can install the latest version of clippy by following the directions here: https://github.com/rust-lang-nursery/rust-clippy"; \
630 .PHONY: check-changes
633 @if test -d "$(top_srcdir)/changes"; then \
634 PACKAGE_VERSION=$(PACKAGE_VERSION) $(PYTHON) $(top_srcdir)/scripts/maint/lintChanges.py $(top_srcdir)/changes; \
638 .PHONY: update-versions
640 abs_top_srcdir="$(abs_top_srcdir)" $(PYTHON) $(top_srcdir)/scripts/maint/update_versions.py
644 cd $(top_builddir); $(abs_top_srcdir)/scripts/maint/run_calltool.sh
647 @echo "Tor @VERSION@"
648 @if test -d "$(top_srcdir)/.git" && test -x "`which git 2>&1;true`"; then \
650 (cd "$(top_srcdir)" && git rev-parse --short=16 HEAD); \
653 .PHONY: autostyle-ifdefs
655 $(PYTHON) $(top_srcdir)/scripts/maint/annotate_ifdef_directives.py $(OWNED_TOR_C_FILES)
657 .PHONY: autostyle-ifdefs
659 $(PERL) $(top_srcdir)/scripts/coccinelle/test-operator-cleanup $(OWNED_TOR_C_FILES)
661 .PHONY: rectify-includes
663 cd $(top_srcdir); $(PYTHON) $(abs_top_srcdir)/scripts/maint/rectify_include_paths.py
665 .PHONY: update-copyright
667 $(PERL) $(top_srcdir)/scripts/maint/updateCopyright.pl $(OWNED_TOR_C_FILES)
670 autostyle: update-versions rustfmt autostyle-ifdefs rectify-includes
673 rm -f $(top_builddir)/src/*/*.gc{da,no} $(top_builddir)/src/*/*/*.gc{da,no}
674 rm -rf $(HTML_COVER_DIR)
675 rm -rf $(top_builddir)/doc/doxygen
676 rm -rf $(TEST_NETWORK_ALL_LOG_DIR)
679 rm -rf $(top_builddir)/src/rust/target
680 rm -rf $(top_builddir)/src/rust/.cargo/registry
683 distclean-local: distclean-rust
686 # This relies on some internal details of how automake implements
687 # distcheck. We check two directories because automake-1.15 changed
688 # from $(distdir)/_build to $(distdir)/_build/sub.
689 show-distdir-testlog:
690 @if test -d "$(distdir)/_build/sub"; then \
691 cat $(distdir)/_build/sub/$(TEST_SUITE_LOG); \
693 cat $(distdir)/_build/$(TEST_SUITE_LOG); fi
695 # Similarly, this relies on automake internals to run file on an
696 # intermittent core file whose provenance is not known to us. See
699 @if test -d "$(distdir)/_build/sub"; then \
700 file $(distdir)/_build/sub/core ; \
702 file $(distdir)/_build/core; fi
705 @echo $(TOR_INTERNAL_LIBS)
708 @echo $(TOR_INTERNAL_TESTING_LIBS)
710 # Note here that we hardcode this -j2 because if the user would pass too many
711 # cores, bear actually chockes and dies :S. For this to work, a make clean
712 # needs to be done else bear will miss some compile flags.
714 @if test -x "`which bear 2>&1;true`"; then \
715 echo "Generating LSP compile_commands.json. Might take few minutes..."; \
716 $(MAKE) clean 2>&1 >/dev/null; \
717 bear >/dev/null 2>&1 -- $(MAKE) -j2 2>&1 >/dev/null; \
718 echo "Generating .ccls file..."; \
719 ./scripts/maint/gen_ccls_file.sh \
721 echo "No bear command found. On debian, apt install bear"; \