Makefile 2.91 KB
Newer Older
1 2
#!/usr/bin/make -f
#
3
# This file is part of FreedomBox.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
MANUAL_URL="https://wiki.debian.org/FreedomBox/Manual?action=show&mimetype=text%2Fdocbook"

20
OUTPUTS=freedombox-manual.pdf plinth.1 manual-pages
21

22 23 24 25 26 27 28 29 30 31 32
# In order to debug various problems with the documents especially
# intermediate LaTeX state, run make as follows:
#
#   $ make DEBUG=true
#   or
#   $ make DEBUG=true <target>
#
XMLTO_DEBUG_FLAGS=
ifneq ($(DEBUG),)
    XMLTO_DEBUG_FLAGS=--noclean -p '--debug'
endif
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

all: $(OUTPUTS)

# Do not edit the manual page in this directory.  The manual is
# maintained as separate pages on the FreedomBox wiki and aggregated
# into a single page using the MoinMoin include feature.  Then it is
# exported as Docbook format and kept here.
#
# It is important to keep a copy of the manual in this source tree
# because Debian packages promise an entire source tree including the
# documentation.
#
# Use 'make fetch' to retrieve the latest manual from the wiki and
# commit it to the repository.  The wiki page is already reviewed, so
# commits that update the manual just using the 'fetch' target do not
# require further reviews.
.PHONY: fetch
fetch:
	wget --quiet -O - $(MANUAL_URL) | \
	  xmllint --format --output freedombox-manual.raw.xml -
	xsltproc fetch-images.xslt freedombox-manual.raw.xml | sort -u | \
	  awk '{print "wget --quiet -O images/" $$1 " " $$2}' | sh
55 56 57 58 59 60 61
	./fetch-manual-pages

.PHONY: manual-pages
manual-pages-list:=$(shell cat manual-pages.list) freedombox-manual
manual-pages-part-html:=$(patsubst %, %.part.html, $(manual-pages-list))
manual-pages-html:=$(patsubst %, %.html, $(manual-pages-list))
manual-pages-xml:=$(patsubst %, %.xml, $(manual-pages-list))
62

63
manual-pages: $(manual-pages-part-html)
64 65

%.pdf: %.xml
66
	xmlto $(XMLTO_DEBUG_FLAGS) --with-dblatex pdf $<
James Vasile's avatar
James Vasile committed
67 68

%.part.html: %.html
69
	perl -pe 'BEGIN {undef $$/} s/.*<body[^>]*>(.*)<\/body\s*>.*/$$1/si' $< > $@
James Vasile's avatar
James Vasile committed
70

71 72 73 74 75 76 77
freedombox-manual.xml: freedombox-manual.raw.xml fixes.xslt
	xsltproc --output $@ fixes.xslt $<

%.xml: %.raw.xml manual-page-fixes.xslt
	xsltproc --output $@ manual-page-fixes.xslt $<
	./post-processor remove-footer $@
	./post-processor fix-wiki-urls $@
James Vasile's avatar
James Vasile committed
78

79
%.html: %.xml
80
	docbook2html --nochunks $<
81

82 83 84
%.1: %.xml
	xmlto man $<

85 86
.PHONY: clean
clean:
87
	rm -f $(manual-pages-html) $(manual-pages-part-html) $(manual-pages-xml)
88
	rm -f $(OUTPUTS)