]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
reverting a change zooko made (2258) to see if it clears up problems in the windows...
[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 ifeq ($(PLAT),cygwin)
36 REACTOR = poll
37 endif
38
39 ifneq ($(REACTOR),)
40         REACTOROPT := --reactor=$(REACTOR)
41 else
42         REACTOROPT := 
43 endif
44
45 # The following target is here because I don't know how to tell the buildmaster
46 # to start instructing his slaves to "build" instead of instructing them to
47 # "build-deps".  --Z
48 build-deps:
49         echo "This is done automatically (by delegating to setuptools) now."
50
51 EGGSPATH = $(shell $(PYTHON) misc/find-dep-eggs.py)
52
53 ifneq ($(PYTHONPATH),)
54         PYTHONPATH := $(PYTHONPATH)$(PATHSEP)
55 endif
56 PP=PYTHONPATH="$(SRCPATH)$(PATHSEP)$(PYTHONPATH)$(PATHSEP)$(EGGSPATH)"
57
58 TRIALCMD = $(shell $(PP) $(PYTHON) misc/find_trial.py)
59 TRIAL=PYTHONUNBUFFERED=1 $(TRIALCMD) --rterrors $(REACTOROPT)
60
61 .PHONY: make-version build
62
63 show-eggspath:
64         @echo $(EGGSPATH)
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
98 src/allmydata/_version.py:
99         $(MAKE) make-version
100
101 build: src/allmydata/_version.py
102         mkdir -p "$(SUPPORTLIB)"
103         PYTHONPATH="$(PYTHONPATH)$(PATHSEP)$(SUPPORTLIB)$(PATHSEP)" \
104                 $(PYTHON) ./setup.py develop install --prefix="$(SUPPORT)"
105         chmod +x bin/tahoe
106         touch .built
107
108 # 'make install' will do the following:
109 #   build+install tahoe (probably to /usr/lib/pythonN.N/site-packages)
110 # 'make install PREFIX=/usr/local/stow/tahoe-N.N' will do the same, but to
111 # a different location
112
113 install: src/allmydata/_version.py
114 ifdef PREFIX
115         mkdir -p $(PREFIX)
116         $(PP) $(PYTHON) ./setup.py install \
117            --single-version-externally-managed \
118            --prefix=$(PREFIX) --record=./tahoe.files
119 else
120         $(PP) $(PYTHON) ./setup.py install \
121            --single-version-externally-managed
122 endif
123
124
125 # TESTING
126
127 .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
128
129
130 signal-error-deps:
131         @echo
132         @echo
133         @echo "ERROR: Not all of Tahoe's dependencies are in place.  Please see\
134 docs/install.html for help on installing dependencies."
135         @echo
136         @echo
137         exit 1
138
139 signal-error-twisted-dep:
140         @echo
141         @echo
142         @echo "ERROR: Twisted is not installed.  Please see docs/install.html for details."
143         @echo
144         @echo
145         exit 1
146
147 signal-error-pywin32-dep:
148         @echo
149         @echo
150         @echo "ERROR: the pywin32 dependency is not in place.  Please see docs/install.html for\
151 help on installing dependencies."
152         @echo
153         @echo
154         exit 1
155
156 signal-error-pyopenssl-dep:
157         @echo
158         @echo
159         @echo "ERROR: the pyOpenSSL dependency is not in place (note that pyOpenSSL required OpenSSL).  Please see docs/install.html for help on installing dependencies."
160         @echo
161         @echo
162         exit 1
163
164 check-auto-deps:
165         $(PP) \
166          $(PYTHON) -c 'import _auto_deps ; _auto_deps.require_auto_deps()' || $(MAKE) signal-error-deps
167
168 check-all-deps: check-deps check-auto-deps
169
170 check-twisted-dep:
171         $(PYTHON) -c 'import twisted, zope.interface' || $(MAKE) signal-error-twisted-dep
172
173 check-pywin32-dep:
174         $(PYTHON) -c 'import win32process' || $(MAKE) signal-error-pywin32-dep
175
176 check-pyopenssl-dep:
177         $(PYTHON) -c 'import OpenSSL' || $(MAKE) signal-error-pyopenssl-dep
178
179 check-deps: check-twisted-dep $(CHECK_PYWIN32_DEP) check-pyopenssl-dep
180
181 .checked-deps:
182         $(MAKE) check-all-deps
183         touch .checked-deps
184
185 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
186 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
187 # too.
188 TEST=allmydata
189
190 # use 'make test TRIALARGS=--reporter=bwverbose' from buildbot, to
191 # suppress the ansi color sequences
192
193 test: .built .checked-deps src/allmydata/_version.py
194         $(PP) \
195          $(TRIAL) $(TRIALARGS) $(TEST)
196
197 test-figleaf: .built .checked-deps
198         rm -f .figleaf
199         $(PP) \
200          $(TRIAL) --reporter=bwverbose-figleaf $(TEST)
201
202 figleaf-output:
203         $(PP) \
204          $(PYTHON) misc/figleaf2html -d coverage-html -r src -x misc/figleaf.excludes
205         @echo "now point your browser at coverage-html/index.html"
206
207 # after doing test-figleaf and figleaf-output, point your browser at
208 # coverage-html/index.html
209
210 .PHONY: upload-figleaf .figleaf.el pyflakes count-lines
211 .PHONY: check-memory check-memory-once clean
212
213 # 'upload-figleaf' is meant to be run with an UPLOAD_TARGET=host:/dir setting
214 ifdef UPLOAD_TARGET
215
216 ifndef UPLOAD_HOST
217 $(error UPLOAD_HOST must be set when using UPLOAD_TARGET)
218 endif
219 ifndef COVERAGEDIR
220 $(error COVERAGEDIR must be set when using UPLOAD_TARGET)
221 endif
222
223 upload-figleaf:
224         rsync -a coverage-html/ $(UPLOAD_TARGET)
225         ssh $(UPLOAD_HOST) make update-tahoe-figleaf COVERAGEDIR=$(COVERAGEDIR)
226 else
227 upload-figleaf:
228         echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
229         false
230 endif
231
232 .figleaf.el: .figleaf
233         $(PP) \
234          $(PYTHON) misc/figleaf2el.py .figleaf src
235
236 pyflakes:
237         $(PYTHON) -OOu `which pyflakes` src/allmydata |sort |uniq
238
239 count-lines:
240         @echo -n "files: "
241         @find src -name '*.py' |grep -v /build/ |wc --lines
242         @echo -n "lines: "
243         @cat `find src -name '*.py' |grep -v /build/` |wc --lines
244         @echo -n "TODO: "
245         @grep TODO `find src -name '*.py' |grep -v /build/` | wc --lines
246
247 check-memory: .built
248         rm -rf _test_memory
249         $(PP) \
250          $(PYTHON) src/allmydata/test/check_memory.py upload
251         $(PP) \
252          $(PYTHON) src/allmydata/test/check_memory.py upload-self
253         $(PP) \
254          $(PYTHON) src/allmydata/test/check_memory.py upload-POST
255         $(PP) \
256          $(PYTHON) src/allmydata/test/check_memory.py download
257         $(PP) \
258          $(PYTHON) src/allmydata/test/check_memory.py download-GET
259         $(PP) \
260          $(PYTHON) src/allmydata/test/check_memory.py download-GET-slow
261         $(PP) \
262          $(PYTHON) src/allmydata/test/check_memory.py receive
263
264 check-memory-once: .built
265         rm -rf _test_memory
266         $(PP) \
267          $(PYTHON) src/allmydata/test/check_memory.py $(MODE)
268
269 # this target uses a pre-established client node to run a canned set of
270 # performance tests against a test network that is also pre-established
271 # (probably on a remote machine). Provide it with the path to a local
272 # directory where this client node has been created (and populated with the
273 # necessary FURLs of the test network). This target will start that client
274 # with the current code and then run the tests. Afterwards it will stop the
275 # client.
276 #
277 # The 'sleep 5' is in there to give the new client a chance to connect to its
278 # storageservers, since check_speed.py has no good way of doing that itself.
279
280 check-speed: .built
281         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
282         @echo "stopping any leftover client code"
283         -$(PYTHON) bin/tahoe stop $(TESTCLIENTDIR)
284         $(PYTHON) bin/tahoe start $(TESTCLIENTDIR)
285         sleep 5
286         $(PYTHON) src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
287         $(PYTHON) bin/tahoe stop $(TESTCLIENTDIR)
288
289 # 'make repl' is a simple-to-type command to get a Python interpreter loop
290 # from which you can type 'import allmydata'
291 repl:
292         $(PP) python
293
294 test-darcs-boringfile:
295         $(MAKE)
296         $(PYTHON) misc/test-darcs-boringfile.py
297
298 test-clean:
299         find . |grep -vEe"allfiles.tmp|src/allmydata/_(version|auto_deps).py|src/allmydata_tahoe.egg-info" |sort >allfiles.tmp.old
300         $(MAKE)
301         $(MAKE) clean
302         find . |grep -vEe"allfiles.tmp|src/allmydata/_(version|auto_deps).py|src/allmydata_tahoe.egg-info" |sort >allfiles.tmp.new
303         diff allfiles.tmp.old allfiles.tmp.new
304
305 clean:
306         rm -rf build _trial_temp _test_memory .checked-deps .built
307         rm -f debian
308         rm -f `find src/allmydata -name '*.so' -or -name '*.pyc'`
309         rm -rf tahoe_deps.egg-info allmydata_tahoe.egg-info
310         rm -rf support dist
311         rm -rf setuptools*.egg *.pyc darcsver*.egg
312         rm -rf misc/dependencies/build misc/dependencies/temp
313         rm -rf misc/dependencies/tahoe_deps.egg-info
314
315 find-trailing-spaces:
316         $(PYTHON) misc/find-trailing-spaces.py -r src
317
318 # TARBALL GENERATION
319 .PHONY: tarballs upload-tarballs
320 tarballs:
321         $(MAKE) make-version
322         $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
323 upload-tarballs:
324         for f in dist/allmydata-tahoe-*; do \
325          xfer-client --furlfile ~/.tahoe-tarball-upload.furl $$f; \
326         done
327
328 # DEBIAN PACKAGING
329
330 VER=$(shell $(PYTHON) misc/get-version.py)
331 DEBCOMMENTS="'make deb' build"
332
333 show-version:
334         @echo $(VER)
335
336 .PHONY: setup-deb deb-ARCH is-known-debian-arch
337 .PHONY: deb-sid deb-feisty deb-edgy deb-etch
338
339 deb-sid:
340         $(MAKE) deb-ARCH ARCH=sid
341 deb-feisty:
342         $(MAKE) deb-ARCH ARCH=feisty
343 # edgy uses the feisty control files for now
344 deb-edgy:
345         $(MAKE) deb-ARCH ARCH=edgy TAHOE_ARCH=feisty
346 # etch uses the feisty control files for now
347 deb-etch:
348         $(MAKE) deb-ARCH ARCH=etch TAHOE_ARCH=feisty
349 # same with gutsy, the process has been nicely stable for a while now
350 deb-gutsy:
351         $(MAKE) deb-ARCH ARCH=gutsy TAHOE_ARCH=feisty
352
353 # we know how to handle the following debian architectures
354 KNOWN_DEBIAN_ARCHES := sid feisty edgy etch gutsy
355
356 ifeq ($(findstring x-$(ARCH)-x,$(foreach arch,$(KNOWN_DEBIAN_ARCHES),"x-$(arch)-x")),)
357 is-known-debian-arch:
358         @echo "ARCH must be set when using setup-deb or deb-ARCH"
359         @echo "I know how to handle:" $(KNOWN_DEBIAN_ARCHES)
360         false
361 else
362 is-known-debian-arch:
363         true
364 endif
365
366 ifndef TAHOE_ARCH
367 TAHOE_ARCH=$(ARCH)
368 endif
369
370 setup-deb: is-known-debian-arch
371         rm -f debian
372         ln -s misc/$(TAHOE_ARCH)/debian debian
373         chmod +x debian/rules
374
375 # etch (current debian stable) has python-simplejson-1.3, which doesn't 
376 #  support indent=
377 # sid (debian unstable) currently has python-simplejson 1.7.1
378 # edgy has 1.3, which doesn't support indent=
379 # feisty has 1.4, which supports indent= but emits a deprecation warning
380 # gutsy has 1.7.1
381 #
382 # we need 1.4 or newer
383
384 deb-ARCH: is-known-debian-arch setup-deb
385         fakeroot debian/rules binary
386         @echo
387         @echo "The newly built .deb packages are in the parent directory from here."
388
389 .PHONY: increment-deb-version
390 .PHONY: deb-sid-head deb-edgy-head deb-feisty-head
391 .PHONY: deb-etch-head
392
393 # The buildbot runs the following targets after each change, to produce
394 # up-to-date tahoe .debs. These steps do not create .debs for anything else.
395
396 increment-deb-version: make-version
397         debchange --newversion $(VER) $(DEBCOMMENTS)
398 deb-sid-head:
399         $(MAKE) setup-deb ARCH=sid
400         $(MAKE) increment-deb-version
401         fakeroot debian/rules binary
402 deb-edgy-head:
403         $(MAKE) setup-deb ARCH=edgy TAHOE_ARCH=feisty
404         $(MAKE) increment-deb-version
405         fakeroot debian/rules binary
406 deb-feisty-head:
407         $(MAKE) setup-deb ARCH=feisty
408         $(MAKE) increment-deb-version
409         fakeroot debian/rules binary
410 deb-etch-head:
411         $(MAKE) setup-deb ARCH=etch TAHOE_ARCH=feisty
412         $(MAKE) increment-deb-version
413         fakeroot debian/rules binary
414 deb-gutsy-head:
415         $(MAKE) setup-deb ARCH=gutsy TAHOE_ARCH=feisty
416         $(MAKE) increment-deb-version
417         fakeroot debian/rules binary
418
419 # These targets provide for windows native builds
420 .PHONY: windows-exe windows-installer windows-installer-upload
421
422 windows-exe: .built
423         cd windows && $(PP) $(PYTHON) setup.py py2exe
424
425 windows-installer: windows-exe
426         $(PP) $(PYTHON) misc/sub-ver.py windows/installer.tmpl >windows/installer.iss
427         cd windows && "$(INNOSETUP)" /cc installer.iss
428
429 windows-installer-upload:
430         chmod -R o+rx windows/dist/installer
431         rsync -av -e /usr/bin/ssh windows/dist/installer/ amduser@dev:/home/amduser/public_html/dist/tahoe/windows/
432
433 # These targets provide for mac native builds
434 .PHONY: mac-exe mac-upload mac-cleanup mac-dbg
435
436 mac-exe: .built
437         $(MAKE) -C mac clean
438         VERSION=$(VER) $(PP) $(MAKE) -C mac build
439
440 mac-dist:
441         VERSION=$(VER) $(MAKE) -C mac diskimage
442
443 mac-upload:
444         VERSION=$(VER) $(MAKE) -C mac upload UPLOAD_DEST=$(UPLOAD_DEST)
445
446 mac-cleanup:
447         VERSION=$(VER) $(MAKE) -C mac cleanup
448
449 mac-dbg:
450         cd mac && $(PP) $(PYTHON)w allmydata_tahoe.py
451
452 # This target runs a stats gatherer server
453 .PHONY: stats-gatherer-run
454 stats-gatherer-run:
455         cd stats_gatherer && $(PP) $(PYTHON) ../src/allmydata/stats.py
456