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