summaryrefslogtreecommitdiff
path: root/doc/Makefile
blob: 751e85af52a4a78a5d873a13b92177f078c11416 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
ASCIIDOC := asciidoc
A2X := a2x

ASCIIDOC_FLAGS := -a toc -d manpage -a revnumber=$(VERSION)
A2X_FLAGS := -d manpage -a revnumber=$(VERSION)

ASCIIDOC_SOURCES := \
        doc/cenv.9.txt \
        doc/init.9.txt \
        doc/intro.9.txt \
        doc/style.9.txt \
        doc/xbuild.9.txt

ASCIIDOC_MANDOCS := $(patsubst %.9.txt,%.9,$(ASCIIDOC_SOURCES))
ASCIIDOC_HTMLDOCS := $(patsubst %.9.txt,%.9.html,$(ASCIIDOC_SOURCES))

define DOC_HELP
	@printf '* mandocs                  - Build man pages\n'
	@printf '* htmldocs                 - Build HTML man pages\n'
endef

define DOC_INSTALL_HELP
	@printf '  install-mandocs          - Install man pages\n'
	@printf '  install-htmldocs         - Install HTML man pages\n'
endef

# Expose intermediate DocBook files for correct parallel builds.
%.9.xml: %.9.txt doc/asciidoc.conf $(ALL_MAKEFILES)
	$(call xbuild_action_mkdir,$@)
	$(Q)$(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -o $@ $<

%.9: %.9.xml doc/asciidoc.conf $(ALL_MAKEFILES)
	$(call xbuild_action,MAN,$@) \
		$(A2X) $(A2X_FLAGS) -f manpage $<

%.9.html: %.9.txt doc/asciidoc.conf $(ALL_MAKEFILES)
	$(call xbuild_action,HTML,$@) \
		$(ASCIIDOC) $(ASCIIDOC_FLAGS) -b html5 -o $@ $<

.PHONY: mandocs
mandocs: $(ASCIIDOC_MANDOCS)

.PHONY: htmldocs
htmldocs: $(ASCIIDOC_HTMLDOCS)

.PHONY: docs
docs: mandocs htmldocs

define mandocs_install_targets
	$(foreach manpage,$(notdir $(ASCIIDOC_MANDOCS)),$(manpage)_man_install)
endef

%_man_install: doc/%
	install -D -m 644 $< $(DESTDIR)$(PREFIX)/$(DATAROOTDIR)/man/man9/$*

.PHONY: install-mandocs
install-mandocs: $(mandocs_install_targets)

.PHONY: install-htmldocs
install-htmldocs: $(htmldocs_install_targets)

define htmldocs_install_targets
	$(foreach htmlpage,$(notdir $(ASCIIDOC_HTMLDOCS)),$(htmlpage)_html_install)
endef

%_html_install: doc/%
	install -D -m 644 $< $(DESTDIR)$(PREFIX)/$(DATAROOTDIR)/doc/x15/$*

.PHONY: install-docs
install-docs: install-mandocs install-htmldocs

define clean_docs
	$(Q)rm -f $(ASCIIDOC_MANDOCS) \
	$(ASCIIDOC_HTMLDOCS)
endef

.PHONY: clean-docs
clean-docs:
	$(call clean_docs)

.PHONY: distclean-docs
distclean-docs: clean-docs