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