]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
setup: direct user to doc/install.html if the build fails
[tahoe-lafs/tahoe-lafs.git] / Makefile
1
2 # this Makefile requires GNU make
3
4 default: simple-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  CHECK_PYWIN32_DEP := check-pywin32-dep
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 TRIALCMD = $(shell PYTHONPATH="$(PYTHONPATH)$(PATHSEP)$(SRCPATH)" $(PYTHON) misc/find_trial.py)
35
36 ifeq ($(PLAT),cygwin)
37 REACTOR = poll
38 endif
39
40 ifneq ($(REACTOR),)
41         REACTOROPT := --reactor=$(REACTOR)
42 else
43         REACTOROPT := 
44 endif
45
46 TRIAL=PYTHONUNBUFFERED=1 $(TRIALCMD) --rterrors $(REACTOROPT)
47
48 build-auto-deps: check-deps
49         mkdir -p "$(SUPPORTLIB)"
50         PYTHONPATH="$(PYTHONPATH)$(PATHSEP)$(SUPPORTLIB)$(PATHSEP)" \
51          $(PYTHON) misc/dependencies/build-deps-setup.py install \
52          --prefix="$(SUPPORT)" || \
53         echo "Build of Tahoe's bundled, automatically built dependent libraries failed -- please see docs/install.html for instructions."
54
55 # The following target is here because I don't know how to tell the buildmaster
56 # to start instructing his slaves to "build-auto-deps" instead of instructing
57 # them to "build-deps".  --Z
58 build-deps: build-auto-deps
59
60 EGGSPATH = $(shell $(PYTHON) misc/find-dep-eggs.py)
61 show-eggspath:
62         @echo $(EGGSPATH)
63
64 ifneq ($(PYTHONPATH),)
65         PYTHONPATH := $(PYTHONPATH)$(PATHSEP)
66 endif
67 PP=PYTHONPATH="$(SRCPATH)$(PATHSEP)$(PYTHONPATH)$(PATHSEP)$(EGGSPATH)"
68
69 .PHONY: make-version build
70
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.
74 make-version:
75         $(PYTHON) ./setup.py darcsver
76
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:
82 #
83 #src/allmydata/_version.py: _darcs/patches
84 #       $(MAKE) make-version
85 #
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.
90 #
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.
99
100 .built:
101         $(MAKE) build
102         touch .built
103
104 simple-build: build-auto-deps build
105
106 src/allmydata/_version.py:
107         $(MAKE) make-version
108
109 build: src/allmydata/_version.py
110         $(PYTHON) ./setup.py build_ext -i $(INCLUDE_DIRS_ARG) $(LIBRARY_DIRS_ARG) || \
111                 echo "Build of Allmydata-Tahoe failed -- please see docs/install.html for instructions."
112         chmod +x bin/tahoe
113
114 # 'make install' will do the following:
115 #   build+install tahoe (probably to /usr/lib/pythonN.N/site-packages)
116 # 'make install PREFIX=/usr/local/stow/tahoe-N.N' will do the same, but to
117 # a different location
118
119 install: src/allmydata/_version.py
120 ifdef PREFIX
121         mkdir -p $(PREFIX)
122         $(PP) $(PYTHON) ./setup.py install \
123            --single-version-externally-managed \
124            --prefix=$(PREFIX) --record=./tahoe.files
125 else
126         $(PP) $(PYTHON) ./setup.py install \
127            --single-version-externally-managed
128 endif
129
130
131 # TESTING
132
133 .PHONY: check-all-deps check-twisted-dep $(CHECK_PYWIN32_DEP) signal-error-deps, signal-error-twisted-dep, signal-error-pywin32-dep, test test-figleaf figleaf-output
134
135
136 signal-error-deps:
137         @echo
138         @echo
139         @echo "ERROR: Not all of Tahoe's dependencies are in place.  Please \
140 see the README for help on installing dependencies."
141         @echo
142         @echo
143         exit 1
144
145 signal-error-twisted-dep:
146         @echo
147         @echo
148         @echo "ERROR: Before running \"make build-auto-deps\" you have to ensure that \
149 Twisted is installed (including its zope.interface dependency).  Twisted and \
150 zope.interface are required for the automatic installation of certain other \
151 libraries that Tahoe requires).  Please see the README for details."
152         @echo
153         @echo
154         exit 1
155
156 signal-error-pywin32-dep:
157         @echo
158         @echo
159         @echo "ERROR: the pywin32 dependency is not in place.  Please see the README \
160 for help on installing dependencies."
161         @echo
162         @echo
163         exit 1
164
165 signal-error-pyopenssl-dep:
166         @echo
167         @echo
168         @echo "ERROR: the pyOpenSSL dependency is not in place (note that pyOpenSSL required \
169 OpenSSL).  Please see the README for help on installing dependencies."
170         @echo
171         @echo
172         exit 1
173
174 check-all-deps: check-deps
175         $(PP) \
176          $(PYTHON) -c 'import allmydata, zfec, foolscap, simplejson, nevow, pycryptopp' || $(MAKE) signal-error-deps
177
178 check-twisted-dep:
179         $(PYTHON) -c 'import twisted, zope.interface' || $(MAKE) signal-error-twisted-dep
180
181 check-pywin32-dep:
182         $(PYTHON) -c 'import win32process' || $(MAKE) signal-error-pywin32-dep
183
184 check-pyopenssl-dep:
185         $(PYTHON) -c 'import OpenSSL' || $(MAKE) signal-error-pyopenssl-dep
186
187 check-deps: check-twisted-dep $(CHECK_PYWIN32_DEP) check-pyopenssl-dep
188
189 .checked-deps:
190         $(MAKE) check-all-deps
191         touch .checked-deps
192
193 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
194 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
195 # too.
196 TEST=allmydata
197
198 # use 'make test TRIALARGS=--reporter=bwverbose' from buildbot, to
199 # suppress the ansi color sequences
200
201 test: .built .checked-deps
202         $(PP) \
203          $(TRIAL) $(TRIALARGS) $(TEST)
204
205 test-figleaf: .built .checked-deps
206         rm -f .figleaf
207         $(PP) \
208          $(TRIAL) --reporter=bwverbose-figleaf $(TEST)
209
210 figleaf-output:
211         $(PP) \
212          $(PYTHON) misc/figleaf2html -d coverage-html -r src -x misc/figleaf.excludes
213         @echo "now point your browser at coverage-html/index.html"
214
215 # after doing test-figleaf and figleaf-output, point your browser at
216 # coverage-html/index.html
217
218 .PHONY: upload-figleaf .figleaf.el pyflakes count-lines
219 .PHONY: check-memory check-memory-once clean
220
221 # 'upload-figleaf' is meant to be run with an UPLOAD_TARGET=host:/dir setting
222 ifdef UPLOAD_TARGET
223
224 ifndef UPLOAD_HOST
225 $(error UPLOAD_HOST must be set when using UPLOAD_TARGET)
226 endif
227 ifndef COVERAGEDIR
228 $(error COVERAGEDIR must be set when using UPLOAD_TARGET)
229 endif
230
231 upload-figleaf:
232         rsync -a coverage-html/ $(UPLOAD_TARGET)
233         ssh $(UPLOAD_HOST) make update-tahoe-figleaf COVERAGEDIR=$(COVERAGEDIR)
234 else
235 upload-figleaf:
236         echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
237         /bin/false
238 endif
239
240 .figleaf.el: .figleaf
241         $(PP) \
242          $(PYTHON) misc/figleaf2el.py .figleaf src
243
244 pyflakes:
245         $(PYTHON) -OOu `which pyflakes` src/allmydata
246
247 count-lines:
248         @echo -n "files: "
249         @find src -name '*.py' |grep -v /build/ |wc --lines
250         @echo -n "lines: "
251         @cat `find src -name '*.py' |grep -v /build/` |wc --lines
252         @echo -n "TODO: "
253         @grep TODO `find src -name '*.py' |grep -v /build/` | wc --lines
254
255 check-memory: .built
256         rm -rf _test_memory
257         $(PP) \
258          $(PYTHON) src/allmydata/test/check_memory.py upload
259         $(PP) \
260          $(PYTHON) src/allmydata/test/check_memory.py upload-self
261         $(PP) \
262          $(PYTHON) src/allmydata/test/check_memory.py upload-POST
263         $(PP) \
264          $(PYTHON) src/allmydata/test/check_memory.py download
265         $(PP) \
266          $(PYTHON) src/allmydata/test/check_memory.py download-GET
267         $(PP) \
268          $(PYTHON) src/allmydata/test/check_memory.py download-GET-slow
269         $(PP) \
270          $(PYTHON) src/allmydata/test/check_memory.py receive
271
272 check-memory-once: .built
273         rm -rf _test_memory
274         $(PP) \
275          $(PYTHON) src/allmydata/test/check_memory.py $(MODE)
276
277 # this target uses a pre-established client node to run a canned set of
278 # performance tests against a test network that is also pre-established
279 # (probably on a remote machine). Provide it with the path to a local
280 # directory where this client node has been created (and populated with the
281 # necessary FURLs of the test network). This target will start that client
282 # with the current code and then run the tests. Afterwards it will stop the
283 # client.
284 #
285 # The 'sleep 5' is in there to give the new client a chance to connect to its
286 # storageservers, since check_speed.py has no good way of doing that itself.
287
288 check-speed: .built
289         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
290         @echo "stopping any leftover client code"
291         -$(PYTHON) bin/tahoe stop $(TESTCLIENTDIR)
292         $(PYTHON) bin/tahoe start $(TESTCLIENTDIR)
293         sleep 5
294         $(PYTHON) src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
295         $(PYTHON) bin/tahoe stop $(TESTCLIENTDIR)
296
297 # 'make repl' is a simple-to-type command to get a Python interpreter loop
298 # from which you can type 'import allmydata'
299 repl:
300         $(PP) python
301
302 test-darcs-boringfile:
303         $(MAKE)
304         $(PYTHON) misc/test-darcs-boringfile.py
305
306 test-clean:
307         find . |grep -v allfiles.tmp |grep -v src/allmydata/_version.py |sort >allfiles.tmp.old
308         $(MAKE)
309         $(MAKE) clean
310         find . |grep -v allfiles.tmp |grep -v src/allmydata/_version.py |sort >allfiles.tmp.new
311         diff allfiles.tmp.old allfiles.tmp.new
312
313 clean:
314         rm -rf build _trial_temp _test_memory .checked-deps .built
315         rm -f debian
316         rm -f `find src/allmydata -name '*.so' -or -name '*.pyc'`
317         rm -rf tahoe_deps.egg-info allmydata_tahoe.egg-info
318         rm -rf support dist
319         rm -rf setuptools*.egg *.pyc darcsver*.egg
320
321 find-trailing-spaces:
322         $(PYTHON) misc/find-trailing-spaces.py -r src
323
324
325 # DEBIAN PACKAGING
326
327 VER=$(shell $(PYTHON) misc/get-version.py)
328 DEBCOMMENTS="'make deb' build"
329
330 show-version:
331         @echo $(VER)
332
333 .PHONY: setup-deb deb-ARCH is-known-debian-arch
334 .PHONY: deb-sid deb-feisty deb-edgy deb-etch
335
336 deb-sid:
337         $(MAKE) deb-ARCH ARCH=sid
338 deb-feisty:
339         $(MAKE) deb-ARCH ARCH=feisty
340 # edgy uses the feisty control files for now
341 deb-edgy:
342         $(MAKE) deb-ARCH ARCH=edgy TAHOE_ARCH=feisty
343 # etch uses the feisty control files for now
344 deb-etch:
345         $(MAKE) deb-ARCH ARCH=etch TAHOE_ARCH=feisty
346 # same with gutsy, the process has been nicely stable for a while now
347 deb-gutsy:
348         $(MAKE) deb-ARCH ARCH=gutsy TAHOE_ARCH=feisty
349
350 # we know how to handle the following debian architectures
351 KNOWN_DEBIAN_ARCHES := sid feisty edgy etch gutsy
352
353 ifeq ($(findstring x-$(ARCH)-x,$(foreach arch,$(KNOWN_DEBIAN_ARCHES),"x-$(arch)-x")),)
354 is-known-debian-arch:
355         @echo "ARCH must be set when using setup-deb or deb-ARCH"
356         @echo "I know how to handle:" $(KNOWN_DEBIAN_ARCHES)
357         false
358 else
359 is-known-debian-arch:
360         true
361 endif
362
363 ifndef TAHOE_ARCH
364 TAHOE_ARCH=$(ARCH)
365 endif
366
367 setup-deb: is-known-debian-arch
368         rm -f debian
369         ln -s misc/$(TAHOE_ARCH)/debian debian
370         chmod +x debian/rules
371
372 # etch (current debian stable) has python-simplejson-1.3, which doesn't 
373 #  support indent=
374 # sid (debian unstable) currently has python-simplejson 1.7.1
375 # edgy has 1.3, which doesn't support indent=
376 # feisty has 1.4, which supports indent= but emits a deprecation warning
377 # gutsy has 1.7.1
378 #
379 # we need 1.4 or newer
380
381 deb-ARCH: is-known-debian-arch setup-deb
382         fakeroot debian/rules binary
383         @echo
384         @echo "The newly built .deb packages are in the parent directory from here."
385
386 .PHONY: increment-deb-version
387 .PHONY: deb-sid-head deb-edgy-head deb-feisty-head
388 .PHONY: deb-etch-head
389
390 # The buildbot runs the following targets after each change, to produce
391 # up-to-date tahoe .debs. These steps do not create .debs for anything else.
392
393 increment-deb-version: make-version
394         debchange --newversion $(VER) $(DEBCOMMENTS)
395 deb-sid-head:
396         $(MAKE) setup-deb ARCH=sid
397         $(MAKE) increment-deb-version
398         fakeroot debian/rules binary
399 deb-edgy-head:
400         $(MAKE) setup-deb ARCH=edgy TAHOE_ARCH=feisty
401         $(MAKE) increment-deb-version
402         fakeroot debian/rules binary
403 deb-feisty-head:
404         $(MAKE) setup-deb ARCH=feisty
405         $(MAKE) increment-deb-version
406         fakeroot debian/rules binary
407 deb-etch-head:
408         $(MAKE) setup-deb ARCH=etch TAHOE_ARCH=feisty
409         $(MAKE) increment-deb-version
410         fakeroot debian/rules binary
411 deb-gutsy-head:
412         $(MAKE) setup-deb ARCH=gutsy TAHOE_ARCH=feisty
413         $(MAKE) increment-deb-version
414         fakeroot debian/rules binary