]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
Makefile: convert check-auto-deps target into 'setup.py check_auto_deps'
[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 PLAT = $(strip $(shell $(PYTHON) -c "import sys ; print sys.platform"))
12 ifeq ($(PLAT),win32)
13         # The platform is Windows with cygwin build tools and the native Python interpreter.
14         SUPPORT = $(shell cygpath -w $(shell pwd))\support
15         SUPPORTLIB := $(SUPPORT)\Lib\site-packages
16         SRCPATH := $(shell cygpath -w $(shell pwd)/src)
17         INNOSETUP := $(shell cygpath -au "$(PROGRAMFILES)/Inno Setup 5/Compil32.exe")
18 else
19         PYVER=$(shell $(PYTHON) misc/pyver.py)
20         SUPPORT = $(shell pwd)/support
21         SUPPORTLIB = $(SUPPORT)/lib/$(PYVER)/site-packages
22         SRCPATH := $(shell pwd)/src
23         CHECK_PYWIN32_DEP := 
24         SITEDIRARG = --site-dirs=/var/lib/python-support/$(PYVER)
25 endif
26
27 PP=$(shell $(PYTHON) setup.py -q show_pythonpath)
28
29 .PHONY: make-version build
30
31 # The 'darcsver' setup.py command comes in the 'darcsver' package:
32 # http://pypi.python.org/pypi/darcsver It is necessary only if you want to
33 # automatically produce a new _version.py file from the current darcs history.
34 make-version:
35         $(PYTHON) ./setup.py darcsver --count-all-patches
36
37 # We want src/allmydata/_version.py to be up-to-date, but it's a fairly
38 # expensive operation (about 6 seconds on a just-before-0.7.0 tree, probably
39 # because of the 332 patches since the last tag), and we've removed the need
40 # for an explicit 'build' step by removing the C code from src/allmydata and
41 # by running everything in place. It would be neat to do:
42 #
43 #src/allmydata/_version.py: _darcs/patches
44 #       $(MAKE) make-version
45 #
46 # since that would update the embedded version string each time new darcs
47 # patches were pulled, but 1) this would break non-darcs trees (i.e. building
48 # from an exported tarball), and 2) without an obligatory 'build' step this
49 # rule wouldn't be run frequently enought anyways.
50 #
51 # So instead, I'll just make sure that we update the version at least once
52 # when we first start using the tree, and again whenever an explicit
53 # 'make-version' is run, since then at least the developer has some means to
54 # update things. It would be nice if 'make clean' deleted any
55 # automatically-generated _version.py too, so that 'make clean; make all'
56 # could be useable as a "what the heck is going on, get me back to a clean
57 # state', but we need 'make clean' to work on non-darcs trees without
58 # destroying useful information.
59
60 .built:
61         $(MAKE) build
62
63 src/allmydata/_version.py:
64         $(MAKE) make-version
65
66 # c.f. ticket #455, there is a problem in the intersection of setuptools,
67 # twisted's setup.py, and nevow's setup.py . A Tahoe build, to satisfy its
68 # dependencies, may try to build both Twisted and Nevow. If both of these
69 # occur during the same invocation of 'setup.py develop', then the Nevow
70 # build will fail with an "ImportError: No module named components". Running
71 # the build a second time will succeed. Until there is a new version of
72 # setuptools which properly sandboxes sys.modules (or a new version of nevow
73 # which doesn't import twisted during its build, or a new version of twisted
74 # which doesn't import itself during its build), we just build tahoe twice
75 # and ignore the errors from the first pass.
76
77 build: src/allmydata/_version.py
78         -$(MAKE) build-once
79         $(MAKE) build-once
80
81 # setuptools has a bug (Issue17, see tahoe #229 for details) that causes it
82 # to mishandle dependencies that are installed in non-site-directories,
83 # including the /var/lib/ place that debian's python-support system uses. We
84 # add this debian/ubuntu-specific directory (via $SITEDIRARG) to the setup.py
85 # command line to work around this. Some day this will probably be fixed in
86 # setuptools.
87 build-once:
88         $(PYTHON) setup.py build_tahoe
89         chmod +x bin/tahoe
90         touch .built
91
92 # 'make install' will do the following:
93 #   build+install tahoe (probably to /usr/lib/pythonN.N/site-packages)
94 # 'make install PREFIX=/usr/local/stow/tahoe-N.N' will do the same, but to
95 # a different location
96
97 install: src/allmydata/_version.py
98 ifdef PREFIX
99         mkdir -p $(PREFIX)
100         $(PYTHON) ./setup.py install --single-version-externally-managed \
101            --prefix=$(PREFIX) --record=./tahoe.files
102 else
103         $(PYTHON) ./setup.py install --single-version-externally-managed
104 endif
105
106
107 # TESTING
108
109 .PHONY: signal-error-deps test test-figleaf figleaf-output
110
111
112 signal-error-deps:
113         @echo
114         @echo
115         @echo "ERROR: Not all of Tahoe's dependencies are in place.  Please see docs/install.html for help on installing dependencies."
116         @echo
117         @echo
118         exit 1
119
120 check-auto-deps:
121         $(PYTHON) setup.py -q check_auto_deps || $(MAKE) signal-error-deps
122
123 .checked-deps:
124         $(MAKE) check-auto-deps
125         touch .checked-deps
126
127 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
128 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
129 # too.
130 TEST=allmydata
131
132 # use 'make test TRIALARGS=--reporter=bwverbose' from buildbot, to
133 # suppress the ansi color sequences
134
135 test: build src/allmydata/_version.py
136         $(PYTHON) setup.py trial -a "$(TRIALARGS) $(TEST)"
137
138 quicktest: .built .checked-deps
139         $(PYTHON) setup.py trial -a "$(TRIALARGS) $(TEST)"
140
141 test-figleaf: build src/allmydata/_version.py
142         rm -f .figleaf
143         $(PYTHON) setup.py trial -a "--reporter=bwverbose-figleaf $(TEST)"
144
145 quicktest-figleaf: src/allmydata/_version.py
146         rm -f .figleaf
147         $(PYTHON) setup.py trial -a "--reporter=bwverbose-figleaf $(TEST)"
148
149 figleaf-output:
150         $(PP) \
151          $(PYTHON) misc/figleaf2html -d coverage-html -r src -x misc/figleaf.excludes
152         @echo "now point your browser at coverage-html/index.html"
153
154 # after doing test-figleaf and figleaf-output, point your browser at
155 # coverage-html/index.html
156
157 .PHONY: upload-figleaf .figleaf.el pyflakes count-lines
158 .PHONY: check-memory check-memory-once clean
159
160 # 'upload-figleaf' is meant to be run with an UPLOAD_TARGET=host:/dir setting
161 ifdef UPLOAD_TARGET
162
163 ifndef UPLOAD_HOST
164 $(error UPLOAD_HOST must be set when using UPLOAD_TARGET)
165 endif
166 ifndef COVERAGEDIR
167 $(error COVERAGEDIR must be set when using UPLOAD_TARGET)
168 endif
169
170 upload-figleaf:
171         rsync -a coverage-html/ $(UPLOAD_TARGET)
172         ssh $(UPLOAD_HOST) make update-tahoe-figleaf COVERAGEDIR=$(COVERAGEDIR)
173 else
174 upload-figleaf:
175         echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
176         false
177 endif
178
179 .figleaf.el: .figleaf
180         $(PP) $(PYTHON) misc/figleaf2el.py .figleaf src
181
182 pyflakes:
183         $(PYTHON) -OOu `which pyflakes` src/allmydata |sort |uniq
184
185 count-lines:
186         @echo -n "files: "
187         @find src -name '*.py' |grep -v /build/ |wc --lines
188         @echo -n "lines: "
189         @cat `find src -name '*.py' |grep -v /build/` |wc --lines
190         @echo -n "TODO: "
191         @grep TODO `find src -name '*.py' |grep -v /build/` | wc --lines
192
193 check-memory: .built
194         rm -rf _test_memory
195         $(PP) \
196          $(PYTHON) src/allmydata/test/check_memory.py upload
197         $(PP) \
198          $(PYTHON) src/allmydata/test/check_memory.py upload-self
199         $(PP) \
200          $(PYTHON) src/allmydata/test/check_memory.py upload-POST
201         $(PP) \
202          $(PYTHON) src/allmydata/test/check_memory.py download
203         $(PP) \
204          $(PYTHON) src/allmydata/test/check_memory.py download-GET
205         $(PP) \
206          $(PYTHON) src/allmydata/test/check_memory.py download-GET-slow
207         $(PP) \
208          $(PYTHON) src/allmydata/test/check_memory.py receive
209
210 check-memory-once: .built
211         rm -rf _test_memory
212         $(PP) \
213          $(PYTHON) src/allmydata/test/check_memory.py $(MODE)
214
215 # The check-speed target uses a pre-established client node to run a canned
216 # set of performance tests against a test network that is also
217 # pre-established (probably on a remote machine). Provide it with the path to
218 # a local directory where this client node has been created (and populated
219 # with the necessary FURLs of the test network). This target will start that
220 # client with the current code and then run the tests. Afterwards it will
221 # stop the client.
222 #
223 # The 'sleep 5' is in there to give the new client a chance to connect to its
224 # storageservers, since check_speed.py has no good way of doing that itself.
225
226 check-speed: .built
227         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
228         @echo "stopping any leftover client code"
229         -$(PYTHON) bin/tahoe stop $(TESTCLIENTDIR)
230         $(PYTHON) bin/tahoe start $(TESTCLIENTDIR)
231         sleep 5
232         $(PYTHON) src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
233         $(PYTHON) bin/tahoe stop $(TESTCLIENTDIR)
234
235 # The check-grid target also uses a pre-established client node, along with a
236 # long-term directory that contains some well-known files. See the docstring
237 # in src/allmydata/test/check_grid.py to see how to set this up.
238 check-grid: .built
239         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
240         $(PYTHON) src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
241
242 # 'make repl' is a simple-to-type command to get a Python interpreter loop
243 # from which you can type 'import allmydata'
244 repl:
245         $(PP) $(PYTHON)
246
247 test-darcs-boringfile:
248         $(MAKE)
249         $(PYTHON) misc/test-darcs-boringfile.py
250
251 test-clean:
252         find . |grep -vEe"allfiles.tmp|src/allmydata/_(version|auto_deps).py|src/allmydata_tahoe.egg-info" |sort >allfiles.tmp.old
253         $(MAKE)
254         $(MAKE) clean
255         find . |grep -vEe"allfiles.tmp|src/allmydata/_(version|auto_deps).py|src/allmydata_tahoe.egg-info" |sort >allfiles.tmp.new
256         diff allfiles.tmp.old allfiles.tmp.new
257
258 clean:
259         rm -rf build _trial_temp _test_memory .checked-deps .built
260         rm -f debian
261         rm -f `find src/allmydata -name '*.so' -or -name '*.pyc'`
262         rm -rf tahoe_deps.egg-info allmydata_tahoe.egg-info
263         rm -rf support dist
264         rm -rf setuptools*.egg *.pyc darcsver*.egg pyutil*.egg
265         rm -rf misc/dependencies/build misc/dependencies/temp
266         rm -rf misc/dependencies/tahoe_deps.egg-info
267
268 find-trailing-spaces:
269         $(PYTHON) misc/find-trailing-spaces.py -r src
270
271 # TARBALL GENERATION
272 .PHONY: tarballs upload-tarballs
273 tarballs:
274         $(MAKE) make-version
275         $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
276 upload-tarballs:
277         for f in dist/allmydata-tahoe-*; do \
278          xfer-client --furlfile ~/.tahoe-tarball-upload.furl $$f; \
279         done
280
281 # DEBIAN PACKAGING
282
283 VER=$(shell $(PYTHON) misc/get-version.py)
284 DEBCOMMENTS="'make deb' build"
285
286 show-version:
287         @echo $(VER)
288
289 .PHONY: setup-deb deb-ARCH is-known-debian-arch
290 .PHONY: deb-etch deb-sid
291 .PHONY: deb-edgy deb-feisty deb-gutsy deb-hardy
292
293 deb-sid:
294         $(MAKE) deb-ARCH ARCH=sid
295 deb-feisty:
296         $(MAKE) deb-ARCH ARCH=feisty
297 # edgy uses the feisty control files for now
298 deb-edgy:
299         $(MAKE) deb-ARCH ARCH=edgy TAHOE_ARCH=feisty
300 # etch uses the feisty control files for now
301 deb-etch:
302         $(MAKE) deb-ARCH ARCH=etch TAHOE_ARCH=feisty
303 # same with gutsy, the process has been nicely stable for a while now
304 deb-gutsy:
305         $(MAKE) deb-ARCH ARCH=gutsy TAHOE_ARCH=feisty
306 deb-hardy:
307         $(MAKE) deb-ARCH ARCH=hardy TAHOE_ARCH=feisty
308
309 # we know how to handle the following debian architectures
310 KNOWN_DEBIAN_ARCHES := etch sid  edgy feisty gutsy hardy
311
312 ifeq ($(findstring x-$(ARCH)-x,$(foreach arch,$(KNOWN_DEBIAN_ARCHES),"x-$(arch)-x")),)
313 is-known-debian-arch:
314         @echo "ARCH must be set when using setup-deb or deb-ARCH"
315         @echo "I know how to handle:" $(KNOWN_DEBIAN_ARCHES)
316         false
317 else
318 is-known-debian-arch:
319         true
320 endif
321
322 ifndef TAHOE_ARCH
323 TAHOE_ARCH=$(ARCH)
324 endif
325
326 setup-deb: is-known-debian-arch
327         rm -f debian
328         ln -s misc/$(TAHOE_ARCH)/debian debian
329         chmod +x debian/rules
330
331 # etch (current debian stable) has python-simplejson-1.3, which doesn't 
332 #  support indent=
333 # sid (debian unstable) currently has python-simplejson 1.7.1
334 # edgy has 1.3, which doesn't support indent=
335 # feisty has 1.4, which supports indent= but emits a deprecation warning
336 # gutsy has 1.7.1
337 #
338 # we need 1.4 or newer
339
340 deb-ARCH: is-known-debian-arch setup-deb
341         fakeroot debian/rules binary
342         @echo
343         @echo "The newly built .deb packages are in the parent directory from here."
344
345 .PHONY: increment-deb-version
346 .PHONY: deb-edgy-head deb-feisty-head deb-gutsy-head deb-hardy-head
347 .PHONY: deb-etch-head deb-sid-head
348
349 # The buildbot runs the following targets after each change, to produce
350 # up-to-date tahoe .debs. These steps do not create .debs for anything else.
351
352 increment-deb-version: make-version
353         debchange --newversion $(VER) $(DEBCOMMENTS)
354 deb-sid-head:
355         $(MAKE) setup-deb ARCH=sid
356         $(MAKE) increment-deb-version
357         fakeroot debian/rules binary
358 deb-edgy-head:
359         $(MAKE) setup-deb ARCH=edgy TAHOE_ARCH=feisty
360         $(MAKE) increment-deb-version
361         fakeroot debian/rules binary
362 deb-feisty-head:
363         $(MAKE) setup-deb ARCH=feisty
364         $(MAKE) increment-deb-version
365         fakeroot debian/rules binary
366 deb-etch-head:
367         $(MAKE) setup-deb ARCH=etch TAHOE_ARCH=feisty
368         $(MAKE) increment-deb-version
369         fakeroot debian/rules binary
370 deb-gutsy-head:
371         $(MAKE) setup-deb ARCH=gutsy TAHOE_ARCH=feisty
372         $(MAKE) increment-deb-version
373         fakeroot debian/rules binary
374 deb-hardy-head:
375         $(MAKE) setup-deb ARCH=hardy TAHOE_ARCH=feisty
376         $(MAKE) increment-deb-version
377         fakeroot debian/rules binary
378
379 # These targets provide for windows native builds
380 .PHONY: windows-exe windows-installer windows-installer-upload
381
382 windows-exe: .built
383         cd windows && $(PP) $(PYTHON) setup.py py2exe
384
385 windows-installer: windows-exe
386         $(PP) $(PYTHON) misc/sub-ver.py windows/installer.tmpl >windows/installer.iss
387         cd windows && "$(INNOSETUP)" /cc installer.iss
388
389 windows-installer-upload:
390         chmod -R o+rx windows/dist/installer
391         rsync -av -e /usr/bin/ssh windows/dist/installer/ amduser@dev:/home/amduser/public_html/dist/tahoe/windows/
392
393 # These targets provide for mac native builds
394 .PHONY: mac-exe mac-upload mac-cleanup mac-dbg
395
396 mac-exe: .built
397         $(MAKE) -C mac clean
398         VERSION=$(VER) $(PP) $(MAKE) -C mac build
399
400 mac-dist:
401         VERSION=$(VER) $(MAKE) -C mac diskimage
402
403 mac-upload:
404         VERSION=$(VER) $(MAKE) -C mac upload UPLOAD_DEST=$(UPLOAD_DEST)
405
406 mac-cleanup:
407         VERSION=$(VER) $(MAKE) -C mac cleanup
408
409 mac-dbg:
410         cd mac && $(PP) $(PYTHON)w allmydata_tahoe.py
411
412 # This target runs a stats gatherer server
413 .PHONY: stats-gatherer-run
414 stats-gatherer-run:
415         cd stats_gatherer && $(PP) $(PYTHON) ../src/allmydata/stats.py