]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
781136365fa8cb9cffa650c8ee5332e940ea63cc
[tahoe-lafs/tahoe-lafs.git] / Makefile
1
2 # this Makefile requires GNU make
3
4 # If you get an error message like the following:
5
6 # error: Setup script exited with error: Python was built with version 7.1 of Visual Studio, and extensions need to be built with the same version of the compiler, but it isn't installed.
7
8 # Then that probably means that you aren't using the the right
9 # compiler.  In that case, try creating distutils configuration file
10 # (as described in http://docs.python.org/inst/config-syntax.html ),
11 # specifying which compiler to use.  For example, if you use either
12 # the cygwin gcc compiler with mingw support, or the MINGW compiler,
13 # then you can add the following lines to your .cfg file:
14 # [build]
15 # compiler=mingw32
16
17 default: build
18
19 PYTHON=python
20 PATHSEP=$(shell python -c 'import os ; print os.pathsep')
21 OSSEP=$(shell python -c 'import os ; print os.sep')
22 TRIALPATH=$(shell which trial.py 2>/dev/null)
23 ifeq ($(TRIALPATH),)
24 TRIALPATH=$(shell which trial 2>/dev/null)
25 endif
26 ifeq ($(TRIALPATH),)
27 TRIALPATH=$(shell $(PYTHON) -c "import os, sys; print repr(os.path.join(sys.prefix, \"Scripts\", \"trial.py\"))")
28 endif
29 ifeq ($(TRIALPATH),)
30 TRIALPATH=$(shell $(PYTHON) -c "import os, sys; print repr(os.path.join(sys.prefix, \"Scripts\", \"trial\"))")
31 endif
32
33 REACTOR=
34
35 PLAT = $(strip $(shell python -c "import sys ; print sys.platform"))
36 ifeq ($(PLAT),win32)
37  # The platform is Windows with cygwin build tools and the native Python interpreter.
38  TRIALPATH := $(shell cygpath -w $(TRIALPATH))
39  SUPPORT = $(shell cygpath -w $(shell pwd))\support
40  SUPPORTLIB := $(SUPPORT)\Lib\site-packages
41  SRCPATH := $(shell cygpath -w $(shell pwd))\src
42  CHECK_PYWIN32_DEP := check-pywin32-dep
43 else
44  PYVER=$(shell $(PYTHON) misc/pyver.py)
45  SUPPORT = $(shell pwd)/support
46  SUPPORTLIB = $(SUPPORT)/lib/$(PYVER)/site-packages
47  SRCPATH := $(shell pwd)/src
48  CHECK_PYWIN32_DEP := 
49 endif
50
51 ifeq ($(PLAT),cygwin)
52 REACTOR = poll
53 endif
54
55 ifneq ($(REACTOR),)
56         REACTOROPT := --reactor=$(REACTOR)
57 else
58         REACTOROPT := 
59 endif
60
61 TRIAL=$(PYTHON) -u "$(TRIALPATH)" --rterrors $(REACTOROPT)
62
63 # build-deps wants setuptools to have been built first. It's easiest to
64 # accomplish this by depending upon the tahoe compile.
65 build-deps: .built check-twisted-dep
66         mkdir -p "$(SUPPORTLIB)"
67         PYTHONPATH="$(PYTHONPATH)$(PATHSEP)$(SUPPORTLIB)$(PATHSEP)" \
68          $(PYTHON) misc/dependencies/build-deps-setup.py install \
69          --prefix="$(SUPPORT)"
70
71 EGGSPATH = $(shell $(PYTHON) misc/find-dep-eggs.py)
72 show-eggspath:
73         @echo $(EGGSPATH)
74
75 ifneq ($(PYTHONPATH),)
76         PYTHONPATH := $(PYTHONPATH)$(PATHSEP)
77 endif
78 PP=PYTHONPATH="$(SRCPATH)$(PATHSEP)$(EGGSPATH)$(PATHSEP)$(PYTHONPATH)"
79
80 .PHONY: make-version build
81 make-version:
82         $(PYTHON) misc/make-version.py "allmydata-tahoe" "src/allmydata/_version.py"
83
84 .built:
85         $(MAKE) build
86         touch .built
87
88 build: 
89         $(PYTHON) ./setup.py build_ext -i
90         chmod +x bin/allmydata-tahoe
91
92 # 'make install' will do the following:
93 #   build+install tahoe (probably to /usr/lib/pythonN.N/site-packages)
94 # 'make install PREFIX=/usr/local/stow/tahoe-N.N' will do the same, but to
95 # a different location
96
97 install: 
98 ifdef PREFIX
99         mkdir -p $(PREFIX)
100         $(PP) $(PYTHON) ./setup.py install \
101            --single-version-externally-managed \
102            --prefix=$(PREFIX) --record=./tahoe.files
103 else
104         $(PP) $(PYTHON) ./setup.py install \
105            --single-version-externally-managed
106 endif
107
108
109 # TESTING
110
111 .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
112
113
114 signal-error-deps:
115         @echo "ERROR: Not all of Tahoe's dependencies are in place.  Please\
116 see the README for help on installing dependencies."
117         exit 1
118
119 signal-error-twisted-dep:
120         @echo "ERROR: Before running \"make build-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         exit 1
125
126 signal-error-pywin32-dep:
127         @echo "ERROR: the pywin32 dependency is not in place.  Please see the README\
128 for help on installing dependencies."
129         exit 1
130
131 check-deps: check-twisted-dep $(CHECK_PYWIN32_DEP)
132         $(PP) \
133          $(PYTHON) -c 'import allmydata, zfec, foolscap, simplejson, nevow, OpenSSL' || $(MAKE) signal-error-deps
134
135 check-twisted-dep:
136         $(PYTHON) -c 'import twisted, zope.interface' || $(MAKE) signal-error-twisted-dep
137
138 check-pywin32-dep:
139         $(PYTHON) -c 'import win32process' || $(MAKE) signal-error-pywin32-dep
140
141 .checked-deps:
142         $(MAKE) check-deps
143         touch .checked-deps
144
145 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
146 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
147 # too.
148 TEST=allmydata
149
150 # use 'make test REPORTER=--reporter=bwverbose' from buildbot, to
151 # suppress the ansi color sequences
152
153 test: .built .checked-deps
154         $(PP) \
155          $(TRIAL) $(REPORTER) $(TEST)
156
157 test-figleaf: .built .checked-deps
158         rm -f .figleaf
159         $(PP) \
160          $(TRIAL) --reporter=bwverbose-figleaf $(TEST)
161
162 figleaf-output:
163         $(PP) \
164          $(PYTHON) misc/figleaf2html -d coverage-html -r src -x misc/figleaf.excludes
165         @echo "now point your browser at coverage-html/index.html"
166
167 # after doing test-figleaf and figleaf-output, point your browser at
168 # coverage-html/index.html
169
170 .PHONY: upload-figleaf .figleaf.el pyflakes count-lines
171 .PHONY: check-memory check-memory-once clean
172
173 # 'upload-figleaf' is meant to be run with an UPLOAD_TARGET=host:/dir setting
174 ifdef UPLOAD_TARGET
175
176 ifndef UPLOAD_HOST
177 $(error UPLOAD_HOST must be set when using UPLOAD_TARGET)
178 endif
179 ifndef COVERAGEDIR
180 $(error COVERAGEDIR must be set when using UPLOAD_TARGET)
181 endif
182
183 upload-figleaf:
184         rsync -a coverage-html/ $(UPLOAD_TARGET)
185         ssh $(UPLOAD_HOST) make update-tahoe-figleaf COVERAGEDIR=$(COVERAGEDIR)
186 else
187 upload-figleaf:
188         echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
189         /bin/false
190 endif
191
192 .figleaf.el: .figleaf
193         $(PP) \
194          $(PYTHON) misc/figleaf2el.py .figleaf src
195
196 pyflakes:
197         $(PYTHON) -OOu `which pyflakes` src/allmydata
198
199 count-lines:
200         @echo -n "files: "
201         @find src -name '*.py' |grep -v /build/ |wc --lines
202         @echo -n "lines: "
203         @cat `find src -name '*.py' |grep -v /build/` |wc --lines
204         @echo -n "TODO: "
205         @grep TODO `find src -name '*.py' |grep -v /build/` | wc --lines
206
207 check-memory: .built
208         rm -rf _test_memory
209         $(PP) \
210          $(PYTHON) src/allmydata/test/check_memory.py upload
211         $(PP) \
212          $(PYTHON) src/allmydata/test/check_memory.py upload-self
213         $(PP) \
214          $(PYTHON) src/allmydata/test/check_memory.py upload-POST
215         $(PP) \
216          $(PYTHON) src/allmydata/test/check_memory.py download
217         $(PP) \
218          $(PYTHON) src/allmydata/test/check_memory.py download-GET
219         $(PP) \
220          $(PYTHON) src/allmydata/test/check_memory.py download-GET-slow
221         $(PP) \
222          $(PYTHON) src/allmydata/test/check_memory.py receive
223
224 check-memory-once: .built
225         rm -rf _test_memory
226         $(PP) \
227          $(PYTHON) src/allmydata/test/check_memory.py $(MODE)
228
229 # this target uses a pre-established client node to run a canned set of
230 # performance tests against a test network that is also pre-established
231 # (probably on a remote machine). Provide it with the path to a local
232 # directory where this client node has been created (and populated with the
233 # necessary FURLs of the test network). This target will start that client
234 # with the current code and then run the tests. Afterwards it will stop the
235 # client.
236 #
237 # The 'sleep 5' is in there to give the new client a chance to connect to its
238 # storageservers, since check_speed.py has no good way of doing that itself.
239
240 check-speed: .built
241         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
242         $(PYTHON) bin/allmydata-tahoe start $(TESTCLIENTDIR)
243         sleep 5
244         $(PYTHON) src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
245         $(PYTHON) bin/allmydata-tahoe stop $(TESTCLIENTDIR)
246
247 test-darcs-boringfile:
248         $(MAKE)
249         $(PYTHON) misc/test-darcs-boringfile.py
250
251 test-clean:
252         find . |grep -v allfiles.tmp |grep -v src/allmydata/_version.py |sort >allfiles.tmp.old
253         $(MAKE)
254         $(MAKE) clean
255         find . |grep -v allfiles.tmp |grep -v src/allmydata/_version.py |sort >allfiles.tmp.new
256         diff allfiles.tmp.old allfiles.tmp.new
257
258 clean:
259         rm -rf build _trial_temp _test_memory .checked-deps .built
260         rm -f debian
261         rm -f `find src/allmydata -name '*.so' -or -name '*.pyc'`
262         rm -rf tahoe_deps.egg-info allmydata_tahoe.egg-info
263         rm -rf support dist
264         rm -rf setuptools*.egg *.pyc
265
266
267
268 # DEBIAN PACKAGING
269
270 VER=$(shell $(PYTHON) misc/get-version.py)
271 DEBCOMMENTS="'make deb' build"
272
273 show-version:
274         @echo $(VER)
275
276 .PHONY: setup-deb deb-ARCH is-known-debian-arch
277 .PHONY: deb-sid deb-feisty deb-edgy deb-etch
278
279 deb-sid:
280         $(MAKE) deb-ARCH ARCH=sid
281 deb-feisty:
282         $(MAKE) deb-ARCH ARCH=feisty
283 # edgy uses the feisty control files for now
284 deb-edgy:
285         $(MAKE) deb-ARCH ARCH=edgy TAHOE_ARCH=feisty
286 # etch uses the feisty control files for now
287 deb-etch:
288         $(MAKE) deb-ARCH ARCH=etch TAHOE_ARCH=feisty
289
290 # we know how to handle the following debian architectures
291 KNOWN_DEBIAN_ARCHES := sid feisty edgy etch
292
293 ifeq ($(findstring x-$(ARCH)-x,$(foreach arch,$(KNOWN_DEBIAN_ARCHES),"x-$(arch)-x")),)
294 is-known-debian-arch:
295         @echo "ARCH must be set when using setup-deb or deb-ARCH"
296         @echo "I know how to handle:" $(KNOWN_DEBIAN_ARCHES)
297         /bin/false
298 else
299 is-known-debian-arch:
300         /bin/true
301 endif
302
303 ifndef TAHOE_ARCH
304 TAHOE_ARCH=$(ARCH)
305 endif
306
307 setup-deb: is-known-debian-arch
308         rm -f debian
309         ln -s misc/$(TAHOE_ARCH)/debian debian
310         chmod +x debian/rules
311
312 # etch (current debian stable) has python-simplejson-1.3, which doesn't 
313 #  support indent=
314 # sid (debian unstable) currently has python-simplejson 1.7.1
315 # edgy has 1.3, which doesn't support indent=
316 # feisty has 1.4, which supports indent= but emits a deprecation warning
317 # gutsy has 1.7.1
318 #
319 # we need 1.4 or newer
320
321 deb-ARCH: is-known-debian-arch setup-deb
322         fakeroot debian/rules binary
323         echo
324         echo "The newly built .deb packages are in the parent directory from here."
325
326 .PHONY: increment-deb-version
327 .PHONY: deb-sid-head deb-edgy-head deb-feisty-head
328 .PHONY: deb-etch-head
329
330 # The buildbot runs the following targets after each change, to produce
331 # up-to-date tahoe .debs. These steps do not create .debs for anything else.
332
333 increment-deb-version: make-version
334         debchange --newversion $(VER) $(DEBCOMMENTS)
335 deb-sid-head:
336         $(MAKE) setup-deb ARCH=sid
337         $(MAKE) increment-deb-version
338         fakeroot debian/rules binary
339 deb-edgy-head:
340         $(MAKE) setup-deb ARCH=edgy TAHOE_ARCH=feisty
341         $(MAKE) increment-deb-version
342         fakeroot debian/rules binary
343 deb-feisty-head:
344         $(MAKE) setup-deb ARCH=feisty
345         $(MAKE) increment-deb-version
346         fakeroot debian/rules binary
347 deb-etch-head:
348         $(MAKE) setup-deb ARCH=etch TAHOE_ARCH=feisty
349         $(MAKE) increment-deb-version
350         fakeroot debian/rules binary