]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
Makefile: make APPNAME a variable.
[tahoe-lafs/tahoe-lafs.git] / Makefile
1
2 # NOTE: this Makefile requires GNU make
3
4 default: build
5
6 PYTHON=python
7 export PYTHON
8
9 # setup.py will extend sys.path to include our support/lib/... directory
10 # itself. It will also create it in the beginning of the 'develop' command.
11
12 TAHOE=$(PYTHON) bin/tahoe
13 SOURCES=src/allmydata src/buildtest static misc bin/tahoe-script.template setup.py
14 APPNAME=allmydata-tahoe
15
16 # This is necessary only if you want to automatically produce a new
17 # _version.py file from the current git history (without doing a build).
18 .PHONY: make-version
19 make-version:
20         $(PYTHON) ./setup.py update_version
21
22 .built:
23         $(MAKE) build
24
25 src/allmydata/_version.py:
26         $(MAKE) make-version
27
28 # It is unnecessary to have this depend on build or src/allmydata/_version.py,
29 # since 'setup.py build' always updates the version.
30 .PHONY: build
31 build:
32         $(PYTHON) setup.py build
33         touch .built
34
35 # Build OS X pkg packages.
36 # The editing of .egg-link and .pth files ensures that we reference the source at the correct path.
37 .PHONY: build-osx-pkg
38 build-osx-pkg:
39         $(PYTHON) setup.py build
40         find support -name $(APPNAME).egg-link -execdir sh -c "echo >> {}; echo /Applications/tahoe.app/src >> {}" \;
41         find support -name easy-install.pth -execdir sed -i.bak 's|^.*/src$$|../../../../src|' '{}' \;
42         touch .built
43
44 # create component pkg
45         pkgbuild --root $(shell pwd) \
46         --identifier com.leastauthority.tahoe \
47         --version $(shell sh -c "cat src/allmydata/_version.py | grep verstr | head -n 1 | cut -d' ' -f 3") \
48         --ownership recommended \
49         --install-location /Applications/tahoe.app \
50         --scripts $(shell pwd)/misc/build_helpers/osx/scripts \
51         tahoe-lafs.pkg
52
53 # create product archive
54         productbuild --distribution $(shell pwd)/misc/build_helpers/osx/Distribution.xml \
55         --package-path . \
56         tahoe-lafs-osx.pkg
57
58 # remove intermediate pkg
59         rm -f tahoe-lafs.pkg
60
61 # test the result
62         $(PYTHON) misc/build_helpers/test-osx-pkg.py
63
64 # TESTING
65
66 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
67 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
68 # too.
69 TEST=allmydata
70
71 # It is unnecessary to have this depend on build or src/allmydata/_version.py,
72 # since 'setup.py test' always updates the version and builds before testing.
73 .PHONY: test
74 test:
75         $(PYTHON) setup.py test $(TRIALARGS) -s $(TEST)
76         touch .built
77
78 .PHONY: check
79 check: test
80
81 .PHONY: quicktest
82 quicktest: make-version
83         $(TAHOE) debug trial $(TRIALARGS) $(TEST)
84
85 # "make tmpfstest" may be a faster way of running tests on Linux. It works best when you have
86 # at least 330 MiB of free physical memory (to run the whole test suite). Since it uses sudo
87 # to mount/unmount the tmpfs filesystem, it might prompt for your password.
88 .PHONY: tmpfstest
89 tmpfstest:
90         time make _tmpfstest 'TMPDIR=$(shell mktemp -d --tmpdir=.)'
91
92 .PHONY: _tmpfstest
93 _tmpfstest: make-version
94         sudo mount -t tmpfs -o size=400m tmpfs '$(TMPDIR)'
95         -$(TAHOE) debug trial --rterrors '--temp-directory=$(TMPDIR)/_trial_temp' $(TRIALARGS) $(TEST)
96         sudo umount '$(TMPDIR)'
97         rmdir '$(TMPDIR)'
98
99
100 # code coverage: install the "coverage" package from PyPI, do "make test-coverage" to
101 # do a unit test run with coverage-gathering enabled, then use "make coverage-output" to
102 # generate an HTML report. Also see "make .coverage.el" and misc/coding_tools/coverage.el
103 # for Emacs integration.
104
105 # This might need to be python-coverage on Debian-based distros.
106 COVERAGE=coverage
107
108 COVERAGEARGS=--branch --source=src/allmydata
109
110 # --include appeared in coverage-3.4
111 COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
112
113 .PHONY: test-coverage
114 test-coverage: build
115         rm -f .coverage
116         $(TAHOE) '@$(COVERAGE)' run $(COVERAGEARGS) @tahoe debug trial $(TRIALARGS) $(TEST)
117
118 .PHONY: coverage-output
119 coverage-output:
120         rm -rf coverage-html
121         coverage html -i -d coverage-html $(COVERAGE_OMIT)
122         cp .coverage coverage-html/coverage.data
123         @echo "now point your browser at coverage-html/index.html"
124
125 .coverage.el: .coverage
126         $(PYTHON) misc/coding_tools/coverage2el.py
127
128
129 .PHONY: code-checks
130 code-checks: build version-and-path check-interfaces check-miscaptures -find-trailing-spaces -check-umids pyflakes
131
132 .PHONY: version-and-path
133 version-and-path:
134         $(TAHOE) --version-and-path
135
136 .PHONY: check-interfaces
137 check-interfaces:
138         $(TAHOE) @misc/coding_tools/check-interfaces.py 2>&1 |tee violations.txt
139         @echo
140
141 .PHONY: check-miscaptures
142 check-miscaptures:
143         $(PYTHON) misc/coding_tools/check-miscaptures.py $(SOURCES) 2>&1 |tee miscaptures.txt
144         @echo
145
146 .PHONY: pyflakes
147 pyflakes:
148         @$(PYTHON) -OOu `which pyflakes` $(SOURCES) |sort |uniq
149         @echo
150
151 .PHONY: check-umids
152 check-umids:
153         $(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
154         @echo
155
156 .PHONY: -check-umids
157 -check-umids:
158         -$(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
159         @echo
160
161 .PHONY: doc-checks
162 doc-checks: check-rst
163
164 .PHONY: check-rst
165 check-rst:
166         @for x in `find *.rst docs -name "*.rst"`; do rst2html -v $${x} >/dev/null; done 2>&1 |grep -v 'Duplicate implicit target name:'
167         @echo
168
169 .PHONY: count-lines
170 count-lines:
171         @echo -n "files: "
172         @find src -name '*.py' |grep -v /build/ |wc -l
173         @echo -n "lines: "
174         @cat `find src -name '*.py' |grep -v /build/` |wc -l
175         @echo -n "TODO: "
176         @grep TODO `find src -name '*.py' |grep -v /build/` | wc -l
177         @echo -n "XXX: "
178         @grep XXX `find src -name '*.py' |grep -v /build/` | wc -l
179
180 .PHONY: check-memory
181 check-memory: .built
182         rm -rf _test_memory
183         $(TAHOE) @src/allmydata/test/check_memory.py upload
184         $(TAHOE) @src/allmydata/test/check_memory.py upload-self
185         $(TAHOE) @src/allmydata/test/check_memory.py upload-POST
186         $(TAHOE) @src/allmydata/test/check_memory.py download
187         $(TAHOE) @src/allmydata/test/check_memory.py download-GET
188         $(TAHOE) @src/allmydata/test/check_memory.py download-GET-slow
189         $(TAHOE) @src/allmydata/test/check_memory.py receive
190
191 .PHONY: check-memory-once
192 check-memory-once: .built
193         rm -rf _test_memory
194         $(TAHOE) @src/allmydata/test/check_memory.py $(MODE)
195
196 # The check-speed target uses a pre-established client node to run a canned
197 # set of performance tests against a test network that is also
198 # pre-established (probably on a remote machine). Provide it with the path to
199 # a local directory where this client node has been created (and populated
200 # with the necessary FURLs of the test network). This target will start that
201 # client with the current code and then run the tests. Afterwards it will
202 # stop the client.
203 #
204 # The 'sleep 5' is in there to give the new client a chance to connect to its
205 # storageservers, since check_speed.py has no good way of doing that itself.
206
207 .PHONY: check-speed
208 check-speed: .built
209         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
210         @echo "stopping any leftover client code"
211         -$(TAHOE) stop $(TESTCLIENTDIR)
212         $(TAHOE) start $(TESTCLIENTDIR)
213         sleep 5
214         $(TAHOE) @src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
215         $(TAHOE) stop $(TESTCLIENTDIR)
216
217 # The check-grid target also uses a pre-established client node, along with a
218 # long-term directory that contains some well-known files. See the docstring
219 # in src/allmydata/test/check_grid.py to see how to set this up.
220 .PHONY: check-grid
221 check-grid: .built
222         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
223         $(TAHOE) @src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
224
225 .PHONY: bench-dirnode
226 bench-dirnode: .built
227         $(TAHOE) @src/allmydata/test/bench_dirnode.py
228
229 # the provisioning tool runs as a stand-alone webapp server
230 .PHONY: run-provisioning-tool
231 run-provisioning-tool: .built
232         $(TAHOE) @misc/operations_helpers/provisioning/run.py
233
234 # 'make repl' is a simple-to-type command to get a Python interpreter loop
235 # from which you can type 'import allmydata'
236 .PHONY: repl
237 repl:
238         $(TAHOE) debug repl
239
240 .PHONY: test-get-ignore
241 test-git-ignore:
242         $(MAKE)
243         $(PYTHON) misc/build_helpers/test-git-ignore.py
244
245 .PHONY: test-clean
246 test-clean:
247         find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
248         $(MAKE)
249         $(MAKE) distclean
250         find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
251         diff allfiles.tmp.old allfiles.tmp.new
252
253 # It would be nice if 'make clean' deleted any automatically-generated
254 # _version.py too, so that 'make clean; make all' could be useable as a
255 # "what the heck is going on, get me back to a clean state', but we need
256 # 'make clean' to work on non-checkout trees without destroying useful information.
257 # Use 'make distclean' instead to delete all generated files.
258 .PHONY: clean
259 clean:
260         rm -rf build _trial_temp _test_memory .built
261         rm -f `find src *.egg -name '*.so' -or -name '*.pyc'`
262         rm -rf support dist
263         rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
264         rm -rf *.pyc
265         rm -rf misc/dependencies/build misc/dependencies/temp
266         rm -rf misc/dependencies/tahoe_deps.egg-info
267         rm -f bin/tahoe bin/tahoe.pyscript
268         rm -f *.pkg
269
270 .PHONY: distclean
271 distclean: clean
272         rm -rf src/allmydata_tahoe.egg-info
273         rm -f src/allmydata/_version.py
274         rm -f src/allmydata/_appname.py
275
276
277 .PHONY: find-trailing-spaces
278 find-trailing-spaces:
279         $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
280         @echo
281
282 .PHONY: -find-trailing-spaces
283 -find-trailing-spaces:
284         -$(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
285         @echo
286
287 # The test-desert-island target grabs the tahoe-deps tarball, unpacks it,
288 # does a build, then asserts that the build did not try to download anything
289 # as it ran. Invoke this on a new tree, or after a 'clean', to make sure the
290 # support/lib/ directory is gone.
291
292 .PHONY: fetch-and-unpack-deps
293 fetch-and-unpack-deps:
294         test -f tahoe-deps.tar.gz || wget https://tahoe-lafs.org/source/tahoe-lafs/deps/tahoe-lafs-deps.tar.gz
295         rm -rf tahoe-deps
296         tar xzf tahoe-lafs-deps.tar.gz
297
298 .PHONY: test-desert-island
299 test-desert-island:
300         $(MAKE) fetch-and-unpack-deps
301         $(MAKE) 2>&1 | tee make.out
302         $(PYTHON) misc/build_helpers/check-build.py make.out no-downloads
303
304
305 # TARBALL GENERATION
306 .PHONY: tarballs
307 tarballs:
308         $(MAKE) make-version
309         $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
310         $(PYTHON) setup.py sdist --sumo --formats=bztar,gztar,zip
311
312 .PHONY: upload-tarballs
313 upload-tarballs:
314         @if [ "X${BB_BRANCH}" = "Xmaster" ] || [ "X${BB_BRANCH}" = "X" ]; then for f in dist/$(APPNAME)-*; do flappclient --furlfile ~/.tahoe-tarball-upload.furl upload-file $$f; done ; else echo not uploading tarballs because this is not trunk but is branch \"${BB_BRANCH}\" ; fi