~bzr-pqm/bzr/bzr.dev

3346.2.2 by Martin Pool
Add a simple 'make dist' rule
1
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
2399.1.1 by John Arbash Meinel
Update Makefile to add 'make api-docs' using pydoctor
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
# A relatively simple Makefile to assist in building parts of bzr. Mostly for
18
# building documentation, etc.
19
2691.1.15 by Ian Clatworthy
reorganise Makefile into logical sections
20
21
### Core Stuff ###
22
2916.1.1 by Andrew Bennetts
Allow overriding the PYTHON executable for 'make extensions', and remove *.so files in 'make clean'.
23
PYTHON=python
3514.1.1 by John Arbash Meinel
Updates to allow building with mingw, and to exclude Vista system dlls
24
PYTHON_BUILDFLAGS=
2916.1.1 by Andrew Bennetts
Allow overriding the PYTHON executable for 'make extensions', and remove *.so files in 'make clean'.
25
3383.1.1 by Martin Pool
Merge back 1.4 and start 1.5 (but not transaction cache reinstatement)
26
.PHONY: all clean extensions pyflakes api-docs
1739.1.6 by Robert Collins
Resolve conflicts with bzr.dev.
27
1739.1.5 by Robert Collins
Review feedback.
28
all: extensions
29
30
extensions:
1739.1.3 by Robert Collins
Merge bzr.dev.
31
	@echo "building extension modules."
3514.1.1 by John Arbash Meinel
Updates to allow building with mingw, and to exclude Vista system dlls
32
	$(PYTHON) setup.py build_ext -i $(PYTHON_BUILDFLAGS)
1102 by Martin Pool
- merge test refactoring from robertc
33
2495.5.1 by John Arbash Meinel
(Andrew Bennetts) 'make check' builds docs as well
34
check: docs extensions
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
35
	$(PYTHON) -Werror -O ./bzr selftest -1v $(tests)
1526.1.1 by Robert Collins
Run the test suite with no locale as well as the default locale. Also add a test for build_tree_shape to selftest.
36
	@echo "Running all tests with no locale."
2749.1.1 by Martin Pool
(mbp) Show 'ascii' prefix when make check runs tests again in ascii mode
37
	LC_CTYPE= LANG=C LC_ALL= ./bzr selftest -1v $(tests) 2>&1 | sed -e 's/^/[ascii] /'
1102 by Martin Pool
- merge test refactoring from robertc
38
1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
39
# Run Python style checker (apt-get install pyflakes)
2625.11.1 by Martin Pool
(trivial) Remove obsolete Makefile targets
40
#
41
# Note that at present this gives many false warnings, because it doesn't
42
# know about identifiers loaded through lazy_import.
1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
43
pyflakes:
44
	pyflakes bzrlib
45
46
pyflakes-nounused:
47
	# There are many of these warnings at the moment and they're not a
48
	# high priority to fix
49
	pyflakes bzrlib | grep -v ' imported but unused'
50
51
clean:
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
52
	$(PYTHON) setup.py clean
2916.1.1 by Andrew Bennetts
Allow overriding the PYTHON executable for 'make extensions', and remove *.so files in 'make clean'.
53
	-find . -name "*.pyc" -o -name "*.pyo" -o -name "*.so" | xargs rm -f
1185.1.21 by Robert Collins
add a clean target
54
2691.1.15 by Ian Clatworthy
reorganise Makefile into logical sections
55
# Build API documentation
2399.1.9 by John Arbash Meinel
Since I have epydoc working with lazy imports, make it the default api doc generator.
56
docfiles = bzr bzrlib
2399.1.1 by John Arbash Meinel
Update Makefile to add 'make api-docs' using pydoctor
57
api-docs:
2413.4.1 by John Arbash Meinel
Cherrypick just the epydoc builder changes.
58
	mkdir -p api/html
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
59
	PYTHONPATH=$(PWD) $(PYTHON) tools/bzr_epydoc --html -o api/html --docformat 'restructuredtext en' $(docfiles)
2399.1.12 by John Arbash Meinel
Add make check-api-docs, which runs epydoc --check, rather than generating output
60
check-api-docs:
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
61
	PYTHONPATH=$(PWD) $(PYTHON) tools/bzr_epydoc --check --docformat 'restructuredtext en' $(docfiles)
2399.1.12 by John Arbash Meinel
Add make check-api-docs, which runs epydoc --check, rather than generating output
62
2625.11.2 by Martin Pool
Put back better rules for building ctags
63
# build tags for emacs and vim
64
TAGS:
65
	ctags -R -e bzrlib
66
67
tags:
68
	ctags -R bzrlib
69
70
# these are treated as phony so they'll always be rebuilt - it's pretty quick
71
.PHONY: TAGS tags
72
2691.1.15 by Ian Clatworthy
reorganise Makefile into logical sections
73
### Documentation ###
1821.1.1 by Alexander Belchenko
win32 installer for bzr.dev.0.9
74
2691.1.17 by Ian Clatworthy
Fix pretty doc generation so works for all html docs
75
# set PRETTY to get docs that look like the Bazaar web site
76
ifdef PRETTY
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
77
rst2html := $(PYTHON) tools/rst2prettyhtml.py doc/bazaar-vcs.org.kid 
2691.1.17 by Ian Clatworthy
Fix pretty doc generation so works for all html docs
78
else
3113.3.1 by Alexander Belchenko
Halt conversion of ReST to HTML if there is warnings.
79
rst2html := $(PYTHON) tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning
2691.1.17 by Ian Clatworthy
Fix pretty doc generation so works for all html docs
80
endif
81
1821.1.1 by Alexander Belchenko
win32 installer for bzr.dev.0.9
82
# translate txt docs to html
2691.1.4 by Ian Clatworthy
teach Makefile and .bzrignore re new doc structure
83
derived_txt_files := \
84
	doc/en/user-reference/bzr_man.txt \
85
	doc/en/developer-guide/HACKING.txt \
3619.3.1 by Andrew Bennetts
Move the notes on writing tests out of HACKING into a new file, and improve
86
	doc/en/developer-guide/testing.txt \
2691.1.4 by Ian Clatworthy
teach Makefile and .bzrignore re new doc structure
87
	doc/en/release-notes/NEWS.txt
3431.1.2 by Martin Pool
Build Spanish docs from the main Makefile
88
txt_files := $(wildcard doc/en/tutorials/*.txt) \
89
	$(derived_txt_files) \
2977.1.14 by Ian Clatworthy
change Makefile to support tutorials
90
	doc/en/user-guide/index.txt \
2691.1.16 by Ian Clatworthy
Ensure doc hierarchy is setup correctly for the Windows installer
91
	doc/en/mini-tutorial/index.txt \
3431.1.2 by Martin Pool
Build Spanish docs from the main Makefile
92
	$(wildcard doc/es/guia-usario/*.txt) \
93
	doc/es/mini-tutorial/index.txt \
94
	doc/index.txt \
95
	doc/index.es.txt
2691.1.17 by Ian Clatworthy
Fix pretty doc generation so works for all html docs
96
non_txt_files := \
97
       doc/default.css \
3065.3.1 by Alexander Belchenko
include doc/en/user-guide/images/*.png to WEB_DOCS
98
       doc/en/quick-reference/quick-start-summary.svg \
3065.3.3 by Alexander Belchenko
merge bzr.dev
99
       doc/en/quick-reference/quick-start-summary.png \
3092.3.1 by Ian Clatworthy
fix Makefile rules for doc generation
100
       doc/en/quick-reference/quick-start-summary.pdf \
3431.1.2 by Martin Pool
Build Spanish docs from the main Makefile
101
       $(wildcard doc/en/user-guide/images/*.png) \
102
       doc/es/referencia-rapida/referencia-rapida.svg \
103
       doc/es/referencia-rapida/referencia-rapida.png \
104
       doc/es/referencia-rapida/referencia-rapida.pdf \
105
       $(wildcard doc/es/guia-usuario/images/*.png)
2666.2.1 by Alexander Belchenko
change generated documentation extension from htm to html
106
htm_files := $(patsubst %.txt, %.html, $(txt_files)) 
2481.1.3 by Robert Collins
Add the performance roadmap rationale.
107
dev_txt_files := $(wildcard $(addsuffix /*.txt, doc/developers))
2666.2.1 by Alexander Belchenko
change generated documentation extension from htm to html
108
dev_htm_files := $(patsubst %.txt, %.html, $(dev_txt_files)) 
2054.2.14 by Aaron Bentley
Add 'pretty-docs' target to makefile
109
3092.3.1 by Ian Clatworthy
fix Makefile rules for doc generation
110
doc/en/user-guide/index.html: $(wildcard $(addsuffix /*.txt, doc/en/user-guide)) 
3097.1.1 by Ian Clatworthy
Tweak Makefile doc fix (Ian Clatworthy)
111
	$(rst2html) --stylesheet=../../default.css doc/en/user-guide/index.txt $@
3092.3.1 by Ian Clatworthy
fix Makefile rules for doc generation
112
2666.2.1 by Alexander Belchenko
change generated documentation extension from htm to html
113
doc/developers/%.html: doc/developers/%.txt
2691.1.17 by Ian Clatworthy
Fix pretty doc generation so works for all html docs
114
	$(rst2html) --stylesheet=../default.css $< $@
2666.2.1 by Alexander Belchenko
change generated documentation extension from htm to html
115
2691.1.6 by Ian Clatworthy
Add a top level doc index
116
doc/index.html: doc/index.txt
2691.1.17 by Ian Clatworthy
Fix pretty doc generation so works for all html docs
117
	$(rst2html) --stylesheet=default.css $< $@
2691.1.6 by Ian Clatworthy
Add a top level doc index
118
2666.2.1 by Alexander Belchenko
change generated documentation extension from htm to html
119
%.html: %.txt
2691.1.17 by Ian Clatworthy
Fix pretty doc generation so works for all html docs
120
	$(rst2html) --stylesheet=../../default.css $< $@
2054.2.14 by Aaron Bentley
Add 'pretty-docs' target to makefile
121
2425.1.1 by Robert Collins
``make docs`` now creates a man page at ``man1/bzr.1`` fixing bug 107388.
122
MAN_DEPENDENCIES = bzrlib/builtins.py \
1928.2.1 by Alexander Belchenko
New target to produce html docs to upload on server
123
		 bzrlib/bundle/commands.py \
124
		 bzrlib/conflicts.py \
3089.3.14 by Ian Clatworthy
follow-up tweaks to bzr.dev integration
125
		 bzrlib/help_topics/__init__.py \
1928.2.1 by Alexander Belchenko
New target to produce html docs to upload on server
126
		 bzrlib/sign_my_commits.py \
3053.8.1 by Ian Clatworthy
Improve bug tracker integration documentation (Ian Clatworthy)
127
		 bzrlib/bugtracker.py \
1928.2.1 by Alexander Belchenko
New target to produce html docs to upload on server
128
		 generate_docs.py \
129
		 tools/doc_generate/__init__.py \
2677.1.1 by Alexander Belchenko
rst2html: workaround for IE bug with id="tags"
130
		 tools/doc_generate/autodoc_man.py \
3089.3.4 by Ian Clatworthy
merge Alex's changes to support Windows installer and use bzrlib/help for topics
131
		 tools/doc_generate/autodoc_rstx.py \
3089.3.6 by Ian Clatworthy
make help topics more discoverable
132
		 $(wildcard $(addsuffix /*.txt, bzrlib/help_topics/en)) 
2977.1.14 by Ian Clatworthy
change Makefile to support tutorials
133
2691.1.4 by Ian Clatworthy
teach Makefile and .bzrignore re new doc structure
134
doc/en/user-reference/bzr_man.txt: $(MAN_DEPENDENCIES)
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
135
	$(PYTHON) generate_docs.py -o $@ rstx
2425.1.1 by Robert Collins
``make docs`` now creates a man page at ``man1/bzr.1`` fixing bug 107388.
136
2691.1.4 by Ian Clatworthy
teach Makefile and .bzrignore re new doc structure
137
doc/en/developer-guide/HACKING.txt: doc/developers/HACKING.txt
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
138
	$(PYTHON) tools/win32/ostools.py copytodir doc/developers/HACKING.txt doc/en/developer-guide
2691.1.4 by Ian Clatworthy
teach Makefile and .bzrignore re new doc structure
139
140
doc/en/release-notes/NEWS.txt: NEWS
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
141
	$(PYTHON) -c "import shutil; shutil.copyfile('$<', '$@')"
2691.1.4 by Ian Clatworthy
teach Makefile and .bzrignore re new doc structure
142
2425.1.1 by Robert Collins
``make docs`` now creates a man page at ``man1/bzr.1`` fixing bug 107388.
143
MAN_PAGES = man1/bzr.1
144
man1/bzr.1: $(MAN_DEPENDENCIES)
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
145
	$(PYTHON) generate_docs.py -o $@ man
2425.1.1 by Robert Collins
``make docs`` now creates a man page at ``man1/bzr.1`` fixing bug 107388.
146
2691.1.15 by Ian Clatworthy
reorganise Makefile into logical sections
147
# build a png of our performance task list
148
doc/developers/performance.png: doc/developers/performance.dot
149
	@echo Generating $@
150
	@dot -Tpng $< -o$@ || echo "Dot not installed; skipping generation of $@"
151
2691.1.17 by Ian Clatworthy
Fix pretty doc generation so works for all html docs
152
derived_web_docs = $(htm_files) $(dev_htm_files) doc/developers/performance.png
153
WEB_DOCS = $(derived_web_docs) $(non_txt_files)
154
ALL_DOCS = $(derived_web_docs) $(MAN_PAGES)
155
156
# the main target to build all the docs
157
docs: $(ALL_DOCS)
158
159
# produce a tree containing just the final docs, ready for uploading to the web
2691.1.15 by Ian Clatworthy
reorganise Makefile into logical sections
160
HTMLDIR := html_docs
161
html-docs: docs
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
162
	$(PYTHON) tools/win32/ostools.py copytree $(WEB_DOCS) $(HTMLDIR)
2691.1.15 by Ian Clatworthy
reorganise Makefile into logical sections
163
1928.2.1 by Alexander Belchenko
New target to produce html docs to upload on server
164
# clean produced docs
165
clean-docs:
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
166
	$(PYTHON) tools/win32/ostools.py remove $(ALL_DOCS) \
2691.1.17 by Ian Clatworthy
Fix pretty doc generation so works for all html docs
167
	$(HTMLDIR) $(derived_txt_files)
2522.3.1 by Robert Collins
Draft proposed integration order for performance changes.
168
169
2691.1.15 by Ian Clatworthy
reorganise Makefile into logical sections
170
### Windows Support ###
1928.2.1 by Alexander Belchenko
New target to produce html docs to upload on server
171
172
# make bzr.exe for win32 with py2exe
173
exe:
174
	@echo *** Make bzr.exe
3514.1.1 by John Arbash Meinel
Updates to allow building with mingw, and to exclude Vista system dlls
175
	$(PYTHON) setup.py build_ext -i -f $(PYTHON_BUILDFLAGS)
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
176
	$(PYTHON) setup.py py2exe > py2exe.log
177
	$(PYTHON) tools/win32/ostools.py copytodir tools/win32/start_bzr.bat win32_bzr.exe
178
	$(PYTHON) tools/win32/ostools.py copytodir tools/win32/bazaar.url win32_bzr.exe
1928.2.1 by Alexander Belchenko
New target to produce html docs to upload on server
179
1821.1.1 by Alexander Belchenko
win32 installer for bzr.dev.0.9
180
# win32 installer for bzr.exe
1982.2.1 by Alexander Belchenko
small but important fix for 'make installer' dependencies
181
installer: exe copy-docs
1861.2.18 by Alexander Belchenko
Makefile: cross-platform actions for building installer
182
	@echo *** Make windows installer
3557.1.3 by John Arbash Meinel
trivial tweak of Makefile to use the PYTHON variable
183
	$(PYTHON) tools/win32/run_script.py cog.py -d -o tools/win32/bzr.iss tools/win32/bzr.iss.cog
1861.2.18 by Alexander Belchenko
Makefile: cross-platform actions for building installer
184
	iscc /Q tools/win32/bzr.iss
1821.1.1 by Alexander Belchenko
win32 installer for bzr.dev.0.9
185
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
186
# win32 Python's distutils-based installer
187
# require to have Python interpreter installed on win32
2946.2.1 by Alexander Belchenko
windows python-based installer: shortcut for uninstall action
188
py-inst-24: docs
2571.3.1 by Alexander Belchenko
Building Python-based installer for bot Python 2.4 and 2.5
189
	python24 setup.py bdist_wininst --install-script="bzr-win32-bdist-postinstall.py" -d .
2946.2.1 by Alexander Belchenko
windows python-based installer: shortcut for uninstall action
190
191
py-inst-25: docs
2571.3.1 by Alexander Belchenko
Building Python-based installer for bot Python 2.4 and 2.5
192
	python25 setup.py bdist_wininst --install-script="bzr-win32-bdist-postinstall.py" -d .
1821.1.2 by Alexander Belchenko
resurrected python's distutils based installer for win32
193
2946.2.1 by Alexander Belchenko
windows python-based installer: shortcut for uninstall action
194
python-installer: py-inst-24 py-inst-25
195
196
2691.1.15 by Ian Clatworthy
reorganise Makefile into logical sections
197
copy-docs: docs
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
198
	$(PYTHON) tools/win32/ostools.py copytodir README win32_bzr.exe/doc
199
	$(PYTHON) tools/win32/ostools.py copytree $(WEB_DOCS) win32_bzr.exe
1821.1.2 by Alexander Belchenko
resurrected python's distutils based installer for win32
200
1821.1.1 by Alexander Belchenko
win32 installer for bzr.dev.0.9
201
# clean on win32 all installer-related files and directories
2666.2.1 by Alexander Belchenko
change generated documentation extension from htm to html
202
clean-win32: clean-docs
2934.2.1 by Ian Clatworthy
generates hooks.html correctly and generalise python command in Makefile
203
	$(PYTHON) tools/win32/ostools.py remove build
204
	$(PYTHON) tools/win32/ostools.py remove win32_bzr.exe
205
	$(PYTHON) tools/win32/ostools.py remove py2exe.log
206
	$(PYTHON) tools/win32/ostools.py remove tools/win32/bzr.iss
207
	$(PYTHON) tools/win32/ostools.py remove bzr-setup*.exe
208
	$(PYTHON) tools/win32/ostools.py remove bzr-*win32.exe
209
	$(PYTHON) tools/win32/ostools.py remove dist
3346.2.2 by Martin Pool
Add a simple 'make dist' rule
210
3346.2.5 by Martin Pool
Add check-dist-tarball to run tests from the packaged source
211
.PHONY: dist dist-upload-escudero check-dist-tarball
3346.2.3 by Martin Pool
Add dist-upload-escudero target
212
3346.2.2 by Martin Pool
Add a simple 'make dist' rule
213
# build a distribution tarball.
214
#
215
# this method of copying the pyrex generated files is a bit ugly; it would be
216
# nicer to generate it from distutils.
3346.2.5 by Martin Pool
Add check-dist-tarball to run tests from the packaged source
217
#
218
# these are a bit ubuntu-specific.
3346.2.2 by Martin Pool
Add a simple 'make dist' rule
219
dist: 
220
	version=`./bzr version --short` && \
221
	echo Building distribution of bzr $$version && \
3421.2.1 by John Arbash Meinel
Update make targets for distribution.
222
	expbasedir=`mktemp -t -d tmp_bzr_dist.XXXXXXXXXX` && \
3346.2.2 by Martin Pool
Add a simple 'make dist' rule
223
	expdir=$$expbasedir/bzr-$$version && \
224
	tarball=$$PWD/../bzr-$$version.tar.gz && \
225
	$(MAKE) clean && \
226
	$(MAKE) && \
227
	bzr export $$expdir && \
228
	cp bzrlib/*.c $$expdir/bzrlib/. && \
229
	tar cfz $$tarball -C $$expbasedir bzr-$$version && \
230
	gpg --detach-sign $$tarball && \
3421.2.1 by John Arbash Meinel
Update make targets for distribution.
231
	echo $$tarball done. && \
232
	rm -rf $$expbasedir
3346.2.3 by Martin Pool
Add dist-upload-escudero target
233
3346.2.5 by Martin Pool
Add check-dist-tarball to run tests from the packaged source
234
# run all tests in a previously built tarball
235
check-dist-tarball:
3421.2.1 by John Arbash Meinel
Update make targets for distribution.
236
	tmpdir=`mktemp -t -d tmp_bzr_check_dist.XXXXXXXXXX` && \
3346.2.5 by Martin Pool
Add check-dist-tarball to run tests from the packaged source
237
	version=`./bzr version --short` && \
238
	tarball=$$PWD/../bzr-$$version.tar.gz && \
239
	tar Cxz $$tmpdir -f $$tarball && \
3421.2.1 by John Arbash Meinel
Update make targets for distribution.
240
	$(MAKE) -C $$tmpdir/bzr-$$version check && \
241
	rm -rf $$tmpdir
3346.2.5 by Martin Pool
Add check-dist-tarball to run tests from the packaged source
242
243
3346.2.3 by Martin Pool
Add dist-upload-escudero target
244
# upload previously built tarball to the download directory on bazaar-vcs.org,
245
# and verify that it can be downloaded ok.
246
dist-upload-escudero:
247
	version=`./bzr version --short` && \
248
	tarball=../bzr-$$version.tar.gz && \
249
	scp $$tarball $$tarball.sig \
250
	    escudero.ubuntu.com:/srv/bazaar.canonical.com/www/releases/src \
251
		&& \
252
	echo verifying over http... && \
253
	curl http://bazaar-vcs.org/releases/src/bzr-$$version.tar.gz \
254
		| diff -s - $$tarball && \
255
	curl http://bazaar-vcs.org/releases/src/bzr-$$version.tar.gz.sig \
256
		| diff -s - $$tarball.sig