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