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