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