2 # NOTE: this Makefile requires GNU make
7 PATHSEP=$(shell $(PYTHON) -c 'import os ; print os.pathsep')
8 OSSEP=$(shell $(PYTHON) -c 'import os ; print os.sep')
10 ifneq ($(INCLUDE_DIRS),)
11 INCLUDE_DIRS_ARG = -I$(INCLUDE_DIRS)
13 ifneq ($(LIBRARY_DIRS),)
14 LIBRARY_DIRS_ARG = -L$(LIBRARY_DIRS)
17 PLAT = $(strip $(shell $(PYTHON) -c "import sys ; print sys.platform"))
19 # The platform is Windows with cygwin build tools and the native Python interpreter.
20 SUPPORT = $(shell cygpath -w $(shell pwd))\support
21 SUPPORTLIB := $(SUPPORT)\Lib\site-packages
22 SRCPATH := $(shell cygpath -w $(shell pwd)/src)
23 INNOSETUP := $(shell cygpath -au "$(PROGRAMFILES)/Inno Setup 5/Compil32.exe")
26 # This is to work-around #402, and anyway the poll reactor is probably better on Linux, if
27 # we have a lot of open fds.
33 # The cygwin select reactor seems to run out of fds in unit tests -- it writes "filedescriptor
34 # out of range in select()". Setting reactor=poll fixes that.
39 PYVER=$(shell $(PYTHON) misc/pyver.py)
40 SUPPORT = $(shell pwd)/support
41 SUPPORTLIB = $(SUPPORT)/lib/$(PYVER)/site-packages
42 SRCPATH := $(shell pwd)/src
47 REACTOROPT := --reactor=$(REACTOR)
52 ifneq ($(PYTHONPATH),)
53 PP=PYTHONPATH="$(PYTHONPATH)$(PATHSEP)$(SUPPORTLIB)"
55 PP=PYTHONPATH="$(SUPPORTLIB)"
58 # Delete any quote chars in PATH. Note that if the chars were escaped
59 # (preceded by a back-slash) then the following subst will screw it up and
60 # weird parsing errors will eventually result.
62 PATH := $(subst ",,${PATH})
63 PATH := $(subst ',,$(PATH))
64 # ' " # emacs syntax-highlighter gets confused by the bare quotes above
66 TRIALCMD = $(shell PATH="$(PATH):${PWD}/support/bin" $(PP) $(PYTHON) misc/find_trial.py)
67 TRIAL=PATH="$(PATH):${PWD}/support/bin" PYTHONUNBUFFERED=1 $(TRIALCMD) --rterrors $(REACTOROPT) $(TRIALOPT)
69 .PHONY: make-version build
71 # The 'darcsver' setup.py command comes in the 'darcsver' package:
72 # http://pypi.python.org/pypi/darcsver It is necessary only if you want to
73 # automatically produce a new _version.py file from the current darcs history.
75 $(PP) $(PYTHON) ./setup.py darcsver --count-all-patches
77 # We want src/allmydata/_version.py to be up-to-date, but it's a fairly
78 # expensive operation (about 6 seconds on a just-before-0.7.0 tree, probably
79 # because of the 332 patches since the last tag), and we've removed the need
80 # for an explicit 'build' step by removing the C code from src/allmydata and
81 # by running everything in place. It would be neat to do:
83 #src/allmydata/_version.py: _darcs/patches
84 # $(MAKE) make-version
86 # since that would update the embedded version string each time new darcs
87 # patches were pulled, but 1) this would break non-darcs trees (i.e. building
88 # from an exported tarball), and 2) without an obligatory 'build' step this
89 # rule wouldn't be run frequently enought anyways.
91 # So instead, I'll just make sure that we update the version at least once
92 # when we first start using the tree, and again whenever an explicit
93 # 'make-version' is run, since then at least the developer has some means to
94 # update things. It would be nice if 'make clean' deleted any
95 # automatically-generated _version.py too, so that 'make clean; make all'
96 # could be useable as a "what the heck is going on, get me back to a clean
97 # state', but we need 'make clean' to work on non-darcs trees without
98 # destroying useful information.
103 src/allmydata/_version.py:
106 # c.f. ticket #455, there is a problem in the intersection of setuptools,
107 # twisted's setup.py, and nevow's setup.py . A Tahoe build, to satisfy its
108 # dependencies, may try to build both Twisted and Nevow. If both of these
109 # occur during the same invocation of 'setup.py develop', then the Nevow
110 # build will fail with an "ImportError: No module named components". Running
111 # the build a second time will succeed. Until there is a new version of
112 # setuptools which properly sandboxes sys.modules (or a new version of nevow
113 # which doesn't import twisted during its build, or a new version of twisted
114 # which doesn't import itself during its build), we just build tahoe twice
115 # and ignore the errors from the first pass.
117 build: src/allmydata/_version.py
122 mkdir -p "$(SUPPORTLIB)"
123 $(PP) $(PYTHON) ./setup.py develop --prefix="$(SUPPORT)"
127 # 'make install' will do the following:
128 # build+install tahoe (probably to /usr/lib/pythonN.N/site-packages)
129 # 'make install PREFIX=/usr/local/stow/tahoe-N.N' will do the same, but to
130 # a different location
132 install: src/allmydata/_version.py
135 $(PP) $(PYTHON) ./setup.py install \
136 --single-version-externally-managed \
137 --prefix=$(PREFIX) --record=./tahoe.files
139 $(PP) $(PYTHON) ./setup.py install \
140 --single-version-externally-managed
146 .PHONY: signal-error-deps test test-figleaf figleaf-output
152 @echo "ERROR: Not all of Tahoe's dependencies are in place. Please see docs/install.html for help on installing dependencies."
158 @$(PP) $(PYTHON) -c 'import _auto_deps ; _auto_deps.require_auto_deps()' || $(MAKE) signal-error-deps
161 $(MAKE) check-auto-deps
164 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
165 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
169 # use 'make test TRIALARGS=--reporter=bwverbose' from buildbot, to
170 # suppress the ansi color sequences
172 test: build src/allmydata/_version.py
173 $(PP) $(TRIAL) $(TRIALARGS) $(TEST)
175 quicktest: .built .checked-deps
176 $(PP) $(TRIAL) $(TRIALARGS) $(TEST)
178 test-figleaf: build src/allmydata/_version.py
180 $(PP) $(TRIAL) --reporter=bwverbose-figleaf $(TEST)
182 quicktest-figleaf: src/allmydata/_version.py
184 $(PP) $(TRIAL) --reporter=bwverbose-figleaf $(TEST)
188 $(PYTHON) misc/figleaf2html -d coverage-html -r src -x misc/figleaf.excludes
189 @echo "now point your browser at coverage-html/index.html"
191 # after doing test-figleaf and figleaf-output, point your browser at
192 # coverage-html/index.html
194 .PHONY: upload-figleaf .figleaf.el pyflakes count-lines
195 .PHONY: check-memory check-memory-once clean
197 # 'upload-figleaf' is meant to be run with an UPLOAD_TARGET=host:/dir setting
201 $(error UPLOAD_HOST must be set when using UPLOAD_TARGET)
204 $(error COVERAGEDIR must be set when using UPLOAD_TARGET)
208 rsync -a coverage-html/ $(UPLOAD_TARGET)
209 ssh $(UPLOAD_HOST) make update-tahoe-figleaf COVERAGEDIR=$(COVERAGEDIR)
212 echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
216 .figleaf.el: .figleaf
217 $(PP) $(PYTHON) misc/figleaf2el.py .figleaf src
220 $(PYTHON) -OOu `which pyflakes` src/allmydata |sort |uniq
224 @find src -name '*.py' |grep -v /build/ |wc --lines
226 @cat `find src -name '*.py' |grep -v /build/` |wc --lines
228 @grep TODO `find src -name '*.py' |grep -v /build/` | wc --lines
233 $(PYTHON) src/allmydata/test/check_memory.py upload
235 $(PYTHON) src/allmydata/test/check_memory.py upload-self
237 $(PYTHON) src/allmydata/test/check_memory.py upload-POST
239 $(PYTHON) src/allmydata/test/check_memory.py download
241 $(PYTHON) src/allmydata/test/check_memory.py download-GET
243 $(PYTHON) src/allmydata/test/check_memory.py download-GET-slow
245 $(PYTHON) src/allmydata/test/check_memory.py receive
247 check-memory-once: .built
250 $(PYTHON) src/allmydata/test/check_memory.py $(MODE)
252 # The check-speed target uses a pre-established client node to run a canned
253 # set of performance tests against a test network that is also
254 # pre-established (probably on a remote machine). Provide it with the path to
255 # a local directory where this client node has been created (and populated
256 # with the necessary FURLs of the test network). This target will start that
257 # client with the current code and then run the tests. Afterwards it will
260 # The 'sleep 5' is in there to give the new client a chance to connect to its
261 # storageservers, since check_speed.py has no good way of doing that itself.
264 if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
265 @echo "stopping any leftover client code"
266 -$(PYTHON) bin/tahoe stop $(TESTCLIENTDIR)
267 $(PYTHON) bin/tahoe start $(TESTCLIENTDIR)
269 $(PYTHON) src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
270 $(PYTHON) bin/tahoe stop $(TESTCLIENTDIR)
272 # The check-grid target also uses a pre-established client node, along with a
273 # long-term directory that contains some well-known files. See the docstring
274 # in src/allmydata/test/check_grid.py to see how to set this up.
276 if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
277 $(PYTHON) src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
279 # 'make repl' is a simple-to-type command to get a Python interpreter loop
280 # from which you can type 'import allmydata'
284 test-darcs-boringfile:
286 $(PYTHON) misc/test-darcs-boringfile.py
289 find . |grep -vEe"allfiles.tmp|src/allmydata/_(version|auto_deps).py|src/allmydata_tahoe.egg-info" |sort >allfiles.tmp.old
292 find . |grep -vEe"allfiles.tmp|src/allmydata/_(version|auto_deps).py|src/allmydata_tahoe.egg-info" |sort >allfiles.tmp.new
293 diff allfiles.tmp.old allfiles.tmp.new
296 rm -rf build _trial_temp _test_memory .checked-deps .built
298 rm -f `find src/allmydata -name '*.so' -or -name '*.pyc'`
299 rm -rf tahoe_deps.egg-info allmydata_tahoe.egg-info
301 rm -rf setuptools*.egg *.pyc darcsver*.egg pyutil*.egg
302 rm -rf misc/dependencies/build misc/dependencies/temp
303 rm -rf misc/dependencies/tahoe_deps.egg-info
305 find-trailing-spaces:
306 $(PYTHON) misc/find-trailing-spaces.py -r src
309 .PHONY: tarballs upload-tarballs
312 $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
314 for f in dist/allmydata-tahoe-*; do \
315 xfer-client --furlfile ~/.tahoe-tarball-upload.furl $$f; \
320 VER=$(shell $(PYTHON) misc/get-version.py)
321 DEBCOMMENTS="'make deb' build"
326 .PHONY: setup-deb deb-ARCH is-known-debian-arch
327 .PHONY: deb-etch deb-sid
328 .PHONY: deb-edgy deb-feisty deb-gutsy deb-hardy
331 $(MAKE) deb-ARCH ARCH=sid
333 $(MAKE) deb-ARCH ARCH=feisty
334 # edgy uses the feisty control files for now
336 $(MAKE) deb-ARCH ARCH=edgy TAHOE_ARCH=feisty
337 # etch uses the feisty control files for now
339 $(MAKE) deb-ARCH ARCH=etch TAHOE_ARCH=feisty
340 # same with gutsy, the process has been nicely stable for a while now
342 $(MAKE) deb-ARCH ARCH=gutsy TAHOE_ARCH=feisty
344 $(MAKE) deb-ARCH ARCH=hardy TAHOE_ARCH=feisty
346 # we know how to handle the following debian architectures
347 KNOWN_DEBIAN_ARCHES := etch sid edgy feisty gutsy hardy
349 ifeq ($(findstring x-$(ARCH)-x,$(foreach arch,$(KNOWN_DEBIAN_ARCHES),"x-$(arch)-x")),)
350 is-known-debian-arch:
351 @echo "ARCH must be set when using setup-deb or deb-ARCH"
352 @echo "I know how to handle:" $(KNOWN_DEBIAN_ARCHES)
355 is-known-debian-arch:
363 setup-deb: is-known-debian-arch
365 ln -s misc/$(TAHOE_ARCH)/debian debian
366 chmod +x debian/rules
368 # etch (current debian stable) has python-simplejson-1.3, which doesn't
370 # sid (debian unstable) currently has python-simplejson 1.7.1
371 # edgy has 1.3, which doesn't support indent=
372 # feisty has 1.4, which supports indent= but emits a deprecation warning
375 # we need 1.4 or newer
377 deb-ARCH: is-known-debian-arch setup-deb
378 fakeroot debian/rules binary
380 @echo "The newly built .deb packages are in the parent directory from here."
382 .PHONY: increment-deb-version
383 .PHONY: deb-edgy-head deb-feisty-head deb-gutsy-head deb-hardy-head
384 .PHONY: deb-etch-head deb-sid-head
386 # The buildbot runs the following targets after each change, to produce
387 # up-to-date tahoe .debs. These steps do not create .debs for anything else.
389 increment-deb-version: make-version
390 debchange --newversion $(VER) $(DEBCOMMENTS)
392 $(MAKE) setup-deb ARCH=sid
393 $(MAKE) increment-deb-version
394 fakeroot debian/rules binary
396 $(MAKE) setup-deb ARCH=edgy TAHOE_ARCH=feisty
397 $(MAKE) increment-deb-version
398 fakeroot debian/rules binary
400 $(MAKE) setup-deb ARCH=feisty
401 $(MAKE) increment-deb-version
402 fakeroot debian/rules binary
404 $(MAKE) setup-deb ARCH=etch TAHOE_ARCH=feisty
405 $(MAKE) increment-deb-version
406 fakeroot debian/rules binary
408 $(MAKE) setup-deb ARCH=gutsy TAHOE_ARCH=feisty
409 $(MAKE) increment-deb-version
410 fakeroot debian/rules binary
412 $(MAKE) setup-deb ARCH=hardy TAHOE_ARCH=feisty
413 $(MAKE) increment-deb-version
414 fakeroot debian/rules binary
416 # These targets provide for windows native builds
417 .PHONY: windows-exe windows-installer windows-installer-upload
420 cd windows && $(PP) $(PYTHON) setup.py py2exe
422 windows-installer: windows-exe
423 $(PP) $(PYTHON) misc/sub-ver.py windows/installer.tmpl >windows/installer.iss
424 cd windows && "$(INNOSETUP)" /cc installer.iss
426 windows-installer-upload:
427 chmod -R o+rx windows/dist/installer
428 rsync -av -e /usr/bin/ssh windows/dist/installer/ amduser@dev:/home/amduser/public_html/dist/tahoe/windows/
430 # These targets provide for mac native builds
431 .PHONY: mac-exe mac-upload mac-cleanup mac-dbg
435 VERSION=$(VER) $(PP) $(MAKE) -C mac build
438 VERSION=$(VER) $(MAKE) -C mac diskimage
441 VERSION=$(VER) $(MAKE) -C mac upload UPLOAD_DEST=$(UPLOAD_DEST)
444 VERSION=$(VER) $(MAKE) -C mac cleanup
447 cd mac && $(PP) $(PYTHON)w allmydata_tahoe.py
449 # This target runs a stats gatherer server
450 .PHONY: stats-gatherer-run
452 cd stats_gatherer && $(PP) $(PYTHON) ../src/allmydata/stats.py