aboutsummaryrefslogtreecommitdiffstats
path: root/docs/Makefile
blob: 053d7af815f9a1fca3f795dfe7bf20ebe82ed2cf (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/make -f

XEN_ROOT=$(CURDIR)/..
include $(XEN_ROOT)/Config.mk
include $(XEN_ROOT)/docs/Docs.mk

VERSION		= xen-unstable

DOC_MAN5SRC	:= $(wildcard man/*.pod.5)
DOC_MAN1SRC	:= $(wildcard man/*.pod.1)
DOC_MAN1	:= $(patsubst man/%.pod.1,man1/%.1,$(DOC_MAN1SRC))
DOC_MAN5	:= $(patsubst man/%.pod.5,man5/%.5,$(DOC_MAN5SRC))
DOC_MARKDOWN	:= $(wildcard misc/*.markdown)
DOC_HTML	:= $(patsubst %.markdown,html/%.html,$(DOC_MARKDOWN)) \
		   $(patsubst man/%.pod.1,html/man/%.1.html,$(DOC_MAN1SRC)) \
		   $(patsubst man/%.pod.5,html/man/%.5.html,$(DOC_MAN5SRC)) \
		   $(patsubst %.txt,html/%.txt,$(wildcard misc/*.txt)) \
		   html/hypercall/index.html
DOC_TXT         := $(patsubst %.txt,txt/%.txt,$(wildcard misc/*.txt)) \
		   $(patsubst %.markdown,txt/%.txt,$(DOC_MARKDOWN)) \
		   $(patsubst man/%.pod.1,txt/man/%.1.txt,$(DOC_MAN1SRC)) \
		   $(patsubst man/%.pod.5,txt/man/%.5.txt,$(DOC_MAN5SRC))

.PHONY: all
all: build

.PHONY: build
build: html txt man-pages figs

.PHONY: html
html: $(DOC_HTML) html/index.html

.PHONY: txt
txt:
	@if which $(POD2TEXT) 1>/dev/null 2>/dev/null; then \
	$(MAKE) $(DOC_TXT); else              \
	echo "pod2text not installed; skipping text outputs."; fi

.PHONY: figs
figs:
	@set -e ; if which $(FIG2DEV) 1>/dev/null 2>/dev/null; then \
	set -x; $(MAKE) -C figs ; else                   \
	echo "fig2dev (transfig) not installed; skipping figs."; fi

.PHONY: man-pages
man-pages:
	@if which $(POD2MAN) 1>/dev/null 2>/dev/null; then \
	$(MAKE) $(DOC_MAN1) $(DOC_MAN5); else              \
	echo "pod2man not installed; skipping man-pages."; fi

man1/%.1: man/%.pod.1 Makefile
	$(INSTALL_DIR) $(@D)
	$(POD2MAN) --release=$(VERSION) --name=`echo $@ | sed 's/^man1.//'| \
		sed 's/.1//'` -s 1 -c "Xen" $< $@

man5/%.5: man/%.pod.5 Makefile
	$(INSTALL_DIR) $(@D)
	$(POD2MAN) --release=$(VERSION) --name=`echo $@ | sed 's/^man5.//'| \
		sed 's/.5//'` -s 5 -c "Xen" $< $@

.PHONY: clean
clean:
	$(MAKE) -C figs clean
	rm -rf .word_count *.aux *.dvi *.bbl *.blg *.glo *.idx *~ 
	rm -rf *.ilg *.log *.ind *.toc *.bak core
	rm -rf html txt
	rm -rf man5
	rm -rf man1

.PHONY: distclean
distclean: clean

.PHONY: install
install: all
	rm -rf $(DESTDIR)$(DOCDIR)
	$(INSTALL_DIR) $(DESTDIR)$(DOCDIR)

	$(INSTALL_DIR) $(DESTDIR)$(MANDIR)
	cp -dR man1 $(DESTDIR)$(MANDIR)
	cp -dR man5 $(DESTDIR)$(MANDIR)
	[ ! -d html ] || cp -dR html $(DESTDIR)$(DOCDIR)

html/index.html: $(DOC_HTML) ./gen-html-index INDEX
	perl -w -- ./gen-html-index -i INDEX html $(DOC_HTML)

html/%.html: %.markdown
	@$(INSTALL_DIR) $(@D)
	@set -e ; if which $(MARKDOWN) 1>/dev/null 2>/dev/null; then \
	echo "Running markdown to generate $*.html ... "; \
	$(MARKDOWN) $< > $@.tmp ; \
	$(call move-if-changed,$@.tmp,$@) ; else \
	echo "markdown not installed; skipping $*.html."; fi

html/%.txt: %.txt
	@$(INSTALL_DIR) $(@D)
	cp $< $@

html/man/%.1.html: man/%.pod.1 Makefile
	$(INSTALL_DIR) $(@D)
	$(POD2HTML) --infile=$< --outfile=$@.tmp
	$(call move-if-changed,$@.tmp,$@)

html/man/%.5.html: man/%.pod.5 Makefile
	$(INSTALL_DIR) $(@D)
	$(POD2HTML) --infile=$< --outfile=$@.tmp
	$(call move-if-changed,$@.tmp,$@)

html/hypercall/index.html: ./xen-headers
	rm -rf $(@D)
	@$(INSTALL_DIR) $(@D)
	./xen-headers -O $(@D) \
		-T 'arch-x86_64 - Xen public headers' \
		-X arch-ia64 -X arch-x86_32 -X xen-x86_32 -X arch-arm \
		../xen include/public include/xen/errno.h

-include html/hypercall/.deps

txt/%.txt: %.txt
	$(INSTALL_DIR) $(@D)
	cp $< $@.tmp
	$(call move-if-changed,$@.tmp,$@)

txt/%.txt: %.markdown
	$(INSTALL_DIR) $(@D)
	cp $< $@.tmp
	$(call move-if-changed,$@.tmp,$@)

txt/man/%.1.txt: man/%.pod.1 Makefile
	$(INSTALL_DIR) $(@D)
	$(POD2TEXT) $< $@.tmp
	$(call move-if-changed,$@.tmp,$@)

txt/man/%.5.txt: man/%.pod.5 Makefile
	$(INSTALL_DIR) $(@D)
	$(POD2TEXT) $< $@.tmp
	$(call move-if-changed,$@.tmp,$@)