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