1 ##===- docs/mk/main.mk -------------------------------------*- Makefile -*-===##
3 # The LLVM Compiler Infrastructure
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
8 ##===----------------------------------------------------------------------===##
10 # Main HTML documentation support module.
12 # The following variables must be defined before including this makefile:
14 # HTML.Project formal project name. eg. LLVM or Clang.
15 # HTML.project filesystem project name. eg. llvm or clang.
17 ##===----------------------------------------------------------------------===##
19 include $(LLVM_SRC_ROOT)/docs/mk/common.defs.mk
21 MAIN.in/ = $(PROJ_SRC_DIR)/
24 MAIN.html/ = $(MAIN.out/)html/
25 MAIN.html.tar = $(MAIN.out/)html.tar.gz
26 MAIN.html.cp.ext = .html .css .txt .png .jpg .gif
27 MAIN.html.cp.in = $(patsubst $(MAIN.in/)%,%, \
28 $(sort $(wildcard $(foreach x,$(MAIN.html.cp.ext), $(MAIN.in/)*$(x) ))) \
29 $(sort $(wildcard $(foreach x,$(MAIN.html.cp.ext), $(MAIN.in/)*/*$(x) ))) \
30 $(sort $(wildcard $(foreach x,$(MAIN.html.cp.ext), $(MAIN.in/)*/*/*$(x) ))) )
31 MAIN.html.cp.out = $(MAIN.html.cp.in:%=$(MAIN.html/)%)
32 MAIN.html.pod.in = $(patsubst $(MAIN.in/)%,%, \
33 $(sort $(wildcard $(MAIN.in/)*.pod )) \
34 $(sort $(wildcard $(MAIN.in/)*.pod )) \
35 $(sort $(wildcard $(MAIN.in/)*/*.pod )) \
36 $(sort $(wildcard $(MAIN.in/)*/*/*.pod )) )
37 MAIN.html.pod.out = $(MAIN.html.pod.in:%.pod=$(MAIN.html/)%.html)
39 MAIN.html.files = $(MAIN.html.cp.out) \
42 MAIN.man/ = $(MAIN.out/)man/man1/
43 MAIN.man.in = $(sort $(wildcard $(MAIN.in/)*.pod )) \
44 $(sort $(wildcard $(MAIN.in/)*/*.pod )) \
45 $(sort $(wildcard $(MAIN.in/)*/*/*.pod ))
46 MAIN.man.out = $(patsubst %.pod,$(MAIN.man/)%.1,$(notdir $(MAIN.man.in)))
48 MAIN.ps/ = $(MAIN.out/)ps/
49 MAIN.ps.out = $(patsubst %.1,$(MAIN.ps/)%.ps,$(notdir $(MAIN.man.out)))
51 MAIN.pdf/ = $(MAIN.out/)pdf/
52 MAIN.pdf.out = $(patsubst %.1,$(MAIN.pdf/)%.pdf,$(notdir $(MAIN.man.out)))
54 MAIN.files += $(MAIN.html.tar)
55 MAIN.files += $(MAIN.html.cp.out)
56 MAIN.files += $(MAIN.html.pod.out)
57 MAIN.files += $(MAIN.man.out)
58 MAIN.files += $(MAIN.ps.out)
59 MAIN.files += $(MAIN.pdf.out)
61 DOCS.mkdir.files += $(MAIN.files)
63 ##===----------------------------------------------------------------------===##
65 INSTALL.out/ = $(PROJ_prefix)/share/
66 INSTALL.doc/ = $(INSTALL.out/)doc/$(MAIN.project)/
68 INSTALL.html/ = $(INSTALL.doc/)html/
69 INSTALL.html.tar = $(INSTALL.doc/)$(notdir $(MAIN.html.tar))
70 INSTALL.html.out = $(MAIN.html.files:$(MAIN.html/)%=$(INSTALL.html/)%)
72 INSTALL.man/ = $(PROJ_mandir)/man1/
73 INSTALL.man.out = $(MAIN.man.out:$(MAIN.man/)%=$(INSTALL.man/)%)
75 INSTALL.ps/ = $(INSTALL.doc/)ps/
76 INSTALL.ps.out = $(MAIN.ps.out:$(MAIN.ps/)%=$(INSTALL.ps/)%)
78 INSTALL.pdf/ = $(INSTALL.doc/)pdf/
79 INSTALL.pdf.out = $(MAIN.pdf.out:$(MAIN.pdf/)%=$(INSTALL.pdf/)%)
81 INSTALL.files += $(INSTALL.html.tar)
82 INSTALL.files += $(INSTALL.html.out)
83 INSTALL.files += $(INSTALL.man.out)
84 INSTALL.files += $(INSTALL.ps.out)
85 INSTALL.files += $(INSTALL.pdf.out)
87 DOCS.mkdir.files += $(INSTALL.out/)file-placebo
88 DOCS.mkdir.files += $(INSTALL.files)
90 ##===----------------------------------------------------------------------===##
93 -$(Verb) $(RM) -f $(MAIN.files)
96 install-local:: install-docs
97 uninstall-local:: uninstall-docs
99 ##===----------------------------------------------------------------------===##
102 docs-tar: $(MAIN.html.tar)
105 docs: $(MAIN.html.files)
106 docs: $(MAIN.man.out)
111 docs: $(MAIN.pdf.out)
114 $(MAIN.html.tar): | $(dir $(MAIN.html.tar))
115 $(MAIN.html.tar): $(MAIN.html.files)
116 $(Echo) Creating $(MAIN.Project) MAIN documentation tarball
117 $(Verb) (set -e; cd $(MAIN.out/); $(TAR) cf - html) \
118 $(call fn.PIPE.COMP,$@) > $@
120 $(MAIN.html.cp.out): | $(dir $(MAIN.html.cp.out))
121 $(MAIN.html.cp.out): $(MAIN.html/)%: %
122 $(Echo) Copying to $(@:$(PROJ_OBJ_ROOT)/%=%)
125 $(MAIN.html.pod.out): | $(dir $(MAIN.html.pod.out))
126 $(MAIN.html.pod.out): $(MAIN.html/)%.html: %.pod
127 $(Echo) Converting pod to $(@:$(PROJ_OBJ_ROOT)/%=%)
128 $(Verb) $(CAT) $< | (set -e; cd $(MAIN.in/); $(POD2HTML) --title=$(*F) \
129 --noindex --css=manpage.css \
130 --htmlroot=. --podpath=. --podroot=$(<D)) > $@
132 $(MAIN.man.out): | $(dir $(MAIN.man.out))
133 $(MAIN.man.out): $(MAIN.man/)%.1: %.pod
134 $(Echo) Converting pod to $(@:$(PROJ_OBJ_ROOT)/%=%)
135 $(Verb) $(POD2MAN) --release=$(PROJ_VERSION) --center="$(MAIN.man.center)" $< $@
137 $(MAIN.ps.out): | $(dir $(MAIN.ps.out))
138 $(MAIN.ps.out): $(MAIN.ps/)%.ps: $(MAIN.man/)%.1
139 $(Echo) Converting man to $(@:$(PROJ_OBJ_ROOT)/%=%)
140 $(Verb) $(GROFF) -Tps -man $< > $@
142 $(MAIN.pdf.out): | $(dir $(MAIN.pdf.out))
143 $(MAIN.pdf.out): $(MAIN.pdf/)%.pdf: $(MAIN.man/)%.1
144 $(Echo) Converting man to $(@:$(PROJ_OBJ_ROOT)/%=%)
145 $(Verb) $(PDFROFF) -man --no-toc-relocation $< > $@
147 # Mapping of src pod files is not always direct so we need a search vpath.
148 # This solution works because no man page filenames (without dir) collide.
149 vpath %.pod $(sort $(dir $(MAIN.man.in)))
151 ##===----------------------------------------------------------------------===##
154 install-docs: $(INSTALL.html.tar)
155 install-docs: $(INSTALL.html.out)
156 install-docs: $(INSTALL.man.out)
158 install-docs: $(INSTALL.ps.out)
161 install-docs: $(INSTALL.pdf.out)
164 $(INSTALL.html.tar): | $(dir $(INSTALL.html.tar))
165 $(INSTALL.html.tar): $(MAIN.html.tar)
166 $(Echo) Installing $(MAIN.Project) MAIN documentation tarball
167 $(Verb) $(DataInstall) $< $@
169 $(INSTALL.html.out): | $(dir $(INSTALL.html.out))
170 $(INSTALL.html.out): $(INSTALL.html/)%: $(MAIN.html/)%
171 $(Echo) Installing $(@:$(INSTALL.out/)%=%)
172 $(Verb) $(DataInstall) $< $@
174 $(INSTALL.man.out): | $(dir $(INSTALL.man.out))
175 $(INSTALL.man.out): $(INSTALL.man/)%: $(MAIN.man/)%
176 $(Echo) Installing $(@:$(INSTALL.out/)%=%)
177 $(Verb) $(DataInstall) $< $@
179 $(INSTALL.ps.out): | $(dir $(INSTALL.ps.out))
180 $(INSTALL.ps.out): $(INSTALL.ps/)%: $(MAIN.ps/)%
181 $(Echo) Installing $(@:$(INSTALL.out/)%=%)
182 $(Verb) $(DataInstall) $< $@
184 $(INSTALL.pdf.out): | $(dir $(INSTALL.pdf.out))
185 $(INSTALL.pdf.out): $(INSTALL.pdf/)%: $(MAIN.pdf/)%
186 $(Echo) Installing $(@:$(INSTALL.out/)%=%)
187 $(Verb) $(DataInstall) $< $@
190 $(Echo) Uninstalling $(MAIN.Project) MAIN documentation
191 -$(Verb) $(RM) -f $(INSTALL.files)
193 ##===----------------------------------------------------------------------===##
195 DOCS.vars.mandatory += MAIN.Project MAIN.project MAIN.man.center
196 DOCS.vars.print += $(sort $(filter INSTALL.%/,$(.VARIABLES)))
198 HELP.sections += MAIN.help
201 MAIN Documentation Module. This module is objdir build-friendly.
203 ------------------------------------------------------------------------------
205 ------------------------------------------------------------------------------
206 *all invokes target docs
207 *install invokes target install-docs
208 *uninstall invokes target uninstall-docs
209 ------------------------------------------------------------------------------
210 docs copy MAIN docs from
212 with extensions { $(MAIN.html.cp.ext) }
214 and perform conversions:
217 --------------------------------------------------------------
218 html -> html $(MAIN.html/)
219 pod -> man $(MAIN.man/)
220 man -> ps $(MAIN.ps/)
221 man -> pdf $(MAIN.pdf/)
222 ------------------------------------------------------------------------------
223 docs-tar create docs tarball $(MAIN.html.tar)
224 clean remove built files
225 install-docs install MAIN docs:
228 --------------------------------------------------------------
229 html -> html $(INSTALL.html/)
230 pod -> man $(INSTALL.man/)
231 man -> ps $(INSTALL.ps/)
232 man -> pdf $(INSTALL.pdf/)
233 ------------------------------------------------------------------------------
234 uninstall-docs remove installed files
235 ------------------------------------------------------------------------------
236 (targets marked with '*' require configure --enable-doxygen)
239 include $(LLVM_SRC_ROOT)/docs/mk/common.rules.mk