Merge branch 'rst-multifile' of https://anonscm.debian.org/git/dbnpolicy/policy into...
[debian-policy.git] / Makefile
blob278a99e6517caea7ccf21c5efb8c066b4aa15cc0
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 MDWN = multimarkdown
19 export XMLLINT = xmllint --nonet --noout --postvalid --xinclude
20 export XSLTPROC = xsltproc --nonet --xinclude
21 export DIA = dia
23 # Installation directories. Normally this is only used by debian/rules
24 # build, which will set DESTDIR to put the installation under the temporary
25 # Debian packaging directory.
26 prefix = /usr
27 datarootdir = $(prefix)/share
28 datadir = $(datarootdir)
29 docdir = $(datadir)/doc/$(PACKAGE)
31 # Installation programs to use.
32 INSTALL = install -p -o root -g root -m 644
33 MKDIR = install -d -o root -g root -m 755
35 # Files included by debconf_specification.xml.
36 DEBCONF_INCLUDES := debconf/commands.xml debconf/priorities.xml \
37 debconf/statuscodes.xml debconf/types.xml
39 # doc-base description files for the documents we include.
40 DESC_FILES := autopkgtest copyright-format-1.0 debconf-spec debian-policy \
41 debian-menu-policy debian-perl-policy fhs
43 # Our local copy of the File Hierarchy Standard. We don't build this from
44 # source, but we do have a copy of the source in FHS_ARCHIVE.
45 FHS_ARCHIVE := fhs-2.3-source.tar.gz
46 FHS_FILES := fhs-2.3.html fhs-2.3.ps.gz fhs-2.3.txt.gz fhs-2.3.pdf.gz
48 # Markdown source files in the top-level directory. We generate text and
49 # HTML versions from these.
50 MDWN_FILES := README autopkgtest
52 # Dia diagrams in the dia/ subdirectory.
53 DIA_FILES := install.dia install-conffiles.dia upgrade.dia \
54 remove.dia purge.dia remove-purge.dia
56 # Dia diagrams converted to PNG in images/ subdirectory.
57 DIA_PNGS := $(addprefix images/, $(DIA_FILES:.dia=.png))
59 # Dia diagrams converted to PNG in images/ subdirectory.
60 DIA_SVGS := $(addprefix images/, $(DIA_FILES:.dia=.svg))
62 # DocBook source files in the top-level directory. We do some common actions
63 # with each of these: build text, HTML, and one-page HTML output.
64 XML_FILES := menu-policy perl-policy policy
66 # DocBook source files in the top-level directory that should only generate
67 # single-page HTML output (no split HTML output).
68 XML_SINGLE_FILES := copyright-format-1.0 debconf_specification
70 # The upgrading-checklist used to be a document of its own, which was merged
71 # with the conversion to DocBook. Keep backwards compatibility files.
72 XML_SPLIT_FILES := upgrading-checklist
74 # XML document version files. These are generated at build time from the
75 # current version and date information from the Debian changelog.
76 XML_VERSION := copyright-format/version.xml debconf_spec/include/version.xml \
77 version.xml
79 # A list of the simple Policy files that we build at the top level and in
80 # subdirectories and include in the documentation directory of the generated
81 # package. The directories of HTML output are handled separately.
82 POLICY_FILES := $(MDWN_FILES:=.html) \
83 $(MDWN_FILES:=.txt) \
84 $(XML_FILES:=-1.html) \
85 $(XML_FILES:=.txt) \
86 $(XML_SINGLE_FILES:=.html) \
87 $(XML_SINGLE_FILES:=.txt) \
88 $(XML_SPLIT_FILES:=-1.html) \
89 $(XML_SPLIT_FILES:=.txt) \
90 README.css \
91 policy.ps policy.pdf \
92 virtual-package-names-list.txt
94 # Used by the clean rules. FILES_TO_CLEAN are individual generated files to
95 # remove. DIRS_TO_CLEAN are entire directories to remove.
96 DIRS_TO_CLEAN := $(XML_FILES:=.html) fhs
97 FILES_TO_CLEAN := $(MDWN_FILES:=.html) \
98 $(MDWN_FILES:=.txt) \
99 $(XML_FILES:=.html.tar.gz) \
100 $(XML_FILES:=-1.html) \
101 $(XML_FILES:=.txt) \
102 $(XML_FILES:=.validate) \
103 $(XML_SINGLE_FILES:=.html) \
104 $(XML_SINGLE_FILES:=.txt) \
105 $(XML_SINGLE_FILES:=.validate) \
106 $(XML_SPLIT_FILES:=-1.html) \
107 $(XML_SPLIT_FILES:=.txt) \
108 $(DIA_PNGS) \
109 $(DIA_SVGS) \
110 version.md version.xml \
111 policy.pdf policy.ps
115 # General build targets. These are the ones a human may build from the
116 # command line, or that are used by the Debian build system.
119 all: $(XML_FILES:=.validate) $(XML_SINGLE_FILES:=.validate) \
120 $(XML_FILES:=.html.tar.gz) $(POLICY_FILES)
122 clean distclean:
123 rm -f $(FILES_TO_CLEAN)
124 rm -rf $(DIRS_TO_CLEAN)
126 install:
127 $(MKDIR) $(DESTDIR)$(docdir)
128 $(MKDIR) $(DESTDIR)$(docdir)/fhs
129 $(INSTALL) $(POLICY_FILES) $(DESTDIR)$(docdir)
130 $(INSTALL) $(FHS_FILES) $(DESTDIR)$(docdir)/fhs
131 @set -ex; for file in $(XML_FILES); do \
132 tar -C $(DESTDIR)$(docdir) -zxf $$file.html.tar.gz; \
133 done
135 .PHONY: all clean distclean install
139 # Version files. These incorporate the version and release date of the
140 # debian-policy package into the various specifications as their version and
141 # publication date.
144 version.md: debian/changelog
145 rm -f $@
146 echo > $@
147 echo '---' >> $@
148 echo 'Debian Policy $(VERSION), $(DATE)' >> $@
150 version.xml: debian/changelog
151 rm -f $@
152 echo '<?xml version="1.0" encoding="utf-8"?>' > $@
153 echo '<!ENTITY version "$(VERSION)">' >> $@
154 echo '<!ENTITY date "$(DATE)">' >> $@
158 # Individual file and pattern build rules.
161 # There doesn't seem to be a better way of adding this include dependency.
162 debconf_specification.html: $(DEBCONF_INCLUDES)
163 debconf_specification.txt: $(DEBCONF_INCLUDES)
164 debconf_specification.validate: $(DEBCONF_INCLUDES)
165 policy-1.html: upgrading-checklist.xml
166 policy.html/index.html: upgrading-checklist.xml
167 policy.pdf: upgrading-checklist.xml
168 policy.ps: upgrading-checklist.xml
169 policy.txt: upgrading-checklist.xml
170 policy.validate: upgrading-checklist.xml
172 policy.html/index.html: $(PNG_FILES)
174 $(MDWN_FILES:=.txt): %.txt: %.md version.md
175 cat $^ > $@
176 test "$@" != "README.txt" || \
177 perl -pli -e 's,./Process.md,Process.txt,g' $@
179 $(MDWN_FILES:=.html): %.html: %.md version.md
180 cat $^ | $(MDWN) > $@
182 $(DIA_PNGS): images/%.png: dia/%.dia
183 mkdir -p images
184 $(DIA) -e $@ $^
186 $(DIA_SVGS): images/%.svg: dia/%.dia
187 mkdir -p images
188 $(DIA) -e $@ $^
190 # Suppress the table of contents for the standalone upgrading checklist.
191 upgrading-checklist-1.html: XSLPARAMS = --stringparam generate.toc ''
192 upgrading-checklist.txt: XSLPARAMS = --stringparam generate.toc ''
194 %.validate: %.xml version.xml
195 $(XMLLINT) $<
196 touch $@
198 %.html/index.html: %.xml xsl/html-chunk.xsl version.xml $(DIA_PNGS)
199 mkdir -p $(@D)/images
200 $(XSLTPROC) $(XSLPARAMS) \
201 --stringparam base.dir $(@D)/ \
202 xsl/html-chunk.xsl $<
203 cp $(DIA_PNGS) $(@D)/images
205 $(XML_SINGLE_FILES:=.html): %.html: %.xml xsl/html-single.xsl version.xml
206 $(XSLTPROC) $(XSLPARAMS) xsl/html-single.xsl $< > $@
208 %-1.html: %.xml xsl/html-single.xsl version.xml $(DIA_PNGS)
209 $(XSLTPROC) $(XSLPARAMS) xsl/html-single.xsl $< > $@
211 %.html.tar.gz: %.html/index.html
212 tar -czf $(<:/index.html=.tar.gz) $(<:/index.html=)
214 $(XML_FILES:=.txt) $(XML_SINGLE_FILES:=.txt) $(XML_SPLIT_FILES:=.txt): \
215 %.txt: %.xml version.xml
216 $(XSLTPROC) $(XSLPARAMS) xsl/text.xsl $< > $@.html
217 links -codepage utf-8 -dump $@.html | perl -pe 's/[\r\0]//g' > $@
218 rm -f $@.html
220 %.ps: %.xml version.xml $(DIA_SVGS)
221 $(DBLATEX) --ps $<
223 %.pdf: %.xml version.xml $(DIA_SVGS)
224 $(DBLATEX) --pdf $<
228 # GNU make configuration.
231 # If a rule bombs out, delete the target.
232 .DELETE_ON_ERROR:
234 # No default suffixes work here, don't waste time on them.
235 .SUFFIXES: