Merge branch 'maint-0.4.7'
[tor.git] / Makefile.am
blobc7b8b16d35d8502f24ec2d80c02644eb86768ae8
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 # Variants of the above for linking the testing variant of tor (for coverage
118 # and tests)
119 if UNITTESTS_ENABLED
120 TOR_CRYPTO_TESTING_LIBS = \
121         src/lib/libtor-tls-testing.a \
122         src/lib/libtor-crypt-ops-testing.a \
123         $(LIBKECCAK_TINY) \
124         $(LIBDONNA)
125 endif
127 # All static libraries used to link tor.
128 TOR_INTERNAL_LIBS = \
129         src/core/libtor-app.a \
130         src/lib/libtor-compress.a \
131         src/lib/libtor-evloop.a \
132         $(TOR_CRYPTO_LIBS) \
133         $(TOR_UTIL_LIBS) \
134         src/trunnel/libor-trunnel.a \
135         src/lib/libtor-trace.a
137 libtor.a: $(TOR_INTERNAL_LIBS)
138         $(AM_V_AR) export AR="$(AR)"; \
139         export ARFLAGS="$(ARFLAGS)"; \
140         export RANLIB="$(RANLIB)"; \
141         $(top_srcdir)/scripts/build/combine_libs libtor.a $(TOR_INTERNAL_LIBS)
143 MOSTLYCLEANFILES += libtor.a
145 # Variants of the above for linking the testing variant of tor (for coverage
146 # and tests)
147 if UNITTESTS_ENABLED
148 TOR_INTERNAL_TESTING_LIBS = \
149         src/core/libtor-app-testing.a \
150         src/lib/libtor-compress-testing.a \
151         src/lib/libtor-evloop-testing.a \
152         $(TOR_CRYPTO_TESTING_LIBS) \
153         $(TOR_UTIL_TESTING_LIBS) \
154         src/trunnel/libor-trunnel-testing.a \
155         src/lib/libtor-trace.a
157 src/test/libtor-testing.a: $(TOR_INTERNAL_TESTING_LIBS)
158         $(AM_V_AR) export AR="$(AR)"; \
159         export ARFLAGS="$(ARFLAGS)"; \
160         export RANLIB="$(RANLIB)"; \
161         $(top_srcdir)/scripts/build/combine_libs src/test/libtor-testing.a $(TOR_INTERNAL_TESTING_LIBS)
163 MOSTLYCLEANFILES += src/test/libtor-testing.a
164 endif
166 TOR_LDFLAGS_CRYPTLIB=@TOR_LDFLAGS_openssl@
167 TOR_LIBS_CRYPTLIB=@TOR_OPENSSL_LIBS@
168 TOR_CFLAGS_CRYPTLIB=
169 if USE_NSS
170 TOR_CFLAGS_CRYPTLIB+=@NSS_CFLAGS@
171 TOR_LIBS_CRYPTLIB+=@NSS_LIBS@
172 endif
174 # All libraries used to link tor-cov
176 include src/include.am
177 include doc/include.am
178 include contrib/include.am
180 manpages: $(nodist_man1_MANS)
182 EXTRA_DIST+= \
183         ChangeLog                                                       \
184         CONTRIBUTING                                                    \
185         CODE_OF_CONDUCT                                                 \
186         INSTALL                                                         \
187         LICENSE                                                         \
188         README.md                                                               \
189         ReleaseNotes                                                    \
190         scripts/build/combine_libs                                      \
191         scripts/maint/checkIncludes.py                                  \
192         scripts/maint/checkSpace.pl                                     \
193         scripts/maint/checkSpaceTest.sh                                 \
194         scripts/maint/checkspace_tests/dubious.c                        \
195         scripts/maint/checkspace_tests/dubious.h                        \
196         scripts/maint/checkspace_tests/expected.txt                     \
197         scripts/maint/checkspace_tests/good_guard.h                     \
198         scripts/maint/checkspace_tests/same_guard.h                     \
199         scripts/maint/checkspace_tests/subdir/dubious.c                 \
200         scripts/maint/checkShellScripts.sh                              \
201         scripts/maint/practracker/README                                \
202         scripts/maint/practracker/exceptions.txt                        \
203         scripts/maint/practracker/includes.py                           \
204         scripts/maint/practracker/metrics.py                            \
205         scripts/maint/practracker/practracker.py                        \
206         scripts/maint/practracker/practracker_tests.py                  \
207         scripts/maint/practracker/problem.py                            \
208         scripts/maint/practracker/testdata/.may_include                 \
209         scripts/maint/practracker/testdata/a.c                          \
210         scripts/maint/practracker/testdata/b.c                          \
211         scripts/maint/practracker/testdata/ex0-expected.txt             \
212         scripts/maint/practracker/testdata/ex0.txt                      \
213         scripts/maint/practracker/testdata/ex1-expected.txt             \
214         scripts/maint/practracker/testdata/ex1.txt                      \
215         scripts/maint/practracker/testdata/ex1-overbroad-expected.txt   \
216         scripts/maint/practracker/testdata/ex1-regen-expected.txt       \
217         scripts/maint/practracker/testdata/ex1-regen-overbroad-expected.txt \
218         scripts/maint/practracker/testdata/ex.txt                       \
219         scripts/maint/practracker/testdata/header.h                     \
220         scripts/maint/practracker/testdata/not_c_file                   \
221         scripts/maint/practracker/test_practracker.sh                   \
222         scripts/maint/practracker/util.py                               \
223         scripts/coccinelle/apply.sh                                     \
224         scripts/coccinelle/check_cocci_parse.sh                         \
225         scripts/coccinelle/exceptions.txt                               \
226         scripts/coccinelle/test-operator-cleanup                        \
227         scripts/coccinelle/tor-coccinelle.h                             \
228         scripts/coccinelle/try_parse.sh
230 ## This tells etags how to find mockable function definitions.
231 AM_ETAGSFLAGS=--regex='{c}/MOCK_IMPL([^,]+,\W*\([a-zA-Z0-9_]+\)\W*,/\1/s'
233 if COVERAGE_ENABLED
234 TEST_CFLAGS=-fno-inline -fprofile-arcs -ftest-coverage
235 if DISABLE_ASSERTS_IN_UNIT_TESTS
236 TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE -DDISABLE_ASSERTS_IN_UNIT_TESTS @TOR_MODULES_ALL_ENABLED@
237 else
238 TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE @TOR_MODULES_ALL_ENABLED@
239 endif
240 TEST_NETWORK_FLAGS=--coverage --hs-multi-client 1
241 else
242 TEST_CFLAGS=
243 TEST_CPPFLAGS=-DTOR_UNIT_TESTS @TOR_MODULES_ALL_ENABLED@
244 TEST_NETWORK_FLAGS=--hs-multi-client 1
245 endif
246 TEST_NETWORK_SHOW_WARNINGS_FOR_LAST_RUN_FLAGS=--quiet --only-warnings
248 if LIBFUZZER_ENABLED
249 TEST_CFLAGS += -fsanitize=fuzzer-no-link
250 # not "edge"
251 endif
253 TEST_NETWORK_ALL_LOG_DIR=$(top_builddir)/test_network_log
254 TEST_NETWORK_ALL_DRIVER_FLAGS=--color-tests yes
256 #install-data-local:
257 #       $(INSTALL) -m 755 -d $(LOCALSTATEDIR)/lib/tor
259 # Allows to override rpmbuild with rpmbuild-md5 from fedora-packager so that
260 # building for EL5 won't fail on https://bugzilla.redhat.com/show_bug.cgi?id=490613
261 RPMBUILD ?= rpmbuild
263 # Use automake's dist-gzip target to build the tarball
264 dist-rpm: dist-gzip
265         TIMESTAMP=$$(date +"%Y-%m-%d_%H.%M.%S");                                \
266         RPM_BUILD_DIR=$$(mktemp -d "/tmp/tor-rpm-build-$$TIMESTAMP-XXXX");      \
267         mkdir -p "$$RPM_BUILD_DIR"/{BUILD,RPMS,SOURCES/"tor-$(VERSION)",SPECS,SRPMS}; \
268         cp -fa "$(distdir).tar.gz" "$$RPM_BUILD_DIR"/SOURCES/;                  \
269         LIBS=-lrt $(RPMBUILD) -ba --define "_topdir $$RPM_BUILD_DIR" tor.spec;  \
270         cp -fa "$$RPM_BUILD_DIR"/SRPMS/* .;                                     \
271         cp -fa "$$RPM_BUILD_DIR"/RPMS/* .;                                      \
272         rm -rf "$$RPM_BUILD_DIR";                                               \
273         echo "RPM build finished";                                              \
274         #end of dist-rpm
276 .PHONY: doxygen
277 doxygen: Doxyfile
278         mkdir -p doc/doxygen
279         (cd "$(top_srcdir)" && doxygen "$(abs_top_builddir)/Doxyfile")
281 test: all
282         $(top_builddir)/src/test/test
284 shellcheck:
285         $(top_srcdir)/scripts/maint/checkShellScripts.sh
287 check-local:                                    \
288         check-spaces                            \
289         check-changes                           \
290         check-includes                          \
291         shellcheck
293 # test-network requires a copy of Chutney in $CHUTNEY_PATH.
294 # Chutney can be cloned from https://git.torproject.org/chutney.git .
295 .PHONY: need-chutney-path
296 need-chutney-path:
297         @if test ! -d "$$CHUTNEY_PATH"; then \
298                 echo '$$CHUTNEY_PATH was not set.'; \
299                 if test -d "$(top_srcdir)/../chutney" && \
300                    test -x "$(top_srcdir)/../chutney/chutney"; then \
301                         echo "Assuming test-network.sh will find" \
302                           "$(top_srcdir)/../chutney"; \
303                 else \
304                         echo; \
305                         echo "To run these tests," \
306                           "git clone" \
307                           "https://git.torproject.org/chutney.git ;" \
308                           "export CHUTNEY_PATH=\`pwd\`/chutney"; \
309                         exit 1; \
310                 fi \
311         fi
313 # Run some basic tests using automake's test-driver
314 .PHONY: test-network
315 # Hide directory path logs from submakes using $(MAKE) -s
316 test-network:
317         @$(MAKE) -s test-network-mkdir
318         @$(MAKE) -s test-network-clean
319         @$(MAKE) -s test-network-run \
320           ipv4_flavors="$(TEST_CHUTNEY_FLAVOR_QUICK)" \
321           ipv6_flavors="$(TEST_CHUTNEY_FLAVOR_QUICK_IPV6)"
322         @$(MAKE) -s test-network-results
324 # Run all available tests using automake's test-driver
325 .PHONY: test-network-all
326 # Hide directory path logs from submakes using $(MAKE) -s
327 test-network-all:
328         @$(MAKE) -s test-network-mkdir
329         @$(MAKE) -s test-network-clean
330         @$(MAKE) -s test-network-run \
331           ipv4_flavors="$(TEST_CHUTNEY_FLAVORS)" \
332           mixed_flavors="$(TEST_CHUTNEY_FLAVORS_MIXED)" \
333           ipv6_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6)" \
334           ipv6_mixed_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6_MIXED)"
335         @$(MAKE) -s test-network-results
337 # Run IPv4 and mixed tests using automake's test-driver
338 .PHONY: test-network-ipv4
339 # Hide directory path logs from submakes using $(MAKE) -s
340 test-network-ipv4:
341         @$(MAKE) -s test-network-mkdir
342         @$(MAKE) -s test-network-clean
343         @$(MAKE) -s test-network-run \
344           ipv4_flavors="$(TEST_CHUTNEY_FLAVORS)" \
345           mixed_flavors="$(TEST_CHUTNEY_FLAVORS_MIXED)"
346         @$(MAKE) -s test-network-results
348 # Run IPv6 tests using automake's test-driver
349 .PHONY: test-network-ipv6
350 # Hide directory path logs from submakes using $(MAKE) -s
351 test-network-ipv6:
352         @$(MAKE) -s test-network-mkdir
353         @$(MAKE) -s test-network-clean
354         @$(MAKE) -s test-network-run \
355           ipv6_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6)" \
356           ipv6_mixed_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6_MIXED)"
357         @$(MAKE) -s test-network-results
359 # Make the test network log directory, if it does not exist
360 .PHONY: test-network-mkdir
361 test-network-mkdir:
362         @mkdir -p "$(TEST_NETWORK_ALL_LOG_DIR)"
364 # Clean the test network log directory
365 .PHONY: test-network-clean
366 # We need to remove all matching files, so we can't quote the glob part of the
367 # rm arguments
368 test-network-clean:
369         rm -f "$(TEST_NETWORK_ALL_LOG_DIR)"/*.log \
370               "$(TEST_NETWORK_ALL_LOG_DIR)"/*.trs
372 # Run tests using automake's test-driver
373 # When checking if a set of test can be run, log the type of test, and the
374 # list of tests that will be run (or skipped).
376 # Run the IPv4 tests in $(ipv4_flavors), unconditionally
377 #   - tor relays and directory authorities require IPv4.
378 # Run the IPv6 tests in $(ipv6_flavors), if IPv6 is available
379 #   - only run IPv6 tests if we can ping6 or ping -6 ::1 (localhost)
380 #     we try the syntax for BSD ping6, Linux ping6, and Linux ping -6,
381 #     because they're incompatible
382 #   - some IPv6 tests may fail without an IPv6 DNS server
383 #     (see #16971 and #17011)
384 # Run the mixed tests in $(mixed_flavors), if a tor-stable binary is available
385 #   - only run mixed tests if we have a tor-stable binary
386 # Run the IPv6 mixed tests in $(ipv6_mixed_flavors), if IPv6 and mixed are run
387 #   - see above for details about IPv6 and mixed
388 .PHONY: test-network-run
389 # We need the word splitting in the "for" lines, so we can't quote
390 # $(skip_flavors) or $(flavors)
391 test-network-run: need-chutney-path test-driver $(TESTING_TOR_BINARY) src/tools/tor-gencert
392         @flavors=""; \
393         skip_flavors=""; \
394         if test -n "$(ipv4_flavors)"; then \
395                 echo "Running IPv4 flavors: $(ipv4_flavors)."; \
396                 flavors="$$flavors $(ipv4_flavors)"; \
397         fi; \
398         test_network_ipv6=false; \
399         if test -n "$(ipv6_flavors)" || \
400            test -n "$(ipv6_mixed_flavors)"; then \
401                 if ping6 -q -c 1 -o   ::1 >/dev/null 2>&1 || \
402                    ping6 -q -c 1 -W 1 ::1 >/dev/null 2>&1 || \
403                    ping  -6 -c 1 -W 1 ::1 >/dev/null 2>&1; then \
404                         test_network_ipv6=true; \
405                 fi; \
406         fi; \
407         if test -n "$(ipv6_flavors)"; then \
408                 if test "$$test_network_ipv6" = "true"; then \
409                         echo "ping6 ::1 or ping ::1 succeeded, running IPv6" \
410                           "flavors: $(ipv6_flavors)."; \
411                         flavors="$$flavors $(ipv6_flavors)"; \
412                 else \
413                         echo "ping6 ::1 and ping ::1 failed, skipping IPv6" \
414                           "flavors: $(ipv6_flavors)."; \
415                         skip_flavors="$$skip_flavors $(ipv6_flavors)"; \
416                 fi; \
417         fi; \
418         test_network_mixed=false; \
419         if test -n "$(mixed_flavors)" || \
420            test -n "$(ipv6_mixed_flavors)"; then \
421                 if command -v tor-stable >/dev/null 2>&1; then \
422                         test_network_mixed=true; \
423                 fi; \
424         fi; \
425         if test -n "$(mixed_flavors)"; then \
426                 if test "$$test_network_mixed" = "true"; then \
427                         echo "tor-stable found, running mixed flavors:" \
428                           "$(mixed_flavors)."; \
429                         flavors="$$flavors $(mixed_flavors)"; \
430                 else \
431                         echo "tor-stable not found, skipping mixed flavors:" \
432                           "$(mixed_flavors)."; \
433                         skip_flavors="$$skip_flavors $(mixed_flavors)"; \
434                 fi; \
435         fi; \
436         if test -n "$(ipv6_mixed_flavors)"; then \
437                 if test "$$test_network_ipv6" = "true" && \
438                    test "$$test_network_mixed" = "true"; then \
439                         echo "Running IPv6 mixed flavors:" \
440                           "$(ipv6_mixed_flavors)."; \
441                         flavors="$$flavors $(ipv6_mixed_flavors)"; \
442                 else \
443                         echo "Skipping IPv6 mixed flavors:" \
444                           "$(ipv6_mixed_flavors)."; \
445                         skip_flavors="$$skip_flavors $(ipv6_mixed_flavors)"; \
446                 fi; \
447         fi; \
448         for f in $$skip_flavors; do \
449                 echo "SKIP: $$f"; \
450         done; \
451         for f in $$flavors; do \
452                 $(SHELL) "$(top_srcdir)/test-driver" --test-name "$$f" \
453                   --log-file "$(TEST_NETWORK_ALL_LOG_DIR)/$$f.log" \
454                   --trs-file "$(TEST_NETWORK_ALL_LOG_DIR)/$$f.trs" \
455                   $(TEST_NETWORK_ALL_DRIVER_FLAGS) \
456                   "$(top_srcdir)/src/test/test-network.sh" \
457                     --flavor "$$f" $(TEST_NETWORK_FLAGS); \
458                 "$(top_srcdir)/src/test/test-network.sh" \
459                   $(TEST_NETWORK_SHOW_WARNINGS_FOR_LAST_RUN_FLAGS); \
460         done
462 # Print the results from automake's test-driver
463 #   - show tor warnings on the console after each network run
464 #     (otherwise, warnings go to the logs, and people don't see them unless
465 #     there is a network failure)
466 .PHONY: test-network-results
467 # We need to grep all matching files, so we can't quote the glob part of the
468 # grep arguments
469 test-network-results:
470         @echo \
471           "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)."
472         @! grep -q FAIL "$(TEST_NETWORK_ALL_LOG_DIR)"/*.trs
474 need-stem-path:
475         @if test ! -d "$$STEM_SOURCE_DIR"; then \
476                 echo '$$STEM_SOURCE_DIR was not set.'; echo; \
477                 echo "To run these tests, git clone https://git.torproject.org/stem.git/ ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \
478                 exit 1; \
479         fi
481 test-stem: need-stem-path $(TESTING_TOR_BINARY)
482         @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --integ --test control.controller --test control.base_controller --test process --log notice;
484 test-stem-full: need-stem-path $(TESTING_TOR_BINARY)
485         @$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor "$(TESTING_TOR_BINARY)" --all --log notice --target RUN_ALL,ONLINE -v;
487 test-full:                                      \
488         need-stem-path                          \
489         need-chutney-path                       \
490         check                                   \
491         test-network                            \
492         test-stem
494 test-full-online:                               \
495         need-stem-path                          \
496         need-chutney-path                       \
497         check                                   \
498         test-network                            \
499         test-stem-full
501 # We can't delete the gcno files, because they are created when tor is compiled
502 reset-gcov:
503         rm -f $(top_builddir)/src/*/*.gcda $(top_builddir)/src/*/*/*.gcda \
504               $(top_builddir)/src/*/*.gcov $(top_builddir)/src/*/*/*.gcov
506 HTML_COVER_DIR=$(top_builddir)/coverage_html
507 coverage-html: all
508 if COVERAGE_ENABLED
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 $(top_builddir)/src --zerocounters
512         $(MAKE) reset-gcov
513         $(MAKE) check
514         lcov --capture --rc lcov_branch_coverage=1 --no-external --directory $(top_builddir) --base-directory $(top_srcdir) --output-file "$(HTML_COVER_DIR)/lcov.tmp"
515         lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
516         genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
517 else
518         @printf "Not configured with --enable-coverage, run ./configure --enable-coverage\n"
519 endif
521 coverage-html-full: all
522         test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
523         test -d "$(HTML_COVER_DIR)" || mkdir -p "$(HTML_COVER_DIR)"
524         lcov --rc lcov_branch_coverage=1 --directory ./src --zerocounters
525         $(MAKE) reset-gcov
526         $(MAKE) check
527         $(MAKE) test-stem-full
528         CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh
529         CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh --flavor hs
530         lcov --capture --rc lcov_branch_coverage=1 --no-external --directory . --output-file "$(HTML_COVER_DIR)/lcov.tmp"
531         lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
532         genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
534 # For scripts: avoid src/ext and src/trunnel.
535 # Keep these lists consistent:
536 #   - OWNED_TOR_C_FILES in Makefile.am
537 #   - CHECK_FILES in pre-commit.git-hook and pre-push.git-hook
538 #   - try_parse in check_cocci_parse.sh
539 OWNED_TOR_C_FILES=\
540                 $(top_srcdir)/src/lib/*/*.[ch] \
541                 $(top_srcdir)/src/core/*/*.[ch] \
542                 $(top_srcdir)/src/feature/*/*.[ch] \
543                 $(top_srcdir)/src/app/*/*.[ch] \
544                 $(top_srcdir)/src/test/*.[ch] \
545                 $(top_srcdir)/src/test/*/*.[ch] \
546                 $(top_srcdir)/src/tools/*.[ch]
548 check-spaces:
549 if USE_PERL
550         $(PERL) $(top_srcdir)/scripts/maint/checkSpace.pl -C \
551                 $(OWNED_TOR_C_FILES)
552 endif
554 check-includes:
555 if USEPYTHON
556         $(PYTHON) $(top_srcdir)/scripts/maint/practracker/includes.py $(top_srcdir)
557 endif
559 check-best-practices:
560 if USEPYTHON
561         @$(PYTHON) $(top_srcdir)/scripts/maint/practracker/practracker.py $(top_srcdir) $(TOR_PRACTRACKER_OPTIONS)
562 endif
564 check-cocci:
565         VERBOSE=1 $(top_srcdir)/scripts/coccinelle/check_cocci_parse.sh $(OWNED_TOR_C_FILES)
567 practracker-regen:
568         $(PYTHON) $(top_srcdir)/scripts/maint/practracker/practracker.py --regen $(top_srcdir)
570 check-docs: all
571         $(PERL) $(top_builddir)/scripts/maint/checkOptionDocs.pl
573 check-logs:
574         $(top_srcdir)/scripts/maint/checkLogs.pl \
575                 $(top_srcdir)/src/*/*.[ch] | sort -n
577 .PHONY: check-typos
578 check-typos:
579         @if test -x "`which misspell 2>&1;true`"; then \
580                 echo "Checking for Typos ..."; \
581                 (misspell \
582                         $(top_srcdir)/src/[^e]*/*.[ch] \
583                         $(top_srcdir)/doc \
584                         $(top_srcdir)/contrib \
585                         $(top_srcdir)/scripts \
586                         $(top_srcdir)/README.md \
587                         $(top_srcdir)/ChangeLog \
588                         $(top_srcdir)/INSTALL \
589                         $(top_srcdir)/ReleaseNotes \
590                         $(top_srcdir)/LICENSE); \
591         else \
592                 echo "Tor can use misspell to check for typos."; \
593                 echo "It seems that you don't have misspell installed."; \
594                 echo "You can install the latest version of misspell here: https://github.com/client9/misspell#install"; \
595         fi
597 .PHONY: check-changes
598 check-changes:
599 if USEPYTHON
600         @if test -d "$(top_srcdir)/changes"; then \
601                 PACKAGE_VERSION=$(PACKAGE_VERSION) $(PYTHON) $(top_srcdir)/scripts/maint/lintChanges.py $(top_srcdir)/changes; \
602                 fi
603 endif
605 .PHONY: update-versions
606 update-versions:
607         abs_top_srcdir="$(abs_top_srcdir)" $(PYTHON) $(top_srcdir)/scripts/maint/update_versions.py
609 .PHONY: callgraph
610 callgraph:
611         cd $(top_builddir); $(abs_top_srcdir)/scripts/maint/run_calltool.sh
613 version:
614         @echo "Tor @VERSION@"
615         @if test -d "$(top_srcdir)/.git" && test -x "`which git 2>&1;true`"; then \
616            echo -n "git: " ;\
617            (cd "$(top_srcdir)" && git rev-parse --short=16 HEAD); \
618         fi
620 .PHONY: autostyle-ifdefs
621 autostyle-ifdefs:
622         $(PYTHON) $(top_srcdir)/scripts/maint/annotate_ifdef_directives.py $(OWNED_TOR_C_FILES)
624 .PHONY: autostyle-ifdefs
625 autostyle-operators:
626         $(PERL) $(top_srcdir)/scripts/coccinelle/test-operator-cleanup $(OWNED_TOR_C_FILES)
628 .PHONY: rectify-includes
629 rectify-includes:
630         cd $(top_srcdir); $(PYTHON) $(abs_top_srcdir)/scripts/maint/rectify_include_paths.py
632 .PHONY: update-copyright
633 update-copyright:
634         $(PERL) $(top_srcdir)/scripts/maint/updateCopyright.pl $(OWNED_TOR_C_FILES)
636 .PHONY: autostyle
637 autostyle: update-versions autostyle-ifdefs rectify-includes
639 mostlyclean-local:
640         rm -f $(top_builddir)/src/*/*.gc{da,no} $(top_builddir)/src/*/*/*.gc{da,no}
641         rm -rf $(HTML_COVER_DIR)
642         rm -rf $(top_builddir)/doc/doxygen
643         rm -rf $(TEST_NETWORK_ALL_LOG_DIR)
645 # This relies on some internal details of how automake implements
646 # distcheck.  We check two directories because automake-1.15 changed
647 # from $(distdir)/_build to $(distdir)/_build/sub.
648 show-distdir-testlog:
649         @if test -d "$(distdir)/_build/sub"; then \
650           cat $(distdir)/_build/sub/$(TEST_SUITE_LOG); \
651         else \
652           cat $(distdir)/_build/$(TEST_SUITE_LOG); fi
654 # Similarly, this relies on automake internals to run file on an
655 # intermittent core file whose provenance is not known to us.  See
656 # ticket 26787.
657 show-distdir-core:
658         @if test -d "$(distdir)/_build/sub"; then \
659           file $(distdir)/_build/sub/core ; \
660         else \
661           file $(distdir)/_build/core; fi
663 show-libs:
664         @echo libtor.a
666 show-testing-libs:
667         @echo src/test/libtor-testing.a
669 # Note here that we hardcode this -j2 because if the user would pass too many
670 # cores, bear actually chockes and dies :S. For this to work, a make clean
671 # needs to be done else bear will miss some compile flags.
672 lsp:
673         @if test -x "`which bear 2>&1;true`"; then \
674                 echo "Generating LSP compile_commands.json. Might take few minutes..."; \
675                 $(MAKE) clean 2>&1 >/dev/null; \
676                 bear >/dev/null 2>&1 -- $(MAKE) -j2 2>&1 >/dev/null; \
677                 echo "Generating .ccls file..."; \
678                 ./scripts/maint/gen_ccls_file.sh \
679         else \
680                 echo "No bear command found. On debian, apt install bear"; \
681         fi
683 # Reproducible tarball. We change the tar options for this.
684 dist-reprod:
685         $(MAKE) dist am__tar="$${TAR-tar} --format=gnu --owner=root --group=root --sort=name --mtime=\"`git show --no-patch --format='%ci'`\" -chof - $(distdir)"