fix formatting in descriptions of symbols & shlibs files
[debian-policy.git] / Makefile
blob91e1ca8a0de17839f5552d8e84d276d96765ca5f
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)
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 policy/images subdirectory.
54 DIA_FILES := $(wildcard policy/images/*.dia)
56 # Dia diagrams converted to PNG in images/ subdirectory.
57 DIA_PNGS := $(DIA_FILES:.dia=.png)
59 # Dia diagrams converted to SVG in images/ subdirectory.
60 DIA_SVGS := $(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
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/_build/latex/policy.pdf \
92 policy/_build/policy.txt \
93 policy.html.tar.gz \
94 virtual-package-names-list.txt
96 # Source files that go into the Debian Policy manual.
97 POLICY_SOURCE := $(wildcard policy/*.rst) policy/index.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) \
106 $(XML_FILES:=.txt) \
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) \
113 $(DIA_PNGS) \
114 policy/index.rst \
115 policy.html.tar.gz \
116 version.md version.xml
120 # General build targets. These are the ones a human may build from the
121 # command line, or that are used by the Debian build system.
124 all: $(XML_FILES:=.validate) $(XML_SINGLE_FILES:=.validate) \
125 $(XML_FILES:=.html.tar.gz) $(POLICY_FILES)
127 clean distclean:
128 rm -f $(FILES_TO_CLEAN)
129 rm -rf $(DIRS_TO_CLEAN)
131 install:
132 $(MKDIR) $(DESTDIR)$(docdir)
133 $(MKDIR) $(DESTDIR)$(docdir)/fhs
134 $(INSTALL) $(POLICY_FILES) $(DESTDIR)$(docdir)
135 $(INSTALL) $(FHS_FILES) $(DESTDIR)$(docdir)/fhs
136 @set -ex; for file in $(XML_FILES); do \
137 tar -C $(DESTDIR)$(docdir) -zxf $$file.html.tar.gz; \
138 done
140 .PHONY: all clean distclean install
144 # Version files. These incorporate the version and release date of the
145 # debian-policy package into the various specifications as their version and
146 # publication date.
149 policy/index.rst: policy/index.rst.in debian/changelog
150 sed -e 's/@VERSION@/$(VERSION)/' -e 's/@DATE@/$(DATE)/' $< > $@
152 version.md: debian/changelog
153 rm -f $@
154 echo > $@
155 echo '---' >> $@
156 echo 'Debian Policy $(VERSION), $(DATE)' >> $@
158 version.xml: debian/changelog
159 rm -f $@
160 echo '<?xml version="1.0" encoding="utf-8"?>' > $@
161 echo '<!ENTITY version "$(VERSION)">' >> $@
162 echo '<!ENTITY date "$(DATE)">' >> $@
166 # Individual file and pattern build rules.
169 # There doesn't seem to be a better way of adding this include dependency.
170 debconf_specification.html: $(DEBCONF_INCLUDES)
171 debconf_specification.txt: $(DEBCONF_INCLUDES)
172 debconf_specification.validate: $(DEBCONF_INCLUDES)
173 policy-1.html: upgrading-checklist.xml
174 policy.txt: upgrading-checklist.xml
175 policy.validate: upgrading-checklist.xml
177 policy.html.tar.gz: policy/_build/html/index.html $(DIA_PNGS)
178 tar -czf policy.html.tar.gz \
179 --transform='s%policy/_build/html%policy.html%' \
180 policy/_build/html
182 policy/_build/html/index.html: $(POLICY_SOURCE) $(DIA_PNGS)
183 $(SPHINX) -M html policy policy/_build
185 policy/_build/latex/policy.pdf: $(POLICY_SOURCE) $(DIA_PNGS)
186 $(SPHINX) -M latexpdf policy policy/_build
188 policy/_build/policy.txt: $(POLICY_SOURCE)
189 rm -f $@
190 $(SPHINX) -M text policy policy/_build
191 cp policy/_build/text/index.txt $@
192 set -e; \
193 files=$$(egrep '^ (ch-|ap-|upgrading-)' policy/index.rst); \
194 for f in $$files; do \
195 printf "\n\n\n" >>$@; \
196 cat policy/_build/text/"$$f".txt >>$@; \
197 done
199 $(MDWN_FILES:=.txt): %.txt: %.md version.md
200 cat $^ > $@
201 test "$@" != "README.txt" || \
202 perl -pli -e 's,./Process.md,Process.txt,g' $@
204 $(MDWN_FILES:=.html): %.html: %.md version.md
205 cat $^ | $(MDWN) > $@
207 $(DIA_PNGS): policy/images/%.png: policy/images/%.dia
208 $(DIA) -e $@ $^
210 $(DIA_SVGS): policy/images/%.svg: policy/images/%.dia
211 $(DIA) -e $@ $^
213 # Suppress the table of contents for the standalone upgrading checklist.
214 upgrading-checklist-1.html: XSLPARAMS = --stringparam generate.toc ''
215 upgrading-checklist.txt: XSLPARAMS = --stringparam generate.toc ''
217 %.validate: %.xml version.xml
218 $(XMLLINT) $<
219 touch $@
221 %.html/index.html: %.xml xsl/html-chunk.xsl version.xml
222 mkdir -p $(@D)/images
223 $(XSLTPROC) $(XSLPARAMS) \
224 --stringparam base.dir $(@D)/ \
225 xsl/html-chunk.xsl $<
227 $(XML_SINGLE_FILES:=.html): %.html: %.xml xsl/html-single.xsl version.xml
228 $(XSLTPROC) $(XSLPARAMS) xsl/html-single.xsl $< > $@
230 %-1.html: %.xml xsl/html-single.xsl version.xml $(DIA_PNGS)
231 $(XSLTPROC) $(XSLPARAMS) xsl/html-single.xsl $< > $@
233 %.html.tar.gz: %.html/index.html
234 tar -czf $(<:/index.html=.tar.gz) $(<:/index.html=)
236 $(XML_FILES:=.txt) $(XML_SINGLE_FILES:=.txt) $(XML_SPLIT_FILES:=.txt): \
237 %.txt: %.xml version.xml
238 $(XSLTPROC) $(XSLPARAMS) xsl/text.xsl $< > $@.html
239 links -codepage utf-8 -dump $@.html | perl -pe 's/[\r\0]//g' > $@
240 rm -f $@.html
244 # GNU make configuration.
247 # If a rule bombs out, delete the target.
248 .DELETE_ON_ERROR:
250 # No default suffixes work here, don't waste time on them.
251 .SUFFIXES: