1
# Copyright (C) 2005-2012, 2016, 2017 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 brz. Mostly for
18
# building documentation, etc.
30
PLUGIN_TARGET=plugin-release
32
BRZ_PLUGIN_PATH=-site:-user
34
# Shorter replacement for $(sort $(wildcard <arg>)) as $(call sw,<arg>)
35
sw = $(sort $(wildcard $(1)))
38
.PHONY: all clean realclean extensions flake8 api-docs check-nodocs check
43
@echo "building extension modules."
44
$(PYTHON) setup.py build_ext -i $(PYTHON_BUILDFLAGS)
46
check: docs check-nodocs
48
check-nodocs: check-nodocs2 check-nodocs3
51
# Generate a stream for PQM to watch.
52
-$(RM) -f selftest.log
53
echo `date` ": selftest starts" 1>&2
54
set -o pipefail; BRZ_PLUGIN_PATH=$(BRZ_PLUGIN_PATH) $(PYTHON3) -Werror -Wignore::ImportWarning -Wignore::PendingDeprecationWarning -Wignore::DeprecationWarning -O \
55
./brz selftest -Oselftest.timeout=120 --strict \
56
--subunit2 $(tests) | tee selftest.log | subunit-2to1
57
echo `date` ": selftest ends" 1>&2
58
# An empty log file should catch errors in the $(PYTHON3)
59
# command above (the '|' swallow any errors since 'make'
60
# sees the 'tee' exit code for the whole line
61
if [ ! -s selftest.log ] ; then exit 1 ; fi
62
# Check that there were no errors reported.
63
subunit-stats < selftest.log
65
check-nodocs2: extensions
66
# Generate a stream for PQM to watch.
67
-$(RM) -f selftest.log
68
echo `date` ": selftest starts" 1>&2
69
set -o pipefail; BRZ_PLUGIN_PATH=$(BRZ_PLUGIN_PATH) $(PYTHON) -Werror -Wignore::ImportWarning -Wignore::DeprecationWarning -O \
70
./brz selftest -Oselftest.timeout=120 \
71
--subunit2 $(tests) | tee selftest.log | subunit-2to1
72
echo `date` ": selftest ends" 1>&2
73
# An empty log file should catch errors in the $(PYTHON)
74
# command above (the '|' swallow any errors since 'make'
75
# sees the 'tee' exit code for the whole line
76
if [ ! -s selftest.log ] ; then exit 1 ; fi
77
# Check that there were no errors reported.
78
subunit-stats < selftest.log
80
check-ci: docs extensions
81
# FIXME: Remove -Wignore::FutureWarning once
82
# https://github.com/paramiko/paramiko/issues/713 is not a concern
83
# anymore -- vila 2017-05-24
85
BRZ_PLUGIN_PATH=$(BRZ_PLUGIN_PATH) $(PYTHON) -Werror -Wignore::FutureWarning -Wignore::DeprecationWarning -Wignore::ImportWarning -Wignore::ResourceWarning -O \
86
./brz selftest -v --parallel=fork -Oselftest.timeout=120 --subunit2 \
87
| subunit-filter -s --passthrough --rename "^" "python2."; \
88
BRZ_PLUGIN_PATH=$(BRZ_PLUGIN_PATH) $(PYTHON3) -Werror -Wignore::FutureWarning -Wignore::DeprecationWarning -Wignore::PendingDeprecationWarning -Wignore::ImportWarning -Wignore::ResourceWarning -O \
89
./brz selftest -v --parallel=fork -Oselftest.timeout=120 --subunit2 \
90
| subunit-filter -s --passthrough --rename "^" "python3."
92
# Run Python style checker (apt-get install flake8)
94
# Note that at present this gives many false warnings, because it doesn't
95
# know about identifiers loaded through lazy_import.
100
$(PYTHON) setup.py clean
101
-find . -name "*.pyc" -o -name "*.pyo" -o -name "*.so" | xargs rm -f
104
# Remove files which are autogenerated but included by the tarball.
105
rm -f breezy/*_pyx.c breezy/bzr/*_pyx.c
106
rm -f breezy/_simple_set_pyx.h breezy/_simple_set_pyx_api.h
108
# Build API documentation
109
docfiles = brz breezy
112
pydoctor --make-html --docformat='restructuredtext' --html-output=api/html $(docfiles)
114
# build tags for emacs and vim
121
# these are treated as phony so they'll always be rebuilt - it's pretty quick
125
### Documentation ###
127
# Default to plain documentation for maximum backwards compatibility.
128
# (Post 2.0, the defaults will most likely be Sphinx-style instead.)
132
clean-docs: clean-plain
134
html-docs: html-plain
137
### Man-page Documentation ###
139
MAN_DEPENDENCIES = breezy/builtins.py \
140
$(call sw,breezy/*.py) \
141
$(call sw,breezy/*/*.py) \
142
tools/generate_docs.py \
143
$(call sw,$(addsuffix /*.txt, breezy/help_topics/en))
145
MAN_PAGES = man1/brz.1
146
man1/brz.1: $(MAN_DEPENDENCIES)
148
$(PYTHON) tools/generate_docs.py -o $@ man
151
### Sphinx-style Documentation ###
153
# Build the documentation. To keep the dependencies down to a minimum
154
# for distro packagers, we only build the html documentation by default.
155
# Sphinx 0.6 or later is preferred for the best rendering, though
156
# Sphinx 0.4 or later should work. See http://sphinx.pocoo.org/index.html
157
# for installation instructions.
158
docs-sphinx: html-sphinx
160
# Clean out generated documentation
162
cd doc/en && make clean
163
cd doc/developers && make clean
165
SPHINX_DEPENDENCIES = \
166
doc/en/release-notes/index.txt \
167
doc/en/user-reference/index.txt \
168
doc/developers/Makefile \
169
doc/developers/make.bat
171
NEWS_FILES = $(call sw,doc/en/release-notes/brz-*.txt)
173
doc/en/user-reference/index.txt: $(MAN_DEPENDENCIES)
174
LANGUAGE=C $(PYTHON) tools/generate_docs.py -o $@ rstx
176
doc/en/release-notes/index.txt: $(NEWS_FILES) tools/generate_release_notes.py
177
$(PYTHON) tools/generate_release_notes.py $@ $(NEWS_FILES)
179
doc/%/Makefile: doc/en/Makefile
180
$(PYTHON) -c "import shutil; shutil.copyfile('$<', '$@')"
182
doc/%/make.bat: doc/en/make.bat
183
$(PYTHON) -c "import shutil; shutil.copyfile('$<', '$@')"
185
# Build the html docs using Sphinx.
186
html-sphinx: $(SPHINX_DEPENDENCIES)
187
cd doc/en && make html
188
cd doc/developers && make html
190
# Build the PDF docs using Sphinx. This requires numerous LaTeX
191
# packages. See http://sphinx.pocoo.org/builders.html for details.
192
# Note: We don't currently build PDFs for the Russian docs because
193
# they require additional packages to be installed (to handle
194
# Russian hyphenation rules, etc.)
195
pdf-sphinx: $(SPHINX_DEPENDENCIES)
196
cd doc/en && make latex
197
cd doc/developers && make latex
198
cd doc/en/_build/latex && make all-pdf
199
cd doc/developers/_build/latex && make all-pdf
201
# Build the CHM (Windows Help) docs using Sphinx.
202
# Note: HtmlHelp Workshop needs to be used on the generated hhp files
203
# to generate the final chm files.
204
chm-sphinx: $(SPHINX_DEPENDENCIES)
205
cd doc/en && make htmlhelp
206
cd doc/developers && make htmlhelp
209
# Build the texinfo files using Sphinx.
210
texinfo-sphinx: $(SPHINX_DEPENDENCIES)
211
cd doc/en && make texinfo
212
cd doc/developers && make texinfo
214
### Documentation Website ###
216
# Where to build the website
217
DOC_WEBSITE_BUILD = build_doc_website
219
# Build and package docs into a website, complete with downloads.
220
doc-website: html-sphinx pdf-sphinx
221
$(PYTHON) tools/package_docs.py doc/en $(DOC_WEBSITE_BUILD)
222
$(PYTHON) tools/package_docs.py doc/developers $(DOC_WEBSITE_BUILD)
225
### Plain Documentation ###
227
# While Sphinx is the preferred tool for building documentation, we still
228
# support our "plain" html documentation so that Sphinx is not a hard
229
# dependency for packagers on older platforms.
231
rst2html = $(PYTHON) tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning
233
# translate txt docs to html
234
derived_txt_files = \
235
doc/en/release-notes/NEWS.txt
237
doc/en/tutorials/tutorial.txt \
238
doc/en/tutorials/using_breezy_with_launchpad.txt \
239
doc/en/tutorials/centralized_workflow.txt \
240
$(call sw,doc/*/mini-tutorial/index.txt) \
241
$(call sw,doc/*/user-guide/index-plain.txt) \
242
doc/en/admin-guide/index-plain.txt \
243
$(call sw,doc/es/guia-usario/*.txt) \
244
$(derived_txt_files) \
245
doc/en/upgrade-guide/index.txt \
247
$(call sw,doc/index.*.txt)
249
doc/en/user-guide/index.txt \
250
doc/en/admin-guide/index.txt
251
txt_files = $(filter-out $(txt_nohtml), $(txt_all))
252
htm_files = $(patsubst %.txt, %.html, $(txt_files))
256
$(call sw,doc/*/brz-en-quick-reference.svg) \
257
$(call sw,doc/*/brz-en-quick-reference.png) \
258
$(call sw,doc/*/brz-en-quick-reference.pdf) \
259
$(call sw,doc/*/bzr-es-quick-reference.svg) \
260
$(call sw,doc/*/bzr-es-quick-reference.png) \
261
$(call sw,doc/*/bzr-es-quick-reference.pdf) \
262
$(call sw,doc/*/bzr-ru-quick-reference.svg) \
263
$(call sw,doc/*/bzr-ru-quick-reference.png) \
264
$(call sw,doc/*/bzr-ru-quick-reference.pdf) \
265
$(call sw,doc/*/user-guide/images/*.png)
267
# doc/developers/*.txt files that should *not* be individually
270
doc/developers/add.txt \
271
doc/developers/annotate.txt \
272
doc/developers/bundle-creation.txt \
273
doc/developers/commit.txt \
274
doc/developers/diff.txt \
275
doc/developers/directory-fingerprints.txt \
276
doc/developers/gc.txt \
277
doc/developers/implementation-notes.txt \
278
doc/developers/incremental-push-pull.txt \
279
doc/developers/index.txt \
280
doc/developers/initial-push-pull.txt \
281
doc/developers/merge-scaling.txt \
282
doc/developers/miscellaneous-notes.txt \
283
doc/developers/missing.txt \
284
doc/developers/performance-roadmap-rationale.txt \
285
doc/developers/performance-use-case-analysis.txt \
286
doc/developers/planned-change-integration.txt \
287
doc/developers/planned-performance-changes.txt \
288
doc/developers/plans.txt \
289
doc/developers/process.txt \
290
doc/developers/revert.txt \
291
doc/developers/specifications.txt \
292
doc/developers/status.txt \
293
doc/developers/uncommit.txt
295
dev_txt_all = $(call sw,$(addsuffix /*.txt, doc/developers))
296
dev_txt_files = $(filter-out $(dev_txt_nohtml), $(dev_txt_all))
297
dev_htm_files = $(patsubst %.txt, %.html, $(dev_txt_files))
299
doc/en/user-guide/index-plain.html: $(call sw,$(addsuffix /*.txt, doc/en/user-guide))
300
$(rst2html) --stylesheet=../../default.css $(dir $@)index-plain.txt $@
302
#doc/es/user-guide/index.html: $(call sw,$(addsuffix /*.txt, doc/es/user-guide))
303
# $(rst2html) --stylesheet=../../default.css $(dir $@)index.txt $@
305
#doc/ru/user-guide/index.html: $(call sw,$(addsuffix /*.txt, doc/ru/user-guide))
306
# $(rst2html) --stylesheet=../../default.css $(dir $@)index.txt $@
308
doc/en/admin-guide/index-plain.html: $(call sw,$(addsuffix /*.txt, doc/en/admin-guide))
309
$(rst2html) --stylesheet=../../default.css $(dir $@)index-plain.txt $@
311
doc/developers/%.html: doc/developers/%.txt
312
$(rst2html) --stylesheet=../default.css $< $@
314
doc/index.html: doc/index.txt
315
$(rst2html) --stylesheet=default.css $< $@
317
doc/index.%.html: doc/index.%.txt
318
$(rst2html) --stylesheet=default.css $< $@
321
$(rst2html) --stylesheet=../../default.css $< "$@"
323
doc/en/release-notes/NEWS.txt: $(NEWS_FILES) tools/generate_release_notes.py
324
$(PYTHON) tools/generate_release_notes.py "$@" $(NEWS_FILES)
326
upgrade_guide_dependencies = $(call sw,$(addsuffix /*.txt, doc/en/upgrade-guide))
328
doc/en/upgrade-guide/index.html: $(upgrade_guide_dependencies)
329
$(rst2html) --stylesheet=../../default.css $(dir $@)index.txt $@
331
derived_web_docs = $(htm_files) $(dev_htm_files)
332
WEB_DOCS = $(derived_web_docs) $(non_txt_files)
333
ALL_DOCS = $(derived_web_docs) $(MAN_PAGES)
335
# the main target to build all the docs
336
docs-plain: $(ALL_DOCS)
338
# produce a tree containing just the final docs, ready for uploading to the web
340
html-plain: docs-plain
341
$(PYTHON) tools/win32/ostools.py copytree $(WEB_DOCS) $(HTMLDIR)
343
# clean produced docs
345
$(PYTHON) tools/win32/ostools.py remove $(ALL_DOCS) \
346
$(HTMLDIR) $(derived_txt_files)
349
### Miscellaneous Documentation Targets ###
351
# build a png of our performance task list
352
# this is no longer built by default; you can build it if you want to look at it
353
doc/developers/performance.png: doc/developers/performance.dot
355
@dot -Tpng $< -o$@ || echo "Dot not installed; skipping generation of $@"
358
### Windows Support ###
360
# make all the installers completely from scratch, using zc.buildout
361
# to fetch the dependencies
362
# These are files that need to be copied into the build location to boostrap
364
# Note that the path is relative to tools/win32
365
BUILDOUT_FILES = buildout.cfg \
366
buildout-templates/bin/build-installer.bat.in \
367
ostools.py bootstrap.py
370
@echo Make all the installers from scratch
371
@# Build everything in a separate directory, to avoid cluttering the WT
372
$(PYTHON) tools/win32/ostools.py makedir build-win32
373
@# cd to tools/win32 so that the relative paths are copied correctly
374
cd tools/win32 && $(PYTHON) ostools.py copytree $(BUILDOUT_FILES) ../../build-win32
375
@# There seems to be a bug in gf.release.brz, It doesn't correctly update
376
@# existing release directories, so delete them manually before building
377
@# It means things may be rebuilt that don't need to be, but at least
378
@# it will be correct when they do.
379
cd build-win32 && $(PYTHON) ostools.py remove release */release
380
cd build-win32 && $(PYTHON) bootstrap.py
381
cd build-win32 && bin/buildout
382
cd build-win32 && bin/build-installer.bat $(BRZ_TARGET) $(PLUGIN_TARGET)
386
$(PYTHON) tools/win32/ostools.py remove build-win32
388
# make brz.exe for win32 with py2exe
390
@echo *** Make brz.exe
391
$(PYTHON) tools/win32/ostools.py remove breezy/*.pyd
392
$(PYTHON) setup.py build_ext -i -f $(PYTHON_BUILDFLAGS)
393
$(PYTHON) setup.py py2exe > py2exe.log
394
$(PYTHON) tools/win32/ostools.py copytodir tools/win32/start_brz.bat win32_brz.exe
395
$(PYTHON) tools/win32/ostools.py copytodir tools/win32/bazaar.url win32_brz.exe
397
# win32 installer for brz.exe
398
installer: exe copy-docs
399
@echo *** Make Windows installer
400
$(PYTHON) tools/win32/run_script.py cog.py -d -o tools/win32/brz.iss tools/win32/brz.iss.cog
401
iscc /Q tools/win32/brz.iss
403
# win32 Python's distutils-based installer
404
# require to have Python interpreter installed on win32
406
$(PYTHON24) setup.py bdist_wininst --install-script="brz-win32-bdist-postinstall.py" -d .
409
$(PYTHON25) setup.py bdist_wininst --install-script="brz-win32-bdist-postinstall.py" -d .
412
$(PYTHON26) setup.py bdist_wininst --install-script="brz-win32-bdist-postinstall.py" -d .
414
python-installer: py-inst-24 py-inst-25 py-inst-26
418
$(PYTHON) tools/win32/ostools.py copytodir README win32_brz.exe/doc
419
$(PYTHON) tools/win32/ostools.py copytree $(WEB_DOCS) win32_brz.exe
421
# clean on win32 all installer-related files and directories
422
clean-win32: clean-docs
423
$(PYTHON) tools/win32/ostools.py remove build
424
$(PYTHON) tools/win32/ostools.py remove win32_brz.exe
425
$(PYTHON) tools/win32/ostools.py remove py2exe.log
426
$(PYTHON) tools/win32/ostools.py remove tools/win32/brz.iss
427
$(PYTHON) tools/win32/ostools.py remove brz-setup*.exe
428
$(PYTHON) tools/win32/ostools.py remove brz-*win32.exe
429
$(PYTHON) tools/win32/ostools.py remove dist
434
.PHONY: update-pot po/brz.pot
435
update-pot: po/brz.pot
437
TRANSLATABLE_PYFILES:=$(shell find breezy -name '*.py' \
438
| grep -v 'breezy/tests/' \
439
| grep -v 'breezy/doc' \
442
po/brz.pot: $(PYFILES) $(DOCFILES)
443
$(PYTHON) ./brz export-pot --include-duplicates > po/brz.pot
444
echo $(TRANSLATABLE_PYFILES) | xargs \
445
xgettext --package-name "brz" \
446
--msgid-bugs-address "<bazaar@canonical.com>" \
447
--copyright-holder "Canonical" \
448
--from-code ISO-8859-1 --join --sort-by-file --add-comments=i18n: \
449
-d bzr -p po -o brz.pot
452
### Packaging Targets ###
454
.PHONY: dist check-dist-tarball
456
# build a distribution source tarball
458
version=`./brz version --short` && \
459
echo Building distribution of brz $$version && \
460
expbasedir=`mktemp -t -d tmp_brz_dist.XXXXXXXXXX` && \
461
expdir=$$expbasedir/brz-$$version && \
462
tarball=$$PWD/../breezy-$$version.tar.gz && \
465
$(PYTHON) setup.py sdist -d $$PWD/.. && \
466
gpg --detach-sign --armor $$tarball && \
469
# run all tests in a previously built tarball
471
tmpdir=`mktemp -t -d tmp_brz_check_dist.XXXXXXXXXX` && \
472
version=`./brz version --short` && \
473
tarball=$$PWD/../breezy-$$version.tar.gz && \
474
tar Cxz $$tmpdir -f $$tarball && \
475
$(MAKE) -C $$tmpdir/breezy-$$version check && \