]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
docs: edit running.html, change "http://allmydata.org" to "http://tahoe-lafs.org...
[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 PP=$(shell $(PYTHON) setup.py -q show_pythonpath)
13 RUNPP=$(PYTHON) setup.py run_with_pythonpath
14 TAHOE=$(PYTHON) bin/tahoe
15
16 .PHONY: make-version build
17
18 # The 'darcsver' setup.py command comes in the 'darcsver' package:
19 # http://pypi.python.org/pypi/darcsver It is necessary only if you want to
20 # automatically produce a new _version.py file from the current darcs history.
21 make-version:
22         $(PYTHON) ./setup.py darcsver --count-all-patches
23
24 # We want src/allmydata/_version.py to be up-to-date, but it's a fairly
25 # expensive operation (about 6 seconds on a just-before-0.7.0 tree, probably
26 # because of the 332 patches since the last tag), and we've removed the need
27 # for an explicit 'build' step by removing the C code from src/allmydata and
28 # by running everything in place. It would be neat to do:
29 #
30 #src/allmydata/_version.py: _darcs/patches
31 #       $(MAKE) make-version
32 #
33 # since that would update the embedded version string each time new darcs
34 # patches were pulled, but without an obligatory 'build' step this rule
35 # wouldn't be run frequently enough anyways.
36 #
37 # So instead, I'll just make sure that we update the version at least once
38 # when we first start using the tree, and again whenever an explicit
39 # 'make-version' is run, since then at least the developer has some means to
40 # update things. It would be nice if 'make clean' deleted any
41 # automatically-generated _version.py too, so that 'make clean; make all'
42 # could be useable as a "what the heck is going on, get me back to a clean
43 # state', but we need 'make clean' to work on non-darcs trees without
44 # destroying useful information.
45
46 .built:
47         $(MAKE) build
48
49 src/allmydata/_version.py:
50         $(MAKE) make-version
51
52 build: src/allmydata/_version.py
53         $(PYTHON) setup.py build
54         touch .built
55
56 # 'make install' will do the following:
57 #   build+install tahoe (probably to /usr/lib/pythonN.N/site-packages)
58 # 'make install PREFIX=/usr/local/stow/tahoe-N.N' will do the same, but to
59 # a different location
60
61 install: src/allmydata/_version.py
62 ifdef PREFIX
63         mkdir -p $(PREFIX)
64         $(PYTHON) ./setup.py install --single-version-externally-managed \
65            --prefix=$(PREFIX) --record=./tahoe.files
66 else
67         $(PYTHON) ./setup.py install --single-version-externally-managed
68 endif
69
70
71 # TESTING
72
73 .PHONY: signal-error-deps test test-coverage quicktest quicktest-coverage
74 .PHONY: coverage-output get-old-coverage-coverage coverage-delta-output
75
76
77 signal-error-deps:
78         @echo
79         @echo
80         @echo "ERROR: Not all of Tahoe's dependencies are in place.  Please see docs/install.html for help on installing dependencies."
81         @echo
82         @echo
83         exit 1
84
85 check-auto-deps:
86         $(PYTHON) setup.py -q check_auto_deps || $(MAKE) signal-error-deps
87
88 .checked-deps:
89         $(MAKE) check-auto-deps
90         touch .checked-deps
91
92 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
93 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
94 # too.
95 TEST=allmydata
96
97 # use 'make test TRIALARGS=--reporter=bwverbose' from buildbot, to
98 # suppress the ansi color sequences
99
100 test: build src/allmydata/_version.py
101         $(PYTHON) setup.py test $(TRIALARGS) -s $(TEST)
102
103 fuse-test: .built .checked-deps
104         $(RUNPP) -d contrib/fuse -p -c runtests.py
105
106 test-coverage: build src/allmydata/_version.py
107         rm -f .coverage
108         $(TAHOE) debug trial --reporter=bwverbose-coverage $(TEST)
109
110 quicktest:
111         $(TAHOE) debug trial $(TRIALARGS) $(TEST)
112
113 # code-coverage: install the "coverage" package from PyPI, do "make
114 # quicktest-coverage" to do a unit test run with coverage-gathering enabled,
115 # then use "make coverate-output-text" for a brief report, or "make
116 # coverage-output" for a pretty HTML report. Also see "make .coverage.el" and
117 # misc/coding_tools/coverage.el for emacs integration.
118
119 quicktest-coverage:
120         rm -f .coverage
121         $(TAHOE) debug trial --reporter=bwverbose-coverage $(TEST)
122 # on my laptop, "quicktest" takes 239s, "quicktest-coverage" takes 304s
123
124 # --include appeared in coverage-3.4
125 COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
126 coverage-output:
127         rm -rf coverage-html
128         coverage html -i -d coverage-html $(COVERAGE_OMIT)
129         cp .coverage coverage-html/coverage.data
130         @echo "now point your browser at coverage-html/index.html"
131
132 .PHONY: upload-coverage .coverage.el pyflakes count-lines
133 .PHONY: check-memory check-memory-once check-speed check-grid
134 .PHONY: repl test-darcs-boringfile test-clean clean find-trailing-spaces
135
136 .coverage.el: .coverage
137         $(PYTHON) misc/coding_tools/coverage2el.py
138
139 # 'upload-coverage' is meant to be run with an UPLOAD_TARGET=host:/dir setting
140 ifdef UPLOAD_TARGET
141
142 ifndef UPLOAD_HOST
143 $(error UPLOAD_HOST must be set when using UPLOAD_TARGET)
144 endif
145 ifndef COVERAGEDIR
146 $(error COVERAGEDIR must be set when using UPLOAD_TARGET)
147 endif
148
149 upload-coverage:
150         rsync -a coverage-html/ $(UPLOAD_TARGET)
151         ssh $(UPLOAD_HOST) make update-tahoe-coverage COVERAGEDIR=$(COVERAGEDIR)
152 else
153 upload-coverage:
154         echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
155         false
156 endif
157
158
159 pyflakes:
160         $(PYTHON) -OOu `which pyflakes` src/allmydata static misc/build_helpers bin/tahoe-script.template twisted setup.py |sort |uniq
161 check-umids:
162         $(PYTHON) misc/coding_tools/check-umids.py `find src/allmydata -name '*.py'`
163
164 count-lines:
165         @echo -n "files: "
166         @find src -name '*.py' |grep -v /build/ |wc --lines
167         @echo -n "lines: "
168         @cat `find src -name '*.py' |grep -v /build/` |wc --lines
169         @echo -n "TODO: "
170         @grep TODO `find src -name '*.py' |grep -v /build/` | wc --lines
171
172 check-memory: .built
173         rm -rf _test_memory
174         $(RUNPP) -p -c "src/allmydata/test/check_memory.py upload"
175         $(RUNPP) -p -c "src/allmydata/test/check_memory.py upload-self"
176         $(RUNPP) -p -c "src/allmydata/test/check_memory.py upload-POST"
177         $(RUNPP) -p -c "src/allmydata/test/check_memory.py download"
178         $(RUNPP) -p -c "src/allmydata/test/check_memory.py download-GET"
179         $(RUNPP) -p -c "src/allmydata/test/check_memory.py download-GET-slow"
180         $(RUNPP) -p -c "src/allmydata/test/check_memory.py receive"
181
182 check-memory-once: .built
183         rm -rf _test_memory
184         $(RUNPP) -p -c "src/allmydata/test/check_memory.py $(MODE)"
185
186 # The check-speed target uses a pre-established client node to run a canned
187 # set of performance tests against a test network that is also
188 # pre-established (probably on a remote machine). Provide it with the path to
189 # a local directory where this client node has been created (and populated
190 # with the necessary FURLs of the test network). This target will start that
191 # client with the current code and then run the tests. Afterwards it will
192 # stop the client.
193 #
194 # The 'sleep 5' is in there to give the new client a chance to connect to its
195 # storageservers, since check_speed.py has no good way of doing that itself.
196
197 check-speed: .built
198         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
199         @echo "stopping any leftover client code"
200         -$(TAHOE) stop $(TESTCLIENTDIR)
201         $(TAHOE) start $(TESTCLIENTDIR)
202         sleep 5
203         $(PYTHON) src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
204         $(TAHOE) stop $(TESTCLIENTDIR)
205
206 # The check-grid target also uses a pre-established client node, along with a
207 # long-term directory that contains some well-known files. See the docstring
208 # in src/allmydata/test/check_grid.py to see how to set this up.
209 check-grid: .built
210         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
211         $(PYTHON) src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
212
213 bench-dirnode: .built
214         $(RUNPP) -p -c src/allmydata/test/bench_dirnode.py
215
216 # 'make repl' is a simple-to-type command to get a Python interpreter loop
217 # from which you can type 'import allmydata'
218 repl:
219         $(TAHOE) debug repl
220
221 test-darcs-boringfile:
222         $(MAKE)
223         $(PYTHON) misc/build_helpers/test-darcs-boringfile.py
224
225 test-clean:
226         find . |grep -vEe "_darcs|allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
227         $(MAKE)
228         $(MAKE) clean
229         find . |grep -vEe "_darcs|allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
230         diff allfiles.tmp.old allfiles.tmp.new
231
232 clean:
233         rm -rf build _trial_temp _test_memory .checked-deps .built
234         rm -f `find src *.egg -name '*.so' -or -name '*.pyc'`
235         rm -rf src/allmydata_tahoe.egg-info
236         rm -rf support dist
237         rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
238         rm -rf *.pyc
239         rm -rf misc/dependencies/build misc/dependencies/temp
240         rm -rf misc/dependencies/tahoe_deps.egg-info
241         rm -f bin/tahoe bin/tahoe.pyscript
242
243 find-trailing-spaces:
244         $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r src
245
246 # The test-desert-island target grabs the tahoe-deps tarball, unpacks it,
247 # does a build, then asserts that the build did not try to download anything
248 # as it ran. Invoke this on a new tree, or after a 'clean', to make sure the
249 # support/lib/ directory is gone.
250
251 fetch-and-unpack-deps:
252         test -f tahoe-deps.tar.gz || wget http://tahoe-lafs.org/source/tahoe/deps/tahoe-deps.tar.gz
253         rm -rf tahoe-deps
254         tar xzf tahoe-deps.tar.gz
255
256 test-desert-island:
257         $(MAKE) fetch-and-unpack-deps
258         $(MAKE) 2>&1 | tee make.out
259         $(PYTHON) misc/build_helpers/check-build.py make.out no-downloads
260
261
262 # TARBALL GENERATION
263 .PHONY: tarballs upload-tarballs
264 tarballs:
265         $(MAKE) make-version
266         $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
267         $(PYTHON) setup.py sdist --sumo --formats=bztar,gztar,zip
268
269 upload-tarballs:
270         @if [ "X${BB_BRANCH}" == "Xtrunk" ] || [ "X${BB_BRANCH}" == "X" ]; then for f in dist/allmydata-tahoe-*; 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
271
272 # DEBIAN PACKAGING
273
274 VER=$(shell $(PYTHON) misc/build_helpers/get-version.py)
275 DEBCOMMENTS="'make deb' build"
276
277 show-version:
278         @echo $(VER)
279 show-pp:
280         @echo $(PP)
281
282 .PHONY: setup-deb deb-ARCH is-known-debian-arch
283 .PHONY: deb-etch deb-lenny deb-sid
284 .PHONY: deb-edgy deb-feisty deb-gutsy deb-hardy deb-intrepid deb-jaunty
285
286 # we use misc/debian_helpers/$TAHOE_ARCH/debian
287
288 deb-etch:      # py2.4
289         $(MAKE) deb-ARCH ARCH=etch TAHOE_ARCH=etch
290 deb-lenny:     # py2.5
291         $(MAKE) deb-ARCH ARCH=lenny TAHOE_ARCH=lenny
292 deb-sid:
293         $(MAKE) deb-ARCH ARCH=sid TAHOE_ARCH=sid
294
295 deb-edgy:     # py2.4
296         $(MAKE) deb-ARCH ARCH=edgy TAHOE_ARCH=etch
297 deb-feisty:   # py2.5
298         $(MAKE) deb-ARCH ARCH=feisty TAHOE_ARCH=lenny
299 deb-gutsy:    # py2.5
300         $(MAKE) deb-ARCH ARCH=gutsy TAHOE_ARCH=lenny
301 deb-hardy:    # py2.5
302         $(MAKE) deb-ARCH ARCH=hardy TAHOE_ARCH=lenny
303 deb-intrepid: # py2.5
304         $(MAKE) deb-ARCH ARCH=intrepid TAHOE_ARCH=lenny
305 deb-jaunty:   # py2.6
306         $(MAKE) deb-ARCH ARCH=jaunty TAHOE_ARCH=lenny
307
308
309
310 # we know how to handle the following debian architectures
311 KNOWN_DEBIAN_ARCHES := etch lenny sid  edgy feisty gutsy hardy intrepid jaunty
312
313 ifeq ($(findstring x-$(ARCH)-x,$(foreach arch,$(KNOWN_DEBIAN_ARCHES),"x-$(arch)-x")),)
314 is-known-debian-arch:
315         @echo "ARCH must be set when using setup-deb or deb-ARCH"
316         @echo "I know how to handle:" $(KNOWN_DEBIAN_ARCHES)
317         false
318 else
319 is-known-debian-arch:
320         true
321 endif
322
323 ifndef TAHOE_ARCH
324 TAHOE_ARCH=$(ARCH)
325 endif
326
327 setup-deb: is-known-debian-arch
328         rm -f debian
329         ln -s misc/debian_helpers/$(TAHOE_ARCH)/debian debian
330         chmod +x debian/rules
331
332 # etch (current debian stable) has python-simplejson-1.3, which doesn't
333 #  support indent=
334 # sid (debian unstable) currently has python-simplejson 1.7.1
335 # edgy has 1.3, which doesn't support indent=
336 # feisty has 1.4, which supports indent= but emits a deprecation warning
337 # gutsy has 1.7.1
338 #
339 # we need 1.4 or newer
340
341 deb-ARCH: is-known-debian-arch setup-deb
342         fakeroot debian/rules binary
343         @echo
344         @echo "The newly built .deb packages are in the parent directory from here."
345
346 .PHONY: increment-deb-version
347 .PHONY: deb-etch-head deb-lenny-head deb-sid-head
348 .PHONY: deb-edgy-head deb-feisty-head deb-gutsy-head deb-hardy-head deb-intrepid-head deb-jaunty-head
349
350 # The buildbot runs the following targets after each change, to produce
351 # up-to-date tahoe .debs. These steps do not create .debs for anything else.
352
353 increment-deb-version: make-version
354         debchange --newversion $(VER) $(DEBCOMMENTS)
355 deb-etch-head:
356         $(MAKE) setup-deb ARCH=etch TAHOE_ARCH=etch
357         $(MAKE) increment-deb-version
358         fakeroot debian/rules binary
359 deb-lenny-head:
360         $(MAKE) setup-deb ARCH=lenny TAHOE_ARCH=lenny
361         $(MAKE) increment-deb-version
362         fakeroot debian/rules binary
363 deb-sid-head:
364         $(MAKE) setup-deb ARCH=sid TAHOE_ARCH=lenny
365         $(MAKE) increment-deb-version
366         fakeroot debian/rules binary
367
368 deb-edgy-head:
369         $(MAKE) setup-deb ARCH=edgy TAHOE_ARCH=etch
370         $(MAKE) increment-deb-version
371         fakeroot debian/rules binary
372 deb-feisty-head:
373         $(MAKE) setup-deb ARCH=feisty TAHOE_ARCH=lenny
374         $(MAKE) increment-deb-version
375         fakeroot debian/rules binary
376 deb-gutsy-head:
377         $(MAKE) setup-deb ARCH=gutsy TAHOE_ARCH=lenny
378         $(MAKE) increment-deb-version
379         fakeroot debian/rules binary
380 deb-hardy-head:
381         $(MAKE) setup-deb ARCH=hardy TAHOE_ARCH=lenny
382         $(MAKE) increment-deb-version
383         fakeroot debian/rules binary
384 deb-intrepid-head:
385         $(MAKE) setup-deb ARCH=intrepid TAHOE_ARCH=lenny
386         $(MAKE) increment-deb-version
387         fakeroot debian/rules binary
388 deb-jaunty-head:
389         $(MAKE) setup-deb ARCH=jaunty TAHOE_ARCH=lenny
390         $(MAKE) increment-deb-version
391         fakeroot debian/rules binary
392
393 # new experimental debian-packaging-building target
394 .PHONY: EXPERIMENTAL-deb
395 EXPERIMENTAL-deb: is-known-debian-arch
396         $(PYTHON) misc/build_helpers/build-deb.py $(ARCH)