changelog & upgrading checklist for CC0
[debian-policy.git] / Makefile
blob3d26478a592ebcb4dc0b2fdb25604e5aa4fe9a2d
1 # Build rules for Debian Policy.
3 # This is not completely standalone and independent of the Debian packaging
4 # in that it uses debian/changelog to get the version number and release
5 # date for incorporation into other documents. Except for that, however,
6 # the design goal of these build rules is to build the Policy documents
7 # independent of their Debian packaging in the debian directory.
9 # Basic package information.
10 PACKAGE := $(shell dpkg-parsechangelog -SSource)
11 TIMESTAMP := $(shell dpkg-parsechangelog -STimestamp)
12 DATE := $(shell date -d '@$(TIMESTAMP)' +'%Y-%m-%d')
13 VERSION := $(shell dpkg-parsechangelog -SVersion)
15 # Conversion programs to use. Export these so that they're visible to
16 # submakes.
17 export DBLATEX = dblatex -p xsl/dblatex.xsl
18 export DIA = dia
19 export MDWN = multimarkdown
20 export SPHINX = sphinx-build
21 export XMLLINT = xmllint --nonet --noout --postvalid --xinclude
22 export XSLTPROC = xsltproc --nonet --xinclude
24 # Installation directories. Normally this is only used by debian/rules
25 # build, which will set DESTDIR to put the installation under the temporary
26 # Debian packaging directory.
27 prefix = /usr
28 datarootdir = $(prefix)/share
29 datadir = $(datarootdir)
30 docdir = $(datadir)/doc/$(PACKAGE)
31 infodir = $(datarootdir)/info
33 # Installation programs to use.
34 INSTALL = install -p -o root -g root -m 644
35 MKDIR = install -d -o root -g root -m 755
37 # Files included by debconf_specification.xml.
38 DEBCONF_INCLUDES := debconf/commands.xml debconf/priorities.xml \
39 debconf/statuscodes.xml debconf/types.xml
41 # doc-base description files for the documents we include.
42 DESC_FILES := autopkgtest copyright-format-1.0 debconf-spec debian-policy \
43 debian-menu-policy debian-perl-policy fhs
45 # Our local copy of the File Hierarchy Standard. We don't build this from
46 # source, but we do have a copy of the source in FHS_ARCHIVE.
47 FHS_ARCHIVE := fhs-2.3-source.tar.gz
48 FHS_FILES := fhs-2.3.html fhs-2.3.ps.gz fhs-2.3.txt.gz fhs-2.3.pdf.gz
50 # Markdown source files in the top-level directory. We generate text and
51 # HTML versions from these.
52 MDWN_FILES := README autopkgtest
54 # Dia diagrams in the policy/images subdirectory.
55 DIA_FILES := $(wildcard policy/images/*.dia)
57 # Dia diagrams converted to PNG in images/ subdirectory.
58 DIA_PNGS := $(DIA_FILES:.dia=.png)
60 # Dia diagrams converted to SVG in images/ subdirectory.
61 DIA_SVGS := $(DIA_FILES:.dia=.svg)
63 # DocBook source files in the top-level directory. We do some common actions
64 # with each of these: build text, HTML, and one-page HTML output.
65 XML_FILES := menu-policy perl-policy
67 # DocBook source files in the top-level directory that should only generate
68 # single-page HTML output (no split HTML output).
69 XML_SINGLE_FILES := copyright-format-1.0 debconf_specification
71 # XML document version files. These are generated at build time from the
72 # current version and date information from the Debian changelog.
73 XML_VERSION := copyright-format/version.xml debconf_spec/include/version.xml \
74 version.xml
76 # A list of the simple Policy files that we build at the top level and in
77 # subdirectories and include in the documentation directory of the generated
78 # package. The directories of HTML output are handled separately.
79 POLICY_FILES := $(MDWN_FILES:=.html) \
80 $(MDWN_FILES:=.txt) \
81 $(XML_FILES:=-1.html) \
82 $(XML_FILES:=.txt) \
83 $(XML_SINGLE_FILES:=.html) \
84 $(XML_SINGLE_FILES:=.txt) \
85 README.css \
86 policy/_build/epub/policy.epub \
87 policy/_build/latex/policy.pdf \
88 policy/_build/policy.txt \
89 policy/_build/text/upgrading-checklist.txt \
90 virtual-package-names-list.txt
92 # A list of generated info files to install.
93 INFO_FILES := policy/_build/texinfo/debian-policy.info
95 # Source files that go into the Debian Policy manual.
96 POLICY_SOURCE := $(wildcard policy/*.rst) policy/conf.py policy/index.rst
98 # Used by the clean rules. FILES_TO_CLEAN are individual generated files to
99 # remove. DIRS_TO_CLEAN are entire directories to remove.
100 DIRS_TO_CLEAN := $(XML_FILES:=.html) policy/_build fhs
101 FILES_TO_CLEAN := $(MDWN_FILES:=.html) \
102 $(MDWN_FILES:=.txt) \
103 $(XML_FILES:=.html.tar.gz) \
104 $(XML_FILES:=-1.html) \
105 $(XML_FILES:=.txt) \
106 $(XML_FILES:=.validate) \
107 $(XML_SINGLE_FILES:=.html) \
108 $(XML_SINGLE_FILES:=.txt) \
109 $(XML_SINGLE_FILES:=.validate) \
110 $(DIA_PNGS) \
111 policy/index.rst \
112 version.md version.xml
116 # General build targets. These are the ones a human may build from the
117 # command line, or that are used by the Debian build system.
120 all: $(XML_FILES:=.validate) $(XML_SINGLE_FILES:=.validate) \
121 $(XML_FILES:=.html.tar.gz) $(POLICY_FILES) $(INFO_FILES) \
122 policy/_build/singlehtml/index.html policy/_build/html/index.html
124 clean distclean:
125 rm -f $(FILES_TO_CLEAN)
126 rm -rf $(DIRS_TO_CLEAN)
128 install: all
129 $(MKDIR) $(DESTDIR)$(docdir)
130 $(MKDIR) $(DESTDIR)$(docdir)/fhs
131 $(INSTALL) $(POLICY_FILES) $(DESTDIR)$(docdir)
132 $(INSTALL) $(FHS_FILES) $(DESTDIR)$(docdir)/fhs
133 @set -ex; for file in $(XML_FILES); do \
134 tar -C $(DESTDIR)$(docdir) -zxf $$file.html.tar.gz; \
135 done
136 $(MKDIR) $(DESTDIR)$(docdir)/policy.html
137 cp -dR policy/_build/html/* $(DESTDIR)$(docdir)/policy.html/
138 $(INSTALL) policy/_build/singlehtml/index.html \
139 $(DESTDIR)$(docdir)/policy-1.html
140 $(MKDIR) $(DESTDIR)$(docdir)/_images
141 cp -dR policy/_build/singlehtml/_images/* $(DESTDIR)$(docdir)/_images/
142 $(MKDIR) $(DESTDIR)$(docdir)/_static
143 cp -dR policy/_build/singlehtml/_static/* $(DESTDIR)$(docdir)/_static/
144 $(MKDIR) $(DESTDIR)$(infodir)
145 $(INSTALL) $(INFO_FILES) $(DESTDIR)$(infodir)
146 $(INSTALL) $(DIA_PNGS) $(DESTDIR)$(infodir)
148 .PHONY: all clean distclean install
152 # Version files. These incorporate the version and release date of the
153 # debian-policy package into the various specifications as their version and
154 # publication date.
157 policy/conf.py policy/index.rst: %: %.in debian/changelog
158 sed -e 's/@VERSION@/$(VERSION)/' -e 's/@DATE@/$(DATE)/' $< > $@
160 version.md: debian/changelog
161 rm -f $@
162 echo > $@
163 echo '---' >> $@
164 echo 'Debian Policy $(VERSION), $(DATE)' >> $@
166 version.xml: debian/changelog
167 rm -f $@
168 echo '<?xml version="1.0" encoding="utf-8"?>' > $@
169 echo '<!ENTITY version "$(VERSION)">' >> $@
170 echo '<!ENTITY date "$(DATE)">' >> $@
174 # Individual file and pattern build rules.
177 # There doesn't seem to be a better way of adding this include dependency.
178 debconf_specification.html: $(DEBCONF_INCLUDES)
179 debconf_specification.txt: $(DEBCONF_INCLUDES)
180 debconf_specification.validate: $(DEBCONF_INCLUDES)
182 # The text version of the upgrading checklist come from the Policy text build.
183 policy/_build/text/upgrading-checklist.txt: policy/_build/policy.txt
185 policy/_build/epub/policy.epub: $(POLICY_SOURCE) $(DIA_PNGS)
186 $(SPHINX) -M epub policy policy/_build
188 policy/_build/html/index.html: $(POLICY_SOURCE) $(DIA_PNGS)
189 $(SPHINX) -M html policy policy/_build
191 policy/_build/latex/policy.pdf: $(POLICY_SOURCE) $(DIA_PNGS)
192 $(SPHINX) -M latexpdf policy policy/_build
194 policy/_build/policy.txt: $(POLICY_SOURCE)
195 rm -f $@
196 $(SPHINX) -M text policy policy/_build
197 cp policy/_build/text/index.txt $@
198 set -e; \
199 files=$$(egrep '^ (ch-|ap-|upgrading-)' policy/index.rst); \
200 for f in $$files; do \
201 printf "\n\n\n" >>$@; \
202 cat policy/_build/text/"$$f".txt >>$@; \
203 done
205 policy/_build/singlehtml/index.html: $(POLICY_SOURCE) $(DIA_PNGS)
206 $(SPHINX) -M singlehtml policy policy/_build
207 perl -pli -e 's,href="index\.html#,href="#,g' $@
208 perl -pli -e 's,(genindex|search)\.html,policy.html/$$1.html,' $@
210 policy/_build/texinfo/debian-policy.info: $(POLICY_SOURCE)
211 $(SPHINX) -M info policy policy/_build
213 $(MDWN_FILES:=.txt): %.txt: %.md version.md
214 cat $^ > $@
215 test "$@" != "README.txt" || \
216 perl -pli -e 's,./Process.md,Process.txt,g' $@
218 $(MDWN_FILES:=.html): %.html: %.md version.md
219 cat $^ | $(MDWN) > $@
221 $(DIA_PNGS): policy/images/%.png: policy/images/%.dia
222 $(DIA) -e $@ $^
224 $(DIA_SVGS): policy/images/%.svg: policy/images/%.dia
225 $(DIA) -e $@ $^
227 # Suppress the table of contents for the standalone upgrading checklist.
228 upgrading-checklist-1.html: XSLPARAMS = --stringparam generate.toc ''
229 upgrading-checklist.txt: XSLPARAMS = --stringparam generate.toc ''
231 %.validate: %.xml version.xml
232 $(XMLLINT) $<
233 touch $@
235 %.html/index.html: %.xml xsl/html-chunk.xsl version.xml
236 mkdir -p $(@D)/images
237 $(XSLTPROC) $(XSLPARAMS) \
238 --stringparam base.dir $(@D)/ \
239 xsl/html-chunk.xsl $<
241 $(XML_SINGLE_FILES:=.html): %.html: %.xml xsl/html-single.xsl version.xml
242 $(XSLTPROC) $(XSLPARAMS) xsl/html-single.xsl $< > $@
244 %-1.html: %.xml xsl/html-single.xsl version.xml $(DIA_PNGS)
245 $(XSLTPROC) $(XSLPARAMS) xsl/html-single.xsl $< > $@
247 %.html.tar.gz: %.html/index.html
248 tar -czf $(<:/index.html=.tar.gz) $(<:/index.html=)
250 $(XML_FILES:=.txt) $(XML_SINGLE_FILES:=.txt) $(XML_SPLIT_FILES:=.txt): \
251 %.txt: %.xml version.xml
252 $(XSLTPROC) $(XSLPARAMS) xsl/text.xsl $< > $@.html
253 links -codepage utf-8 -dump $@.html | perl -pe 's/[\r\0]//g' > $@
254 rm -f $@.html
258 # GNU make configuration.
261 # If a rule bombs out, delete the target.
262 .DELETE_ON_ERROR:
264 # No default suffixes work here, don't waste time on them.
265 .SUFFIXES: