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