]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
check_memory: add download, download-GET
[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 TRIALPATH=$(shell which trial.py 2>/dev/null)
22 ifeq ($(TRIALPATH),)
23 TRIALPATH=$(shell which trial 2>/dev/null)
24 endif
25 ifeq ($(TRIALPATH),)
26 TRIALPATH=$(shell $(PYTHON) -c "import os, sys; print repr(os.path.join(sys.prefix, \"Scripts\", \"trial.py\"))")
27 endif
28 ifeq ($(TRIALPATH),)
29 TRIALPATH=$(shell $(PYTHON) -c "import os, sys; print repr(os.path.join(sys.prefix, \"Scripts\", \"trial\"))")
30 endif
31
32 REACTOR=
33
34 PLAT = $(strip $(shell python -c "import sys ; print sys.platform"))
35 ifeq ($(PLAT),win32)
36  # The platform is Windows with cygwin build tools and the native Python interpreter.
37  TRIALPATH := $(shell cygpath -w $(TRIALPATH))
38  SUPPORT = $(shell cygpath -w $(shell pwd))\support
39  SUPPORTLIB := $(SUPPORT)\Lib\site-packages
40  SRCPATH := $(shell cygpath -w $(shell pwd))\src
41 else
42  PYVER=$(shell $(PYTHON) misc/pyver.py)
43  SUPPORT = $(shell pwd)/support
44  SUPPORTLIB = $(SUPPORT)/lib/$(PYVER)/site-packages
45  SRCPATH := $(shell pwd)/src
46 endif
47
48 ifeq ($(PLAT),cygwin)
49 REACTOR = poll
50 endif
51
52 ifneq ($(REACTOR),)
53         REACTOROPT := --reactor=$(REACTOR)
54 else
55         REACTOROPT := 
56 endif
57
58 TRIAL=$(PYTHON) -u "$(TRIALPATH)" --rterrors $(REACTOROPT)
59
60 build-deps: build
61         mkdir -p "$(SUPPORTLIB)"
62         PYTHONPATH="$(PYTHONPATH)$(PATHSEP)$(SUPPORTLIB)$(PATHSEP)." \
63          $(PYTHON) misc/dependencies/build-deps-setup.py install \
64          --prefix="$(SUPPORT)"
65
66 EGGSPATH = $(shell $(PYTHON) misc/find-dep-eggs.py)
67 show-eggspath:
68         @echo $(EGGSPATH)
69
70 PP=PYTHONPATH="$(SRCPATH)$(PATHSEP)$(EGGSPATH)$(PATHSEP)$(PYTHONPATH)"
71
72 .PHONY: make-version build
73 make-version:
74         $(PYTHON) misc/make-version.py "allmydata-tahoe" "src/allmydata/_version.py"
75
76 build: make-version
77         $(PYTHON) ./setup.py build_ext -i
78         chmod +x bin/allmydata-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: make-version
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 test test-figleaf figleaf-output
100
101
102 check-deps:
103         $(PP) \
104          $(PYTHON) -c 'import allmydata, zfec, foolscap, simplejson, nevow, OpenSSL'
105
106 .checked-deps:
107         $(MAKE) check-deps
108         touch .checked-deps
109
110 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
111 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
112 # too.
113 TEST=allmydata
114
115 # use 'make test REPORTER=--reporter=bwverbose' from buildbot, to
116 # suppress the ansi color sequences
117
118 test: build .checked-deps
119         $(PP) \
120          $(TRIAL) $(REPORTER) $(TEST)
121
122 test-figleaf: build .checked-deps
123         rm -f .figleaf
124         $(PP) \
125          $(TRIAL) --reporter=bwverbose-figleaf $(TEST)
126
127 figleaf-output:
128         $(PP) \
129          $(PYTHON) misc/figleaf2html -d coverage-html -r src -x misc/figleaf.excludes
130         @echo "now point your browser at coverage-html/index.html"
131
132 # after doing test-figleaf and figleaf-output, point your browser at
133 # coverage-html/index.html
134
135 .PHONY: upload-figleaf .figleaf.el pyflakes count-lines check-memory
136 .PHONY: clean
137
138 # 'upload-figleaf' is meant to be run with an UPLOAD_TARGET=host:/dir setting
139 ifdef UPLOAD_TARGET
140
141 ifndef UPLOAD_HOST
142 $(error UPLOAD_HOST must be set when using UPLOAD_TARGET)
143 endif
144 ifndef COVERAGEDIR
145 $(error COVERAGEDIR must be set when using UPLOAD_TARGET)
146 endif
147
148 upload-figleaf:
149         rsync -a coverage-html/ $(UPLOAD_TARGET)
150         ssh $(UPLOAD_HOST) make update-tahoe-figleaf COVERAGEDIR=$(COVERAGEDIR)
151 else
152 upload-figleaf:
153         echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
154         /bin/false
155 endif
156
157 .figleaf.el: .figleaf
158         $(PP) \
159          $(PYTHON) misc/figleaf2el.py .figleaf src
160
161 pyflakes:
162         $(PYTHON) -OOu `which pyflakes` src/allmydata
163
164 count-lines:
165         @echo -n "files: "
166         @find src -name '*.py' |grep -v /build/ |wc --lines
167         @echo -n "lines: "
168         @cat `find src -name '*.py' |grep -v /build/` |wc --lines
169         @echo -n "TODO: "
170         @grep TODO `find src -name '*.py' |grep -v /build/` | wc --lines
171
172 check-memory: build
173         rm -rf _test_memory
174         $(PP) \
175          $(PYTHON) src/allmydata/test/check_memory.py upload
176         $(PP) \
177          $(PYTHON) src/allmydata/test/check_memory.py upload-self
178         $(PP) \
179          $(PYTHON) src/allmydata/test/check_memory.py upload-POST
180         $(PP) \
181          $(PYTHON) src/allmydata/test/check_memory.py download
182         $(PP) \
183          $(PYTHON) src/allmydata/test/check_memory.py download-GET
184
185
186 test-darcs-boringfile:
187         $(MAKE)
188         $(PYTHON) misc/test-darcs-boringfile.py
189
190 test-clean:
191         find . |grep -v allfiles.tmp |grep -v src/allmydata/_version.py |sort >allfiles.tmp.old
192         $(MAKE)
193         $(MAKE) clean
194         find . |grep -v allfiles.tmp |grep -v src/allmydata/_version.py |sort >allfiles.tmp.new
195         diff allfiles.tmp.old allfiles.tmp.new
196
197 clean:
198         rm -rf build _trial_temp _test_memory .checked-deps
199         rm -f debian
200         rm -f `find src/allmydata -name '*.so' -or -name '*.pyc'`
201         rm -rf tahoe_deps.egg-info allmydata_tahoe.egg-info
202         rm -rf support dist
203         rm -rf setuptools*.egg *.pyc
204
205
206
207 # DEBIAN PACKAGING
208
209 VER=$(shell $(PYTHON) misc/get-version.py)
210 DEBCOMMENTS="'make deb' build"
211
212 show-version:
213         @echo $(VER)
214
215 .PHONY: setup-deb deb-ARCH is-known-debian-arch
216 .PHONY: deb-sid deb-feisty deb-edgy deb-etch
217
218 deb-sid:
219         $(MAKE) deb-ARCH ARCH=sid
220 deb-feisty:
221         $(MAKE) deb-ARCH ARCH=feisty
222 # edgy uses the feisty control files for now
223 deb-edgy:
224         $(MAKE) deb-ARCH ARCH=edgy TAHOE_ARCH=feisty
225 # etch uses the feisty control files for now
226 deb-etch:
227         $(MAKE) deb-ARCH ARCH=etch TAHOE_ARCH=feisty
228
229 # we know how to handle the following debian architectures
230 KNOWN_DEBIAN_ARCHES := sid feisty edgy etch
231
232 ifeq ($(findstring x-$(ARCH)-x,$(foreach arch,$(KNOWN_DEBIAN_ARCHES),"x-$(arch)-x")),)
233 is-known-debian-arch:
234         @echo "ARCH must be set when using setup-deb or deb-ARCH"
235         @echo "I know how to handle:" $(KNOWN_DEBIAN_ARCHES)
236         /bin/false
237 else
238 is-known-debian-arch:
239         /bin/true
240 endif
241
242 ifndef TAHOE_ARCH
243 TAHOE_ARCH=$(ARCH)
244 endif
245
246 setup-deb: is-known-debian-arch
247         rm -f debian
248         ln -s misc/$(TAHOE_ARCH)/debian debian
249         chmod +x debian/rules
250
251 # etch (current debian stable) has python-simplejson-1.3, which doesn't 
252 #  support indent=
253 # sid (debian unstable) currently has python-simplejson 1.7.1
254 # edgy has 1.3, which doesn't support indent=
255 # feisty has 1.4, which supports indent= but emits a deprecation warning
256 # gutsy has 1.7.1
257 #
258 # we need 1.4 or newer
259
260 deb-ARCH: is-known-debian-arch setup-deb
261         fakeroot debian/rules binary
262         echo
263         echo "The newly built .deb packages are in the parent directory from here."
264
265 .PHONY: increment-deb-version
266 .PHONY: deb-sid-head deb-edgy-head deb-feisty-head
267 .PHONY: deb-etch-head
268
269 # The buildbot runs the following targets after each change, to produce
270 # up-to-date tahoe .debs. These steps do not create .debs for anything else.
271
272 increment-deb-version: make-version
273         debchange --newversion $(VER) $(DEBCOMMENTS)
274 deb-sid-head:
275         $(MAKE) setup-deb ARCH=sid
276         $(MAKE) increment-deb-version
277         fakeroot debian/rules binary
278 deb-edgy-head:
279         $(MAKE) setup-deb ARCH=edgy TAHOE_ARCH=feisty
280         $(MAKE) increment-deb-version
281         fakeroot debian/rules binary
282 deb-feisty-head:
283         $(MAKE) setup-deb ARCH=feisty
284         $(MAKE) increment-deb-version
285         fakeroot debian/rules binary
286 deb-etch-head:
287         $(MAKE) setup-deb ARCH=etch TAHOE_ARCH=feisty
288         $(MAKE) increment-deb-version
289         fakeroot debian/rules binary