]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - GNUmakefile
make pyflakes run faster and with more alacrity
[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 ifneq ($(PYTHONPATH),)
39 PYTHONPATH := "$(PYTHONPATH)$(PATHSEP)$(INSTDIR)"
40 else
41 PYTHONPATH := "$(INSTDIR)"
42 endif
43
44 TRIAL=$(PYTHON) -u "$(TRIALPATH)" --rterrors --reactor=$(REACTOR)
45
46 show-instdir:
47         @echo $(INSTDIR)
48
49 PP=PYTHONPATH=$(PYTHONPATH)
50
51 .PHONY: build
52 build: build-zfec build-Crypto
53         $(PYTHON) setup.py $(EXTRA_SETUP_ARGS) install --install-lib="$(INSTDIR)" --install-scripts="$(INSTDIR)/scripts"
54
55 build-zfec:
56         cd src/zfec && $(PYTHON) ./setup.py $(EXTRA_SETUP_ARGS) install --single-version-externally-managed --root="$(INSTDIR)" --install-lib="." --install-scripts="$(INSTDIR)/scripts"
57
58 clean-zfec:
59         -cd src/zfec && python ./setup.py clean --all
60
61
62 build-Crypto:
63         cd src/Crypto && $(PYTHON) ./setup.py $(EXTRA_SETUP_ARGS) install --install-lib="$(INSTDIR)" --install-scripts="$(INSTDIR)/scripts"
64
65 clean-Crypto:
66         cd src/Crypto && python ./setup.py clean --all
67
68
69 .PHONY: run-queen run-client test
70
71 run-queen:
72         cd queen-basedir && PYTHONPATH=.. twistd -noy ../queen.tac
73
74 run-client: build
75         cd client-basedir && $(PP) twistd -noy ../client.tac
76
77 run-client2:
78         cd client-basedir2 && PYTHONPATH=.. twistd -noy ../client.tac
79 run-client3:
80         cd client-basedir3 && PYTHONPATH=.. twistd -noy ../client.tac
81
82 ifeq ($(TEST),)
83 TEST=allmydata zfec
84 endif
85 REPORTER=
86
87 # use 'make test REPORTER=--reporter=bwverbose' from buildbot, to supress the
88 # ansi color sequences
89 test: build
90         $(PP) $(TRIAL) $(REPORTER) $(TEST)
91
92 test-figleaf: build
93         rm -f .figleaf
94         $(PP) $(TRIAL) --reporter=bwverbose-figleaf $(TEST)
95
96 figleaf-output:
97         $(PP) $(PYTHON) misc/figleaf2html -d coverage-html -r $(INSTDIR) -x misc/figleaf.excludes
98         @echo "now point your browser at coverage-html/index.html"
99 # after doing test-figleaf and figleaf-output, point your browser at
100 # coverage-html/index.html
101
102 # this command is meant to be run with an
103 ifdef UPLOAD_TARGET
104 upload-figleaf:
105         rsync -a coverage-html/ $(UPLOAD_TARGET)
106 else
107 upload-figleaf:
108         echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
109         /bin/false
110 endif
111
112 .figleaf.el: .figleaf
113         $(PP) $(PYTHON) misc/figleaf2el.py .figleaf $(INSTDIR)
114
115 pyflakes:
116         $(PYTHON) -OOu /usr/local/bin/pyflakes src/allmydata
117
118 count-lines:
119         @echo -n "files: "
120         @find src -name '*.py' |grep -v /build/ |wc --lines
121         @echo -n "lines: "
122         @cat `find src -name '*.py' |grep -v /build/` |wc --lines
123         @echo -n "TODO: "
124         @grep TODO `find src -name '*.py' |grep -v /build/` | wc --lines
125
126 check-memory:
127         $(PP) $(PYTHON) src/allmydata/test/check_memory.py
128
129 clean: clean-zfec clean-Crypto
130         rm -rf build
131         rm -f debian
132         rm -rf instdir
133
134 create_dirs:
135         mkdir -p queen-basedir
136         mkdir -p client-basedir
137         mkdir -p client-basedir2
138         mkdir -p client-basedir/storage
139         mkdir -p client-basedir2/storage
140
141 DEBVER=`head -1 debian/changelog | sed -e 's/^[^(]*(\([^)]*\)).*$$/\1/' | sed -e 's/^\([0-9]\+\.[0-9]\+\.[0-9]\+\).*$$/\1/'`
142 DEBSTRING=$(DEBVER)-T`date +%s`
143 DEBCOMMENTS="'make deb' build"
144
145 show:
146         echo $(DEBVER)
147         echo $(DEBSTRING)
148
149 .PHONY: setup-dapper setup-sid setup-edgy setup-feisty
150 .PHONY: deb-dapper deb-sid deb-edgy deb-feisty
151 .PHONY: increment-deb-version
152 .PHONY: deb-dapper-head deb-sid-head deb-edgy-head deb-feisty-head
153
154 setup-dapper:
155         rm -f debian
156         ln -s dapper/debian debian
157         chmod a+x debian/rules
158
159 setup-sid:
160         rm -f debian
161         ln -s sid/debian debian
162         chmod a+x debian/rules
163
164 # edgy uses the feisty control files for now
165 setup-edgy:
166         rm -f debian
167         ln -s feisty/debian debian
168         chmod a+x debian/rules
169
170 setup-feisty:
171         rm -f debian
172         ln -s feisty/debian debian
173         chmod a+x debian/rules
174
175
176 deb-dapper: setup-dapper
177         fakeroot debian/rules binary
178 deb-sid: setup-sid
179         fakeroot debian/rules binary
180 deb-edgy: setup-edgy
181         fakeroot debian/rules binary
182 deb-feisty: setup-feisty
183         fakeroot debian/rules binary
184
185 increment-deb-version:
186         debchange --newversion $(DEBSTRING) $(DEBCOMMENTS)
187 deb-dapper-head: setup-dapper increment-deb-version
188         fakeroot debian/rules binary
189 deb-sid-head: setup-sid increment-deb-version
190         fakeroot debian/rules binary
191 deb-edgy-head: setup-edgy increment-deb-version
192         fakeroot debian/rules binary
193 deb-feisty-head: setup-feisty increment-deb-version
194         fakeroot debian/rules binary
195