Makefile.am 8.18 KB
Newer Older
Roger Dingledine's avatar
Roger Dingledine committed
1
# Copyright (c) 2001-2004, Roger Dingledine
2
# Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
3
# Copyright (c) 2007-2015, The Tor Project, Inc.
Nick Mathewson's avatar
Nick Mathewson committed
4
5
# See LICENSE for licensing information

6
# "foreign" means we don't follow GNU package layout standards
7
8
9
# 1.11 means we require automake vesion 1.11
# "subdir-objects" means put .o files in the same directory as the .c files
AUTOMAKE_OPTIONS = foreign 1.11 subdir-objects
10

11
12
ACLOCAL_AMFLAGS = -I m4

Stewart Smith's avatar
Stewart Smith committed
13
14
15
16
17
18
19
20
21
noinst_LIBRARIES=
EXTRA_DIST=
noinst_HEADERS=
bin_PROGRAMS=
CLEANFILES=
TESTS=
noinst_PROGRAMS=
DISTCLEANFILES=
bin_SCRIPTS=
22
AM_CPPFLAGS=
23
AM_CFLAGS = @TOR_SYSTEMD_CFLAGS@
24
SHELL = @SHELL@
25
26
27
28
29
30
31

if COVERAGE_ENABLED
TESTING_TOR_BINARY="$(top_builddir)/src/or/tor-cov"
else
TESTING_TOR_BINARY="$(top_builddir)/src/or/tor"
endif

Stewart Smith's avatar
Stewart Smith committed
32
33
34
include src/include.am
include doc/include.am
include contrib/include.am
35

Stewart Smith's avatar
Stewart Smith committed
36
EXTRA_DIST+= \
37
38
39
	ChangeLog					\
	INSTALL						\
	LICENSE						\
40
	Makefile.nmake					\
41
	README						\
Nick Mathewson's avatar
Nick Mathewson committed
42
	ReleaseNotes
43

44
45
if COVERAGE_ENABLED
TEST_CFLAGS=-fno-inline -fprofile-arcs -ftest-coverage
46
47
48
if DISABLE_ASSERTS_IN_UNIT_TESTS
TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE -DDISABLE_ASSERTS_IN_UNIT_TESTS
else
49
TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE
50
endif
51
TEST_NETWORK_FLAGS=--coverage --hs-multi-client 1
52
53
else
TEST_CFLAGS=
54
TEST_CPPFLAGS=-DTOR_UNIT_TESTS
55
TEST_NETWORK_FLAGS=--hs-multi-client 1
56
57
endif

58
59
60
TEST_NETWORK_ALL_LOG_DIR=$(top_builddir)/test_network_log
TEST_NETWORK_ALL_DRIVER_FLAGS=--color-tests yes

61
62
#install-data-local:
#	$(INSTALL) -m 755 -d $(LOCALSTATEDIR)/lib/tor
63

64
65
66
67
# Allows to override rpmbuild with rpmbuild-md5 from fedora-packager so that
# building for EL5 won't fail on https://bugzilla.redhat.com/show_bug.cgi?id=490613
RPMBUILD ?= rpmbuild

68
69
70
71
72
73
# Use automake's dist-gzip target to build the tarball
dist-rpm: dist-gzip
	TIMESTAMP=$$(date +"%Y-%m-%d_%H.%M.%S"); 				\
	RPM_BUILD_DIR=$$(mktemp -d "/tmp/tor-rpm-build-$$TIMESTAMP-XXXX");	\
	mkdir -p "$$RPM_BUILD_DIR"/{BUILD,RPMS,SOURCES/"tor-$(VERSION)",SPECS,SRPMS}; \
	cp -fa "$(distdir).tar.gz" "$$RPM_BUILD_DIR"/SOURCES/;			\
74
	LIBS=-lrt $(RPMBUILD) -ba --define "_topdir $$RPM_BUILD_DIR" tor.spec; 	\
75
76
77
78
79
	cp -fa "$$RPM_BUILD_DIR"/SRPMS/* .;                           		\
	cp -fa "$$RPM_BUILD_DIR"/RPMS/* .;                            		\
	rm -rf "$$RPM_BUILD_DIR";						\
	echo "RPM build finished";						\
	#end of dist-rpm
80
81

doxygen:
82
	doxygen && cd doc/doxygen/latex && make
83

84
test: all
85
	$(top_builddir)/src/test/test
86

87
88
need-chutney-path:
	@if test ! -d "$$CHUTNEY_PATH"; then \
89
90
91
92
93
94
95
96
		echo '$$CHUTNEY_PATH was not set.'; \
		if test -d $(top_srcdir)/../chutney -a -x $(top_srcdir)/../chutney/chutney; then \
			echo "Assuming test-network.sh will find" $(top_srcdir)/../chutney; \
		else \
			echo; \
			echo "To run these tests, git clone https://git.torproject.org/chutney.git ; export CHUTNEY_PATH=\`pwd\`/chutney"; \
			exit 1; \
		fi \
97
98
	fi

99
100
# Note that test-network requires a copy of Chutney in $CHUTNEY_PATH.
# Chutney can be cloned from https://git.torproject.org/chutney.git .
101
test-network: need-chutney-path all
102
	$(top_srcdir)/src/test/test-network.sh $(TEST_NETWORK_FLAGS)
103

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# Run all available tests using automake's test-driver
# only run IPv6 tests if we can ping6 ::1 (localhost)
# some IPv6 tests will fail without an IPv6 DNS server (see #16971 and #17011)
# only run mixed tests if we have a tor-stable binary
# see #17015 for autodetection of different tor versions
test-network-all: need-chutney-path all test-driver
	mkdir -p $(TEST_NETWORK_ALL_LOG_DIR)
	@flavors="$(TEST_CHUTNEY_FLAVORS)"; \
	if ping6 -q -o ::1 >/dev/null 2>&1; then \
		echo "ping6 ::1 succeeded, running IPv6 flavors: $(TEST_CHUTNEY_FLAVORS_IPV6)."; \
		flavors="$$flavors $(TEST_CHUTNEY_FLAVORS_IPV6)"; \
	else \
		echo "ping6 ::1 failed, skipping IPv6 flavors: $(TEST_CHUTNEY_FLAVORS_IPV6)."; \
		skip_flavors="$$skip_flavors $(TEST_CHUTNEY_FLAVORS_IPV6)"; \
	fi; \
	if command -v tor-stable >/dev/null 2>&1; then \
		echo "tor-stable found, running mixed flavors: $(TEST_CHUTNEY_FLAVORS_MIXED)."; \
		flavors="$$flavors $(TEST_CHUTNEY_FLAVORS_MIXED)"; \
	else \
		echo "tor-stable not found, skipping mixed flavors: $(TEST_CHUTNEY_FLAVORS_MIXED)."; \
		skip_flavors="$$skip_flavors $(TEST_CHUTNEY_FLAVORS_MIXED)"; \
	fi; \
	for f in $$skip_flavors; do \
		echo "SKIP: $$f"; \
	done; \
	for f in $$flavors; do \
		./test-driver --test-name $$f --log-file $(TEST_NETWORK_ALL_LOG_DIR)/$$f.log --trs-file $(TEST_NETWORK_ALL_LOG_DIR)/$$f.trs $(TEST_NETWORK_ALL_DRIVER_FLAGS) $(top_srcdir)/src/test/test-network.sh --flavor $$f $(TEST_NETWORK_FLAGS); \
131
132
133
	done; \
	echo "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)."; \
	! grep -q FAIL test_network_log/*.trs
134

135
136
need-stem-path:
	@if test ! -d "$$STEM_SOURCE_DIR"; then \
137
138
		echo '$$STEM_SOURCE_DIR was not set.'; echo; \
		echo "To run these tests, git clone https://git.torproject.org/stem.git/ ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \
139
		exit 1; \
140
141
	fi

142
143
144
145
146
147
148
149
150
test-stem: need-stem-path $(TESTING_TOR_BINARY)
	@$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor $(TESTING_TOR_BINARY) --all --log notice --target RUN_ALL;

test-stem-full: need-stem-path $(TESTING_TOR_BINARY)
	@$(PYTHON) "$$STEM_SOURCE_DIR"/run_tests.py --tor $(TESTING_TOR_BINARY) --all --log notice --target RUN_ALL,ONLINE -v;

test-full: need-stem-path need-chutney-path check test-network test-stem

test-full-online: need-stem-path need-chutney-path check test-network test-stem-full
151

152
reset-gcov:
153
	rm -f $(top_builddir)/src/*/*.gcda $(top_builddir)/src/*/*/*.gcda
154

155
HTML_COVER_DIR=$(top_builddir)/coverage_html
156
coverage-html: all
157
if COVERAGE_ENABLED
Nick Mathewson's avatar
Nick Mathewson committed
158
	test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
159
160
	test -d "$(HTML_COVER_DIR)" || $(MKDIR_P) "$(HTML_COVER_DIR)"
	lcov --rc lcov_branch_coverage=1 --directory $(top_builddir)/src --zerocounters
Nick Mathewson's avatar
Nick Mathewson committed
161
162
	$(MAKE) reset-gcov
	$(MAKE) check
163
	lcov --capture --rc lcov_branch_coverage=1 --no-external --directory $(top_builddir) --base-directory $(top_srcdir) --output-file "$(HTML_COVER_DIR)/lcov.tmp"
164
165
	lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
	genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"
166
167
168
else
	@printf "Not configured with --enable-coverage, run ./configure --enable-coverage\n"
endif
169

170
171
172
173
174
175
176
coverage-html-full: all
	test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false)
	test -d "$(HTML_COVER_DIR)" || mkdir -p "$(HTML_COVER_DIR)"
	lcov --rc lcov_branch_coverage=1 --directory ./src --zerocounters
	$(MAKE) reset-gcov
	$(MAKE) check
	$(MAKE) test-stem-full
177
178
	CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh
	CHUTNEY_TOR=tor-cov CHUTNEY_TOR_GENCERT=tor-cov-gencert $(top_srcdir)/src/test/test-network.sh --flavor hs
179
180
181
182
	lcov --capture --rc lcov_branch_coverage=1 --no-external --directory . --output-file "$(HTML_COVER_DIR)/lcov.tmp"
	lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info"
	genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info"

183
# Avoid strlcpy.c, strlcat.c, aes.c, OpenBSD_malloc_Linux.c, sha256.c,
184
# eventdns.[hc], tinytest*.[ch]
185
check-spaces:
186
187
188
189
	$(top_srcdir)/scripts/maint/checkSpace.pl -C \
		$(top_srcdir)/src/common/*.[ch] \
		$(top_srcdir)/src/or/*.[ch] \
		$(top_srcdir)/src/test/*.[ch] \
190
		$(top_srcdir)/src/tools/*.[ch]
191

192
193
check-docs: all
	$(PERL) $(top_builddir)/scripts/maint/checkOptionDocs.pl
194

195
check-logs:
196
197
	$(top_srcdir)/scripts/maint/checkLogs.pl \
		$(top_srcdir)/src/*/*.[ch] | sort -n
198

199
200
201
202
203
204
.PHONY: check-changes
check-changes:
	@if test -d "$(top_srcdir)/changes"; then \
		$(PYTHON) $(top_srcdir)/scripts/maint/lintChanges.py $(top_srcdir)/changes/*; \
		fi

205
206
207
208
.PHONY: update-versions
update-versions:
	$(PERL) $(top_builddir)/scripts/maint/updateVersions.pl

209
210
211
212
213
214
215
version:
	@echo "Tor @VERSION@"
	@if test -d "$(top_srcdir)/.git" && test -x "`which git 2>&1;true`"; then \
	   echo -n "git: " ;\
	   (cd "$(top_srcdir)" && git rev-parse --short=16 HEAD); \
	fi

216
mostlyclean-local:
217
218
219
	rm -f $(top_builddir)/src/*/*.gc{da,no} $(top_builddir)/src/*/*/*.gc{da,no}
	rm -rf $(HTML_COVER_DIR)
	rm -rf $(top_builddir)/doc/doxygen
220
	rm -rf $(TEST_NETWORK_ALL_LOG_DIR)