]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
2075341e3c37c0c9b27ca82d7ce787444200db7a
[tahoe-lafs/tahoe-lafs.git] / Makefile
1
2 # this Makefile requires GNU make
3
4 default: build
5
6 BASE=$(shell pwd)
7 PYTHON=python
8 INSTDIR=$(BASE)/instdir
9 PATHSEP=$(shell python -c 'import os ; print os.pathsep')
10 TRIALPATH=$(shell which trial.py 2>/dev/null)
11 ifeq ($(TRIALPATH),)
12 TRIALPATH=$(shell which trial 2>/dev/null)
13 endif
14 ifeq ($(TRIALPATH),)
15 TRIALPATH=$(shell $(PYTHON) -c "import os, sys; print repr(os.path.join(sys.prefix, \"Scripts\", \"trial.py\"))")
16 endif
17 ifeq ($(TRIALPATH),)
18 TRIALPATH=$(shell $(PYTHON) -c "import os, sys; print repr(os.path.join(sys.prefix, \"Scripts\", \"trial\"))")
19 endif
20
21 EXTRA_SETUP_ARGS=
22 REACTOR=poll
23
24 PLAT = $(strip $(shell python -c "import sys ; print sys.platform"))
25 ifeq ($(PLAT),cygwin)
26  # The platform is Windows with cygwin build tools and the cygwin Python interpreter.
27  INSTDIR := $(shell cygpath -u $(INSTDIR))
28 else
29  ifeq ($(PLAT),win32)
30   # The platform is Windows with cygwin build tools and the native Python interpreter.
31   EXTRA_SETUP_ARGS=build -c mingw32
32   REACTOR=select
33   INSTDIR := $(shell cygpath -w $(INSTDIR))
34   TRIALPATH := $(shell cygpath -w $(TRIALPATH))
35   ifneq ($(PYTHONPATH),)
36    PYTHONPATH := $(shell cygpath -w $(PYTHONPATH))
37   endif
38  endif
39 endif
40
41 ORIGPYTHONPATH=$(PYTHONPATH)
42
43 # Append instdir/lib instead of prepending it so that people can override
44 # things from lib with alternate packages of their choosing by setting their
45 # PYTHONPATH.
46
47 ifneq ($(PYTHONPATH),)
48 PYTHONPATH := "$(PYTHONPATH)$(PATHSEP)$(INSTDIR)/lib"
49 else
50 PYTHONPATH := "$(INSTDIR)/lib"
51 endif
52
53 TRIAL=$(PYTHON) -u "$(TRIALPATH)" --rterrors --reactor=$(REACTOR)
54
55 show-instdir:
56         @echo $(INSTDIR)/lib
57
58 PP=PYTHONPATH=$(PYTHONPATH)
59
60 .PHONY: make-version build
61 make-version:
62         $(PYTHON) misc/make-version.py
63
64 build: make-version build-zfec build-Crypto build-foolscap build-simplejson
65         $(PP) $(PYTHON) ./setup.py $(EXTRA_SETUP_ARGS) install --prefix="$(INSTDIR)" --install-lib="$(INSTDIR)/lib" --install-scripts="$(INSTDIR)/bin"
66
67 build-zfec:
68         cd src/zfec &&  \
69         $(PP) $(PYTHON) ./setup.py $(EXTRA_SETUP_ARGS) install --single-version-externally-managed --prefix="$(INSTDIR)" --record="$(INSTDIR)/zfec_install.log" --install-lib="$(INSTDIR)/lib" --install-scripts="$(INSTDIR)/bin"
70
71 build-foolscap:
72         cd src/foolscap && \
73         $(PP) $(PYTHON) ./setup.py $(EXTRA_SETUP_ARGS) install --prefix="$(INSTDIR)" --record="$(INSTDIR)/foolscap_install.log" --install-lib="$(INSTDIR)/lib" --install-scripts="$(INSTDIR)/bin"
74
75 build-simplejson:
76         cd src/simplejson && \
77         $(PP) $(PYTHON) ./setup.py $(EXTRA_SETUP_ARGS) install --single-version-externally-managed --prefix="$(INSTDIR)" --record="$(INSTDIR)/simplejson_install.log" --install-lib="$(INSTDIR)/lib" --install-scripts="$(INSTDIR)/bin"
78
79 build-Crypto:
80         cd src/Crypto && \
81         $(PP) $(PYTHON) ./setup.py $(EXTRA_SETUP_ARGS) install --prefix="$(INSTDIR)" --record="$(INSTDIR)/Crypto_install.log" --install-lib="$(INSTDIR)/lib" --install-scripts="$(INSTDIR)/bin"
82
83 clean-zfec:
84         -cd src/zfec && \
85         $(PP) $(PYTHON) ./setup.py clean --all
86
87 clean-foolscap:
88         -cd src/foolscap && \
89         $(PP) $(PYTHON) ./setup.py clean --all
90
91 clean-Crypto:
92         cd src/Crypto && \
93         $(PP) $(PYTHON) ./setup.py clean --all
94
95
96 # RUNNING
97 #
98 # these targets let you create a client node in the current directory and
99 # start/stop it.
100
101 .PHONY: create-client start-client stop-client run-client
102 .PHONY: create-introducer start-introducer stop-introducer
103
104 create-client: build
105         $(PP) $(PYTHON) bin/allmydata-tahoe create-client -C CLIENTDIR
106 start-client: build
107         $(PP) $(PYTHON) bin/allmydata-tahoe start -C CLIENTDIR
108 stop-client: build
109         $(PP) $(PYTHON) bin/allmydata-tahoe stop -C CLIENTDIR
110
111 create-introducer: build
112         $(PP) $(PYTHON) bin/allmydata-tahoe create-introducer -C INTRODUCERDIR
113 start-introducer: build
114         $(PP) $(PYTHON) bin/allmydata-tahoe start -C INTRODUCERDIR
115 stop-introducer: build
116         $(PP) $(PYTHON) bin/allmydata-tahoe stop -C INTRODUCERDIR
117
118
119
120 # TESTING
121
122 .PHONY: test-all test test-foolscap test-figleaf figleaf-output
123
124 # you can use 'make test TEST=allmydata.test.test_introducer' to run just a
125 # specific test. TEST=allmydata.test.test_client.Basic.test_permute works
126 # too.
127 TEST=allmydata zfec
128 REPORTER=
129
130 test-all: test-foolscap test
131
132 # use 'make test REPORTER=--reporter=bwverbose' from buildbot, to supress the
133 # ansi color sequences
134
135 test: build
136         $(PP) $(TRIAL) $(REPORTER) $(TEST)
137
138 # foolscap tests need to be run in their own source dir, so that the paths to
139 # the .pyc files are correct (since some of the foolscap tests depend upon
140 # stack traces having actual source code in them, and they don't when the
141 # tests are run from the 'instdir' that the tahoe makefile uses).
142 test-foolscap:
143         cd src/foolscap && PYTHONPATH=$(ORIGPYTHONPATH) $(TRIAL) $(REPORTER) foolscap
144
145 test-figleaf: build
146         find $(INSTDIR) -name '*.pyc' |xargs rm
147         rm -f .figleaf
148         $(PP) $(TRIAL) --reporter=bwverbose-figleaf $(TEST)
149
150 figleaf-output:
151         $(PP) $(PYTHON) misc/figleaf2html -d coverage-html -r $(INSTDIR)/lib -x misc/figleaf.excludes
152         @echo "now point your browser at coverage-html/index.html"
153
154 # after doing test-figleaf and figleaf-output, point your browser at
155 # coverage-html/index.html
156
157 .PHONY: upload-figleaf .figleaf.el pyflakes count-lines check-memory clean
158
159 # 'upload-figleaf' is meant to be run with an UPLOAD_TARGET=host:/dir setting
160 ifdef UPLOAD_TARGET
161
162 ifndef UPLOAD_HOST
163 $(error UPLOAD_HOST must be set when using UPLOAD_TARGET)
164 endif
165 ifndef COVERAGEDIR
166 $(error COVERAGEDIR must be set when using UPLOAD_TARGET)
167 endif
168
169 upload-figleaf:
170         rsync -a coverage-html/ $(UPLOAD_TARGET)
171         ssh $(UPLOAD_HOST) make update-tahoe-figleaf COVERAGEDIR=$(COVERAGEDIR)
172 else
173 upload-figleaf:
174         echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
175         /bin/false
176 endif
177
178 .figleaf.el: .figleaf
179         $(PP) $(PYTHON) misc/figleaf2el.py .figleaf $(INSTDIR)/lib
180
181 pyflakes:
182         $(PP) $(PYTHON) -OOu `which pyflakes` src/allmydata
183
184 count-lines:
185         @echo -n "files: "
186         @find src -name '*.py' |grep -v /build/ |wc --lines
187         @echo -n "lines: "
188         @cat `find src -name '*.py' |grep -v /build/` |wc --lines
189         @echo -n "TODO: "
190         @grep TODO `find src -name '*.py' |grep -v /build/` | wc --lines
191
192 check-memory: build
193         touch memstats.out
194         $(PP) $(PYTHON) src/allmydata/test/check_memory.py upload
195         cat _test_memory/stats.out >>memstats.out
196         $(PP) $(PYTHON) src/allmydata/test/check_memory.py upload-POST
197         cat _test_memory/stats.out >>memstats.out
198
199 test-darcs-boringfile:
200         $(MAKE)
201         $(PYTHON) misc/test-darcs-boringfile.py
202
203 test-clean:
204         find . |sort >allfiles.tmp.old
205         $(MAKE)
206         $(MAKE) clean
207         find . |grep -v allfiles.tmp |sort >allfiles.tmp.new
208         diff allfiles.tmp.old allfiles.tmp.new
209
210 clean: clean-zfec clean-Crypto clean-foolscap
211         rm -rf build
212         rm -f debian
213         rm -rf instdir
214
215 install: 
216         cd src/zfec && python ./setup.py install && cd ../..
217         cd src/foolscap && python ./setup.py install && cd ../..
218         cd src/Crypto && python ./setup.py install && cd ../..
219         python ./setup.py install
220
221
222 # DEBIAN PACKAGING
223
224 VER=$(shell $(PYTHON) misc/get-version.py)
225 DEBCOMMENTS="'make deb' build"
226
227 show-version:
228         @echo $(VER)
229
230 .PHONY: setup-deb deb-ARCH is-known-debian-arch
231 .PHONY: deb-sid deb-feisty deb-edgy deb-etch
232
233 deb-sid:
234         $(MAKE) deb-ARCH ARCH=sid
235 deb-feisty:
236         $(MAKE) deb-ARCH ARCH=feisty
237 # edgy uses the feisty control files for now
238 deb-edgy:
239         $(MAKE) deb-ARCH ARCH=edgy TAHOE_ARCH=feisty
240 # etch uses the feisty control files for now
241 deb-etch:
242         $(MAKE) deb-ARCH ARCH=etch FOOLSCAP_ARCH=sid TAHOE_ARCH=feisty
243
244 # we know how to handle the following debian architectures
245 KNOWN_DEBIAN_ARCHES := sid feisty edgy etch
246
247 ifeq ($(findstring x-$(ARCH)-x,$(foreach arch,$(KNOWN_DEBIAN_ARCHES),"x-$(arch)-x")),)
248 is-known-debian-arch:
249         @echo "ARCH must be set when using setup-deb or deb-ARCH"
250         @echo "I know how to handle:" $(KNOWN_DEBIAN_ARCHES)
251         /bin/false
252 else
253 is-known-debian-arch:
254         /bin/true
255 endif
256
257 ifndef FOOLSCAP_ARCH
258 FOOLSCAP_ARCH=$(ARCH)
259 endif
260 ifndef TAHOE_ARCH
261 TAHOE_ARCH=$(ARCH)
262 endif
263
264 setup-deb: is-known-debian-arch
265         rm -f debian
266         ln -s misc/$(TAHOE_ARCH)/debian debian
267         chmod +x debian/rules
268
269 deb-foolscap-ARCH: is-known-debian-arch
270         $(MAKE) -C src/foolscap debian-$(FOOLSCAP_ARCH)
271         mv src/python-foolscap*.deb ..
272
273 # etch (current debian stable) has python-simplejson-1.3
274 # sid (debian unstable) currently has python-simplejson 1.7.1
275 # edgy has 1.3
276 # feisty has 1.4
277 # gutsy has 1.7.1
278
279 deb-ARCH: is-known-debian-arch setup-deb
280         fakeroot debian/rules binary
281         $(MAKE) deb-foolscap-ARCH
282         echo
283         echo "The newly built .deb packages are in the parent directory from here."
284
285 .PHONY: increment-deb-version
286 .PHONY: deb-sid-head deb-edgy-head deb-feisty-head
287 .PHONY: deb-etch-head
288
289 # The buildbot runs the following targets after each change, to produce
290 # up-to-date tahoe .debs. These steps do not create foolscap or simplejson
291 # .debs, only the deb-$ARCH targets (above) do that.
292
293 increment-deb-version: make-version
294         debchange --newversion $(VER) $(DEBCOMMENTS)
295 deb-sid-head:
296         $(MAKE) setup-deb ARCH=sid
297         $(MAKE) increment-deb-version
298         fakeroot debian/rules binary
299 deb-edgy-head:
300         $(MAKE) setup-deb ARCH=edgy TAHOE_ARCH=feisty
301         $(MAKE) increment-deb-version
302         fakeroot debian/rules binary
303 deb-feisty-head:
304         $(MAKE) setup-deb ARCH=feisty
305         $(MAKE) increment-deb-version
306         fakeroot debian/rules binary
307 deb-etch-head:
308         $(MAKE) setup-deb ARCH=etch TAHOE_ARCH=feisty
309         $(MAKE) increment-deb-version
310         fakeroot debian/rules binary
311