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