summaryrefslogtreecommitdiffstats
path: root/debian/rules
blob: 0a40e5d7f629f8a42fd8b5407d10747f4fad8332 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/make -f
# -*- makefile -*-

export NO_PKG_MANGLE=1
export LC_ALL=C.UTF-8
export PYTHONWARNINGS=d

export PYBUILD_TEST_ARGS=--verbose --ignore tests/test_api_translator.py

locales = $(notdir $(patsubst %/LC_MESSAGES,%,$(wildcard sphinx/locale/*/LC_MESSAGES)))

debroot = debian/tmp/
py3_libdir = /usr/lib/$(shell py3versions -d)/dist-packages
py3_builddir = $(shell pybuild --print build_dir --interpreter python3)
javascript_path = /usr/share/javascript/sphinxdoc/1.0/

%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_auto_build:
	dh_auto_build
ifeq "$(filter nodoc,$(DEB_BUILD_OPTIONS))" ""
	PYTHONPATH=$(py3_builddir) python3 ./sphinx/cmd/build.py -T doc build/html/
	find build/html/ -name '*.txt' -or -name '*.html' | xargs -L1 sed -i \
		's!http://docutils.sourceforge.net/docs/!file:///usr/share/doc/docutils-doc/docs/!g'
	PYTHONPATH=$(py3_builddir) python3 ./sphinx/cmd/build.py -T -b man doc build/man
endif
	PYTHONPATH=$(py3_builddir) python3 ./utils/babel_runner.py compile

override_dh_auto_install:
	pybuild --install -p $(shell py3versions -vd)
	# move static files outside dist-packages
	sed -i -e "s!^package_dir = .*!package_dir = '/usr/share/sphinx'!" \
		$(debroot)$(py3_libdir)/sphinx/__init__.py
	mkdir -p $(debroot)/usr/share/sphinx
	cd $(debroot) && mv -t usr/share/sphinx/ \
		.$(py3_libdir)/sphinx/templates \
		.$(py3_libdir)/sphinx/texinputs \
		.$(py3_libdir)/sphinx/themes
	mkdir -p $(debroot)/usr/share/sphinx/ext/autosummary/
	cd $(debroot) && mv -t usr/share/sphinx/ext/autosummary/ \
		.$(py3_libdir)/sphinx/ext/autosummary/templates
	mkdir -p $(debroot)/usr/share/sphinx/search/
	cd $(debroot) && mv -t usr/share/sphinx/search/ \
		.$(py3_libdir)/sphinx/search/minified-js \
		.$(py3_libdir)/sphinx/search/non-minified-js
	set -e -x; \
	cd $(debroot) && \
		for lang in $(locales); \
		do \
			install -m 644 -D $(CURDIR)/sphinx/locale/$$lang/LC_MESSAGES/sphinx.js \
				usr/share/sphinx/locale/$$lang/sphinx.js; \
			install -m 644 -D $(CURDIR)/sphinx/locale/$$lang/LC_MESSAGES/sphinx.mo \
				usr/share/locale/$$lang/LC_MESSAGES/sphinx.mo; \
		done
	cd $(debroot)$(py3_libdir)/sphinx/locale && rm -rf sphinx.pot */
	# Move JavaScript code to libjs-sphinxdoc:
	PYTHONPATH=$(py3_builddir) debian/dh-sphinxdoc/install-js debian/libjs-sphinxdoc$(javascript_path)
	rm -f $(debroot)/usr/share/sphinx/themes/bizstyle/static/css3-mediaqueries_src.js
	set -e; \
	for js in $$(find $(debroot)/usr/share/sphinx/themes/ -name '*.js' -a '!' -name 'websupport.js'); do \
		mv $$js debian/libjs-sphinxdoc/$(javascript_path); \
		ln -sf "$(javascript_path)/$${js##*/}" $$js; \
	done

override_dh_installchangelogs:
	dh_installchangelogs CHANGES

override_dh_installdocs:
	dh_installdocs
ifeq "$(filter nodoc,$(DEB_BUILD_OPTIONS))" ""
	./debian/dh-sphinxdoc/dh_sphinxdoc -p sphinx-doc /usr/share/doc/sphinx-doc/html/
endif

override_dh_installman:
	cd debian/dh-sphinxdoc/ && pod2man -c Debhelper -r '' dh_sphinxdoc dh_sphinxdoc.1
ifeq "$(filter nodoc,$(DEB_BUILD_OPTIONS))" ""
	dh_installman
endif

override_dh_compress:
	dh_compress -X.py -X.rst -X.json -X.txt