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