1
# Copyright (C) 2005-2011 Canonical Ltd
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
# A relatively simple Makefile to assist in building parts of bzr. Mostly for
18
# building documentation, etc.
28
PLUGIN_TARGET=plugin-release
31
.PHONY: all clean realclean extensions pyflakes api-docs check-nodocs check
36
@echo "building extension modules."
37
$(PYTHON) setup.py build_ext -i $(PYTHON_BUILDFLAGS)
39
check: docs check-nodocs
41
check-nodocs: extensions
43
# Generate a stream for PQM to watch.
44
-$(RM) -f selftest.log
45
echo `date` ": selftest starts" 1>&2
46
$(PYTHON) -Werror -Wignore::ImportWarning -O ./bzr selftest -Oselftest.timeout=120 \
47
--subunit $(tests) | tee selftest.log
48
echo `date` ": selftest ends" 1>&2
49
# An empty log file should catch errors in the $(PYTHON)
50
# command above (the '|' swallow any errors since 'make'
51
# sees the 'tee' exit code for the whole line
52
if [ ! -s selftest.log ] ; then exit 1 ; fi
53
# Check that there were no errors reported.
54
subunit-stats < selftest.log
56
# Run Python style checker (apt-get install pyflakes)
58
# Note that at present this gives many false warnings, because it doesn't
59
# know about identifiers loaded through lazy_import.
64
# There are many of these warnings at the moment and they're not a
65
# high priority to fix
66
pyflakes bzrlib | grep -v ' imported but unused'
69
$(PYTHON) setup.py clean
70
-find . -name "*.pyc" -o -name "*.pyo" -o -name "*.so" | xargs rm -f
73
# Remove files which are autogenerated but included by the tarball.
75
rm -f bzrlib/_simple_set_pyx.h bzrlib/_simple_set_pyx_api.h
77
# Build API documentation
81
pydoctor --make-html --docformat='restructuredtext' --html-output=api/html $(docfiles)
83
# build tags for emacs and vim
90
# these are treated as phony so they'll always be rebuilt - it's pretty quick
96
# Default to plain documentation for maximum backwards compatibility.
97
# (Post 2.0, the defaults will most likely be Sphinx-style instead.)
101
clean-docs: clean-plain
103
html-docs: html-plain
106
### Man-page Documentation ###
108
MAN_DEPENDENCIES = bzrlib/builtins.py \
109
$(wildcard bzrlib/*.py) \
110
$(wildcard bzrlib/*/*.py) \
111
tools/generate_docs.py \
112
$(wildcard $(addsuffix /*.txt, bzrlib/help_topics/en))
114
MAN_PAGES = man1/bzr.1
115
man1/bzr.1: $(MAN_DEPENDENCIES)
116
$(PYTHON) tools/generate_docs.py -o $@ man
119
### Sphinx-style Documentation ###
121
# Build the documentation. To keep the dependencies down to a minimum
122
# for distro packagers, we only build the html documentation by default.
123
# Sphinx 0.6 or later is preferred for the best rendering, though
124
# Sphinx 0.4 or later should work. See http://sphinx.pocoo.org/index.html
125
# for installation instructions.
126
docs-sphinx: html-sphinx
128
# Clean out generated documentation
130
cd doc/en && make clean
131
cd doc/es && make clean
132
cd doc/ja && make clean
133
cd doc/ru && make clean
134
cd doc/developers && make clean
136
SPHINX_DEPENDENCIES = \
137
doc/en/release-notes/index.txt \
138
doc/en/user-reference/index.txt \
145
doc/developers/Makefile \
146
doc/developers/make.bat
148
NEWS_FILES = $(wildcard doc/en/release-notes/bzr-*.txt)
150
doc/en/user-reference/index.txt: $(MAN_DEPENDENCIES)
151
$(PYTHON) tools/generate_docs.py -o $@ rstx
153
doc/en/release-notes/index.txt: $(NEWS_FILES) tools/generate_release_notes.py
154
$(PYTHON) tools/generate_release_notes.py $@ $(NEWS_FILES)
156
doc/%/Makefile: doc/en/Makefile
157
$(PYTHON) -c "import shutil; shutil.copyfile('$<', '$@')"
159
doc/%/make.bat: doc/en/make.bat
160
$(PYTHON) -c "import shutil; shutil.copyfile('$<', '$@')"
162
# Build the html docs using Sphinx.
163
html-sphinx: $(SPHINX_DEPENDENCIES)
164
cd doc/en && make html
165
cd doc/es && make html
166
cd doc/ru && make html
167
cd doc/ja && make html
168
cd doc/developers && make html
170
# Build the PDF docs using Sphinx. This requires numerous LaTeX
171
# packages. See http://sphinx.pocoo.org/builders.html for details.
172
# Note: We don't currently build PDFs for the Russian docs because
173
# they require additional packages to be installed (to handle
174
# Russian hyphenation rules, etc.)
175
pdf-sphinx: $(SPHINX_DEPENDENCIES)
176
cd doc/en && make latex
177
cd doc/es && make latex
178
cd doc/ja && make latex
179
cd doc/developers && make latex
180
cd doc/en/_build/latex && make all-pdf
181
cd doc/es/_build/latex && make all-pdf
182
cd doc/developers/_build/latex && make all-pdf
184
# Build the CHM (Windows Help) docs using Sphinx.
185
# Note: HtmlHelp Workshop needs to be used on the generated hhp files
186
# to generate the final chm files.
187
chm-sphinx: $(SPHINX_DEPENDENCIES)
188
cd doc/en && make htmlhelp
189
cd doc/es && make htmlhelp
190
cd doc/ru && make htmlhelp
191
cd doc/ja && make htmlhelp
192
cd doc/developers && make htmlhelp
195
### Documentation Website ###
197
# Where to build the website
198
DOC_WEBSITE_BUILD = build_doc_website
200
# Build and package docs into a website, complete with downloads.
201
doc-website: html-sphinx pdf-sphinx
202
$(PYTHON) tools/package_docs.py doc/en $(DOC_WEBSITE_BUILD)
203
$(PYTHON) tools/package_docs.py doc/es $(DOC_WEBSITE_BUILD)
204
$(PYTHON) tools/package_docs.py doc/ru $(DOC_WEBSITE_BUILD)
205
$(PYTHON) tools/package_docs.py doc/ja $(DOC_WEBSITE_BUILD)
206
$(PYTHON) tools/package_docs.py doc/developers $(DOC_WEBSITE_BUILD)
209
### Plain Documentation ###
211
# While Sphinx is the preferred tool for building documentation, we still
212
# support our "plain" html documentation so that Sphinx is not a hard
213
# dependency for packagers on older platforms.
215
rst2html = $(PYTHON) tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning
217
# translate txt docs to html
218
derived_txt_files = \
219
doc/en/release-notes/NEWS.txt
221
doc/en/tutorials/tutorial.txt \
222
doc/en/tutorials/using_bazaar_with_launchpad.txt \
223
doc/en/tutorials/centralized_workflow.txt \
224
$(wildcard doc/es/tutorials/*.txt) \
225
$(wildcard doc/ru/tutorials/*.txt) \
226
doc/ja/tutorials/tutorial.txt \
227
doc/ja/tutorials/using_bazaar_with_launchpad.txt \
228
doc/ja/tutorials/centralized_workflow.txt \
229
$(wildcard doc/*/mini-tutorial/index.txt) \
230
$(wildcard doc/*/user-guide/index-plain.txt) \
231
doc/en/admin-guide/index-plain.txt \
232
$(wildcard doc/es/guia-usario/*.txt) \
233
$(derived_txt_files) \
234
doc/en/upgrade-guide/index.txt \
236
$(wildcard doc/index.*.txt)
238
doc/en/user-guide/index.txt \
239
doc/es/user-guide/index.txt \
240
doc/ja/user-guide/index.txt \
241
doc/ru/user-guide/index.txt \
242
doc/en/admin-guide/index.txt
243
txt_files = $(filter-out $(txt_nohtml), $(txt_all))
244
htm_files = $(patsubst %.txt, %.html, $(txt_files))
248
$(wildcard doc/*/bzr-en-quick-reference.svg) \
249
$(wildcard doc/*/bzr-en-quick-reference.png) \
250
$(wildcard doc/*/bzr-en-quick-reference.pdf) \
251
$(wildcard doc/*/bzr-es-quick-reference.svg) \
252
$(wildcard doc/*/bzr-es-quick-reference.png) \
253
$(wildcard doc/*/bzr-es-quick-reference.pdf) \
254
$(wildcard doc/*/bzr-ru-quick-reference.svg) \
255
$(wildcard doc/*/bzr-ru-quick-reference.png) \
256
$(wildcard doc/*/bzr-ru-quick-reference.pdf) \
257
$(wildcard doc/*/user-guide/images/*.png)
259
# doc/developers/*.txt files that should *not* be individually
262
doc/developers/add.txt \
263
doc/developers/annotate.txt \
264
doc/developers/bundle-creation.txt \
265
doc/developers/commit.txt \
266
doc/developers/diff.txt \
267
doc/developers/directory-fingerprints.txt \
268
doc/developers/gc.txt \
269
doc/developers/implementation-notes.txt \
270
doc/developers/incremental-push-pull.txt \
271
doc/developers/index.txt \
272
doc/developers/initial-push-pull.txt \
273
doc/developers/merge-scaling.txt \
274
doc/developers/miscellaneous-notes.txt \
275
doc/developers/missing.txt \
276
doc/developers/performance-roadmap-rationale.txt \
277
doc/developers/performance-use-case-analysis.txt \
278
doc/developers/planned-change-integration.txt \
279
doc/developers/planned-performance-changes.txt \
280
doc/developers/plans.txt \
281
doc/developers/process.txt \
282
doc/developers/revert.txt \
283
doc/developers/specifications.txt \
284
doc/developers/status.txt \
285
doc/developers/uncommit.txt
287
dev_txt_all = $(wildcard $(addsuffix /*.txt, doc/developers))
288
dev_txt_files = $(filter-out $(dev_txt_nohtml), $(dev_txt_all))
289
dev_htm_files = $(patsubst %.txt, %.html, $(dev_txt_files))
291
doc/en/user-guide/index-plain.html: $(wildcard $(addsuffix /*.txt, doc/en/user-guide))
292
$(rst2html) --stylesheet=../../default.css $(dir $@)index-plain.txt $@
294
#doc/es/user-guide/index.html: $(wildcard $(addsuffix /*.txt, doc/es/user-guide))
295
# $(rst2html) --stylesheet=../../default.css $(dir $@)index.txt $@
297
#doc/ru/user-guide/index.html: $(wildcard $(addsuffix /*.txt, doc/ru/user-guide))
298
# $(rst2html) --stylesheet=../../default.css $(dir $@)index.txt $@
300
doc/en/admin-guide/index-plain.html: $(wildcard $(addsuffix /*.txt, doc/en/admin-guide))
301
$(rst2html) --stylesheet=../../default.css $(dir $@)index-plain.txt $@
303
doc/developers/%.html: doc/developers/%.txt
304
$(rst2html) --stylesheet=../default.css $< $@
306
doc/index.html: doc/index.txt
307
$(rst2html) --stylesheet=default.css $< $@
309
doc/index.%.html: doc/index.%.txt
310
$(rst2html) --stylesheet=default.css $< $@
313
$(rst2html) --stylesheet=../../default.css $< "$@"
315
doc/en/release-notes/NEWS.txt: $(NEWS_FILES) tools/generate_release_notes.py
316
$(PYTHON) tools/generate_release_notes.py "$@" $(NEWS_FILES)
318
upgrade_guide_dependencies = $(wildcard $(addsuffix /*.txt, doc/en/upgrade-guide))
320
doc/en/upgrade-guide/index.html: $(upgrade_guide_dependencies)
321
$(rst2html) --stylesheet=../../default.css $(dir $@)index.txt $@
323
derived_web_docs = $(htm_files) $(dev_htm_files)
324
WEB_DOCS = $(derived_web_docs) $(non_txt_files)
325
ALL_DOCS = $(derived_web_docs) $(MAN_PAGES)
327
# the main target to build all the docs
328
docs-plain: $(ALL_DOCS)
330
# produce a tree containing just the final docs, ready for uploading to the web
332
html-plain: docs-plain
333
$(PYTHON) tools/win32/ostools.py copytree $(WEB_DOCS) $(HTMLDIR)
335
# clean produced docs
337
$(PYTHON) tools/win32/ostools.py remove $(ALL_DOCS) \
338
$(HTMLDIR) $(derived_txt_files)
341
### Miscellaneous Documentation Targets ###
343
# build a png of our performance task list
344
# this is no longer built by default; you can build it if you want to look at it
345
doc/developers/performance.png: doc/developers/performance.dot
347
@dot -Tpng $< -o$@ || echo "Dot not installed; skipping generation of $@"
350
### Windows Support ###
352
# make all the installers completely from scratch, using zc.buildout
353
# to fetch the dependencies
354
# These are files that need to be copied into the build location to boostrap
356
# Note that the path is relative to tools/win32
357
BUILDOUT_FILES = buildout.cfg \
358
buildout-templates/bin/build-installer.bat.in \
359
ostools.py bootstrap.py
362
@echo Make all the installers from scratch
363
@# Build everything in a separate directory, to avoid cluttering the WT
364
$(PYTHON) tools/win32/ostools.py makedir build-win32
365
@# cd to tools/win32 so that the relative paths are copied correctly
366
cd tools/win32 && $(PYTHON) ostools.py copytree $(BUILDOUT_FILES) ../../build-win32
367
@# There seems to be a bug in gf.release.bzr, It doesn't correctly update
368
@# existing release directories, so delete them manually before building
369
@# It means things may be rebuilt that don't need to be, but at least
370
@# it will be correct when they do.
371
cd build-win32 && $(PYTHON) ostools.py remove release */release
372
cd build-win32 && $(PYTHON) bootstrap.py
373
cd build-win32 && bin/buildout
374
cd build-win32 && bin/build-installer.bat $(BZR_TARGET) $(PLUGIN_TARGET)
378
$(PYTHON) tools/win32/ostools.py remove build-win32
380
# make bzr.exe for win32 with py2exe
382
@echo *** Make bzr.exe
383
$(PYTHON) tools/win32/ostools.py remove bzrlib/*.pyd
384
$(PYTHON) setup.py build_ext -i -f $(PYTHON_BUILDFLAGS)
385
$(PYTHON) setup.py py2exe > py2exe.log
386
$(PYTHON) tools/win32/ostools.py copytodir tools/win32/start_bzr.bat win32_bzr.exe
387
$(PYTHON) tools/win32/ostools.py copytodir tools/win32/bazaar.url win32_bzr.exe
389
# win32 installer for bzr.exe
390
installer: exe copy-docs
391
@echo *** Make Windows installer
392
$(PYTHON) tools/win32/run_script.py cog.py -d -o tools/win32/bzr.iss tools/win32/bzr.iss.cog
393
iscc /Q tools/win32/bzr.iss
395
# win32 Python's distutils-based installer
396
# require to have Python interpreter installed on win32
398
$(PYTHON24) setup.py bdist_wininst --install-script="bzr-win32-bdist-postinstall.py" -d .
401
$(PYTHON25) setup.py bdist_wininst --install-script="bzr-win32-bdist-postinstall.py" -d .
404
$(PYTHON26) setup.py bdist_wininst --install-script="bzr-win32-bdist-postinstall.py" -d .
406
python-installer: py-inst-24 py-inst-25 py-inst-26
410
$(PYTHON) tools/win32/ostools.py copytodir README win32_bzr.exe/doc
411
$(PYTHON) tools/win32/ostools.py copytree $(WEB_DOCS) win32_bzr.exe
413
# clean on win32 all installer-related files and directories
414
clean-win32: clean-docs
415
$(PYTHON) tools/win32/ostools.py remove build
416
$(PYTHON) tools/win32/ostools.py remove win32_bzr.exe
417
$(PYTHON) tools/win32/ostools.py remove py2exe.log
418
$(PYTHON) tools/win32/ostools.py remove tools/win32/bzr.iss
419
$(PYTHON) tools/win32/ostools.py remove bzr-setup*.exe
420
$(PYTHON) tools/win32/ostools.py remove bzr-*win32.exe
421
$(PYTHON) tools/win32/ostools.py remove dist
426
.PHONY: update-pot po/bzr.pot
427
update-pot: po/bzr.pot
429
TRANSLATABLE_PYFILES:=$(shell find bzrlib -name '*.py' \
430
| grep -v 'bzrlib/tests/' \
431
| grep -v 'bzrlib/doc' \
434
po/bzr.pot: $(PYFILES) $(DOCFILES)
435
$(PYTHON) ./bzr export-pot > po/bzr.pot
436
echo $(TRANSLATABLE_PYFILES) | xargs \
437
xgettext --package-name "bzr" \
438
--msgid-bugs-address "<bazaar@canonical.com>" \
439
--copyright-holder "Canonical" \
440
--from-code ISO-8859-1 --join --sort-by-file --add-comments=i18n: \
441
-d bzr -p po -o bzr.pot
444
### Packaging Targets ###
446
.PHONY: dist check-dist-tarball
448
# build a distribution source tarball
450
# this method of copying the pyrex generated files is a bit ugly; it would be
451
# nicer to generate it from distutils.
453
version=`./bzr version --short` && \
454
echo Building distribution of bzr $$version && \
455
expbasedir=`mktemp -t -d tmp_bzr_dist.XXXXXXXXXX` && \
456
expdir=$$expbasedir/bzr-$$version && \
457
tarball=$$PWD/../bzr-$$version.tar.gz && \
460
bzr export $$expdir && \
461
cp bzrlib/*.c bzrlib/*.h $$expdir/bzrlib/. && \
462
tar cfz $$tarball -C $$expbasedir bzr-$$version && \
463
gpg --detach-sign $$tarball && \
466
# run all tests in a previously built tarball
468
tmpdir=`mktemp -t -d tmp_bzr_check_dist.XXXXXXXXXX` && \
469
version=`./bzr version --short` && \
470
tarball=$$PWD/../bzr-$$version.tar.gz && \
471
tar Cxz $$tmpdir -f $$tarball && \
472
$(MAKE) -C $$tmpdir/bzr-$$version check && \