Merge branch 'ticket40883_048_01' into maint-0.4.8
[tor.git] / Makefile.am
blob7567ca99c75f067d65c726345cb3f37f7e0f2e5b
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), if IPv6 is available
384 #   - only run IPv6 tests if we can ping6 or ping -6 ::1 (localhost)
385 #     we try the syntax for BSD ping6, Linux ping6, and Linux ping -6,
386 #     because they're incompatible
387 #   - some IPv6 tests may fail without an IPv6 DNS server
388 #     (see #16971 and #17011)
389 # Run the mixed tests in $(mixed_flavors), if a tor-stable binary is available
390 #   - only run mixed tests if we have a tor-stable binary
391 # Run the IPv6 mixed tests in $(ipv6_mixed_flavors), if IPv6 and mixed are run
392 #   - see above for details about IPv6 and mixed
393 .PHONY: test-network-run
394 # We need the word splitting in the "for" lines, so we can't quote
395 # $(skip_flavors) or $(flavors)
396 test-network-run: need-chutney-path test-driver $(TESTING_TOR_BINARY) src/tools/tor-gencert
397         @flavors=""; \
398         skip_flavors=""; \
399         if test -n "$(ipv4_flavors)"; then \
400                 echo "Running IPv4 flavors: $(ipv4_flavors)."; \
401                 flavors="$$flavors $(ipv4_flavors)"; \
402         fi; \
403         test_network_ipv6=false; \
404         if test -n "$(ipv6_flavors)" || \
405            test -n "$(ipv6_mixed_flavors)"; then \
406                 if ping6 -q -c 1 -o   ::1 >/dev/null 2>&1 || \
407                    ping6 -q -c 1 -W 1 ::1 >/dev/null 2>&1 || \
408                    ping  -6 -c 1 -W 1 ::1 >/dev/null 2>&1; then \
409                         test_network_ipv6=true; \
410                 fi; \
411         fi; \
412         if test -n "$(ipv6_flavors)"; then \
413                 if test "$$test_network_ipv6" = "true"; then \
414                         echo "ping6 ::1 or ping ::1 succeeded, running IPv6" \
415                           "flavors: $(ipv6_flavors)."; \
416                         flavors="$$flavors $(ipv6_flavors)"; \
417                 else \
418                         echo "ping6 ::1 and ping ::1 failed, skipping IPv6" \
419                           "flavors: $(ipv6_flavors)."; \
420                         skip_flavors="$$skip_flavors $(ipv6_flavors)"; \
421                 fi; \
422         fi; \
423         test_network_mixed=false; \
424         if test -n "$(mixed_flavors)" || \
425            test -n "$(ipv6_mixed_flavors)"; then \
426                 if command -v tor-stable >/dev/null 2>&1; then \
427                         test_network_mixed=true; \
428                 fi; \
429         fi; \
430         if test -n "$(mixed_flavors)"; then \
431                 if test "$$test_network_mixed" = "true"; then \
432                         echo "tor-stable found, running mixed flavors:" \
433                           "$(mixed_flavors)."; \
434                         flavors="$$flavors $(mixed_flavors)"; \
435                 else \
436                         echo "tor-stable not found, skipping mixed flavors:" \
437                           "$(mixed_flavors)."; \
438                         skip_flavors="$$skip_flavors $(mixed_flavors)"; \
439                 fi; \
440         fi; \
441         if test -n "$(ipv6_mixed_flavors)"; then \
442                 if test "$$test_network_ipv6" = "true" && \
443                    test "$$test_network_mixed" = "true"; then \
444                         echo "Running IPv6 mixed flavors:" \
445                           "$(ipv6_mixed_flavors)."; \
446                         flavors="$$flavors $(ipv6_mixed_flavors)"; \
447                 else \
448                         echo "Skipping IPv6 mixed flavors:" \
449                           "$(ipv6_mixed_flavors)."; \
450                         skip_flavors="$$skip_flavors $(ipv6_mixed_flavors)"; \
451                 fi; \
452         fi; \
453         for f in $$skip_flavors; do \
454                 echo "SKIP: $$f"; \
455         done; \
456         for f in $$flavors; do \
457                 $(SHELL) "$(top_srcdir)/test-driver" --test-name "$$f" \
458                   --log-file "$(TEST_NETWORK_ALL_LOG_DIR)/$$f.log" \
459                   --trs-file "$(TEST_NETWORK_ALL_LOG_DIR)/$$f.trs" \
460                   $(TEST_NETWORK_ALL_DRIVER_FLAGS) \
461                   "$(top_srcdir)/src/test/test-network.sh" \
462                     --flavor "$$f" $(TEST_NETWORK_FLAGS); \
463                 "$(top_srcdir)/src/test/test-network.sh" \
464                   $(TEST_NETWORK_SHOW_WARNINGS_FOR_LAST_RUN_FLAGS); \
465         done
467 # Print the results from automake's test-driver
468 #   - show tor warnings on the console after each network run
469 #     (otherwise, warnings go to the logs, and people don't see them unless
470 #     there is a network failure)
471 .PHONY: test-network-results
472 # We need to grep all matching files, so we can't quote the glob part of the
473 # grep arguments
474 test-network-results:
475         @echo \
476           "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)."
477         @! grep -q FAIL "$(TEST_NETWORK_ALL_LOG_DIR)"/*.trs
479 need-stem-path:
480         @if test ! -d "$$STEM_SOURCE_DIR"; then \
481                 echo '$$STEM_SOURCE_DIR was not set.'; echo; \
482                 echo "To run these tests, git clone https://gitlab.torproject.org/tpo/network-health/stem ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \
483                 exit 1; \
484         fi
486 test-stem: need-stem-path $(TESTING_TOR_BINARY)
487         @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --integ --test control.controller --test control.base_controller --test process --log notice;
489 test-stem-full: need-stem-path $(TESTING_TOR_BINARY)
490         @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --all --log notice --target RUN_ALL,ONLINE -v;
492 test-full:                                      \
493         need-stem-path                          \
494         need-chutney-path                       \
495         check                                   \
496         test-network                            \
497         test-stem
499 test-full-online:                               \
500         need-stem-path                          \
501         need-chutney-path                       \
502         check                                   \
503         test-network                            \
504         test-stem-full
506 # We can't delete the gcno files, because they are created when tor is compiled
507 reset-gcov:
508         rm -f $(top_builddir)/src/*/*.gcda $(top_builddir)/src/*/*/*.gcda \
509               $(top_builddir)/src/*/*.gcov $(top_builddir)/src/*/*/*.gcov
511 HTML_COVER_DIR=$(top_builddir)/coverage_html
512 coverage-html: all
513 if COVERAGE_ENABLED
514         test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
515         test -d "$(HTML_COVER_DIR)" || $(MKDIR_P) "$(HTML_COVER_DIR)"
516         lcov --rc lcov_branch_coverage=1 --directory $(top_builddir)/src --zerocounters
517         $(MAKE) reset-gcov
518         $(MAKE) check
519         lcov --capture --rc lcov_branch_coverage=1 --no-external --directory $(top_builddir) --base-directory $(top_srcdir) --output-file "$(HTML_COVER_DIR)/lcov.tmp"
520         lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
521         genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
522 else
523         @printf "Not configured with --enable-coverage, run ./configure --enable-coverage\n"
524 endif
526 coverage-html-full: all
527         test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
528         test -d "$(HTML_COVER_DIR)" || mkdir -p "$(HTML_COVER_DIR)"
529         lcov --rc lcov_branch_coverage=1 --directory ./src --zerocounters
530         $(MAKE) reset-gcov
531         $(MAKE) check
532         $(MAKE) test-stem-full
533         CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh
534         CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh --flavor hs
535         lcov --capture --rc lcov_branch_coverage=1 --no-external --directory . --output-file "$(HTML_COVER_DIR)/lcov.tmp"
536         lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
537         genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
539 # For scripts: avoid src/ext and src/trunnel.
540 # Keep these lists consistent:
541 #   - OWNED_TOR_C_FILES in Makefile.am
542 #   - CHECK_FILES in pre-commit.git-hook and pre-push.git-hook
543 #   - try_parse in check_cocci_parse.sh
544 OWNED_TOR_C_FILES=\
545                 $(top_srcdir)/src/lib/*/*.[ch] \
546                 $(top_srcdir)/src/core/*/*.[ch] \
547                 $(top_srcdir)/src/feature/*/*.[ch] \
548                 $(top_srcdir)/src/app/*/*.[ch] \
549                 $(top_srcdir)/src/test/*.[ch] \
550                 $(top_srcdir)/src/test/*/*.[ch] \
551                 $(top_srcdir)/src/tools/*.[ch]
553 check-spaces:
554 if USE_PERL
555         $(PERL) $(top_srcdir)/scripts/maint/checkSpace.pl -C \
556                 $(OWNED_TOR_C_FILES)
557 endif
559 check-includes:
560 if USEPYTHON
561         $(PYTHON) $(top_srcdir)/scripts/maint/practracker/includes.py $(top_srcdir)
562 endif
564 check-best-practices:
565 if USEPYTHON
566         @$(PYTHON) $(top_srcdir)/scripts/maint/practracker/practracker.py $(top_srcdir) $(TOR_PRACTRACKER_OPTIONS)
567 endif
569 check-cocci:
570         VERBOSE=1 $(top_srcdir)/scripts/coccinelle/check_cocci_parse.sh $(OWNED_TOR_C_FILES)
572 practracker-regen:
573         $(PYTHON) $(top_srcdir)/scripts/maint/practracker/practracker.py --regen $(top_srcdir)
575 check-docs: all
576         $(PERL) $(top_builddir)/scripts/maint/checkOptionDocs.pl
578 check-logs:
579         $(top_srcdir)/scripts/maint/checkLogs.pl \
580                 $(top_srcdir)/src/*/*.[ch] | sort -n
582 .PHONY: check-typos
583 check-typos:
584         @if test -x "`which misspell 2>&1;true`"; then \
585                 echo "Checking for Typos ..."; \
586                 (misspell \
587                         $(top_srcdir)/src/[^e]*/*.[ch] \
588                         $(top_srcdir)/doc \
589                         $(top_srcdir)/contrib \
590                         $(top_srcdir)/scripts \
591                         $(top_srcdir)/README.md \
592                         $(top_srcdir)/ChangeLog \
593                         $(top_srcdir)/INSTALL \
594                         $(top_srcdir)/ReleaseNotes \
595                         $(top_srcdir)/LICENSE); \
596         else \
597                 echo "Tor can use misspell to check for typos."; \
598                 echo "It seems that you don't have misspell installed."; \
599                 echo "You can install the latest version of misspell here: https://github.com/client9/misspell#install"; \
600         fi
602 .PHONY: check-changes
603 check-changes:
604 if USEPYTHON
605         @if test -d "$(top_srcdir)/changes"; then \
606                 PACKAGE_VERSION=$(PACKAGE_VERSION) $(PYTHON) $(top_srcdir)/scripts/maint/lintChanges.py $(top_srcdir)/changes; \
607                 fi
608 endif
610 .PHONY: update-versions
611 update-versions:
612         abs_top_srcdir="$(abs_top_srcdir)" $(PYTHON) $(top_srcdir)/scripts/maint/update_versions.py
614 .PHONY: callgraph
615 callgraph:
616         cd $(top_builddir); $(abs_top_srcdir)/scripts/maint/run_calltool.sh
618 version:
619         @echo "Tor @VERSION@"
620         @if test -d "$(top_srcdir)/.git" && test -x "`which git 2>&1;true`"; then \
621            echo -n "git: " ;\
622            (cd "$(top_srcdir)" && git rev-parse --short=16 HEAD); \
623         fi
625 .PHONY: autostyle-ifdefs
626 autostyle-ifdefs:
627         $(PYTHON) $(top_srcdir)/scripts/maint/annotate_ifdef_directives.py $(OWNED_TOR_C_FILES)
629 .PHONY: autostyle-ifdefs
630 autostyle-operators:
631         $(PERL) $(top_srcdir)/scripts/coccinelle/test-operator-cleanup $(OWNED_TOR_C_FILES)
633 .PHONY: rectify-includes
634 rectify-includes:
635         cd $(top_srcdir); $(PYTHON) $(abs_top_srcdir)/scripts/maint/rectify_include_paths.py
637 .PHONY: update-copyright
638 update-copyright:
639         $(PERL) $(top_srcdir)/scripts/maint/updateCopyright.pl $(OWNED_TOR_C_FILES)
641 .PHONY: autostyle
642 autostyle: update-versions autostyle-ifdefs rectify-includes
644 mostlyclean-local:
645         rm -f $(top_builddir)/src/*/*.gc{da,no} $(top_builddir)/src/*/*/*.gc{da,no}
646         rm -rf $(HTML_COVER_DIR)
647         rm -rf $(top_builddir)/doc/doxygen
648         rm -rf $(TEST_NETWORK_ALL_LOG_DIR)
650 # This relies on some internal details of how automake implements
651 # distcheck.  We check two directories because automake-1.15 changed
652 # from $(distdir)/_build to $(distdir)/_build/sub.
653 show-distdir-testlog:
654         @if test -d "$(distdir)/_build/sub"; then \
655           cat $(distdir)/_build/sub/$(TEST_SUITE_LOG); \
656         else \
657           cat $(distdir)/_build/$(TEST_SUITE_LOG); fi
659 # Similarly, this relies on automake internals to run file on an
660 # intermittent core file whose provenance is not known to us.  See
661 # ticket 26787.
662 show-distdir-core:
663         @if test -d "$(distdir)/_build/sub"; then \
664           file $(distdir)/_build/sub/core ; \
665         else \
666           file $(distdir)/_build/core; fi
668 show-libs:
669         @echo libtor.a
671 show-testing-libs:
672         @echo src/test/libtor-testing.a
674 # Note here that we hardcode this -j2 because if the user would pass too many
675 # cores, bear actually chockes and dies :S. For this to work, a make clean
676 # needs to be done else bear will miss some compile flags.
677 lsp:
678         @if test -x "`which bear 2>&1;true`"; then \
679                 echo "Generating LSP compile_commands.json. Might take few minutes..."; \
680                 $(MAKE) clean 2>&1 >/dev/null; \
681                 bear >/dev/null 2>&1 -- $(MAKE) -j2 2>&1 >/dev/null; \
682                 echo "Generating .ccls file..."; \
683                 ./scripts/maint/gen_ccls_file.sh \
684         else \
685                 echo "No bear command found. On debian, apt install bear"; \
686         fi
688 # Reproducible tarball. We change the tar options for this.
689 dist-reprod:
690         $(MAKE) dist am__tar="$${TAR-tar} --format=gnu --owner=root --group=root --sort=name --mtime=\"`git show --no-patch --format='%ci'`\" -chof - $(distdir)"