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
17 export DBLATEX
= dblatex
-p xsl
/dblatex.xsl
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.
28 datarootdir
= $(prefix)/share
29 datadir = $(datarootdir
)
30 docdir
= $(datadir)/doc
/$(PACKAGE
)
32 # Installation programs to use.
33 INSTALL
= install -p
-o root
-g root
-m
644
34 MKDIR
= install -d
-o root
-g root
-m
755
36 # Files included by debconf_specification.xml.
37 DEBCONF_INCLUDES
:= debconf
/commands.xml debconf
/priorities.xml \
38 debconf
/statuscodes.xml debconf
/types.xml
40 # doc-base description files for the documents we include.
41 DESC_FILES
:= autopkgtest copyright-format-1.0 debconf-spec debian-policy \
42 debian-menu-policy debian-perl-policy fhs
44 # Our local copy of the File Hierarchy Standard. We don't build this from
45 # source, but we do have a copy of the source in FHS_ARCHIVE.
46 FHS_ARCHIVE
:= fhs-2.3
-source.
tar.gz
47 FHS_FILES
:= fhs-2.3.html fhs-2.3.ps.gz fhs-2.3.txt.gz fhs-2.3.pdf.gz
49 # Markdown source files in the top-level directory. We generate text and
50 # HTML versions from these.
51 MDWN_FILES
:= README autopkgtest
53 # Dia diagrams in the dia/ subdirectory.
54 DIA_FILES
:= install.dia install-conffiles.dia upgrade.dia \
55 remove.dia purge.dia remove-purge.dia
57 # Dia diagrams converted to PNG in images/ subdirectory.
58 DIA_PNGS
:= $(addprefix images
/, $(DIA_FILES
:.dia
=.png
))
60 # Dia diagrams converted to PNG in images/ subdirectory.
61 DIA_SVGS
:= $(addprefix images
/, $(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 # The upgrading-checklist used to be a document of its own, which was merged
72 # with the conversion to DocBook. Keep backwards compatibility files.
73 XML_SPLIT_FILES
:= upgrading-checklist
75 # XML document version files. These are generated at build time from the
76 # current version and date information from the Debian changelog.
77 XML_VERSION
:= copyright-format
/version.xml debconf_spec
/include/version.xml \
80 # A list of the simple Policy files that we build at the top level and in
81 # subdirectories and include in the documentation directory of the generated
82 # package. The directories of HTML output are handled separately.
83 POLICY_FILES
:= $(MDWN_FILES
:=.html
) \
85 $(XML_FILES
:=-1.html
) \
87 $(XML_SINGLE_FILES
:=.html
) \
88 $(XML_SINGLE_FILES
:=.txt
) \
89 $(XML_SPLIT_FILES
:=-1.html
) \
90 $(XML_SPLIT_FILES
:=.txt
) \
92 policy
/_build
/latex
/policy.pdf \
94 virtual-package-names-list.txt
96 # Source files that go into the Debian Policy manual.
97 POLICY_SOURCE
:= $(wildcard policy
/*.rst
)
99 # Used by the clean rules. FILES_TO_CLEAN are individual generated files to
100 # remove. DIRS_TO_CLEAN are entire directories to remove.
101 DIRS_TO_CLEAN
:= $(XML_FILES
:=.html
) policy
/_build fhs
102 FILES_TO_CLEAN
:= $(MDWN_FILES
:=.html
) \
103 $(MDWN_FILES
:=.txt
) \
104 $(XML_FILES
:=.html.
tar.gz
) \
105 $(XML_FILES
:=-1.html
) \
107 $(XML_FILES
:=.validate
) \
108 $(XML_SINGLE_FILES
:=.html
) \
109 $(XML_SINGLE_FILES
:=.txt
) \
110 $(XML_SINGLE_FILES
:=.validate
) \
111 $(XML_SPLIT_FILES
:=-1.html
) \
112 $(XML_SPLIT_FILES
:=.txt
) \
115 version.md version.xml
119 # General build targets. These are the ones a human may build from the
120 # command line, or that are used by the Debian build system.
123 all: $(XML_FILES
:=.validate
) $(XML_SINGLE_FILES
:=.validate
) \
124 $(XML_FILES
:=.html.
tar.gz
) $(POLICY_FILES
)
127 rm -f
$(FILES_TO_CLEAN
)
128 rm -rf
$(DIRS_TO_CLEAN
)
131 $(MKDIR
) $(DESTDIR
)$(docdir
)
132 $(MKDIR
) $(DESTDIR
)$(docdir
)/fhs
133 $(INSTALL
) $(POLICY_FILES
) $(DESTDIR
)$(docdir
)
134 $(INSTALL
) $(FHS_FILES
) $(DESTDIR
)$(docdir
)/fhs
135 @set
-ex
; for file in
$(XML_FILES
); do \
136 tar -C
$(DESTDIR
)$(docdir
) -zxf
$$file.html.
tar.gz
; \
139 .PHONY
: all clean distclean install
143 # Version files. These incorporate the version and release date of the
144 # debian-policy package into the various specifications as their version and
148 version.md
: debian
/changelog
152 echo
'Debian Policy $(VERSION), $(DATE)' >> $@
154 version.xml
: debian
/changelog
156 echo
'<?xml version="1.0" encoding="utf-8"?>' > $@
157 echo
'<!ENTITY version "$(VERSION)">' >> $@
158 echo
'<!ENTITY date "$(DATE)">' >> $@
162 # Individual file and pattern build rules.
165 # There doesn't seem to be a better way of adding this include dependency.
166 debconf_specification.html
: $(DEBCONF_INCLUDES
)
167 debconf_specification.txt
: $(DEBCONF_INCLUDES
)
168 debconf_specification.validate
: $(DEBCONF_INCLUDES
)
169 policy-1.html
: upgrading-checklist.xml
170 policy.html
/index.html
: upgrading-checklist.xml
171 policy.pdf
: upgrading-checklist.xml
172 policy.ps
: upgrading-checklist.xml
173 policy.txt
: upgrading-checklist.xml
174 policy.validate
: upgrading-checklist.xml
176 policy.html.
tar.gz
: policy
/_build
/html
/index.html
177 tar -czf policy.html.
tar.gz \
178 --transform
='s%policy/_build/html%policy.html%' \
181 policy
/_build
/html
/index.html
: $(POLICY_SOURCE
) $(PNG_FILES
)
182 $(SPHINX
) -M html policy policy
/_build
184 policy
/_build
/latex
/policy.pdf
: $(POLICY_SOURCE
) $(PNG_FILES
)
185 $(SPHINX
) -M latexpdf policy policy
/_build
187 $(MDWN_FILES
:=.txt
): %.txt
: %.md version.md
189 test "$@" != "README.txt" || \
190 perl
-pli
-e
's,./Process.md,Process.txt,g' $@
192 $(MDWN_FILES
:=.html
): %.html
: %.md version.md
193 cat
$^ |
$(MDWN
) > $@
195 $(DIA_PNGS
): images
/%.png
: dia
/%.dia
199 $(DIA_SVGS
): images
/%.svg
: dia
/%.dia
203 # Suppress the table of contents for the standalone upgrading checklist.
204 upgrading-checklist-1.html
: XSLPARAMS
= --stringparam generate.toc
''
205 upgrading-checklist.txt
: XSLPARAMS
= --stringparam generate.toc
''
207 %.validate
: %.xml version.xml
211 %.html
/index.html
: %.xml xsl
/html-chunk.xsl version.xml
$(DIA_PNGS
)
212 mkdir
-p
$(@D
)/images
213 $(XSLTPROC
) $(XSLPARAMS
) \
214 --stringparam base.
dir $(@D
)/ \
215 xsl
/html-chunk.xsl
$<
216 cp
$(DIA_PNGS
) $(@D
)/images
218 $(XML_SINGLE_FILES
:=.html
): %.html
: %.xml xsl
/html-single.xsl version.xml
219 $(XSLTPROC
) $(XSLPARAMS
) xsl
/html-single.xsl
$< > $@
221 %-1.html
: %.xml xsl
/html-single.xsl version.xml
$(DIA_PNGS
)
222 $(XSLTPROC
) $(XSLPARAMS
) xsl
/html-single.xsl
$< > $@
224 %.html.
tar.gz
: %.html
/index.html
225 tar -czf
$(<:/index.html
=.
tar.gz
) $(<:/index.html
=)
227 $(XML_FILES
:=.txt
) $(XML_SINGLE_FILES
:=.txt
) $(XML_SPLIT_FILES
:=.txt
): \
228 %.txt
: %.xml version.xml
229 $(XSLTPROC
) $(XSLPARAMS
) xsl
/text.xsl
$< > $@.html
230 links
-codepage utf-8
-dump
$@.html | perl
-pe
's/[\r\0]//g' > $@
233 %.ps
: %.xml version.xml
$(DIA_SVGS
)
236 %.pdf
: %.xml version.xml
$(DIA_SVGS
)
241 # GNU make configuration.
244 # If a rule bombs out, delete the target.
247 # No default suffixes work here, don't waste time on them.