Merge branch 'maint-0.3.5' into maint-0.4.3
[tor.git] / Makefile.am
blob117c6a5a70c786f0e9882312192dd6114fa41432
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-intmath.a \
74         src/lib/libtor-ctime.a
76 # Variants of the above for linking the testing variant of tor (for coverage
77 # and tests)
78 if UNITTESTS_ENABLED
79 TOR_UTIL_TESTING_LIBS = \
80         src/lib/libtor-geoip-testing.a \
81         src/lib/libtor-process-testing.a \
82         src/lib/libtor-buf-testing.a \
83         src/lib/libtor-confmgt-testing.a \
84         src/lib/libtor-pubsub-testing.a \
85         src/lib/libtor-dispatch-testing.a \
86         src/lib/libtor-time-testing.a \
87         src/lib/libtor-fs-testing.a \
88         src/lib/libtor-encoding-testing.a \
89         src/lib/libtor-sandbox-testing.a \
90         src/lib/libtor-container-testing.a \
91         src/lib/libtor-net-testing.a \
92         src/lib/libtor-thread-testing.a \
93         src/lib/libtor-memarea-testing.a \
94         src/lib/libtor-math-testing.a \
95         src/lib/libtor-meminfo-testing.a \
96         src/lib/libtor-osinfo-testing.a \
97         src/lib/libtor-term-testing.a \
98         src/lib/libtor-log-testing.a \
99         src/lib/libtor-lock-testing.a \
100         src/lib/libtor-fdio-testing.a \
101         src/lib/libtor-string-testing.a \
102         src/lib/libtor-smartlist-core-testing.a \
103         src/lib/libtor-malloc-testing.a \
104         src/lib/libtor-wallclock-testing.a \
105         src/lib/libtor-err-testing.a \
106         src/lib/libtor-version-testing.a \
107         src/lib/libtor-intmath.a \
108         src/lib/libtor-ctime-testing.a
109 endif
111 # Internal crypto libraries used in Tor
112 TOR_CRYPTO_LIBS = \
113         src/lib/libtor-tls.a \
114         src/lib/libtor-crypt-ops.a \
115         $(LIBKECCAK_TINY) \
116         $(LIBDONNA)
118 # Variants of the above for linking the testing variant of tor (for coverage
119 # and tests)
120 if UNITTESTS_ENABLED
121 TOR_CRYPTO_TESTING_LIBS = \
122         src/lib/libtor-tls-testing.a \
123         src/lib/libtor-crypt-ops-testing.a \
124         $(LIBKECCAK_TINY) \
125         $(LIBDONNA)
126 endif
128 # All static libraries used to link tor.
129 TOR_INTERNAL_LIBS = \
130         src/core/libtor-app.a \
131         src/lib/libtor-compress.a \
132         src/lib/libtor-evloop.a \
133         $(TOR_CRYPTO_LIBS) \
134         $(TOR_UTIL_LIBS) \
135         src/trunnel/libor-trunnel.a \
136         src/lib/libtor-trace.a
138 # Variants of the above for linking the testing variant of tor (for coverage
139 # and tests)
140 if UNITTESTS_ENABLED
141 TOR_INTERNAL_TESTING_LIBS = \
142         src/core/libtor-app-testing.a \
143         src/lib/libtor-compress-testing.a \
144         src/lib/libtor-evloop-testing.a \
145         $(TOR_CRYPTO_TESTING_LIBS) \
146         $(TOR_UTIL_TESTING_LIBS) \
147         src/trunnel/libor-trunnel-testing.a \
148         src/lib/libtor-trace.a
149 endif
151 TOR_LDFLAGS_CRYPTLIB=@TOR_LDFLAGS_openssl@
152 TOR_LIBS_CRYPTLIB=@TOR_OPENSSL_LIBS@
153 TOR_CFLAGS_CRYPTLIB=
154 if USE_NSS
155 TOR_CFLAGS_CRYPTLIB+=@NSS_CFLAGS@
156 TOR_LIBS_CRYPTLIB+=@NSS_LIBS@
157 endif
159 # All libraries used to link tor-cov
161 include src/include.am
162 include doc/include.am
163 include contrib/include.am
165 manpages: $(nodist_man1_MANS)
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 need-chutney-path:
279         @if test ! -d "$$CHUTNEY_PATH"; then \
280                 echo '$$CHUTNEY_PATH was not set.'; \
281                 if test -d $(top_srcdir)/../chutney -a -x $(top_srcdir)/../chutney/chutney; then \
282                         echo "Assuming test-network.sh will find" $(top_srcdir)/../chutney; \
283                 else \
284                         echo; \
285                         echo "To run these tests, git clone https://git.torproject.org/chutney.git ; export CHUTNEY_PATH=\`pwd\`/chutney"; \
286                         exit 1; \
287                 fi \
288         fi
290 # Note that test-network requires a copy of Chutney in $CHUTNEY_PATH.
291 # Chutney can be cloned from https://git.torproject.org/chutney.git .
292 test-network: need-chutney-path $(TESTING_TOR_BINARY) src/tools/tor-gencert
293         $(top_srcdir)/src/test/test-network.sh $(TEST_NETWORK_FLAGS)
295 # Run all available tests using automake's test-driver
296 #   - only run IPv6 tests if we can ping6 or ping -6 ::1 (localhost)
297 #     we try the syntax for BSD ping6, Linux ping6, and Linux ping -6,
298 #     because they're incompatible
299 #   - some IPv6 tests may fail without an IPv6 DNS server
300 #     (see #16971 and #17011)
301 #   - only run mixed tests if we have a tor-stable binary
302 #   - show tor warnings on the console after each network run
303 #     (otherwise, warnings go to the logs, and people don't see them unless
304 #     there is a network failure)
305 test-network-all: need-chutney-path test-driver $(TESTING_TOR_BINARY) src/tools/tor-gencert
306         mkdir -p $(TEST_NETWORK_ALL_LOG_DIR)
307         rm -f $(TEST_NETWORK_ALL_LOG_DIR)/*.log $(TEST_NETWORK_ALL_LOG_DIR)/*.trs
308         @flavors="$(TEST_CHUTNEY_FLAVORS)"; \
309         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 \
310                 echo "ping6 ::1 or ping ::1 succeeded, running IPv6 flavors: $(TEST_CHUTNEY_FLAVORS_IPV6)."; \
311                 flavors="$$flavors $(TEST_CHUTNEY_FLAVORS_IPV6)"; \
312         else \
313                 echo "ping6 ::1 and ping ::1 failed, skipping IPv6 flavors: $(TEST_CHUTNEY_FLAVORS_IPV6)."; \
314                 skip_flavors="$$skip_flavors $(TEST_CHUTNEY_FLAVORS_IPV6)"; \
315         fi; \
316         if command -v tor-stable >/dev/null 2>&1; then \
317                 echo "tor-stable found, running mixed flavors: $(TEST_CHUTNEY_FLAVORS_MIXED)."; \
318                 flavors="$$flavors $(TEST_CHUTNEY_FLAVORS_MIXED)"; \
319         else \
320                 echo "tor-stable not found, skipping mixed flavors: $(TEST_CHUTNEY_FLAVORS_MIXED)."; \
321                 skip_flavors="$$skip_flavors $(TEST_CHUTNEY_FLAVORS_MIXED)"; \
322         fi; \
323         for f in $$skip_flavors; do \
324                 echo "SKIP: $$f"; \
325         done; \
326         for f in $$flavors; do \
327                 $(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); \
328                 $(top_srcdir)/src/test/test-network.sh $(TEST_NETWORK_SHOW_WARNINGS_FOR_LAST_RUN_FLAGS); \
329         done; \
330         echo "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)."; \
331         ! grep -q FAIL $(TEST_NETWORK_ALL_LOG_DIR)/*.trs
333 need-stem-path:
334         @if test ! -d "$$STEM_SOURCE_DIR"; then \
335                 echo '$$STEM_SOURCE_DIR was not set.'; echo; \
336                 echo "To run these tests, git clone https://git.torproject.org/stem.git/ ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \
337                 exit 1; \
338         fi
340 test-stem: need-stem-path $(TESTING_TOR_BINARY)
341         @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --integ --test control.controller --test control.base_controller --test process --log notice;
343 test-stem-full: need-stem-path $(TESTING_TOR_BINARY)
344         @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --all --log notice --target RUN_ALL,ONLINE -v;
346 test-full:                                      \
347         need-stem-path                          \
348         need-chutney-path                       \
349         check                                   \
350         test-network                            \
351         test-stem
353 test-full-online:                               \
354         need-stem-path                          \
355         need-chutney-path                       \
356         check                                   \
357         test-network                            \
358         test-stem-full
360 # We can't delete the gcno files, because they are created when tor is compiled
361 reset-gcov:
362         rm -f $(top_builddir)/src/*/*.gcda $(top_builddir)/src/*/*/*.gcda \
363               $(top_builddir)/src/*/*.gcov $(top_builddir)/src/*/*/*.gcov
365 HTML_COVER_DIR=$(top_builddir)/coverage_html
366 coverage-html: all
367 if COVERAGE_ENABLED
368         test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
369         test -d "$(HTML_COVER_DIR)" || $(MKDIR_P) "$(HTML_COVER_DIR)"
370         lcov --rc lcov_branch_coverage=1 --directory $(top_builddir)/src --zerocounters
371         $(MAKE) reset-gcov
372         $(MAKE) check
373         lcov --capture --rc lcov_branch_coverage=1 --no-external --directory $(top_builddir) --base-directory $(top_srcdir) --output-file "$(HTML_COVER_DIR)/lcov.tmp"
374         lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
375         genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
376 else
377         @printf "Not configured with --enable-coverage, run ./configure --enable-coverage\n"
378 endif
380 coverage-html-full: all
381         test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
382         test -d "$(HTML_COVER_DIR)" || mkdir -p "$(HTML_COVER_DIR)"
383         lcov --rc lcov_branch_coverage=1 --directory ./src --zerocounters
384         $(MAKE) reset-gcov
385         $(MAKE) check
386         $(MAKE) test-stem-full
387         CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh
388         CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh --flavor hs
389         lcov --capture --rc lcov_branch_coverage=1 --no-external --directory . --output-file "$(HTML_COVER_DIR)/lcov.tmp"
390         lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
391         genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
393 # For scripts: avoid src/ext and src/trunnel.
394 # Keep these lists consistent:
395 #   - OWNED_TOR_C_FILES in Makefile.am
396 #   - CHECK_FILES in pre-commit.git-hook and pre-push.git-hook
397 #   - try_parse in check_cocci_parse.sh
398 OWNED_TOR_C_FILES=\
399                 $(top_srcdir)/src/lib/*/*.[ch] \
400                 $(top_srcdir)/src/core/*/*.[ch] \
401                 $(top_srcdir)/src/feature/*/*.[ch] \
402                 $(top_srcdir)/src/app/*/*.[ch] \
403                 $(top_srcdir)/src/test/*.[ch] \
404                 $(top_srcdir)/src/test/*/*.[ch] \
405                 $(top_srcdir)/src/tools/*.[ch]
407 check-spaces:
408 if USE_PERL
409         $(PERL) $(top_srcdir)/scripts/maint/checkSpace.pl -C \
410                 $(OWNED_TOR_C_FILES)
411 endif
413 check-includes:
414 if USEPYTHON
415         $(PYTHON) $(top_srcdir)/scripts/maint/practracker/includes.py $(top_srcdir)
416 endif
418 check-best-practices:
419 if USEPYTHON
420         @$(PYTHON) $(top_srcdir)/scripts/maint/practracker/practracker.py $(top_srcdir) $(TOR_PRACTRACKER_OPTIONS)
421 endif
423 check-cocci:
424         VERBOSE=1 $(top_srcdir)/scripts/coccinelle/check_cocci_parse.sh $(OWNED_TOR_C_FILES)
426 practracker-regen:
427         $(PYTHON) $(top_srcdir)/scripts/maint/practracker/practracker.py --regen $(top_srcdir)
429 check-docs: all
430         $(PERL) $(top_builddir)/scripts/maint/checkOptionDocs.pl
432 check-logs:
433         $(top_srcdir)/scripts/maint/checkLogs.pl \
434                 $(top_srcdir)/src/*/*.[ch] | sort -n
436 .PHONY: check-typos
437 check-typos:
438         @if test -x "`which misspell 2>&1;true`"; then \
439                 echo "Checking for Typos ..."; \
440                 (misspell \
441                         $(top_srcdir)/src/[^e]*/*.[ch] \
442                         $(top_srcdir)/doc \
443                         $(top_srcdir)/contrib \
444                         $(top_srcdir)/scripts \
445                         $(top_srcdir)/README \
446                         $(top_srcdir)/ChangeLog \
447                         $(top_srcdir)/INSTALL \
448                         $(top_srcdir)/ReleaseNotes \
449                         $(top_srcdir)/LICENSE); \
450         else \
451                 echo "Tor can use misspell to check for typos."; \
452                 echo "It seems that you don't have misspell installed."; \
453                 echo "You can install the latest version of misspell here: https://github.com/client9/misspell#install"; \
454         fi
456 .PHONY: rustfmt
457 rustfmt:
458 if USE_RUST
459         @if test -x "`which cargo-fmt 2>&1;true`"; then \
460                 echo "Formatting Rust code ..."; \
461                 (cd "$(top_srcdir)/src/rust" && cargo fmt --all --); \
462         else \
463                 echo "Tor uses rustfmt (via cargo-fmt) to format Rust code."; \
464                 echo "However, it seems that you don't have rustfmt installed."; \
465                 printf "You can install rustfmt by following the directions here:"; \
466                 echo " https://github.com/rust-lang-nursery/rustfmt"; \
467         fi
468 endif
470 .PHONY: check-rustfmt
471 check-rustfmt:
472 if USE_RUST
473         @if test -x "`which cargo-fmt 2>&1;true`"; then \
474                 printf "Running rustfmt..."; \
475                 (cd "$(top_srcdir)/src/rust" && cargo fmt --all -- --check && echo "done.") || \
476                 (echo "**************** check-rustfmt failed. ****************"; \
477                  echo "   Run \`make rustfmt\` to apply the above changes."; \
478                  exit 1); \
479         else \
480                 echo "Tor uses rustfmt (via cargo-fmt) to format Rust code."; \
481                 echo "However, it seems that you don't have rustfmt installed."; \
482                 printf "You can install rustfmt by following the directions here:"; \
483                 echo " https://github.com/rust-lang-nursery/rustfmt"; \
484         fi
485 endif
487 .PHONY: clippy
488 clippy:
489 if USE_RUST
490         @if test -x "`which cargo-clippy 2>&1;true`"; then \
491                 echo "Running cargo clippy ..."; \
492                 echo "Prepare yourself for the onslaught of suggestions ..."; \
493                 (cd "$(top_srcdir)/src/rust" && cargo clippy); \
494         else \
495                 echo "Tor can use clippy to lint Rust code."; \
496                 echo "However, it seems that you don't have clippy installed."; \
497                 echo "You can install the latest version of clippy by following the directions here: https://github.com/rust-lang-nursery/rust-clippy"; \
498         fi
499 endif
501 .PHONY: check-changes
502 check-changes:
503 if USEPYTHON
504         @if test -d "$(top_srcdir)/changes"; then \
505                 PACKAGE_VERSION=$(PACKAGE_VERSION) $(PYTHON) $(top_srcdir)/scripts/maint/lintChanges.py $(top_srcdir)/changes; \
506                 fi
507 endif
509 .PHONY: update-versions
510 update-versions:
511         abs_top_srcdir="$(abs_top_srcdir)" $(PYTHON) $(top_srcdir)/scripts/maint/update_versions.py
513 .PHONY: callgraph
514 callgraph:
515         cd $(top_builddir); $(abs_top_srcdir)/scripts/maint/run_calltool.sh
517 version:
518         @echo "Tor @VERSION@"
519         @if test -d "$(top_srcdir)/.git" && test -x "`which git 2>&1;true`"; then \
520            echo -n "git: " ;\
521            (cd "$(top_srcdir)" && git rev-parse --short=16 HEAD); \
522         fi
524 .PHONY: autostyle-ifdefs
525 autostyle-ifdefs:
526         $(PYTHON) $(top_srcdir)/scripts/maint/annotate_ifdef_directives.py $(OWNED_TOR_C_FILES)
528 .PHONY: autostyle-ifdefs
529 autostyle-operators:
530         $(PERL) $(top_srcdir)/scripts/coccinelle/test-operator-cleanup $(OWNED_TOR_C_FILES)
532 .PHONY: rectify-includes
533 rectify-includes:
534         cd $(top_srcdir); $(PYTHON) $(abs_top_srcdir)/scripts/maint/rectify_include_paths.py
536 .PHONY: update-copyright
537 update-copyright:
538         $(PERL) $(top_srcdir)/scripts/maint/updateCopyright.pl $(OWNED_TOR_C_FILES)
540 .PHONY: autostyle
541 autostyle: update-versions rustfmt autostyle-ifdefs rectify-includes
543 mostlyclean-local:
544         rm -f $(top_builddir)/src/*/*.gc{da,no} $(top_builddir)/src/*/*/*.gc{da,no}
545         rm -rf $(HTML_COVER_DIR)
546         rm -rf $(top_builddir)/doc/doxygen
547         rm -rf $(TEST_NETWORK_ALL_LOG_DIR)
549 clean-local:
550         rm -rf $(top_builddir)/src/rust/target
551         rm -rf $(top_builddir)/src/rust/.cargo/registry
553 if USE_RUST
554 distclean-local: distclean-rust
555 endif
557 # This relies on some internal details of how automake implements
558 # distcheck.  We check two directories because automake-1.15 changed
559 # from $(distdir)/_build to $(distdir)/_build/sub.
560 show-distdir-testlog:
561         @if test -d "$(distdir)/_build/sub"; then \
562           cat $(distdir)/_build/sub/$(TEST_SUITE_LOG); \
563         else \
564           cat $(distdir)/_build/$(TEST_SUITE_LOG); fi
566 # Similarly, this relies on automake internals to run file on an
567 # intermittent core file whose provenance is not known to us.  See
568 # ticket 26787.
569 show-distdir-core:
570         @if test -d "$(distdir)/_build/sub"; then \
571           file $(distdir)/_build/sub/core ; \
572         else \
573           file $(distdir)/_build/core; fi
575 show-libs:
576         @echo $(TOR_INTERNAL_LIBS)
578 show-testing-libs:
579         @echo $(TOR_INTERNAL_TESTING_LIBS)
581 # Note here that we hardcode this -j2 because if the user would pass too many
582 # cores, bear actually chockes and dies :S. For this to work, a make clean
583 # needs to be done else bear will miss some compile flags.
584 lsp:
585         @if test -x "`which bear 2>&1;true`"; then \
586                 echo "Generating LSP compile_commands.json. Might take few minutes..."; \
587                 $(MAKE) clean 2>&1 >/dev/null; \
588                 bear >/dev/null 2>&1 -- $(MAKE) -j2 2>&1 >/dev/null; \
589                 echo "Generating .ccls file..."; \
590                 ./scripts/maint/gen_ccls_file.sh \
591         else \
592                 echo "No bear command found. On debian, apt install bear"; \
593         fi