gtk-doc*.mak: be a lot less noisy when building the docs.
[platform/upstream/gst-common.git] / gtk-doc.mak
1 ###########################################################################
2 # Everything below here is generic and you shouldn't need to change it.
3 ###########################################################################
4 # thomas: except of course that we did
5
6 # thomas: copied from glib-2
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 # thomas: make docs parallel installable
15 TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@
16
17 EXTRA_DIST =                            \
18         $(content_files)                \
19         $(extra_files)                  \
20         $(HTML_IMAGES)                  \
21         $(DOC_MAIN_SGML_FILE)           \
22         $(DOC_MODULE).types             \
23         $(DOC_OVERRIDES)                \
24         $(DOC_MODULE)-sections.txt
25
26 DOC_STAMPS =                            \
27         setup-build.stamp               \
28         scan-build.stamp                \
29         sgml-build.stamp                \
30         html-build.stamp                \
31         sgml.stamp              \
32         html.stamp
33
34 SCANOBJ_FILES =                         \
35         $(DOC_MODULE).args              \
36         $(DOC_MODULE).hierarchy         \
37         $(DOC_MODULE).interfaces                \
38         $(DOC_MODULE).prerequisites     \
39         $(DOC_MODULE).signals           \
40         .libs/$(DOC_MODULE)-scan.o
41
42 REPORT_FILES = \
43         $(DOC_MODULE)-undocumented.txt \
44         $(DOC_MODULE)-undeclared.txt \
45         $(DOC_MODULE)-unused.txt
46
47 CLEANFILES = $(SCANOBJ_FILES) $(REPORT_FILES) $(DOC_STAMPS) doc-registry.xml
48
49 if ENABLE_GTK_DOC
50 all-local: html-build.stamp
51
52 #### setup ####
53
54 setup-build.stamp: $(content_files)
55         -@if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
56            cp -p $(abs_srcdir)/$(DOC_MAIN_SGML_FILE) \
57              $(abs_srcdir)/$(DOC_MODULE)-overrides.txt \
58              $(abs_srcdir)/$(DOC_MODULE)-sections.txt \
59              $(abs_srcdir)/$(DOC_MODULE).types \
60              $(abs_builddir)/; \
61            if test "x$(content_files)" != "x" ; then \
62                for file in $(content_files) ; do \
63                    test -f $(abs_srcdir)/$$file || \
64                        cp -p $(abs_srcdir)/$$file $(abs_builddir)/; \
65                done \
66            fi \
67         fi
68         @touch setup-build.stamp
69
70 #### scan ####
71
72 # in the case of non-srcdir builds, the built gst directory gets added
73 # to gtk-doc scanning; but only then, to avoid duplicates
74 scan-build.stamp: $(HFILE_GLOB) $(CFILE_GLOB)
75         @echo '*** Scanning header files ***'
76         @if grep -l '^..*$$' $(DOC_MODULE).types > /dev/null;   \
77         then                                                            \
78             GST_PLUGIN_SYSTEM_PATH=`cd $(top_builddir) && pwd`          \
79             GST_PLUGIN_PATH=                                            \
80             GST_REGISTRY=doc-registry.xml                               \
81             $(GTKDOC_EXTRA_ENVIRONMENT)                                 \
82             CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)"                         \
83             CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS)"                         \
84             LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)"                         \
85             gtkdoc-scangobj --type-init-func="gst_init(NULL,NULL)"      \
86                 --module=$(DOC_MODULE) ;                                \
87         else                                                            \
88             for i in $(SCANOBJ_FILES) ; do                              \
89                test -f $$i || touch $$i ;                               \
90             done                                                        \
91         fi
92         @if test "x$(top_srcdir)" != "x$(top_builddir)";                        \
93         then                                                            \
94           export BUILT_OPTIONS="--source-dir=$(DOC_BUILD_DIR)";         \
95         fi;                                                             \
96         gtkdoc-scan                                                     \
97                 $(SCAN_OPTIONS) $(EXTRA_HFILES)                         \
98                 --module=$(DOC_MODULE)                                  \
99                 --source-dir=$(DOC_SOURCE_DIR)                          \
100                 $$BUILT_OPTIONS                                         \
101                 --ignore-headers="$(IGNORE_HFILES)"
102         @touch scan-build.stamp
103
104 $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt: scan-build.stamp
105         @true
106
107 #### xml ####
108
109 ### FIXME: make this error out again when docs are complete
110 sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(expand_content_files)
111         @echo '*** Building XML ***'
112         @gtkdoc-mkdb --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR)  --expand-content-files="$(expand_content_files)" --main-sgml-file=$(DOC_MAIN_SGML_FILE) --output-format=xml $(MKDB_OPTIONS) | tee sgml-build.log
113         @if grep "WARNING:" sgml-build.log > /dev/null; then true; fi # exit 1; fi
114         @cp ../version.entities xml
115         @rm sgml-build.log
116         @touch sgml-build.stamp
117
118 sgml.stamp: sgml-build.stamp
119         @true
120
121 #### html ####
122
123 html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
124         @echo '*** Building HTML ***'
125         @rm -rf html
126         @mkdir html
127         @cp -pr xml html
128         @cp ../version.entities ./
129         @mkhtml_options=""; \
130         @gtkdoc-mkhtml 2>&1 --help | grep  >/dev/null "\-\-path"; \
131         if test "$(?)" = "0"; then \
132           mkhtml_options=--path="$(abs_srcdir)"; \
133         fi; \
134         cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
135         @mv html/index.sgml html/index.sgml.bak
136         @$(SED) "s/ href=\"$(DOC_MODULE)\// href=\"$(DOC_MODULE)-@GST_MAJORMINOR@\//g" html/index.sgml.bak >html/index.sgml
137         @rm -f html/index.sgml.bak
138         @rm -rf html/xml
139         @rm -f version.entities
140         @test "x$(HTML_IMAGES)" = "x" ||  ( cd $(srcdir) && cp $(HTML_IMAGES) $(abs_builddir)/html )
141         @echo '-- Fixing Crossreferences'
142         @gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
143         @touch html-build.stamp
144
145 clean-local-gtkdoc:
146         @rm -rf xml tmpl html
147 # clean files copied for nonsrcdir templates build
148         @if test x"$(srcdir)" != x. ; then \
149                 rm -rf $(DOC_MODULE).types; \
150         fi
151 else
152 all-local:
153 clean-local-gtkdoc:
154 endif
155
156 clean-local: clean-local-gtkdoc
157         @rm -f *~ *.bak
158         @rm -rf .libs
159
160 distclean-local:
161         @rm -f $(REPORT_FILES) \
162                 $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
163         @rm -rf tmpl/*.sgml.bak
164         @rm -f $(DOC_MODULE).hierarchy
165         @rm -f *.stamp || true
166         @if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
167             rm -f $(DOC_MODULE)-docs.sgml ; \
168             rm -f $(DOC_MODULE).types ; \
169             rm -f $(DOC_MODULE).interfaces ; \
170             rm -f $(DOC_MODULE)-overrides.txt ; \
171             rm -f $(DOC_MODULE).prerequisites ; \
172             rm -f $(DOC_MODULE)-sections.txt ; \
173             rm -rf tmpl/*.sgml ; \
174         fi
175         @rm -rf *.o
176
177 maintainer-clean-local: clean
178         @cd $(srcdir) && rm -rf html \
179                 xml $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
180
181 # thomas: make docs parallel installable; devhelp requires majorminor too
182 install-data-local:
183         (installfiles=`echo $(builddir)/html/*.sgml $(builddir)/html/*.html $(builddir)/html/*.png $(builddir)/html/*.css`; \
184         if test "$$installfiles" = '$(builddir)/html/*.sgml $(builddir)/html/*.html $(builddir)/html/*.png $(builddir)/html/*.css'; \
185         then echo '-- Nothing to install' ; \
186         else \
187           $(mkinstalldirs) $(DESTDIR)$(TARGET_DIR); \
188           for i in $$installfiles; do \
189             echo '-- Installing '$$i ; \
190             $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
191           done; \
192           echo '-- Installing $(builddir)/html/$(DOC_MODULE).devhelp' ; \
193           $(INSTALL_DATA) $(builddir)/html/$(DOC_MODULE).devhelp \
194             $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp; \
195           if test -e $(builddir)/html/$(DOC_MODULE).devhelp2; then \
196                     $(INSTALL_DATA) $(builddir)/html/$(DOC_MODULE).devhelp2 \
197                     $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp2; \
198           fi; \
199           (which gtkdoc-rebase >/dev/null && \
200             gtkdoc-rebase --relative --dest-dir=$(DESTDIR) --html-dir=$(DESTDIR)$(TARGET_DIR)) || true ; \
201         fi)
202 uninstall-local:
203         if test -d $(DESTDIR)$(TARGET_DIR); then \
204           rm -rf $(DESTDIR)$(TARGET_DIR)/*; \
205           rmdir -p $(DESTDIR)$(TARGET_DIR) 2>/dev/null || true; \
206         else \
207           echo '-- Nothing to uninstall' ; \
208         fi;
209
210
211 #
212 # Require gtk-doc when making dist
213 #
214 if ENABLE_GTK_DOC
215 dist-check-gtkdoc:
216 else
217 dist-check-gtkdoc:
218         @echo "*** gtk-doc must be installed and enabled in order to make dist"
219         @false
220 endif
221
222 dist-hook: dist-check-gtkdoc dist-hook-local
223         mkdir $(distdir)/html
224         cp html/* $(distdir)/html
225         -cp $(srcdir)/$(DOC_MODULE).types $(distdir)/
226         -cp $(srcdir)/$(DOC_MODULE)-sections.txt $(distdir)/
227         cd $(distdir) && rm -f $(DISTCLEANFILES)
228         -gtkdoc-rebase --online --relative --html-dir=$(distdir)/html
229
230 .PHONY : dist-hook-local docs
231
232 # avoid spurious build errors when distchecking with -jN
233 .NOTPARALLEL: