plugin-docs: be less noisy
[platform/upstream/gst-common.git] / gtk-doc-plugins.mak
1 # This is an include file specifically tuned for building documentation
2 # for GStreamer plug-ins
3
4 help:
5         @echo
6         @echo "If you are a doc maintainer, run 'make update' to update"
7         @echo "the documentation files maintained in git"
8         @echo
9         @echo Other useful make targets:
10         @echo
11         @echo  check-inspected-versions: make sure the inspected plugin info
12         @echo                            is up to date before a release
13         @echo
14
15 # update the stuff maintained by doc maintainers
16 update:
17         $(MAKE) scanobj-update
18         $(MAKE) check-outdated-docs
19
20 # We set GPATH here; this gives us semantics for GNU make
21 # which are more like other make's VPATH, when it comes to
22 # whether a source that is a target of one rule is then
23 # searched for in VPATH/GPATH.
24 #
25 GPATH = $(srcdir)
26
27 # thomas: make docs parallel installable
28 TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@
29
30 MAINTAINER_DOC_STAMPS =                 \
31         scanobj-build.stamp
32
33 EXTRA_DIST =                            \
34         $(MAINTAINER_DOC_STAMPS)                \
35         $(srcdir)/inspect/*.xml         \
36         $(SCANOBJ_FILES)                \
37         $(content_files)                \
38         $(extra_files)                  \
39         $(HTML_IMAGES)                  \
40         $(DOC_MAIN_SGML_FILE)   \
41         $(DOC_OVERRIDES)                \
42         $(DOC_MODULE)-sections.txt
43
44 # we don't add scanobj-build.stamp here since they are built manually by docs
45 # maintainers and result is commited to git
46 DOC_STAMPS =                            \
47         scan-build.stamp                \
48         tmpl-build.stamp                \
49         sgml-build.stamp                \
50         html-build.stamp                \
51         scan.stamp                      \
52         tmpl.stamp                      \
53         sgml.stamp                      \
54         html.stamp
55
56 # files generated/updated by gtkdoc-scangobj
57 SCANOBJ_FILES =                         \
58         $(DOC_MODULE).signals           \
59         $(DOC_MODULE).hierarchy         \
60         $(DOC_MODULE).interfaces        \
61         $(DOC_MODULE).prerequisites     \
62         $(DOC_MODULE).types             \
63         $(DOC_MODULE).args
64
65 SCANOBJ_FILES_O =                       \
66         .libs/$(DOC_MODULE)-scan.o
67
68 # files generated/updated by gtkdoc-scan
69 SCAN_FILES =                            \
70         $(DOC_MODULE)-sections.txt      \
71         $(DOC_MODULE)-overrides.txt     \
72         $(DOC_MODULE)-decl.txt          \
73         $(DOC_MODULE)-decl-list.txt
74
75
76 REPORT_FILES = \
77         $(DOC_MODULE)-undocumented.txt \
78         $(DOC_MODULE)-undeclared.txt \
79         $(DOC_MODULE)-unused.txt
80
81 # FC3 seems to need -scan.c to be part of CLEANFILES for distcheck
82 # no idea why FC4 can do without
83 CLEANFILES = \
84         $(SCANOBJ_FILES_O) \
85         $(DOC_MODULE)-scan.c \
86         $(REPORT_FILES) \
87         $(DOC_STAMPS) \
88         inspect-registry.xml
89
90 INSPECT_DIR = inspect
91
92 if ENABLE_GTK_DOC
93 all-local: html-build.stamp
94
95 ### inspect GStreamer plug-ins; done by documentation maintainer ###
96
97 # only look at the plugins in this module when building inspect .xml stuff
98 INSPECT_REGISTRY=$(top_builddir)/docs/plugins/inspect-registry.xml
99 INSPECT_ENVIRONMENT=\
100         LC_ALL=C \
101         GST_PLUGIN_SYSTEM_PATH= \
102         GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/sys:$(top_builddir)/ext:$(top_builddir)/plugins:$(top_builddir)/src:$(top_builddir)/gnl \
103         GST_REGISTRY=$(INSPECT_REGISTRY) \
104         PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" \
105         $(INSPECT_EXTRA_ENVIRONMENT)
106
107 # update the element and plugin XML descriptions; store in inspect/
108 inspect:
109         @-mkdir -p $(INSPECT_DIR)
110
111 #### scan gobjects; done by documentation maintainer ####
112 scanobj-update:
113         -rm scanobj-build.stamp
114         $(MAKE) scanobj-build.stamp
115
116 # TODO: finish elite script that updates the output files of this step
117 # instead of rewriting them, so that multiple maintainers can generate
118 # a collective set of args and signals
119 scanobj-build.stamp: $(SCANOBJ_DEPS) $(basefiles) inspect
120         @echo '*** Scanning GObjects ***'
121         if test x"$(srcdir)" != x. ; then                               \
122             for f in $(SCANOBJ_FILES);                                  \
123             do                                                          \
124                 cp $(srcdir)/$$f . ;                                    \
125             done;                                                       \
126         else                                                            \
127             $(INSPECT_ENVIRONMENT)                                      \
128             CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)"                         \
129             CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS) $(WARNING_CFLAGS)"       \
130             LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)"                         \
131             $(GST_DOC_SCANOBJ) --type-init-func="gst_init(NULL,NULL)"   \
132                 --module=$(DOC_MODULE) --source=$(PACKAGE) --inspect-dir=$(INSPECT_DIR) &&              \
133                 $(PYTHON)                                               \
134                 $(top_srcdir)/common/scangobj-merge.py $(DOC_MODULE);   \
135         fi
136         touch scanobj-build.stamp
137
138 $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(SCANOBJ_FILES_O): scan-build.stamp
139         @true
140
141 ### scan headers; done on every build ###
142 scan-build.stamp: $(HFILE_GLOB) $(EXTRA_HFILES) $(basefiles) scanobj-build.stamp
143         @echo '*** Scanning header files ***'
144         gtkdoc-scan                                                     \
145             $(SCAN_OPTIONS) $(EXTRA_HFILES)                             \
146             --module=$(DOC_MODULE)                                      \
147             --source-dir=$(DOC_SOURCE_DIR)                              \
148             --ignore-headers="$(IGNORE_HFILES)";                        \
149         touch scan-build.stamp
150
151 #### update templates; done on every build ####
152
153 ### FIXME: make this error out again when docs are fixed for 0.X
154 # in a non-srcdir build, we need to copy files from the previous step
155 # and the files from previous runs of this step
156 tmpl-build.stamp: $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_OVERRIDES)
157         @echo '*** Rebuilding template files ***'
158         @if test x"$(srcdir)" != x. ; then                              \
159             for f in $(SCANOBJ_FILES) $(SCAN_FILES);                    \
160             do                                                          \
161                 if test -e $(srcdir)/$$f; then cp $(srcdir)/$$f . ; fi; \
162             done;                                                       \
163         fi
164         gtkdoc-mktmpl --module=$(DOC_MODULE) | tee tmpl-build.log
165         $(PYTHON) \
166                 $(top_srcdir)/common/mangle-tmpl.py $(srcdir)/$(INSPECT_DIR) tmpl
167         @cat $(DOC_MODULE)-unused.txt
168         @rm -f tmpl-build.log
169         touch tmpl-build.stamp
170
171 tmpl.stamp: tmpl-build.stamp
172         @true
173
174 #### build xml; done on every build ####
175
176 ### FIXME: make this error out again when docs are fixed for 0.9
177 sgml-build.stamp: tmpl.stamp scan-build.stamp $(CFILE_GLOB) $(top_srcdir)/common/plugins.xsl $(expand_content_files)
178         @echo '*** Building XML ***'
179         @-mkdir -p xml
180         @for a in $(srcdir)/$(INSPECT_DIR)/*.xml; do \
181             xsltproc --stringparam module $(MODULE) \
182                 $(top_srcdir)/common/plugins.xsl $$a > xml/`basename $$a`; done
183         @for f in $(EXAMPLE_CFILES); do \
184                 $(PYTHON) $(top_srcdir)/common/c-to-xml.py $$f > xml/element-`basename $$f .c`.xml; done
185         gtkdoc-mkdb \
186                 --module=$(DOC_MODULE) \
187                 --source-dir=$(DOC_SOURCE_DIR) \
188                  --expand-content-files="$(expand_content_files)" \
189                 --main-sgml-file=$(srcdir)/$(DOC_MAIN_SGML_FILE) \
190                 --output-format=xml \
191                 --ignore-files="$(IGNORE_HFILES) $(IGNORE_CFILES)" \
192                 $(MKDB_OPTIONS) \
193                 | tee sgml-build.log
194         @if grep "WARNING:" sgml-build.log > /dev/null; then true; fi # exit 1; fi
195         cp ../version.entities xml
196         rm sgml-build.log
197         touch sgml-build.stamp
198
199 sgml.stamp: sgml-build.stamp
200         @true
201
202 #### build html; done on every step ####
203
204 html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
205         @echo '*** Building HTML ***'
206         if test -d html; then rm -rf html; fi
207         mkdir html
208         cp $(srcdir)/$(DOC_MAIN_SGML_FILE) html
209         @for f in $(content_files); do cp $(srcdir)/$$f html; done
210         cp -pr xml html
211         cp ../version.entities html
212         cd html && gtkdoc-mkhtml $(DOC_MODULE) $(DOC_MAIN_SGML_FILE)
213         mv html/index.sgml html/index.sgml.bak
214         $(SED) "s/ href=\"$(DOC_MODULE)\// href=\"$(DOC_MODULE)-@GST_MAJORMINOR@\//g" html/index.sgml.bak >html/index.sgml
215         rm -f html/index.sgml.bak
216         rm -f html/$(DOC_MAIN_SGML_FILE)
217         rm -rf html/xml
218         rm -f html/version.entities
219         test "x$(HTML_IMAGES)" = "x" || for i in "" $(HTML_IMAGES) ; do \
220             if test "$$i" != ""; then cp $(srcdir)/$$i html ; fi; done
221         @echo '-- Fixing Crossreferences'
222         gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
223         touch html-build.stamp
224
225 clean-local-gtkdoc:
226         rm -rf xml tmpl html
227 # clean files copied for nonsrcdir templates build
228         if test x"$(srcdir)" != x. ; then \
229             rm -rf $(SCANOBJ_FILES) $(SCAN_FILES) $(REPORT_FILES) \
230                 $(MAINTAINER_DOC_STAMPS); \
231         fi
232 else
233 all-local:
234 clean-local-gtkdoc:
235 endif
236
237 clean-local: clean-local-gtkdoc
238         rm -f *~ *.bak
239         rm -rf .libs
240
241 distclean-local:
242         rm -f $(REPORT_FILES) \
243                 $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
244         rm -rf tmpl/*.sgml.bak
245         rm -f $(DOC_MODULE).hierarchy
246         rm -f *.stamp || true
247         if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
248             rm -f $(DOC_MODULE)-docs.sgml ; \
249             rm -f $(DOC_MODULE).types ; \
250             rm -f $(DOC_MODULE).interfaces ; \
251             rm -f $(DOC_MODULE)-overrides.txt ; \
252             rm -f $(DOC_MODULE).prerequisites ; \
253             rm -f $(DOC_MODULE)-sections.txt ; \
254             rm -rf tmpl/*.sgml ; \
255         fi
256         rm -rf *.o
257
258 MAINTAINERCLEANFILES = $(MAINTAINER_DOC_STAMPS)
259
260 # thomas: make docs parallel installable; devhelp requires majorminor too
261 install-data-local:
262         (installfiles=`echo $(builddir)/html/*.sgml $(builddir)/html/*.html $(builddir)/html/*.png $(builddir)/html/*.css`; \
263         if test "$$installfiles" = '$(builddir)/html/*.sgml $(builddir)/html/*.html $(builddir)/html/*.png $(builddir)/html/*.css'; \
264         then echo '-- Nothing to install' ; \
265         else \
266           $(mkinstalldirs) $(DESTDIR)$(TARGET_DIR); \
267           for i in $$installfiles; do \
268             echo '-- Installing '$$i ; \
269             $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
270           done; \
271           pngfiles=`echo ./html/*.png`; \
272           if test "$$pngfiles" != './html/*.png'; then \
273             for i in $$pngfiles; do \
274               echo '-- Installing '$$i ; \
275               $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
276             done; \
277           fi; \
278           echo '-- Installing $(builddir)/html/$(DOC_MODULE).devhelp' ; \
279           $(INSTALL_DATA) $(builddir)/html/$(DOC_MODULE).devhelp \
280             $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp; \
281           if test -e $(builddir)/html/$(DOC_MODULE).devhelp2; then \
282                     $(INSTALL_DATA) $(builddir)/html/$(DOC_MODULE).devhelp2 \
283                     $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp2; \
284           fi; \
285           (which gtkdoc-rebase >/dev/null && \
286             gtkdoc-rebase --relative --dest-dir=$(DESTDIR) --html-dir=$(DESTDIR)$(TARGET_DIR)) || true ; \
287         fi)
288 uninstall-local:
289         if test -d $(DESTDIR)$(TARGET_DIR); then \
290           rm -rf $(DESTDIR)$(TARGET_DIR)/*; \
291           rmdir -p $(DESTDIR)$(TARGET_DIR) 2>/dev/null || true; \
292         else \
293           echo '-- Nothing to uninstall' ; \
294         fi;
295
296 #
297 # Checks
298 #
299 check-hierarchy: $(DOC_MODULE).hierarchy
300         @if grep '      ' $(DOC_MODULE).hierarchy; then \
301             echo "$(DOC_MODULE).hierarchy contains tabs, please fix"; \
302             /bin/false; \
303         fi
304
305 check: check-hierarchy
306
307 # wildcard is apparently not portable to other makes, hence the use of find
308 inspect_files = $(shell find $(srcdir)/$(INSPECT_DIR) -name '*.xml')
309
310 check-inspected-versions:
311         @echo Checking plugin versions of inspected plugin data ...; \
312         fail=0 ; \
313         for each in $(inspect_files) ; do \
314           if (grep -H '<version>' $$each | grep -v '<version>$(VERSION)'); then \
315             echo $$each should be fixed to say version $(VERSION) or be removed ; \
316             echo "sed -i -e 's/<version.*version>/<version>$(VERSION)<\/version>/'" $$each; \
317             echo ; \
318             fail=1; \
319           fi ; \
320         done ; \
321         exit $$fail
322
323 check-outdated-docs:
324         $(AM_V_GEN)echo Checking for outdated plugin inspect data ...; \
325         fail=0 ; \
326         if [ -d $(top_srcdir)/.git/ ]; then \
327           files=`find $(srcdir)/inspect/ -name '*xml'`; \
328           for f in $$files; do \
329             ver=`grep '<version>$(PACKAGE_VERSION)</version>' $$f`; \
330             if test "x$$ver" = "x"; then \
331               plugin=`echo $$f | sed -e 's/^.*plugin-//' -e 's/.xml//'`; \
332               # echo "Checking $$plugin $$f"; \
333               pushd "$(top_srcdir)" >/dev/null; \
334               pinit=`git grep -A3 GST_PLUGIN_DEFINE -- ext/ gst/ sys/ | grep "\"$$plugin\""`; \
335               popd >/dev/null; \
336               # echo "[$$pinit]"; \
337               if test "x$$pinit" = "x"; then \
338                 printf " **** outdated docs for plugin %-15s: %s\n" $$plugin $$f; \
339                 fail=1; \
340               fi; \
341             fi; \
342           done; \
343         fi ; \
344         exit $$fail
345
346 #
347 # Require gtk-doc when making dist
348 #
349 if ENABLE_GTK_DOC
350 dist-check-gtkdoc:
351 else
352 dist-check-gtkdoc:
353         @echo "*** gtk-doc must be installed and enabled in order to make dist"
354         @false
355 endif
356
357 # FIXME: decide whether we want to dist generated html or not
358 # also this only works, if the project has been build before
359 # we could dist html only if its there, but that might lead to missing html in
360 # tarballs
361 dist-hook: dist-check-gtkdoc dist-hook-local
362         mkdir $(distdir)/html
363         cp html/* $(distdir)/html
364         -cp $(srcdir)/$(DOC_MODULE).types $(distdir)/
365         -cp $(srcdir)/$(DOC_MODULE)-sections.txt $(distdir)/
366         cd $(distdir) && rm -f $(DISTCLEANFILES)
367         -gtkdoc-rebase --online --relative --html-dir=$(distdir)/html
368
369 .PHONY : dist-hook-local docs check-outdated-docs inspect
370
371 # avoid spurious build errors when distchecking with -jN
372 .NOTPARALLEL: