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