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