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