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