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