]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
setup: it is okay to leave src/allmydata_tahoe.egg-info in place
[tahoe-lafs/tahoe-lafs.git] / Makefile
1
2 # this Makefile requires GNU make
3
4 default: build
5
6 PYTHON=python
7 PATHSEP=$(shell python -c 'import os ; print os.pathsep')
8 OSSEP=$(shell python -c 'import os ; print os.sep')
9
10 REACTOR=
11
12 ifneq ($(INCLUDE_DIRS),)
13 INCLUDE_DIRS_ARG = -I$(INCLUDE_DIRS)
14 endif
15 ifneq ($(LIBRARY_DIRS),)
16 LIBRARY_DIRS_ARG = -L$(LIBRARY_DIRS)
17 endif
18
19 PLAT = $(strip $(shell python -c "import sys ; print sys.platform"))
20 ifeq ($(PLAT),win32)
21  # The platform is Windows with cygwin build tools and the native Python interpreter.
22  SUPPORT = $(shell cygpath -w $(shell pwd))\support
23  SUPPORTLIB := $(SUPPORT)\Lib\site-packages
24  SRCPATH := $(shell cygpath -w $(shell pwd)/src)
25  CHECK_PYWIN32_DEP := check-pywin32-dep
26  INNOSETUP := $(shell cygpath -au "$(PROGRAMFILES)/Inno Setup 5/Compil32.exe")
27 else
28  PYVER=$(shell $(PYTHON) misc/pyver.py)
29  SUPPORT = $(shell pwd)/support
30  SUPPORTLIB = $(SUPPORT)/lib/$(PYVER)/site-packages
31  SRCPATH := $(shell pwd)/src
32  CHECK_PYWIN32_DEP := 
33 endif
34
35 TRIALCMD = $(shell PYTHONPATH="$(PYTHONPATH)$(PATHSEP)$(SRCPATH)" $(PYTHON) misc/find_trial.py)
36
37 ifeq ($(PLAT),cygwin)
38 REACTOR = poll
39 endif
40
41 ifneq ($(REACTOR),)
42         REACTOROPT := --reactor=$(REACTOR)
43 else
44         REACTOROPT := 
45 endif
46
47 TRIAL=PYTHONUNBUFFERED=1 $(TRIALCMD) --rterrors $(REACTOROPT)
48
49 # The following target is here because I don't know how to tell the buildmaster
50 # to start instructing his slaves to "build" instead of instructing them to
51 # "build-deps".  --Z
52 build-deps:
53         echo "This is done automatically (by delegating to setuptools) now."
54
55 EGGSPATH = $(shell $(PYTHON) misc/find-dep-eggs.py)
56 show-eggspath:
57         @echo $(EGGSPATH)
58
59 ifneq ($(PYTHONPATH),)
60         PYTHONPATH := $(PYTHONPATH)$(PATHSEP)
61 endif
62 PP=PYTHONPATH="$(SRCPATH)$(PATHSEP)$(PYTHONPATH)$(PATHSEP)$(EGGSPATH)"
63
64 .PHONY: make-version build
65
66 # The 'darcsver' setup.py command comes in the 'darcsver' package:
67 # http://pypi.python.org/pypi/darcsver It is necessary only if you want to
68 # automatically produce a new _version.py file from the current darcs history.
69 make-version:
70         $(PYTHON) ./setup.py darcsver
71
72 # We want src/allmydata/_version.py to be up-to-date, but it's a fairly
73 # expensive operation (about 6 seconds on a just-before-0.7.0 tree, probably
74 # because of the 332 patches since the last tag), and we've removed the need
75 # for an explicit 'build' step by removing the C code from src/allmydata and
76 # by running everything in place. It would be neat to do:
77 #
78 #src/allmydata/_version.py: _darcs/patches
79 #       $(MAKE) make-version
80 #
81 # since that would update the embedded version string each time new darcs
82 # patches were pulled, but 1) this would break non-darcs trees (i.e. building
83 # from an exported tarball), and 2) without an obligatory 'build' step this
84 # rule wouldn't be run frequently enought anyways.
85 #
86 # So instead, I'll just make sure that we update the version at least once
87 # when we first start using the tree, and again whenever an explicit
88 # 'make-version' is run, since then at least the developer has some means to
89 # update things. It would be nice if 'make clean' deleted any
90 # automatically-generated _version.py too, so that 'make clean; make all'
91 # could be useable as a "what the heck is going on, get me back to a clean
92 # state', but we need 'make clean' to work on non-darcs trees without
93 # destroying useful information.
94
95 .built:
96         $(MAKE) build
97         touch .built
98
99 src/allmydata/_version.py:
100         $(MAKE) make-version
101
102 build: src/allmydata/_version.py
103         mkdir -p "$(SUPPORTLIB)"
104         PYTHONPATH="$(PYTHONPATH)$(PATHSEP)$(SUPPORTLIB)$(PATHSEP)" \
105                 $(PYTHON) ./setup.py develop install --prefix="$(SUPPORT)"
106
107 # 'make install' will do the following:
108 #   build+install tahoe (probably to /usr/lib/pythonN.N/site-packages)
109 # 'make install PREFIX=/usr/local/stow/tahoe-N.N' will do the same, but to
110 # a different location
111
112 install: src/allmydata/_version.py
113 ifdef PREFIX
114         mkdir -p $(PREFIX)
115         $(PP) $(PYTHON) ./setup.py install \
116            --single-version-externally-managed \
117            --prefix=$(PREFIX) --record=./tahoe.files
118 else
119         $(PP) $(PYTHON) ./setup.py install \
120            --single-version-externally-managed
121 endif
122
123
124 # TESTING
125
126 .PHONY: check-all-deps check-twisted-dep $(CHECK_PYWIN32_DEP) signal-error-deps, signal-error-twisted-dep, signal-error-pywin32-dep, test test-figleaf figleaf-output
127
128
129 signal-error-deps:
130         @echo
131         @echo
132         @echo "ERROR: Not all of Tahoe's dependencies are in place.  Please \
133 see the README for help on installing dependencies."
134         @echo
135         @echo
136         exit 1
137
138 signal-error-twisted-dep:
139         @echo
140         @echo
141         @echo "ERROR: Before running \"make build-auto-deps\" you have to ensure that \
142 Twisted is installed (including its zope.interface dependency).  Twisted and \
143 zope.interface are required for the automatic installation of certain other \
144 libraries that Tahoe requires).  Please see the README for details."
145         @echo
146         @echo
147         exit 1
148
149 signal-error-pywin32-dep:
150         @echo
151         @echo
152         @echo "ERROR: the pywin32 dependency is not in place.  Please see the README \
153 for help on installing dependencies."
154         @echo
155         @echo
156         exit 1
157
158 signal-error-pyopenssl-dep:
159         @echo
160         @echo
161         @echo "ERROR: the pyOpenSSL dependency is not in place (note that pyOpenSSL required \
162 OpenSSL).  Please see the README for help on installing dependencies."
163         @echo
164         @echo
165         exit 1
166
167 check-all-deps: check-deps
168         $(PP) \
169          $(PYTHON) -c 'import allmydata, zfec, foolscap, simplejson, nevow, pycryptopp' || $(MAKE) signal-error-deps
170
171 check-twisted-dep:
172         $(PYTHON) -c 'import twisted, zope.interface' || $(MAKE) signal-error-twisted-dep
173
174 check-pywin32-dep:
175         $(PYTHON) -c 'import win32process' || $(MAKE) signal-error-pywin32-dep
176
177 check-pyopenssl-dep:
178         $(PYTHON) -c 'import OpenSSL' || $(MAKE) signal-error-pyopenssl-dep
179
180 check-deps: check-twisted-dep $(CHECK_PYWIN32_DEP) check-pyopenssl-dep
181
182 .checked-deps:
183         $(MAKE) check-all-deps
184         touch .checked-deps
185
186 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
187 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
188 # too.
189 TEST=allmydata
190
191 # use 'make test TRIALARGS=--reporter=bwverbose' from buildbot, to
192 # suppress the ansi color sequences
193
194 test: .built .checked-deps
195         $(PP) \
196          $(TRIAL) $(TRIALARGS) $(TEST)
197
198 test-figleaf: .built .checked-deps
199         rm -f .figleaf
200         $(PP) \
201          $(TRIAL) --reporter=bwverbose-figleaf $(TEST)
202
203 figleaf-output:
204         $(PP) \
205          $(PYTHON) misc/figleaf2html -d coverage-html -r src -x misc/figleaf.excludes
206         @echo "now point your browser at coverage-html/index.html"
207
208 # after doing test-figleaf and figleaf-output, point your browser at
209 # coverage-html/index.html
210
211 .PHONY: upload-figleaf .figleaf.el pyflakes count-lines
212 .PHONY: check-memory check-memory-once clean
213
214 # 'upload-figleaf' is meant to be run with an UPLOAD_TARGET=host:/dir setting
215 ifdef UPLOAD_TARGET
216
217 ifndef UPLOAD_HOST
218 $(error UPLOAD_HOST must be set when using UPLOAD_TARGET)
219 endif
220 ifndef COVERAGEDIR
221 $(error COVERAGEDIR must be set when using UPLOAD_TARGET)
222 endif
223
224 upload-figleaf:
225         rsync -a coverage-html/ $(UPLOAD_TARGET)
226         ssh $(UPLOAD_HOST) make update-tahoe-figleaf COVERAGEDIR=$(COVERAGEDIR)
227 else
228 upload-figleaf:
229         echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
230         false
231 endif
232
233 .figleaf.el: .figleaf
234         $(PP) \
235          $(PYTHON) misc/figleaf2el.py .figleaf src
236
237 pyflakes:
238         $(PYTHON) -OOu `which pyflakes` src/allmydata |sort |uniq
239
240 count-lines:
241         @echo -n "files: "
242         @find src -name '*.py' |grep -v /build/ |wc --lines
243         @echo -n "lines: "
244         @cat `find src -name '*.py' |grep -v /build/` |wc --lines
245         @echo -n "TODO: "
246         @grep TODO `find src -name '*.py' |grep -v /build/` | wc --lines
247
248 check-memory: .built
249         rm -rf _test_memory
250         $(PP) \
251          $(PYTHON) src/allmydata/test/check_memory.py upload
252         $(PP) \
253          $(PYTHON) src/allmydata/test/check_memory.py upload-self
254         $(PP) \
255          $(PYTHON) src/allmydata/test/check_memory.py upload-POST
256         $(PP) \
257          $(PYTHON) src/allmydata/test/check_memory.py download
258         $(PP) \
259          $(PYTHON) src/allmydata/test/check_memory.py download-GET
260         $(PP) \
261          $(PYTHON) src/allmydata/test/check_memory.py download-GET-slow
262         $(PP) \
263          $(PYTHON) src/allmydata/test/check_memory.py receive
264
265 check-memory-once: .built
266         rm -rf _test_memory
267         $(PP) \
268          $(PYTHON) src/allmydata/test/check_memory.py $(MODE)
269
270 # this target uses a pre-established client node to run a canned set of
271 # performance tests against a test network that is also pre-established
272 # (probably on a remote machine). Provide it with the path to a local
273 # directory where this client node has been created (and populated with the
274 # necessary FURLs of the test network). This target will start that client
275 # with the current code and then run the tests. Afterwards it will stop the
276 # client.
277 #
278 # The 'sleep 5' is in there to give the new client a chance to connect to its
279 # storageservers, since check_speed.py has no good way of doing that itself.
280
281 check-speed: .built
282         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
283         @echo "stopping any leftover client code"
284         -$(PYTHON) bin/tahoe stop $(TESTCLIENTDIR)
285         $(PYTHON) bin/tahoe start $(TESTCLIENTDIR)
286         sleep 5
287         $(PYTHON) src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
288         $(PYTHON) bin/tahoe stop $(TESTCLIENTDIR)
289
290 # 'make repl' is a simple-to-type command to get a Python interpreter loop
291 # from which you can type 'import allmydata'
292 repl:
293         $(PP) python
294
295 test-darcs-boringfile:
296         $(MAKE)
297         $(PYTHON) misc/test-darcs-boringfile.py
298
299 test-clean:
300         find . |grep -vEe"allfiles.tmp|src/allmydata/_version.py|src/allmydata_tahoe.egg-info" |sort >allfiles.tmp.old
301         $(MAKE)
302         $(MAKE) clean
303         find . |grep -vEe"allfiles.tmp|src/allmydata/_version.py|src/allmydata_tahoe.egg-info" |sort >allfiles.tmp.new
304         diff allfiles.tmp.old allfiles.tmp.new
305
306 clean:
307         rm -rf build _trial_temp _test_memory .checked-deps .built
308         rm -f debian
309         rm -f `find src/allmydata -name '*.so' -or -name '*.pyc'`
310         rm -rf tahoe_deps.egg-info allmydata_tahoe.egg-info
311         rm -rf support dist
312         rm -rf setuptools*.egg *.pyc darcsver*.egg
313         rm -rf misc/dependencies/build misc/dependencies/temp
314         rm -rf misc/dependencies/tahoe_deps.egg-info
315
316 find-trailing-spaces:
317         $(PYTHON) misc/find-trailing-spaces.py -r src
318
319
320 # DEBIAN PACKAGING
321
322 VER=$(shell $(PYTHON) misc/get-version.py)
323 DEBCOMMENTS="'make deb' build"
324
325 show-version:
326         @echo $(VER)
327
328 .PHONY: setup-deb deb-ARCH is-known-debian-arch
329 .PHONY: deb-sid deb-feisty deb-edgy deb-etch
330
331 deb-sid:
332         $(MAKE) deb-ARCH ARCH=sid
333 deb-feisty:
334         $(MAKE) deb-ARCH ARCH=feisty
335 # edgy uses the feisty control files for now
336 deb-edgy:
337         $(MAKE) deb-ARCH ARCH=edgy TAHOE_ARCH=feisty
338 # etch uses the feisty control files for now
339 deb-etch:
340         $(MAKE) deb-ARCH ARCH=etch TAHOE_ARCH=feisty
341 # same with gutsy, the process has been nicely stable for a while now
342 deb-gutsy:
343         $(MAKE) deb-ARCH ARCH=gutsy TAHOE_ARCH=feisty
344
345 # we know how to handle the following debian architectures
346 KNOWN_DEBIAN_ARCHES := sid feisty edgy etch gutsy
347
348 ifeq ($(findstring x-$(ARCH)-x,$(foreach arch,$(KNOWN_DEBIAN_ARCHES),"x-$(arch)-x")),)
349 is-known-debian-arch:
350         @echo "ARCH must be set when using setup-deb or deb-ARCH"
351         @echo "I know how to handle:" $(KNOWN_DEBIAN_ARCHES)
352         false
353 else
354 is-known-debian-arch:
355         true
356 endif
357
358 ifndef TAHOE_ARCH
359 TAHOE_ARCH=$(ARCH)
360 endif
361
362 setup-deb: is-known-debian-arch
363         rm -f debian
364         ln -s misc/$(TAHOE_ARCH)/debian debian
365         chmod +x debian/rules
366
367 # etch (current debian stable) has python-simplejson-1.3, which doesn't 
368 #  support indent=
369 # sid (debian unstable) currently has python-simplejson 1.7.1
370 # edgy has 1.3, which doesn't support indent=
371 # feisty has 1.4, which supports indent= but emits a deprecation warning
372 # gutsy has 1.7.1
373 #
374 # we need 1.4 or newer
375
376 deb-ARCH: is-known-debian-arch setup-deb
377         fakeroot debian/rules binary
378         @echo
379         @echo "The newly built .deb packages are in the parent directory from here."
380
381 .PHONY: increment-deb-version
382 .PHONY: deb-sid-head deb-edgy-head deb-feisty-head
383 .PHONY: deb-etch-head
384
385 # The buildbot runs the following targets after each change, to produce
386 # up-to-date tahoe .debs. These steps do not create .debs for anything else.
387
388 increment-deb-version: make-version
389         debchange --newversion $(VER) $(DEBCOMMENTS)
390 deb-sid-head:
391         $(MAKE) setup-deb ARCH=sid
392         $(MAKE) increment-deb-version
393         fakeroot debian/rules binary
394 deb-edgy-head:
395         $(MAKE) setup-deb ARCH=edgy TAHOE_ARCH=feisty
396         $(MAKE) increment-deb-version
397         fakeroot debian/rules binary
398 deb-feisty-head:
399         $(MAKE) setup-deb ARCH=feisty
400         $(MAKE) increment-deb-version
401         fakeroot debian/rules binary
402 deb-etch-head:
403         $(MAKE) setup-deb ARCH=etch TAHOE_ARCH=feisty
404         $(MAKE) increment-deb-version
405         fakeroot debian/rules binary
406 deb-gutsy-head:
407         $(MAKE) setup-deb ARCH=gutsy TAHOE_ARCH=feisty
408         $(MAKE) increment-deb-version
409         fakeroot debian/rules binary
410
411 # These targets provide for windows native builds
412 .PHONY: hatch-eggs windows-exe windows-installer windows-installer-upload
413
414 hatch-eggs:
415         $(PP) $(PYTHON) misc/hatch-eggs.py
416
417 windows-exe: hatch-eggs
418         cd windows && $(PP) $(PYTHON) setup.py py2exe
419
420 windows-installer: windows-exe
421         $(PP) $(PYTHON) misc/sub-ver.py windows/installer.tmpl >windows/installer.iss
422         cd windows && "$(INNOSETUP)" /cc installer.iss
423
424 windows-installer-upload:
425         chmod -R o+rx windows/dist/installer
426         rsync -av -e /usr/bin/ssh windows/dist/installer/ amduser@dev:/home/amduser/public_html/dist/tahoe/windows/
427
428