1##===- docs/Makefile ---------------------------------------*- Makefile -*-===##
2#
3#                     The LLVM Compiler Infrastructure
4#
5# This file is distributed under the University of Illinois Open Source
6# License. See LICENSE.TXT for details.
7#
8##===----------------------------------------------------------------------===##
9
10LEVEL      := ..
11DIRS       :=
12
13ifdef BUILD_FOR_WEBSITE
14PROJ_OBJ_DIR = .
15DOXYGEN = doxygen
16
17$(PROJ_OBJ_DIR)/doxygen.cfg: doxygen.cfg.in
18	cat $< | sed \
19	  -e 's/@DOT@/dot/g' \
20	  -e 's/@PACKAGE_VERSION@/mainline/' \
21	  -e 's/@abs_top_builddir@/../g' \
22	  -e 's/@abs_top_srcdir@/../g' \
23	  -e 's/@enable_external_search@/NO/g' \
24	  -e 's/@enable_searchengine@/NO/g' \
25	  -e 's/@enable_server_based_search@/NO/g' \
26	  -e 's/@extra_search_mappings@//g' \
27	  -e 's/@llvm_doxygen_generate_qhp@//g' \
28	  -e 's/@llvm_doxygen_qch_filename@//g' \
29	  -e 's/@llvm_doxygen_qhelpgenerator_path@//g' \
30	  -e 's/@llvm_doxygen_qhp_cust_filter_attrs@//g' \
31	  -e 's/@llvm_doxygen_qhp_cust_filter_name@//g' \
32	  -e 's/@llvm_doxygen_qhp_namespace@//g' \
33	  -e 's/@searchengine_url@//g' \
34	  > $@
35endif
36
37include $(LEVEL)/Makefile.common
38
39HTML       := $(wildcard $(PROJ_SRC_DIR)/*.html) \
40              $(wildcard $(PROJ_SRC_DIR)/*.css)
41DOXYFILES  := doxygen.cfg.in doxygen.intro
42
43.PHONY: install-html install-doxygen doxygen install-ocamldoc ocamldoc generated
44
45install_targets := install-html
46ifeq ($(ENABLE_DOXYGEN),1)
47install_targets += install-doxygen
48endif
49ifdef OCAMLFIND
50ifneq (,$(filter ocaml,$(BINDINGS_TO_BUILD)))
51install_targets += install-ocamldoc
52endif
53endif
54install-local:: $(install_targets)
55
56generated_targets := doxygen
57ifdef OCAMLFIND
58generated_targets += ocamldoc
59endif
60
61# Live documentation is generated for the web site using this target:
62# 'make generated BUILD_FOR_WEBSITE=1'
63generated:: $(generated_targets)
64
65install-html: $(PROJ_OBJ_DIR)/html.tar.gz
66	$(Echo) Installing HTML documentation
67	$(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/html
68	$(Verb) $(DataInstall) $(HTML) $(DESTDIR)$(PROJ_docsdir)/html
69	$(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/html.tar.gz $(DESTDIR)$(PROJ_docsdir)
70
71$(PROJ_OBJ_DIR)/html.tar.gz: $(HTML)
72	$(Echo) Packaging HTML documentation
73	$(Verb) $(RM) -rf $@ $(PROJ_OBJ_DIR)/html.tar
74	$(Verb) cd $(PROJ_SRC_DIR) && \
75	  $(TAR) cf $(PROJ_OBJ_DIR)/html.tar *.html
76	$(Verb) $(GZIPBIN) $(PROJ_OBJ_DIR)/html.tar
77
78install-doxygen: doxygen
79	$(Echo) Installing doxygen documentation
80	$(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/doxygen.tar.gz $(DESTDIR)$(PROJ_docsdir)
81	$(Verb) cd $(PROJ_OBJ_DIR)/doxygen/html && \
82	  for DIR in $$($(FIND) . -type d); do \
83	    DESTSUB="$(DESTDIR)$(PROJ_docsdir)/html/doxygen/$$(echo $$DIR | cut -c 3-)"; \
84	    $(MKDIR) $$DESTSUB && \
85	    $(FIND) $$DIR -maxdepth 1 -type f -exec $(DataInstall) {} $$DESTSUB \; ; \
86	    if [ $$? != 0 ]; then exit 1; fi \
87	  done
88
89doxygen: regendoc $(PROJ_OBJ_DIR)/doxygen.tar.gz
90
91regendoc:
92	$(Echo) Building doxygen documentation
93	$(Verb) $(RM) -rf $(PROJ_OBJ_DIR)/doxygen
94	$(Verb) $(DOXYGEN) $(PROJ_OBJ_DIR)/doxygen.cfg
95
96$(PROJ_OBJ_DIR)/doxygen.tar.gz: $(DOXYFILES) $(PROJ_OBJ_DIR)/doxygen.cfg
97	$(Echo) Packaging doxygen documentation
98	$(Verb) $(RM) -rf $@ $(PROJ_OBJ_DIR)/doxygen.tar
99	$(Verb) $(TAR) cf $(PROJ_OBJ_DIR)/doxygen.tar doxygen
100	$(Verb) $(GZIPBIN) $(PROJ_OBJ_DIR)/doxygen.tar
101	$(Verb) $(CP) $(PROJ_OBJ_DIR)/doxygen.tar.gz $(PROJ_OBJ_DIR)/doxygen/html/
102
103userloc: $(LLVM_SRC_ROOT)/docs/userloc.html
104
105$(LLVM_SRC_ROOT)/docs/userloc.html:
106	$(Echo) Making User LOC Table
107	$(Verb) cd $(LLVM_SRC_ROOT) ; ./utils/userloc.pl -details -recurse \
108	  -html lib include tools runtime utils examples autoconf test > docs/userloc.html
109
110install-ocamldoc: ocamldoc
111	$(Echo) Installing ocamldoc documentation
112	$(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/ocamldoc/html
113	$(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/ocamldoc.tar.gz $(DESTDIR)$(PROJ_docsdir)
114	$(Verb) cd $(PROJ_OBJ_DIR)/ocamldoc && \
115	  $(FIND) . -type f -exec \
116	    $(DataInstall) {} $(DESTDIR)$(PROJ_docsdir)/ocamldoc/html \;
117
118ocamldoc: regen-ocamldoc
119	$(Echo) Packaging ocamldoc documentation
120	$(Verb) $(RM) -rf $(PROJ_OBJ_DIR)/ocamldoc.tar*
121	$(Verb) $(TAR) cf $(PROJ_OBJ_DIR)/ocamldoc.tar ocamldoc
122	$(Verb) $(GZIPBIN) $(PROJ_OBJ_DIR)/ocamldoc.tar
123	$(Verb) $(CP) $(PROJ_OBJ_DIR)/ocamldoc.tar.gz $(PROJ_OBJ_DIR)/ocamldoc/html/
124
125regen-ocamldoc:
126	$(Echo) Building ocamldoc documentation
127	$(Verb) $(RM) -rf $(PROJ_OBJ_DIR)/ocamldoc
128	$(Verb) $(MAKE) -C $(LEVEL)/bindings/ocaml ocamldoc
129	$(Verb) $(MKDIR) $(PROJ_OBJ_DIR)/ocamldoc/html
130	$(Verb) \
131		$(OCAMLFIND) ocamldoc -d $(PROJ_OBJ_DIR)/ocamldoc/html -sort -colorize-code -html \
132		`$(FIND) $(LEVEL)/bindings/ocaml -name "*.odoc" \
133		         -path "*/$(BuildMode)/*.odoc" -exec echo -load '{}' ';'`
134
135uninstall-local::
136	$(Echo) Uninstalling Documentation
137	$(Verb) $(RM) -rf $(DESTDIR)$(PROJ_docsdir)
138