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