| 1 |
XEN_ROOT=$(CURDIR)/.. |
| 2 |
include $(XEN_ROOT)/Config.mk |
| 3 |
-include $(XEN_ROOT)/config/Docs.mk |
| 4 |
|
| 5 |
VERSION := $(shell $(MAKE) -C $(XEN_ROOT)/xen --no-print-directory xenversion) |
| 6 |
DATE := $(call date,"+%Y-%m-%d") |
| 7 |
|
| 8 |
DOC_ARCHES := arm ppc riscv x86_32 x86_64 |
| 9 |
MAN_SECTIONS := 1 5 7 8 |
| 10 |
|
| 11 |
# Documentation sources to build |
| 12 |
MAN-SRC-y := $(sort $(basename $(wildcard man/*.pod man/*.pandoc))) |
| 13 |
|
| 14 |
RST-SRC-y := $(sort $(filter-out %index.rst,$(shell find * -type f -name '*.rst' -print))) |
| 15 |
|
| 16 |
TXTSRC-y := $(sort $(shell find misc -name '*.txt' -print)) |
| 17 |
|
| 18 |
PANDOCSRC-y := $(sort $(shell find designs/ features/ misc/ process/ specs/ \( -name '*.pandoc' -o -name '*.md' \) -print)) |
| 19 |
|
| 20 |
# Documentation targets |
| 21 |
$(foreach i,$(MAN_SECTIONS), \ |
| 22 |
$(eval DOC_MAN$(i) := $(patsubst man/%.$(i),man$(i)/%.$(i), \ |
| 23 |
$(filter %.$(i),$(MAN-SRC-y))))) |
| 24 |
|
| 25 |
DOC_HTML := html/SUPPORT.html \ |
| 26 |
$(patsubst %.pandoc,html/%.html,$(PANDOCSRC-y)) \ |
| 27 |
$(patsubst %.md,html/%.html,$(PANDOCSRC-y)) \ |
| 28 |
$(patsubst %.rst,html/%.html,$(RST-SRC-y)) \ |
| 29 |
$(patsubst %,html/%.html,$(MAN-SRC-y)) \ |
| 30 |
$(patsubst %.txt,html/%.txt,$(TXTSRC-y)) \ |
| 31 |
$(patsubst %,html/hypercall/%/index.html,$(DOC_ARCHES)) |
| 32 |
DOC_TXT := $(patsubst %.txt,txt/%.txt,$(TXTSRC-y)) \ |
| 33 |
$(patsubst %.pandoc,txt/%.txt,$(PANDOCSRC-y)) \ |
| 34 |
$(patsubst %.md,txt/%.txt,$(PANDOCSRC-y)) \ |
| 35 |
$(patsubst %.rst,txt/%.txt,$(RST-SRC-y)) \ |
| 36 |
$(patsubst %,txt/%.txt,$(MAN-SRC-y)) |
| 37 |
DOC_PDF := $(patsubst %.pandoc,pdf/%.pdf,$(PANDOCSRC-y)) \ |
| 38 |
$(patsubst %.md,pdf/%.pdf,$(PANDOCSRC-y)) \ |
| 39 |
$(patsubst %.rst,pdf/%.pdf,$(RST-SRC-y)) |
| 40 |
|
| 41 |
# Top level build targets |
| 42 |
.PHONY: all |
| 43 |
all: build |
| 44 |
|
| 45 |
.PHONY: build |
| 46 |
build: html txt pdf man-pages figs |
| 47 |
|
| 48 |
.PHONY: sphinx-html |
| 49 |
sphinx-html: |
| 50 |
sphinx-build -b html . sphinx/html |
| 51 |
|
| 52 |
.PHONY: html |
| 53 |
html: $(DOC_HTML) html/index.html |
| 54 |
|
| 55 |
.PHONY: txt |
| 56 |
txt: $(DOC_TXT) |
| 57 |
|
| 58 |
.PHONY: figs |
| 59 |
figs: |
| 60 |
ifneq ($(FIG2DEV),) |
| 61 |
$(MAKE) -C figs |
| 62 |
else |
| 63 |
@echo "fig2dev (transfig) not installed; skipping figs." |
| 64 |
endif |
| 65 |
|
| 66 |
.PHONY: pdf |
| 67 |
pdf: $(DOC_PDF) |
| 68 |
|
| 69 |
.PHONY: clean |
| 70 |
clean: clean-man-pages |
| 71 |
$(MAKE) -C figs clean |
| 72 |
rm -rf .word_count *.aux *.dvi *.bbl *.blg *.glo *.idx *~ |
| 73 |
rm -rf *.ilg *.log *.ind *.toc *.bak *.tmp core |
| 74 |
rm -rf html txt pdf sphinx/html |
| 75 |
|
| 76 |
.PHONY: distclean |
| 77 |
distclean: clean |
| 78 |
rm -rf $(XEN_ROOT)/config/Docs.mk config.log config.status config.cache \ |
| 79 |
autom4te.cache |
| 80 |
|
| 81 |
# Top level install targets |
| 82 |
|
| 83 |
.PHONY: man-pages install-man-pages clean-man-pages uninstall-man-pages |
| 84 |
|
| 85 |
# Metarules for generating manpages. Run with $(1) substitued for section |
| 86 |
define GENERATE_MANPAGE_RULES |
| 87 |
|
| 88 |
# Real manpages |
| 89 |
man$(1)/%.$(1): man/%.$(1).pod Makefile |
| 90 |
ifneq ($(POD2MAN),) |
| 91 |
@$(INSTALL_DIR) $$(@D) |
| 92 |
$(POD2MAN) --release=$(VERSION) --name=$$* -s $(1) -c "Xen" $$< $$@ |
| 93 |
else |
| 94 |
@echo "pod2man not installed; skipping $$@" |
| 95 |
endif |
| 96 |
|
| 97 |
man$(1)/%.$(1): man/%.$(1).pandoc Makefile |
| 98 |
ifneq ($(PANDOC),) |
| 99 |
@$(INSTALL_DIR) $$(@D) |
| 100 |
$(PANDOC) --standalone -V title=$$* -V section=$(1) \ |
| 101 |
-V date="$(DATE)" -V footer="$(VERSION)" \ |
| 102 |
-V header=Xen $$< -t man --output $$@ |
| 103 |
else |
| 104 |
@echo "pandoc not installed; skipping $$@" |
| 105 |
endif |
| 106 |
|
| 107 |
# HTML manpages |
| 108 |
# sed used to fix up links between man-pages |
| 109 |
# 1) L<xl(1)> -> L<xl(1)|relative:xl.1.html> |
| 110 |
# 2) <a href="relative:xl.1.html"> -> <a href="xl.1.html"> |
| 111 |
html/man/%.$(1).html: man/%.$(1).pod Makefile |
| 112 |
ifneq ($(POD2HTML),) |
| 113 |
@$(INSTALL_DIR) $$(@D) |
| 114 |
sed -r -e 's%L<([^>]+)\(([1-9])\)>%L<\1(\2)|relative:\1.\2.html>%g' $$< | \ |
| 115 |
$(POD2HTML) | \ |
| 116 |
sed -r -e 's%( href=")relative:%\1%g' > $$@ |
| 117 |
else |
| 118 |
@echo "pod2html not installed; skipping $$@" |
| 119 |
endif |
| 120 |
|
| 121 |
html/man/%.$(1).html: man/%.$(1).pandoc Makefile |
| 122 |
ifneq ($(PANDOC),) |
| 123 |
@$(INSTALL_DIR) $$(@D) |
| 124 |
$(PANDOC) --standalone $$< -t html --toc --output $$@ |
| 125 |
else |
| 126 |
@echo "pandoc not installed; skipping $$@" |
| 127 |
endif |
| 128 |
|
| 129 |
# Text manpages |
| 130 |
txt/man/%.$(1).txt: man/%.$(1).pod Makefile |
| 131 |
ifneq ($(POD2TEXT),) |
| 132 |
@$(INSTALL_DIR) $$(@D) |
| 133 |
$(POD2TEXT) $$< $$@ |
| 134 |
else |
| 135 |
@echo "pod2text not installed; skipping $$@" |
| 136 |
endif |
| 137 |
|
| 138 |
txt/man/%.$(1).txt: man/%.$(1).pandoc Makefile |
| 139 |
ifneq ($(PANDOC),) |
| 140 |
@$(INSTALL_DIR) $$(@D) |
| 141 |
$(PANDOC) --standalone $$< -t plain --output $$@ |
| 142 |
else |
| 143 |
@echo "pandoc not installed; skipping $$@" |
| 144 |
endif |
| 145 |
|
| 146 |
# Build |
| 147 |
.PHONY: man$(1)-pages |
| 148 |
man$(1)-pages: $$(DOC_MAN$(1)) |
| 149 |
|
| 150 |
# Install |
| 151 |
.PHONY: install-man$(1)-pages |
| 152 |
install-man$(1)-pages: man$(1)-pages |
| 153 |
$(INSTALL_DIR) $(DESTDIR)$(mandir) |
| 154 |
[ ! -d man$(1) ] || cp -r man$(1) $(DESTDIR)$(mandir) |
| 155 |
|
| 156 |
# Clean |
| 157 |
.PHONY: clean-man$(1)-pages |
| 158 |
clean-man$(1)-pages: |
| 159 |
rm -rf man$(1) |
| 160 |
|
| 161 |
# Uninstall |
| 162 |
.PHONY: uninstall-man$(1)-pages |
| 163 |
uninstall-man$(1)-pages: |
| 164 |
rm -f $(addprefix $(DESTDIR)$(mandir)/,$(DOC_MAN$(1))) |
| 165 |
|
| 166 |
# Link buld/install/clean to toplevel rules |
| 167 |
man-pages: man$(1)-pages |
| 168 |
install-man-pages: install-man$(1)-pages |
| 169 |
clean-man-pages: clean-man$(1)-pages |
| 170 |
uninstall-man-pages: uninstall-man$(1)-pages |
| 171 |
|
| 172 |
endef |
| 173 |
|
| 174 |
# Generate manpage rules for each section |
| 175 |
$(foreach i,$(MAN_SECTIONS),$(eval $(call GENERATE_MANPAGE_RULES,$(i)))) |
| 176 |
|
| 177 |
.PHONY: install-html |
| 178 |
install-html: html txt figs |
| 179 |
$(INSTALL_DIR) $(DESTDIR)$(docdir) |
| 180 |
[ ! -d html ] || cp -R html $(DESTDIR)$(docdir) |
| 181 |
rm -f $(DESTDIR)$(docdir)/html/hypercall/*/.deps |
| 182 |
|
| 183 |
.PHONY: install |
| 184 |
install: install-man-pages install-html |
| 185 |
|
| 186 |
.PHONY: uninstall-html |
| 187 |
uninstall-html: |
| 188 |
rm -rf $(DESTDIR)$(docdir) |
| 189 |
|
| 190 |
.PHONY: uninstall |
| 191 |
uninstall: uninstall-man-pages uninstall-html |
| 192 |
|
| 193 |
# Individual file build targets |
| 194 |
html/index.html: $(DOC_HTML) $(CURDIR)/gen-html-index INDEX |
| 195 |
$(PERL) -w -- $(CURDIR)/gen-html-index -i INDEX html $(DOC_HTML) |
| 196 |
|
| 197 |
html/%.txt: %.txt |
| 198 |
@$(INSTALL_DIR) $(@D) |
| 199 |
$(INSTALL_DATA) $< $@ |
| 200 |
|
| 201 |
|
| 202 |
# For non-x86 arches exclude the subarch whole x86 arch. |
| 203 |
$(foreach i,$(filter-out x86_32 x86_64,$(DOC_ARCHES)),html/hypercall/$(i)/index.html): EXTRA_EXCLUDE := -X arch-x86 |
| 204 |
|
| 205 |
html/hypercall/%/index.html: $(CURDIR)/xen-headers Makefile |
| 206 |
rm -rf $(@D) |
| 207 |
$(INSTALL_DIR) $(@D) |
| 208 |
$(PERL) -w $(CURDIR)/xen-headers -O $(@D) \ |
| 209 |
-T 'arch-$* - Xen public headers' \ |
| 210 |
$(patsubst %,-X arch-%,$(filter-out $*,$(DOC_ARCHES))) \ |
| 211 |
$(patsubst %,-X xen-%,$(filter-out $*,$(DOC_ARCHES))) \ |
| 212 |
$(EXTRA_EXCLUDE) \ |
| 213 |
$(XEN_ROOT)/xen include/public include/xen/errno.h |
| 214 |
|
| 215 |
-include $(wildcard html/hypercall/*/.deps) |
| 216 |
|
| 217 |
txt/%.txt: %.txt |
| 218 |
@$(INSTALL_DIR) $(@D) |
| 219 |
$(INSTALL_DATA) $< $@ |
| 220 |
|
| 221 |
# Metarule for generating pandoc rules. |
| 222 |
define GENERATE_PANDOC_RULE_RAW |
| 223 |
$(1): $(2) |
| 224 |
ifneq ($(PANDOC),) |
| 225 |
@$(INSTALL_DIR) $$(@D) |
| 226 |
$(PANDOC) --number-sections --toc --standalone $$< --output $$@ |
| 227 |
else |
| 228 |
@echo "pandoc not installed; skipping $$@" |
| 229 |
endif |
| 230 |
endef |
| 231 |
define GENERATE_PANDOC_RULE |
| 232 |
# $(1) is the target documentation format. $(2) is the source format. |
| 233 |
$(call GENERATE_PANDOC_RULE_RAW,$(1)/%.$(1),%.$(2)) |
| 234 |
endef |
| 235 |
|
| 236 |
$(foreach dst-fmt,pdf txt html,\ |
| 237 |
$(foreach src-fmt,pandoc md rst,\ |
| 238 |
$(eval $(call GENERATE_PANDOC_RULE,$(dst-fmt),$(src-fmt))))) |
| 239 |
|
| 240 |
$(eval $(call GENERATE_PANDOC_RULE_RAW,html/SUPPORT.html,$(XEN_ROOT)/SUPPORT.md)) |
| 241 |
|
| 242 |
ifeq (,$(findstring clean,$(MAKECMDGOALS))) |
| 243 |
$(XEN_ROOT)/config/Docs.mk: |
| 244 |
$(error You have to run ./configure before building docs) |
| 245 |
endif |