]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
Makefile: use run_with_pythonpath, move windows targets into a separate Makefile
[tahoe-lafs/tahoe-lafs.git] / Makefile
1
2 # NOTE: this Makefile requires GNU make
3
4 default: build
5
6 PYTHON=python
7
8 # setup.py will extend sys.path to include our support/lib/... directory
9 # itself. It will also create it in the beginning of the 'develop' command.
10
11 PP=$(shell $(PYTHON) setup.py -q show_pythonpath)
12 RUNPP=$(PYTHON) setup.py run_with_pythonpath
13
14 .PHONY: make-version build
15
16 # The 'darcsver' setup.py command comes in the 'darcsver' package:
17 # http://pypi.python.org/pypi/darcsver It is necessary only if you want to
18 # automatically produce a new _version.py file from the current darcs history.
19 make-version:
20         $(PYTHON) ./setup.py darcsver --count-all-patches
21
22 # We want src/allmydata/_version.py to be up-to-date, but it's a fairly
23 # expensive operation (about 6 seconds on a just-before-0.7.0 tree, probably
24 # because of the 332 patches since the last tag), and we've removed the need
25 # for an explicit 'build' step by removing the C code from src/allmydata and
26 # by running everything in place. It would be neat to do:
27 #
28 #src/allmydata/_version.py: _darcs/patches
29 #       $(MAKE) make-version
30 #
31 # since that would update the embedded version string each time new darcs
32 # patches were pulled, but 1) this would break non-darcs trees (i.e. building
33 # from an exported tarball), and 2) without an obligatory 'build' step this
34 # rule wouldn't be run frequently enought 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.
61
62 build: src/allmydata/_version.py
63         -$(MAKE) build-once
64         $(MAKE) build-once
65
66 # setuptools has a bug (Issue17, see tahoe #229 for details) that causes it
67 # to mishandle dependencies that are installed in non-site-directories,
68 # including the /var/lib/ place that debian's python-support system uses. We
69 # add this debian/ubuntu-specific directory (via $SITEDIRARG) to the setup.py
70 # command line to work around this. Some day this will probably be fixed in
71 # setuptools.
72 build-once:
73         $(PYTHON) setup.py build_tahoe
74         chmod +x bin/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 test-figleaf: build src/allmydata/_version.py
127         rm -f .figleaf
128         $(PYTHON) setup.py trial -a "--reporter=bwverbose-figleaf $(TEST)"
129
130 quicktest-figleaf: src/allmydata/_version.py
131         rm -f .figleaf
132         $(PYTHON) setup.py trial -a "--reporter=bwverbose-figleaf $(TEST)"
133
134 figleaf-output:
135         $(RUNPP) -p -c "misc/figleaf2html -d coverage-html -r src -x misc/figleaf.excludes"
136         @echo "now point your browser at coverage-html/index.html"
137
138 # after doing test-figleaf and figleaf-output, point your browser at
139 # coverage-html/index.html
140
141 .PHONY: upload-figleaf .figleaf.el pyflakes count-lines
142 .PHONY: check-memory check-memory-once clean
143
144 # 'upload-figleaf' is meant to be run with an UPLOAD_TARGET=host:/dir setting
145 ifdef UPLOAD_TARGET
146
147 ifndef UPLOAD_HOST
148 $(error UPLOAD_HOST must be set when using UPLOAD_TARGET)
149 endif
150 ifndef COVERAGEDIR
151 $(error COVERAGEDIR must be set when using UPLOAD_TARGET)
152 endif
153
154 upload-figleaf:
155         rsync -a coverage-html/ $(UPLOAD_TARGET)
156         ssh $(UPLOAD_HOST) make update-tahoe-figleaf COVERAGEDIR=$(COVERAGEDIR)
157 else
158 upload-figleaf:
159         echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
160         false
161 endif
162
163 .figleaf.el: .figleaf
164         $(RUNPP) -p -c "misc/figleaf2el.py .figleaf src"
165
166 pyflakes:
167         $(PYTHON) -OOu `which pyflakes` src/allmydata |sort |uniq
168
169 count-lines:
170         @echo -n "files: "
171         @find src -name '*.py' |grep -v /build/ |wc --lines
172         @echo -n "lines: "
173         @cat `find src -name '*.py' |grep -v /build/` |wc --lines
174         @echo -n "TODO: "
175         @grep TODO `find src -name '*.py' |grep -v /build/` | wc --lines
176
177 check-memory: .built
178         rm -rf _test_memory
179         $(RUNPP) -p -c "src/allmydata/test/check_memory.py upload"
180         $(RUNPP) -p -c "src/allmydata/test/check_memory.py upload-self"
181         $(RUNPP) -p -c "src/allmydata/test/check_memory.py upload-POST"
182         $(RUNPP) -p -c "src/allmydata/test/check_memory.py download"
183         $(RUNPP) -p -c "src/allmydata/test/check_memory.py download-GET"
184         $(RUNPP) -p -c "src/allmydata/test/check_memory.py download-GET-slow"
185         $(RUNPP) -p -c "src/allmydata/test/check_memory.py receive"
186
187 check-memory-once: .built
188         rm -rf _test_memory
189         $(RUNPP) -p -c "src/allmydata/test/check_memory.py $(MODE)"
190
191 # The check-speed target uses a pre-established client node to run a canned
192 # set of performance tests against a test network that is also
193 # pre-established (probably on a remote machine). Provide it with the path to
194 # a local directory where this client node has been created (and populated
195 # with the necessary FURLs of the test network). This target will start that
196 # client with the current code and then run the tests. Afterwards it will
197 # stop the client.
198 #
199 # The 'sleep 5' is in there to give the new client a chance to connect to its
200 # storageservers, since check_speed.py has no good way of doing that itself.
201
202 check-speed: .built
203         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
204         @echo "stopping any leftover client code"
205         -$(PYTHON) bin/tahoe stop $(TESTCLIENTDIR)
206         $(PYTHON) bin/tahoe start $(TESTCLIENTDIR)
207         sleep 5
208         $(PYTHON) src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
209         $(PYTHON) bin/tahoe stop $(TESTCLIENTDIR)
210
211 # The check-grid target also uses a pre-established client node, along with a
212 # long-term directory that contains some well-known files. See the docstring
213 # in src/allmydata/test/check_grid.py to see how to set this up.
214 check-grid: .built
215         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
216         $(PYTHON) src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
217
218 # 'make repl' is a simple-to-type command to get a Python interpreter loop
219 # from which you can type 'import allmydata'
220 repl:
221         $(RUNPP) -p
222
223 test-darcs-boringfile:
224         $(MAKE)
225         $(PYTHON) misc/test-darcs-boringfile.py
226
227 test-clean:
228         find . |grep -vEe"allfiles.tmp|src/allmydata/_(version|auto_deps).py|src/allmydata_tahoe.egg-info" |sort >allfiles.tmp.old
229         $(MAKE)
230         $(MAKE) clean
231         find . |grep -vEe"allfiles.tmp|src/allmydata/_(version|auto_deps).py|src/allmydata_tahoe.egg-info" |sort >allfiles.tmp.new
232         diff allfiles.tmp.old allfiles.tmp.new
233
234 clean:
235         rm -rf build _trial_temp _test_memory .checked-deps .built
236         rm -f debian
237         rm -f `find src/allmydata -name '*.so' -or -name '*.pyc'`
238         rm -rf tahoe_deps.egg-info allmydata_tahoe.egg-info
239         rm -rf support dist
240         rm -rf setuptools*.egg *.pyc darcsver*.egg pyutil*.egg
241         rm -rf misc/dependencies/build misc/dependencies/temp
242         rm -rf misc/dependencies/tahoe_deps.egg-info
243
244 find-trailing-spaces:
245         $(PYTHON) misc/find-trailing-spaces.py -r src
246
247 # TARBALL GENERATION
248 .PHONY: tarballs upload-tarballs
249 tarballs:
250         $(MAKE) make-version
251         $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
252 upload-tarballs:
253         for f in dist/allmydata-tahoe-*; do \
254          xfer-client --furlfile ~/.tahoe-tarball-upload.furl $$f; \
255         done
256
257 # DEBIAN PACKAGING
258
259 VER=$(shell $(PYTHON) misc/get-version.py)
260 DEBCOMMENTS="'make deb' build"
261
262 show-version:
263         @echo $(VER)
264 show-pp:
265         @echo $(PP)
266
267 .PHONY: setup-deb deb-ARCH is-known-debian-arch
268 .PHONY: deb-etch deb-sid
269 .PHONY: deb-edgy deb-feisty deb-gutsy deb-hardy
270
271 deb-sid:
272         $(MAKE) deb-ARCH ARCH=sid
273 deb-feisty:
274         $(MAKE) deb-ARCH ARCH=feisty
275 # edgy uses the feisty control files for now
276 deb-edgy:
277         $(MAKE) deb-ARCH ARCH=edgy TAHOE_ARCH=feisty
278 # etch uses the feisty control files for now
279 deb-etch:
280         $(MAKE) deb-ARCH ARCH=etch TAHOE_ARCH=feisty
281 # same with gutsy, the process has been nicely stable for a while now
282 deb-gutsy:
283         $(MAKE) deb-ARCH ARCH=gutsy TAHOE_ARCH=feisty
284 deb-hardy:
285         $(MAKE) deb-ARCH ARCH=hardy TAHOE_ARCH=feisty
286
287 # we know how to handle the following debian architectures
288 KNOWN_DEBIAN_ARCHES := etch sid  edgy feisty gutsy hardy
289
290 ifeq ($(findstring x-$(ARCH)-x,$(foreach arch,$(KNOWN_DEBIAN_ARCHES),"x-$(arch)-x")),)
291 is-known-debian-arch:
292         @echo "ARCH must be set when using setup-deb or deb-ARCH"
293         @echo "I know how to handle:" $(KNOWN_DEBIAN_ARCHES)
294         false
295 else
296 is-known-debian-arch:
297         true
298 endif
299
300 ifndef TAHOE_ARCH
301 TAHOE_ARCH=$(ARCH)
302 endif
303
304 setup-deb: is-known-debian-arch
305         rm -f debian
306         ln -s misc/$(TAHOE_ARCH)/debian debian
307         chmod +x debian/rules
308
309 # etch (current debian stable) has python-simplejson-1.3, which doesn't 
310 #  support indent=
311 # sid (debian unstable) currently has python-simplejson 1.7.1
312 # edgy has 1.3, which doesn't support indent=
313 # feisty has 1.4, which supports indent= but emits a deprecation warning
314 # gutsy has 1.7.1
315 #
316 # we need 1.4 or newer
317
318 deb-ARCH: is-known-debian-arch setup-deb
319         fakeroot debian/rules binary
320         @echo
321         @echo "The newly built .deb packages are in the parent directory from here."
322
323 .PHONY: increment-deb-version
324 .PHONY: deb-edgy-head deb-feisty-head deb-gutsy-head deb-hardy-head
325 .PHONY: deb-etch-head deb-sid-head
326
327 # The buildbot runs the following targets after each change, to produce
328 # up-to-date tahoe .debs. These steps do not create .debs for anything else.
329
330 increment-deb-version: make-version
331         debchange --newversion $(VER) $(DEBCOMMENTS)
332 deb-sid-head:
333         $(MAKE) setup-deb ARCH=sid
334         $(MAKE) increment-deb-version
335         fakeroot debian/rules binary
336 deb-edgy-head:
337         $(MAKE) setup-deb ARCH=edgy TAHOE_ARCH=feisty
338         $(MAKE) increment-deb-version
339         fakeroot debian/rules binary
340 deb-feisty-head:
341         $(MAKE) setup-deb ARCH=feisty
342         $(MAKE) increment-deb-version
343         fakeroot debian/rules binary
344 deb-etch-head:
345         $(MAKE) setup-deb ARCH=etch TAHOE_ARCH=feisty
346         $(MAKE) increment-deb-version
347         fakeroot debian/rules binary
348 deb-gutsy-head:
349         $(MAKE) setup-deb ARCH=gutsy TAHOE_ARCH=feisty
350         $(MAKE) increment-deb-version
351         fakeroot debian/rules binary
352 deb-hardy-head:
353         $(MAKE) setup-deb ARCH=hardy TAHOE_ARCH=feisty
354         $(MAKE) increment-deb-version
355         fakeroot debian/rules binary
356
357 # These targets provide for windows native builds
358 .PHONY: windows-exe windows-installer windows-installer-upload
359
360 windows-exe: .built
361         $(RUNPP) -c "$(MAKE) -C windows windows-exe"
362
363 windows-installer: windows-exe
364         $(RUNPP) -c "$(MAKE) -C windows windows-installer"
365
366 windows-installer-upload:
367         $(RUNPP) -c "$(MAKE) -C windows windows-installer-upload"
368
369
370 # These targets provide for mac native builds
371 .PHONY: mac-exe mac-upload mac-cleanup mac-dbg
372
373 mac-exe: .built
374         $(MAKE) -C mac clean
375         VERSION=$(VER) $(RUNPP) -c "$(MAKE) -C mac build"
376
377 mac-dist:
378         VERSION=$(VER) $(MAKE) -C mac diskimage
379
380 mac-upload:
381         VERSION=$(VER) $(MAKE) -C mac upload UPLOAD_DEST=$(UPLOAD_DEST)
382
383 mac-cleanup:
384         VERSION=$(VER) $(MAKE) -C mac cleanup
385
386 mac-dbg:
387         cd mac && $(PP) $(PYTHON)w allmydata_tahoe.py
388
389 # This target runs a stats gatherer server
390 .PHONY: stats-gatherer-run
391 stats-gatherer-run:
392         $(RUNPP) -d stats_gatherer -p ../src/allmydata/stats.py