Merge branch 'maint-0.4.8'
[tor.git] / Makefile.am
blobed43ec72fca0f52d60cf11a48385d1e260696c0f
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 # "Common" libraries used to link tor's utility code.
40 TOR_UTIL_LIBS = \
41         src/lib/libtor-geoip.a \
42         src/lib/libtor-process.a \
43         src/lib/libtor-buf.a \
44         src/lib/libtor-confmgt.a \
45         src/lib/libtor-pubsub.a \
46         src/lib/libtor-dispatch.a \
47         src/lib/libtor-time.a \
48         src/lib/libtor-fs.a \
49         src/lib/libtor-encoding.a \
50         src/lib/libtor-sandbox.a \
51         src/lib/libtor-container.a \
52         src/lib/libtor-net.a \
53         src/lib/libtor-thread.a \
54         src/lib/libtor-memarea.a \
55         src/lib/libtor-math.a \
56         src/lib/libtor-meminfo.a \
57         src/lib/libtor-osinfo.a \
58         src/lib/libtor-log.a \
59         src/lib/libtor-lock.a \
60         src/lib/libtor-fdio.a \
61         src/lib/libtor-string.a \
62         src/lib/libtor-term.a \
63         src/lib/libtor-smartlist-core.a \
64         src/lib/libtor-malloc.a \
65         src/lib/libtor-wallclock.a \
66         src/lib/libtor-err.a \
67         src/lib/libtor-version.a \
68         src/lib/libtor-llharden.a \
69         src/lib/libtor-intmath.a \
70         src/lib/libtor-ctime.a \
71         src/lib/libtor-metrics.a
73 # Variants of the above for linking the testing variant of tor (for coverage
74 # and tests)
75 if UNITTESTS_ENABLED
76 TOR_UTIL_TESTING_LIBS = \
77         src/lib/libtor-geoip-testing.a \
78         src/lib/libtor-process-testing.a \
79         src/lib/libtor-buf-testing.a \
80         src/lib/libtor-confmgt-testing.a \
81         src/lib/libtor-pubsub-testing.a \
82         src/lib/libtor-dispatch-testing.a \
83         src/lib/libtor-time-testing.a \
84         src/lib/libtor-fs-testing.a \
85         src/lib/libtor-encoding-testing.a \
86         src/lib/libtor-sandbox-testing.a \
87         src/lib/libtor-container-testing.a \
88         src/lib/libtor-net-testing.a \
89         src/lib/libtor-thread-testing.a \
90         src/lib/libtor-memarea-testing.a \
91         src/lib/libtor-math-testing.a \
92         src/lib/libtor-meminfo-testing.a \
93         src/lib/libtor-osinfo-testing.a \
94         src/lib/libtor-term-testing.a \
95         src/lib/libtor-log-testing.a \
96         src/lib/libtor-lock-testing.a \
97         src/lib/libtor-fdio-testing.a \
98         src/lib/libtor-string-testing.a \
99         src/lib/libtor-smartlist-core-testing.a \
100         src/lib/libtor-malloc-testing.a \
101         src/lib/libtor-wallclock-testing.a \
102         src/lib/libtor-err-testing.a \
103         src/lib/libtor-version-testing.a \
104         src/lib/libtor-llharden-testing.a \
105         src/lib/libtor-intmath.a \
106         src/lib/libtor-ctime-testing.a \
107         src/lib/libtor-metrics-testing.a
108 endif
110 # Internal crypto libraries used in Tor
111 TOR_CRYPTO_LIBS = \
112         src/lib/libtor-tls.a \
113         src/lib/libtor-crypt-ops.a \
114         $(LIBKECCAK_TINY) \
115         $(LIBDONNA)
117 if BUILD_MODULE_POW
118 TOR_CRYPTO_LIBS += $(EQUIX_LIBS)
119 endif
121 # Variants of the above for linking the testing variant of tor (for coverage
122 # and tests)
123 if UNITTESTS_ENABLED
124 TOR_CRYPTO_TESTING_LIBS = \
125         src/lib/libtor-tls-testing.a \
126         src/lib/libtor-crypt-ops-testing.a \
127         $(LIBKECCAK_TINY) \
128         $(LIBDONNA) \
129         $(EQUIX_LIBS)
130 endif
132 # All static libraries used to link tor.
133 TOR_INTERNAL_LIBS = \
134         src/core/libtor-app.a \
135         src/lib/libtor-compress.a \
136         src/lib/libtor-evloop.a \
137         $(TOR_CRYPTO_LIBS) \
138         $(TOR_UTIL_LIBS) \
139         src/trunnel/libor-trunnel.a \
140         src/lib/libtor-trace.a
142 libtor.a: $(TOR_INTERNAL_LIBS)
143         $(AM_V_AR) export AR="$(AR)"; \
144         export ARFLAGS="$(ARFLAGS)"; \
145         export RANLIB="$(RANLIB)"; \
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         README.md                                                               \
194         ReleaseNotes                                                    \
195         scripts/build/combine_libs                                      \
196         scripts/maint/checkIncludes.py                                  \
197         scripts/maint/checkSpace.pl                                     \
198         scripts/maint/checkSpaceTest.sh                                 \
199         scripts/maint/checkspace_tests/dubious.c                        \
200         scripts/maint/checkspace_tests/dubious.h                        \
201         scripts/maint/checkspace_tests/expected.txt                     \
202         scripts/maint/checkspace_tests/good_guard.h                     \
203         scripts/maint/checkspace_tests/same_guard.h                     \
204         scripts/maint/checkspace_tests/subdir/dubious.c                 \
205         scripts/maint/checkShellScripts.sh                              \
206         scripts/maint/practracker/README                                \
207         scripts/maint/practracker/exceptions.txt                        \
208         scripts/maint/practracker/includes.py                           \
209         scripts/maint/practracker/metrics.py                            \
210         scripts/maint/practracker/practracker.py                        \
211         scripts/maint/practracker/practracker_tests.py                  \
212         scripts/maint/practracker/problem.py                            \
213         scripts/maint/practracker/testdata/.may_include                 \
214         scripts/maint/practracker/testdata/a.c                          \
215         scripts/maint/practracker/testdata/b.c                          \
216         scripts/maint/practracker/testdata/ex0-expected.txt             \
217         scripts/maint/practracker/testdata/ex0.txt                      \
218         scripts/maint/practracker/testdata/ex1-expected.txt             \
219         scripts/maint/practracker/testdata/ex1.txt                      \
220         scripts/maint/practracker/testdata/ex1-overbroad-expected.txt   \
221         scripts/maint/practracker/testdata/ex1-regen-expected.txt       \
222         scripts/maint/practracker/testdata/ex1-regen-overbroad-expected.txt \
223         scripts/maint/practracker/testdata/ex.txt                       \
224         scripts/maint/practracker/testdata/header.h                     \
225         scripts/maint/practracker/testdata/not_c_file                   \
226         scripts/maint/practracker/test_practracker.sh                   \
227         scripts/maint/practracker/util.py                               \
228         scripts/coccinelle/apply.sh                                     \
229         scripts/coccinelle/check_cocci_parse.sh                         \
230         scripts/coccinelle/exceptions.txt                               \
231         scripts/coccinelle/test-operator-cleanup                        \
232         scripts/coccinelle/tor-coccinelle.h                             \
233         scripts/coccinelle/try_parse.sh
235 ## This tells etags how to find mockable function definitions.
236 AM_ETAGSFLAGS=--regex='{c}/MOCK_IMPL([^,]+,\W*\([a-zA-Z0-9_]+\)\W*,/\1/s'
238 if COVERAGE_ENABLED
239 TEST_CFLAGS=-fno-inline -fprofile-arcs -ftest-coverage
240 if DISABLE_ASSERTS_IN_UNIT_TESTS
241 TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE -DDISABLE_ASSERTS_IN_UNIT_TESTS @TOR_MODULES_ALL_ENABLED@
242 else
243 TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE @TOR_MODULES_ALL_ENABLED@
244 endif
245 TEST_NETWORK_FLAGS=--coverage --hs-multi-client 1
246 else
247 TEST_CFLAGS=
248 TEST_CPPFLAGS=-DTOR_UNIT_TESTS @TOR_MODULES_ALL_ENABLED@
249 TEST_NETWORK_FLAGS=--hs-multi-client 1
250 endif
251 TEST_NETWORK_SHOW_WARNINGS_FOR_LAST_RUN_FLAGS=--quiet --only-warnings
253 if LIBFUZZER_ENABLED
254 TEST_CFLAGS += -fsanitize=fuzzer-no-link
255 # not "edge"
256 endif
258 TEST_NETWORK_ALL_LOG_DIR=$(top_builddir)/test_network_log
259 TEST_NETWORK_ALL_DRIVER_FLAGS=--color-tests yes
261 #install-data-local:
262 #       $(INSTALL) -m 755 -d $(LOCALSTATEDIR)/lib/tor
264 # Allows to override rpmbuild with rpmbuild-md5 from fedora-packager so that
265 # building for EL5 won't fail on https://bugzilla.redhat.com/show_bug.cgi?id=490613
266 RPMBUILD ?= rpmbuild
268 # Use automake's dist-gzip target to build the tarball
269 dist-rpm: dist-gzip
270         TIMESTAMP=$$(date +"%Y-%m-%d_%H.%M.%S");                                \
271         RPM_BUILD_DIR=$$(mktemp -d "/tmp/tor-rpm-build-$$TIMESTAMP-XXXX");      \
272         mkdir -p "$$RPM_BUILD_DIR"/{BUILD,RPMS,SOURCES/"tor-$(VERSION)",SPECS,SRPMS}; \
273         cp -fa "$(distdir).tar.gz" "$$RPM_BUILD_DIR"/SOURCES/;                  \
274         LIBS=-lrt $(RPMBUILD) -ba --define "_topdir $$RPM_BUILD_DIR" tor.spec;  \
275         cp -fa "$$RPM_BUILD_DIR"/SRPMS/* .;                                     \
276         cp -fa "$$RPM_BUILD_DIR"/RPMS/* .;                                      \
277         rm -rf "$$RPM_BUILD_DIR";                                               \
278         echo "RPM build finished";                                              \
279         #end of dist-rpm
281 .PHONY: doxygen
282 doxygen: Doxyfile
283         mkdir -p doc/doxygen
284         (cd "$(top_srcdir)" && doxygen "$(abs_top_builddir)/Doxyfile")
286 test: all
287         $(top_builddir)/src/test/test
289 shellcheck:
290         $(top_srcdir)/scripts/maint/checkShellScripts.sh
292 check-local:                                    \
293         check-spaces                            \
294         check-changes                           \
295         check-includes                          \
296         shellcheck
298 # test-network requires a copy of Chutney in $CHUTNEY_PATH.
299 # Chutney can be cloned from https://gitlab.torproject.org/tpo/core/chutney.git .
300 .PHONY: need-chutney-path
301 need-chutney-path:
302         @if test ! -d "$$CHUTNEY_PATH"; then \
303                 echo '$$CHUTNEY_PATH was not set.'; \
304                 if test -d "$(top_srcdir)/../chutney" && \
305                    test -x "$(top_srcdir)/../chutney/chutney"; then \
306                         echo "Assuming test-network.sh will find" \
307                           "$(top_srcdir)/../chutney"; \
308                 else \
309                         echo; \
310                         echo "To run these tests," \
311                           "git clone" \
312                           "https://gitlab.torproject.org/tpo/core/chutney.git ;" \
313                           "export CHUTNEY_PATH=\`pwd\`/chutney"; \
314                         exit 1; \
315                 fi \
316         fi
318 # Run some basic tests using automake's test-driver
319 .PHONY: test-network
320 # Hide directory path logs from submakes using $(MAKE) -s
321 test-network:
322         @$(MAKE) -s test-network-mkdir
323         @$(MAKE) -s test-network-clean
324         @$(MAKE) -s test-network-run \
325           ipv4_flavors="$(TEST_CHUTNEY_FLAVOR_QUICK)" \
326           ipv6_flavors="$(TEST_CHUTNEY_FLAVOR_QUICK_IPV6)"
327         @$(MAKE) -s test-network-results
329 # Run all available tests using automake's test-driver
330 .PHONY: test-network-all
331 # Hide directory path logs from submakes using $(MAKE) -s
332 test-network-all:
333         @$(MAKE) -s test-network-mkdir
334         @$(MAKE) -s test-network-clean
335         @$(MAKE) -s test-network-run \
336           ipv4_flavors="$(TEST_CHUTNEY_FLAVORS)" \
337           mixed_flavors="$(TEST_CHUTNEY_FLAVORS_MIXED)" \
338           ipv6_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6)" \
339           ipv6_mixed_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6_MIXED)"
340         @$(MAKE) -s test-network-results
342 # Run IPv4 and mixed tests using automake's test-driver
343 .PHONY: test-network-ipv4
344 # Hide directory path logs from submakes using $(MAKE) -s
345 test-network-ipv4:
346         @$(MAKE) -s test-network-mkdir
347         @$(MAKE) -s test-network-clean
348         @$(MAKE) -s test-network-run \
349           ipv4_flavors="$(TEST_CHUTNEY_FLAVORS)" \
350           mixed_flavors="$(TEST_CHUTNEY_FLAVORS_MIXED)"
351         @$(MAKE) -s test-network-results
353 # Run IPv6 tests using automake's test-driver
354 .PHONY: test-network-ipv6
355 # Hide directory path logs from submakes using $(MAKE) -s
356 test-network-ipv6:
357         @$(MAKE) -s test-network-mkdir
358         @$(MAKE) -s test-network-clean
359         @$(MAKE) -s test-network-run \
360           ipv6_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6)" \
361           ipv6_mixed_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6_MIXED)"
362         @$(MAKE) -s test-network-results
364 # Make the test network log directory, if it does not exist
365 .PHONY: test-network-mkdir
366 test-network-mkdir:
367         @mkdir -p "$(TEST_NETWORK_ALL_LOG_DIR)"
369 # Clean the test network log directory
370 .PHONY: test-network-clean
371 # We need to remove all matching files, so we can't quote the glob part of the
372 # rm arguments
373 test-network-clean:
374         rm -f "$(TEST_NETWORK_ALL_LOG_DIR)"/*.log \
375               "$(TEST_NETWORK_ALL_LOG_DIR)"/*.trs
377 # Run tests using automake's test-driver
378 # When checking if a set of test can be run, log the type of test, and the
379 # list of tests that will be run (or skipped).
381 # Run the IPv4 tests in $(ipv4_flavors), unconditionally
382 #   - tor relays and directory authorities require IPv4.
383 # Run the IPv6 tests in $(ipv6_flavors), unconditionally
384 #   - clients don't technically require IPv6, but it's not worth
385 #     supporting running this test suite on such systems.
386 #   - some IPv6 tests may fail without an IPv6 DNS server
387 #     (see #16971 and #17011)
388 # Run the mixed tests in $(mixed_flavors), if a tor-stable binary is available
389 #   - only run mixed tests if we have a tor-stable binary
390 # Run the IPv6 mixed tests in $(ipv6_mixed_flavors), if IPv6 and mixed are run
391 #   - see above for details about IPv6 and mixed
392 .PHONY: test-network-run
393 # We need the word splitting in the "for" lines, so we can't quote
394 # $(skip_flavors) or $(flavors)
395 test-network-run: need-chutney-path test-driver $(TESTING_TOR_BINARY) src/tools/tor-gencert
396         @flavors=""; \
397         skip_flavors=""; \
398         if test -n "$(ipv4_flavors)"; then \
399                 echo "Running IPv4 flavors: $(ipv4_flavors)."; \
400                 flavors="$$flavors $(ipv4_flavors)"; \
401         fi; \
402         if test -n "$(ipv6_flavors)"; then \
403                 echo "Running IPv6 flavors: $(ipv6_flavors)."; \
404                 flavors="$$flavors $(ipv6_flavors)"; \
405         fi; \
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; \
411                 fi; \
412         fi; \
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)"; \
418                 else \
419                         echo "tor-stable not found, skipping mixed flavors:" \
420                           "$(mixed_flavors)."; \
421                         skip_flavors="$$skip_flavors $(mixed_flavors)"; \
422                 fi; \
423         fi; \
424         if test -n "$(ipv6_mixed_flavors)"; then \
425                 if test "$$test_network_mixed" = "true"; then \
426                         echo "Running IPv6 mixed flavors:" \
427                           "$(ipv6_mixed_flavors)."; \
428                         flavors="$$flavors $(ipv6_mixed_flavors)"; \
429                 else \
430                         echo "Skipping IPv6 mixed flavors:" \
431                           "$(ipv6_mixed_flavors)."; \
432                         skip_flavors="$$skip_flavors $(ipv6_mixed_flavors)"; \
433                 fi; \
434         fi; \
435         for f in $$skip_flavors; do \
436                 echo "SKIP: $$f"; \
437         done; \
438         for f in $$flavors; do \
439                 $(SHELL) "$(top_srcdir)/test-driver" --test-name "$$f" \
440                   --log-file "$(TEST_NETWORK_ALL_LOG_DIR)/$$f.log" \
441                   --trs-file "$(TEST_NETWORK_ALL_LOG_DIR)/$$f.trs" \
442                   $(TEST_NETWORK_ALL_DRIVER_FLAGS) \
443                   "$(top_srcdir)/src/test/test-network.sh" \
444                     --flavor "$$f" $(TEST_NETWORK_FLAGS); \
445                 "$(top_srcdir)/src/test/test-network.sh" \
446                   $(TEST_NETWORK_SHOW_WARNINGS_FOR_LAST_RUN_FLAGS); \
447         done
449 # Print the results from automake's test-driver
450 #   - show tor warnings on the console after each network run
451 #     (otherwise, warnings go to the logs, and people don't see them unless
452 #     there is a network failure)
453 .PHONY: test-network-results
454 # We need to grep all matching files, so we can't quote the glob part of the
455 # grep arguments
456 test-network-results:
457         @echo \
458           "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)."
459         @! grep -q FAIL "$(TEST_NETWORK_ALL_LOG_DIR)"/*.trs
461 need-stem-path:
462         @if test ! -d "$$STEM_SOURCE_DIR"; then \
463                 echo '$$STEM_SOURCE_DIR was not set.'; echo; \
464                 echo "To run these tests, git clone https://gitlab.torproject.org/tpo/network-health/stem ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \
465                 exit 1; \
466         fi
468 test-stem: need-stem-path $(TESTING_TOR_BINARY)
469         @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --integ --test control.controller --test control.base_controller --test process --log notice;
471 test-stem-full: need-stem-path $(TESTING_TOR_BINARY)
472         @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --all --log notice --target RUN_ALL,ONLINE -v;
474 test-full:                                      \
475         need-stem-path                          \
476         need-chutney-path                       \
477         check                                   \
478         test-network                            \
479         test-stem
481 test-full-online:                               \
482         need-stem-path                          \
483         need-chutney-path                       \
484         check                                   \
485         test-network                            \
486         test-stem-full
488 # We can't delete the gcno files, because they are created when tor is compiled
489 reset-gcov:
490         rm -f $(top_builddir)/src/*/*.gcda $(top_builddir)/src/*/*/*.gcda \
491               $(top_builddir)/src/*/*.gcov $(top_builddir)/src/*/*/*.gcov
493 HTML_COVER_DIR=$(top_builddir)/coverage_html
494 coverage-html: all
495 if COVERAGE_ENABLED
496         test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
497         test -d "$(HTML_COVER_DIR)" || $(MKDIR_P) "$(HTML_COVER_DIR)"
498         lcov --rc lcov_branch_coverage=1 --directory $(top_builddir)/src --zerocounters
499         $(MAKE) reset-gcov
500         $(MAKE) check
501         lcov --capture --rc lcov_branch_coverage=1 --no-external --directory $(top_builddir) --base-directory $(top_srcdir) --output-file "$(HTML_COVER_DIR)/lcov.tmp"
502         lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
503         genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
504 else
505         @printf "Not configured with --enable-coverage, run ./configure --enable-coverage\n"
506 endif
508 coverage-html-full: all
509         test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
510         test -d "$(HTML_COVER_DIR)" || mkdir -p "$(HTML_COVER_DIR)"
511         lcov --rc lcov_branch_coverage=1 --directory ./src --zerocounters
512         $(MAKE) reset-gcov
513         $(MAKE) check
514         $(MAKE) test-stem-full
515         CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh
516         CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh --flavor hs
517         lcov --capture --rc lcov_branch_coverage=1 --no-external --directory . --output-file "$(HTML_COVER_DIR)/lcov.tmp"
518         lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
519         genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
521 # For scripts: avoid src/ext and src/trunnel.
522 # Keep these lists consistent:
523 #   - OWNED_TOR_C_FILES in Makefile.am
524 #   - CHECK_FILES in pre-commit.git-hook and pre-push.git-hook
525 #   - try_parse in check_cocci_parse.sh
526 OWNED_TOR_C_FILES=\
527                 $(top_srcdir)/src/lib/*/*.[ch] \
528                 $(top_srcdir)/src/core/*/*.[ch] \
529                 $(top_srcdir)/src/feature/*/*.[ch] \
530                 $(top_srcdir)/src/app/*/*.[ch] \
531                 $(top_srcdir)/src/test/*.[ch] \
532                 $(top_srcdir)/src/test/*/*.[ch] \
533                 $(top_srcdir)/src/tools/*.[ch]
535 check-spaces:
536 if USE_PERL
537         $(PERL) $(top_srcdir)/scripts/maint/checkSpace.pl -C \
538                 $(OWNED_TOR_C_FILES)
539 endif
541 check-includes:
542 if USEPYTHON
543         $(PYTHON) $(top_srcdir)/scripts/maint/practracker/includes.py $(top_srcdir)
544 endif
546 check-best-practices:
547 if USEPYTHON
548         @$(PYTHON) $(top_srcdir)/scripts/maint/practracker/practracker.py $(top_srcdir) $(TOR_PRACTRACKER_OPTIONS)
549 endif
551 check-cocci:
552         VERBOSE=1 $(top_srcdir)/scripts/coccinelle/check_cocci_parse.sh $(OWNED_TOR_C_FILES)
554 practracker-regen:
555         $(PYTHON) $(top_srcdir)/scripts/maint/practracker/practracker.py --regen $(top_srcdir)
557 check-docs: all
558         $(PERL) $(top_builddir)/scripts/maint/checkOptionDocs.pl
560 check-logs:
561         $(top_srcdir)/scripts/maint/checkLogs.pl \
562                 $(top_srcdir)/src/*/*.[ch] | sort -n
564 .PHONY: check-typos
565 check-typos:
566         @if test -x "`which misspell 2>&1;true`"; then \
567                 echo "Checking for Typos ..."; \
568                 (misspell \
569                         $(top_srcdir)/src/[^e]*/*.[ch] \
570                         $(top_srcdir)/doc \
571                         $(top_srcdir)/contrib \
572                         $(top_srcdir)/scripts \
573                         $(top_srcdir)/README.md \
574                         $(top_srcdir)/ChangeLog \
575                         $(top_srcdir)/INSTALL \
576                         $(top_srcdir)/ReleaseNotes \
577                         $(top_srcdir)/LICENSE); \
578         else \
579                 echo "Tor can use misspell to check for typos."; \
580                 echo "It seems that you don't have misspell installed."; \
581                 echo "You can install the latest version of misspell here: https://github.com/client9/misspell#install"; \
582         fi
584 .PHONY: check-changes
585 check-changes:
586 if USEPYTHON
587         @if test -d "$(top_srcdir)/changes"; then \
588                 PACKAGE_VERSION=$(PACKAGE_VERSION) $(PYTHON) $(top_srcdir)/scripts/maint/lintChanges.py $(top_srcdir)/changes; \
589                 fi
590 endif
592 .PHONY: update-versions
593 update-versions:
594         abs_top_srcdir="$(abs_top_srcdir)" $(PYTHON) $(top_srcdir)/scripts/maint/update_versions.py
596 .PHONY: callgraph
597 callgraph:
598         cd $(top_builddir); $(abs_top_srcdir)/scripts/maint/run_calltool.sh
600 version:
601         @echo "Tor @VERSION@"
602         @if test -d "$(top_srcdir)/.git" && test -x "`which git 2>&1;true`"; then \
603            echo -n "git: " ;\
604            (cd "$(top_srcdir)" && git rev-parse --short=16 HEAD); \
605         fi
607 .PHONY: autostyle-ifdefs
608 autostyle-ifdefs:
609         $(PYTHON) $(top_srcdir)/scripts/maint/annotate_ifdef_directives.py $(OWNED_TOR_C_FILES)
611 .PHONY: autostyle-ifdefs
612 autostyle-operators:
613         $(PERL) $(top_srcdir)/scripts/coccinelle/test-operator-cleanup $(OWNED_TOR_C_FILES)
615 .PHONY: rectify-includes
616 rectify-includes:
617         cd $(top_srcdir); $(PYTHON) $(abs_top_srcdir)/scripts/maint/rectify_include_paths.py
619 .PHONY: update-copyright
620 update-copyright:
621         $(PERL) $(top_srcdir)/scripts/maint/updateCopyright.pl $(OWNED_TOR_C_FILES)
623 .PHONY: autostyle
624 autostyle: update-versions autostyle-ifdefs rectify-includes
626 mostlyclean-local:
627         rm -f $(top_builddir)/src/*/*.gc{da,no} $(top_builddir)/src/*/*/*.gc{da,no}
628         rm -rf $(HTML_COVER_DIR)
629         rm -rf $(top_builddir)/doc/doxygen
630         rm -rf $(TEST_NETWORK_ALL_LOG_DIR)
632 # This relies on some internal details of how automake implements
633 # distcheck.  We check two directories because automake-1.15 changed
634 # from $(distdir)/_build to $(distdir)/_build/sub.
635 show-distdir-testlog:
636         @if test -d "$(distdir)/_build/sub"; then \
637           cat $(distdir)/_build/sub/$(TEST_SUITE_LOG); \
638         else \
639           cat $(distdir)/_build/$(TEST_SUITE_LOG); fi
641 # Similarly, this relies on automake internals to run file on an
642 # intermittent core file whose provenance is not known to us.  See
643 # ticket 26787.
644 show-distdir-core:
645         @if test -d "$(distdir)/_build/sub"; then \
646           file $(distdir)/_build/sub/core ; \
647         else \
648           file $(distdir)/_build/core; fi
650 show-libs:
651         @echo libtor.a
653 show-testing-libs:
654         @echo src/test/libtor-testing.a
656 # Note here that we hardcode this -j2 because if the user would pass too many
657 # cores, bear actually chockes and dies :S. For this to work, a make clean
658 # needs to be done else bear will miss some compile flags.
659 lsp:
660         @if test -x "`which bear 2>&1;true`"; then \
661                 echo "Generating LSP compile_commands.json. Might take few minutes..."; \
662                 $(MAKE) clean 2>&1 >/dev/null; \
663                 bear >/dev/null 2>&1 -- $(MAKE) -j2 2>&1 >/dev/null; \
664                 echo "Generating .ccls file..."; \
665                 ./scripts/maint/gen_ccls_file.sh \
666         else \
667                 echo "No bear command found. On debian, apt install bear"; \
668         fi
670 # Reproducible tarball. We change the tar options for this.
671 dist-reprod:
672         $(MAKE) dist am__tar="$${TAR-tar} --format=gnu --owner=root --group=root --sort=name --mtime=\"`git show --no-patch --format='%ci'`\" -chof - $(distdir)"