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