[GTK] Streamline wk1 documentation build
[WebKit-https.git] / Source / WebKit / gtk / GNUmakefile.gtk-doc.am
1 # -*- mode: makefile -*-
2
3 GTKDOC_CC = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
4 GTKDOC_LD = $(LIBTOOL) --tag=CC --mode=link $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS)
5 GTKDOC_RUN = $(LIBTOOL) --mode=execute
6
7 # We set GPATH here; this gives us semantics for GNU make
8 # which are more like other make's VPATH, when it comes to
9 # whether a source that is a target of one rule is then
10 # searched for in VPATH/GPATH.
11 #
12 GPATH = $(srcdir)
13
14 TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)
15
16 SETUP_FILES = \
17         $(DOC_MAIN_SGML_FILE)           \
18         webkitenvironment.xml           \
19         $(DOC_MODULE)-sections.txt      \
20         $(DOC_MODULE)-overrides.txt
21
22 EXTRA_DIST += \
23         $(HTML_IMAGES)                  \
24         $(SETUP_FILES)
25
26 DOC_STAMPS=doc-setup-build.stamp scan-build.stamp tmpl-build.stamp sgml-build.stamp \
27         html-build.stamp pdf-build.stamp \
28         tmpl.stamp sgml.stamp html.stamp pdf.stamp
29
30 SCANOBJ_FILES =                  \
31         $(DOC_MODULE).args       \
32         $(DOC_MODULE).hierarchy  \
33         $(DOC_MODULE).interfaces \
34         $(DOC_MODULE).prerequisites \
35         $(DOC_MODULE).signals
36
37 REPORT_FILES = \
38         $(DOC_MODULE)-undocumented.txt \
39         $(DOC_MODULE)-undeclared.txt \
40         $(DOC_MODULE)-unused.txt
41
42 CLEANFILES += $(SCANOBJ_FILES) $(REPORT_FILES) $(DOC_STAMPS)
43
44 if ENABLE_GTK_DOC
45 HTML_BUILD_STAMP=html-build.stamp
46 endif
47
48 doc_srcdir := $(abs_srcdir)/Source/WebKit/gtk/docs
49
50 docs: $(HTML_BUILD_STAMP)
51
52 $(REPORT_FILES): sgml-build.stamp
53
54 #### setup ####
55
56 doc-setup-build.stamp: libwebkitgtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la
57         -@mkdir -p Documentation
58         -@ln -fs ../doltlibtool Documentation/
59         -@ln -fs ../doltcompile Documentation/
60         -@ln -fs ../libtool Documentation/
61         -@if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
62             echo '  DOC   Preparing build'; \
63             files=`echo $(SETUP_FILES) $(DOC_MODULE).types`; \
64             if test "x$$files" != "x" ; then \
65                 for file in $$files ; do \
66                     test -f $(doc_srcdir)/$$file && \
67                         cp -pu $(doc_srcdir)/$$file $(abs_builddir)/Documentation/ || true; \
68                 done; \
69             fi; \
70             test -d $(doc_srcdir)/tmpl && \
71                 { cp -rp $(doc_srcdir)/tmpl $(abs_builddir)/Documentation/; \
72                 chmod -R u+w $(abs_builddir)/Documentation/tmpl; } \
73         fi
74         @touch doc-setup-build.stamp
75
76 #### scan ####
77
78 scan-build.stamp: doc-setup-build.stamp $(HFILE_GLOB) $(CFILE_GLOB)
79         @echo '  DOC   Scanning header files'
80         @cd Documentation; _source_dir='' ; \
81         for i in $(DOC_SOURCE_DIR) ; do \
82             _source_dir="$${_source_dir} --source-dir=../$$i" ; \
83         done ; \
84         gtkdoc-scan --module=$(DOC_MODULE) --ignore-headers="$(IGNORE_HFILES)" $${_source_dir} $(SCAN_OPTIONS) $(EXTRA_HFILES)
85         @cd Documentation; if grep -l '^..*$$' $(DOC_MODULE).types > /dev/null 2>&1 ; then \
86             echo "  DOC   Introspecting gobjects"; \
87             scanobj_options=""; \
88             gtkdoc-scangobj 2>&1 --help | grep  >/dev/null "\-\-verbose"; \
89             if test "$(?)" = "0"; then \
90                 if test "x$(V)" = "x1"; then \
91                     scanobj_options="--verbose"; \
92                 fi; \
93             fi; \
94             CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)" RUN="$(GTKDOC_RUN)" CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS)" LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)" \
95             gtkdoc-scangobj $(SCANGOBJ_OPTIONS) $$scanobj_options --module=$(DOC_MODULE); \
96         else \
97             for i in $(SCANOBJ_FILES) ; do \
98                 test -f $$i || touch $$i ; \
99             done \
100         fi
101         @touch scan-build.stamp
102
103 Documentation/$(DOC_MODULE)-decl.txt Documentation/$(SCANOBJ_FILES) Documentation/$(DOC_MODULE)-sections.txt Documentation/$(DOC_MODULE)-overrides.txt: scan-build.stamp
104         @true
105
106 #### templates ####
107
108 tmpl-build.stamp: doc-setup-build.stamp Documentation/$(DOC_MODULE)-decl.txt Documentation/$(SCANOBJ_FILES) Documentation/$(DOC_MODULE)-sections.txt Documentation/$(DOC_MODULE)-overrides.txt
109         @echo '  DOC   Rebuilding template files'
110         @cd Documentation; gtkdoc-mktmpl --module=$(DOC_MODULE) $(MKTMPL_OPTIONS)
111         @if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
112           if test -w $(abs_srcdir) ; then \
113             cp -rp $(abs_builddir)/Documentation/tmpl $(doc_srcdir); \
114           fi \
115         fi
116         @touch tmpl-build.stamp
117
118 tmpl.stamp: tmpl-build.stamp
119         @true
120
121 $(srcdir)/tmpl/*.sgml:
122         @true
123
124 #### xml ####
125
126 sgml-build.stamp: doc-setup-build.stamp tmpl.stamp Documentation/$(DOC_MODULE)-sections.txt $(srcdir)/tmpl/*.sgml
127         @echo '  DOC   Building XML'
128         @-chmod -R u+w $(srcdir)
129         @cd Documentation; _source_dir='' ; \
130         for i in $(DOC_SOURCE_DIR) ; do \
131             _source_dir="$${_source_dir} --source-dir=../$$i" ; \
132         done ; \
133         gtkdoc-mkdb --module=$(DOC_MODULE) --output-format=xml --expand-content-files="" --main-sgml-file=$(DOC_MAIN_SGML_FILE) $${_source_dir} $(MKDB_OPTIONS)
134         @touch sgml-build.stamp
135
136 sgml.stamp: sgml-build.stamp
137         @true
138
139 #### html ####
140
141 Documentation/$(DOC_MAIN_SGML_FILE): sgml.stamp
142 Documentation/webkitenvironment.xml: doc-setup-build.stamp
143
144 html-build.stamp: sgml.stamp Documentation/$(DOC_MAIN_SGML_FILE)
145         @echo '  DOC   Building HTML'
146         @rm -rf Documentation/html
147         @mkdir Documentation/html
148         @cd Documentation; mkhtml_options=""; \
149         gtkdoc-mkhtml 2>&1 --help | grep  >/dev/null "\-\-verbose"; \
150         if test "$(?)" = "0"; then \
151           if test "x$(V)" = "x1"; then \
152             mkhtml_options="$$mkhtml_options --verbose"; \
153           fi; \
154         fi; \
155         gtkdoc-mkhtml 2>&1 --help | grep  >/dev/null "\-\-path"; \
156         if test "$(?)" = "0"; then \
157           mkhtml_options="$$mkhtml_options --path=\"$(doc_srcdir)\""; \
158         fi; \
159         cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
160         -@test "x$(HTML_IMAGES)" = "x" || \
161         for file in $(HTML_IMAGES) ; do \
162           if test -f $(abs_srcdir)/$$file ; then \
163             cp $(abs_srcdir)/$$file $(abs_builddir)/html; \
164           fi; \
165           if test -f $(abs_builddir)/$$file ; then \
166             cp $(abs_builddir)/$$file $(abs_builddir)/html; \
167           fi; \
168         done;
169         @echo '  DOC   Fixing cross-references'
170         @cd Documentation; gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
171         @touch html-build.stamp
172
173 clean-local: doc-clean-local
174
175 doc-clean-local:
176         @rm -f Documentation/*~ Documentation/*.bak
177         @rm -rf Documentation/.libs
178
179 distclean-local: doc-distclean-local
180
181 doc-distclean-local:
182         @rm -rf Documentation
183
184 maintainer-clean-local: doc-maintainer-clean-local
185
186 doc-maintainer-clean-local: clean
187         @rm -rf Documentation/xml Documentation/html
188         -@rmdir Documentation
189
190 #
191 # Require gtk-doc when making dist
192 #
193 if ENABLE_GTK_DOC
194 dist-check-gtkdoc:
195
196 all: docs
197 else
198 dist-check-gtkdoc:
199         @echo "*** gtk-doc must be installed and enabled in order to make dist"
200         @false
201 endif
202
203 dist-hook: doc-dist-hook
204
205 doc-dist-hook: dist-check-gtkdoc dist-hook-local
206         @mkdir $(distdir)/tmpl
207         @mkdir $(distdir)/html
208         @-cp ./Documentation/tmpl/*.sgml $(distdir)/tmpl
209         @cp ./Documentation/html/* $(distdir)/html
210         @-cp ./Documentation/$(DOC_MODULE).types $(distdir)/
211         @-cp ./Documentation/$(DOC_MODULE)-sections.txt $(distdir)/
212         @cd $(distdir) && rm -f $(DISTCLEANFILES)
213         @$(GTKDOC_REBASE) --online --relative --html-dir=$(distdir)/html
214
215 .PHONY : dist-hook-local docs