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