]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
Makefile: give explicit failure message to user if dependencies aren't found
[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 wants setuptools to have been built first. It's easiest to
61 # accomplish this by depending upon the tahoe compile.
62 build-deps: .built
63         mkdir -p "$(SUPPORTLIB)"
64         PYTHONPATH="$(PYTHONPATH)$(PATHSEP)$(SUPPORTLIB)$(PATHSEP)." \
65          $(PYTHON) misc/dependencies/build-deps-setup.py install \
66          --prefix="$(SUPPORT)"
67
68 EGGSPATH = $(shell $(PYTHON) misc/find-dep-eggs.py)
69 show-eggspath:
70         @echo $(EGGSPATH)
71
72 PP=PYTHONPATH="$(SRCPATH)$(PATHSEP)$(EGGSPATH)$(PATHSEP)$(PYTHONPATH)"
73
74 .PHONY: make-version build
75 make-version:
76         $(PYTHON) misc/make-version.py "allmydata-tahoe" "src/allmydata/_version.py"
77
78 .built:
79         $(MAKE) build
80         touch .built
81
82 build: make-version
83         $(PYTHON) ./setup.py build_ext -i
84         chmod +x bin/allmydata-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: make-version
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-deps test test-figleaf figleaf-output
106
107
108 check-deps:
109         $(PP) \
110          $(PYTHON) -c 'import allmydata, zfec, foolscap, simplejson, nevow, OpenSSL' || \
111         echo "Not all of Tahoe's dependencies are in place.  Please see the README for help on installing dependencies." && \
112         exit 1
113
114 .checked-deps:
115         $(MAKE) check-deps
116         touch .checked-deps
117
118 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
119 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
120 # too.
121 TEST=allmydata
122
123 # use 'make test REPORTER=--reporter=bwverbose' from buildbot, to
124 # suppress the ansi color sequences
125
126 test: .built .checked-deps
127         $(PP) \
128          $(TRIAL) $(REPORTER) $(TEST)
129
130 test-figleaf: .built .checked-deps
131         rm -f .figleaf
132         $(PP) \
133          $(TRIAL) --reporter=bwverbose-figleaf $(TEST)
134
135 figleaf-output:
136         $(PP) \
137          $(PYTHON) misc/figleaf2html -d coverage-html -r src -x misc/figleaf.excludes
138         @echo "now point your browser at coverage-html/index.html"
139
140 # after doing test-figleaf and figleaf-output, point your browser at
141 # coverage-html/index.html
142
143 .PHONY: upload-figleaf .figleaf.el pyflakes count-lines
144 .PHONY: check-memory check-memory-once clean
145
146 # 'upload-figleaf' is meant to be run with an UPLOAD_TARGET=host:/dir setting
147 ifdef UPLOAD_TARGET
148
149 ifndef UPLOAD_HOST
150 $(error UPLOAD_HOST must be set when using UPLOAD_TARGET)
151 endif
152 ifndef COVERAGEDIR
153 $(error COVERAGEDIR must be set when using UPLOAD_TARGET)
154 endif
155
156 upload-figleaf:
157         rsync -a coverage-html/ $(UPLOAD_TARGET)
158         ssh $(UPLOAD_HOST) make update-tahoe-figleaf COVERAGEDIR=$(COVERAGEDIR)
159 else
160 upload-figleaf:
161         echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
162         /bin/false
163 endif
164
165 .figleaf.el: .figleaf
166         $(PP) \
167          $(PYTHON) misc/figleaf2el.py .figleaf src
168
169 pyflakes:
170         $(PYTHON) -OOu `which pyflakes` src/allmydata
171
172 count-lines:
173         @echo -n "files: "
174         @find src -name '*.py' |grep -v /build/ |wc --lines
175         @echo -n "lines: "
176         @cat `find src -name '*.py' |grep -v /build/` |wc --lines
177         @echo -n "TODO: "
178         @grep TODO `find src -name '*.py' |grep -v /build/` | wc --lines
179
180 check-memory: .built
181         rm -rf _test_memory
182         $(PP) \
183          $(PYTHON) src/allmydata/test/check_memory.py upload
184         $(PP) \
185          $(PYTHON) src/allmydata/test/check_memory.py upload-self
186         $(PP) \
187          $(PYTHON) src/allmydata/test/check_memory.py upload-POST
188         $(PP) \
189          $(PYTHON) src/allmydata/test/check_memory.py download
190         $(PP) \
191          $(PYTHON) src/allmydata/test/check_memory.py download-GET
192         $(PP) \
193          $(PYTHON) src/allmydata/test/check_memory.py download-GET-slow
194         $(PP) \
195          $(PYTHON) src/allmydata/test/check_memory.py receive
196
197 check-memory-once: .built
198         rm -rf _test_memory
199         $(PP) \
200          $(PYTHON) src/allmydata/test/check_memory.py $(MODE)
201
202
203 test-darcs-boringfile:
204         $(MAKE)
205         $(PYTHON) misc/test-darcs-boringfile.py
206
207 test-clean:
208         find . |grep -v allfiles.tmp |grep -v src/allmydata/_version.py |sort >allfiles.tmp.old
209         $(MAKE)
210         $(MAKE) clean
211         find . |grep -v allfiles.tmp |grep -v src/allmydata/_version.py |sort >allfiles.tmp.new
212         diff allfiles.tmp.old allfiles.tmp.new
213
214 clean:
215         rm -rf build _trial_temp _test_memory .checked-deps .built
216         rm -f debian
217         rm -f `find src/allmydata -name '*.so' -or -name '*.pyc'`
218         rm -rf tahoe_deps.egg-info allmydata_tahoe.egg-info
219         rm -rf support dist
220         rm -rf setuptools*.egg *.pyc
221
222
223
224 # DEBIAN PACKAGING
225
226 VER=$(shell $(PYTHON) misc/get-version.py)
227 DEBCOMMENTS="'make deb' build"
228
229 show-version:
230         @echo $(VER)
231
232 .PHONY: setup-deb deb-ARCH is-known-debian-arch
233 .PHONY: deb-sid deb-feisty deb-edgy deb-etch
234
235 deb-sid:
236         $(MAKE) deb-ARCH ARCH=sid
237 deb-feisty:
238         $(MAKE) deb-ARCH ARCH=feisty
239 # edgy uses the feisty control files for now
240 deb-edgy:
241         $(MAKE) deb-ARCH ARCH=edgy TAHOE_ARCH=feisty
242 # etch uses the feisty control files for now
243 deb-etch:
244         $(MAKE) deb-ARCH ARCH=etch TAHOE_ARCH=feisty
245
246 # we know how to handle the following debian architectures
247 KNOWN_DEBIAN_ARCHES := sid feisty edgy etch
248
249 ifeq ($(findstring x-$(ARCH)-x,$(foreach arch,$(KNOWN_DEBIAN_ARCHES),"x-$(arch)-x")),)
250 is-known-debian-arch:
251         @echo "ARCH must be set when using setup-deb or deb-ARCH"
252         @echo "I know how to handle:" $(KNOWN_DEBIAN_ARCHES)
253         /bin/false
254 else
255 is-known-debian-arch:
256         /bin/true
257 endif
258
259 ifndef TAHOE_ARCH
260 TAHOE_ARCH=$(ARCH)
261 endif
262
263 setup-deb: is-known-debian-arch
264         rm -f debian
265         ln -s misc/$(TAHOE_ARCH)/debian debian
266         chmod +x debian/rules
267
268 # etch (current debian stable) has python-simplejson-1.3, which doesn't 
269 #  support indent=
270 # sid (debian unstable) currently has python-simplejson 1.7.1
271 # edgy has 1.3, which doesn't support indent=
272 # feisty has 1.4, which supports indent= but emits a deprecation warning
273 # gutsy has 1.7.1
274 #
275 # we need 1.4 or newer
276
277 deb-ARCH: is-known-debian-arch setup-deb
278         fakeroot debian/rules binary
279         echo
280         echo "The newly built .deb packages are in the parent directory from here."
281
282 .PHONY: increment-deb-version
283 .PHONY: deb-sid-head deb-edgy-head deb-feisty-head
284 .PHONY: deb-etch-head
285
286 # The buildbot runs the following targets after each change, to produce
287 # up-to-date tahoe .debs. These steps do not create .debs for anything else.
288
289 increment-deb-version: make-version
290         debchange --newversion $(VER) $(DEBCOMMENTS)
291 deb-sid-head:
292         $(MAKE) setup-deb ARCH=sid
293         $(MAKE) increment-deb-version
294         fakeroot debian/rules binary
295 deb-edgy-head:
296         $(MAKE) setup-deb ARCH=edgy TAHOE_ARCH=feisty
297         $(MAKE) increment-deb-version
298         fakeroot debian/rules binary
299 deb-feisty-head:
300         $(MAKE) setup-deb ARCH=feisty
301         $(MAKE) increment-deb-version
302         fakeroot debian/rules binary
303 deb-etch-head:
304         $(MAKE) setup-deb ARCH=etch TAHOE_ARCH=feisty
305         $(MAKE) increment-deb-version
306         fakeroot debian/rules binary