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