docs: update todo comment
[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).args              \
59         $(DOC_MODULE).hierarchy         \
60         $(DOC_MODULE).interfaces        \
61         $(DOC_MODULE).prerequisites     \
62         $(DOC_MODULE).signals           \
63         $(DOC_MODULE).types
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 CLEANFILES = \
82         $(SCANOBJ_FILES_O) \
83         $(REPORT_FILES) \
84         $(DOC_STAMPS) \
85         inspect-registry.xml
86
87 INSPECT_DIR = inspect
88
89 if ENABLE_GTK_DOC
90 all-local: html-build.stamp
91
92 ### inspect GStreamer plug-ins; done by documentation maintainer ###
93
94 # only look at the plugins in this module when building inspect .xml stuff
95 INSPECT_REGISTRY=$(top_builddir)/docs/plugins/inspect-registry.xml
96 INSPECT_ENVIRONMENT=\
97         LC_ALL=C \
98         GST_PLUGIN_SYSTEM_PATH= \
99         GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/sys:$(top_builddir)/ext:$(top_builddir)/plugins:$(top_builddir)/src:$(top_builddir)/gnl \
100         GST_REGISTRY=$(INSPECT_REGISTRY) \
101         PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" \
102         $(INSPECT_EXTRA_ENVIRONMENT)
103
104 #### scan gobjects; done by documentation maintainer ####
105 scanobj-update:
106         -rm scanobj-build.stamp
107         $(MAKE) scanobj-build.stamp
108
109 # gstdoc-scanobj produces 5 output files (.new)
110 # scangobj-merge.py merges them into the file which we commit later
111 # TODO: scangobj-merge.py only merges signals and args
112 #  - for interfaces and prerequisites do:
113 #    'sort -du file file.new' and update file if changed
114 #  - do that either in gstdoc-scanobj (which we change already) or in
115 #    scangobj-merge.py
116 scanobj-build.stamp: $(SCANOBJ_DEPS) $(basefiles)
117         @echo "  DOC   Introspecting gobjects"
118         @if test x"$(srcdir)" != x. ; then                              \
119             for f in $(SCANOBJ_FILES) $(SCAN_FILES);                    \
120             do                                                          \
121                 if test -e $(srcdir)/$$f; then cp -u $(srcdir)/$$f . ; fi;      \
122             done;                                                       \
123         fi;                                                             \
124         mkdir -p $(INSPECT_DIR); \
125         scanobj_options=""; \
126         if test "x$(V)" = "x1"; then \
127             scanobj_options="--verbose"; \
128         fi; \
129         $(INSPECT_ENVIRONMENT)                                  \
130         CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)"                             \
131         CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS) $(WARNING_CFLAGS)"   \
132         LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)"                             \
133         $(GST_DOC_SCANOBJ) $$scanobj_options --type-init-func="gst_init(NULL,NULL)"     \
134             --module=$(DOC_MODULE) --source=$(PACKAGE) --inspect-dir=$(INSPECT_DIR) &&          \
135             echo "  DOC   Merging introspection data" && \
136             $(PYTHON)                                           \
137             $(top_srcdir)/common/scangobj-merge.py $(DOC_MODULE);       \
138         if test x"$(srcdir)" != x. ; then                               \
139             for f in $(SCANOBJ_FILES);                                  \
140             do                                                          \
141                 cmp -s ./$$f $(srcdir)/$$f || cp ./$$f $(srcdir)/ ;             \
142             done;                                                       \
143         fi;                                                             \
144         touch scanobj-build.stamp
145
146 $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(SCANOBJ_FILES_O): scan-build.stamp
147         @true
148
149 ### scan headers; done on every build ###
150 scan-build.stamp: $(HFILE_GLOB) $(EXTRA_HFILES) $(basefiles) scanobj-build.stamp
151         @echo '  DOC   Scanning header files'
152         @gtkdoc-scan                                                    \
153             $(SCAN_OPTIONS) $(EXTRA_HFILES)                             \
154             --module=$(DOC_MODULE)                                      \
155             --source-dir=$(DOC_SOURCE_DIR)                              \
156             --ignore-headers="$(IGNORE_HFILES)";                        \
157         touch scan-build.stamp
158
159 #### update templates; done on every build ####
160
161 # in a non-srcdir build, we need to copy files from the previous step
162 # and the files from previous runs of this step
163 tmpl-build.stamp: $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_OVERRIDES)
164         @echo '  DOC   Rebuilding template files'
165         @if test x"$(srcdir)" != x. ; then                              \
166             for f in $(SCANOBJ_FILES) $(SCAN_FILES);                    \
167             do                                                          \
168                 if test -e $(srcdir)/$$f; then cp -u $(srcdir)/$$f . ; fi;      \
169             done;                                                       \
170         fi
171         @gtkdoc-mktmpl --module=$(DOC_MODULE)
172         @$(PYTHON) \
173                 $(top_srcdir)/common/mangle-tmpl.py $(srcdir)/$(INSPECT_DIR) tmpl
174         @touch tmpl-build.stamp
175
176 tmpl.stamp: tmpl-build.stamp
177         @true
178
179 #### xml ####
180
181 sgml-build.stamp: tmpl.stamp scan-build.stamp $(CFILE_GLOB) $(top_srcdir)/common/plugins.xsl $(expand_content_files)
182         @echo '  DOC   Building XML'
183         @-mkdir -p xml
184         @for a in $(srcdir)/$(INSPECT_DIR)/*.xml; do \
185             xsltproc --stringparam module $(MODULE) \
186                 $(top_srcdir)/common/plugins.xsl $$a > xml/`basename $$a`; done
187         @for f in $(EXAMPLE_CFILES); do \
188                 $(PYTHON) $(top_srcdir)/common/c-to-xml.py $$f > xml/element-`basename $$f .c`.xml; done
189         @gtkdoc-mkdb \
190                 --module=$(DOC_MODULE) \
191                 --source-dir=$(DOC_SOURCE_DIR) \
192                  --expand-content-files="$(expand_content_files)" \
193                 --main-sgml-file=$(srcdir)/$(DOC_MAIN_SGML_FILE) \
194                 --output-format=xml \
195                 --ignore-files="$(IGNORE_HFILES) $(IGNORE_CFILES)" \
196                 $(MKDB_OPTIONS)
197         @cp ../version.entities xml
198         @touch sgml-build.stamp
199
200 sgml.stamp: sgml-build.stamp
201         @true
202
203 #### html ####
204
205 html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
206         @echo '  DOC   Building HTML'
207         @rm -rf html
208         @mkdir html
209         @cp $(srcdir)/$(DOC_MAIN_SGML_FILE) html
210         @for f in $(content_files); do cp $(srcdir)/$$f html; done
211         @cp -pr xml html
212         @cp ../version.entities html
213         @mkhtml_options=""; \
214         gtkdoc-mkhtml 2>&1 --help | grep  >/dev/null "\-\-verbose"; \
215         if test "$(?)" = "0"; then \
216           if test "x$(V)" = "x1"; then \
217             mkhtml_options="$$mkhtml_options --verbose"; \
218           fi; \
219         fi; \
220         cd html && gtkdoc-mkhtml $$mkhtml_options $(DOC_MODULE) $(DOC_MAIN_SGML_FILE)
221         @mv html/index.sgml html/index.sgml.bak
222         @$(SED) "s/ href=\"$(DOC_MODULE)\// href=\"$(DOC_MODULE)-@GST_MAJORMINOR@\//g" html/index.sgml.bak >html/index.sgml
223         @rm -f html/index.sgml.bak
224         @rm -f html/$(DOC_MAIN_SGML_FILE)
225         @rm -rf html/xml
226         @rm -f html/version.entities
227         @test "x$(HTML_IMAGES)" = "x" || for i in "" $(HTML_IMAGES) ; do \
228             if test "$$i" != ""; then cp $(srcdir)/$$i html ; fi; done
229         @echo '  DOC   Fixing cross-references'
230         @gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
231         @touch html-build.stamp
232
233 clean-local-gtkdoc:
234         @rm -rf xml tmpl html
235 # clean files copied for nonsrcdir templates build
236         @if test x"$(srcdir)" != x. ; then \
237             rm -rf $(SCANOBJ_FILES) $(SCAN_FILES) $(REPORT_FILES) \
238                 $(MAINTAINER_DOC_STAMPS); \
239         fi
240 else
241 all-local:
242 clean-local-gtkdoc:
243 endif
244
245 clean-local: clean-local-gtkdoc
246         @rm -f *~ *.bak
247         @rm -rf .libs
248
249 distclean-local:
250         @rm -f $(REPORT_FILES) \
251                 $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
252         @rm -rf tmpl/*.sgml.bak
253         @rm -f $(DOC_MODULE).hierarchy
254         @rm -f *.stamp || true
255         @if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
256             rm -f $(DOC_MODULE)-docs.sgml ; \
257             rm -f $(DOC_MODULE).types ; \
258             rm -f $(DOC_MODULE).interfaces ; \
259             rm -f $(DOC_MODULE)-overrides.txt ; \
260             rm -f $(DOC_MODULE).prerequisites ; \
261             rm -f $(DOC_MODULE)-sections.txt ; \
262             rm -rf tmpl/*.sgml ; \
263             rm -rf $(INSPECT_DIR); \
264         fi
265         @rm -rf *.o
266
267 MAINTAINERCLEANFILES = $(MAINTAINER_DOC_STAMPS)
268
269 # thomas: make docs parallel installable; devhelp requires majorminor too
270 install-data-local:
271         (installfiles=`echo $(builddir)/html/*.sgml $(builddir)/html/*.html $(builddir)/html/*.png $(builddir)/html/*.css`; \
272         if test "$$installfiles" = '$(builddir)/html/*.sgml $(builddir)/html/*.html $(builddir)/html/*.png $(builddir)/html/*.css'; \
273         then echo '-- Nothing to install' ; \
274         else \
275           $(mkinstalldirs) $(DESTDIR)$(TARGET_DIR); \
276           for i in $$installfiles; do \
277             echo '-- Installing '$$i ; \
278             $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
279           done; \
280           pngfiles=`echo ./html/*.png`; \
281           if test "$$pngfiles" != './html/*.png'; then \
282             for i in $$pngfiles; do \
283               echo '-- Installing '$$i ; \
284               $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
285             done; \
286           fi; \
287           echo '-- Installing $(builddir)/html/$(DOC_MODULE).devhelp2' ; \
288           if test -e $(builddir)/html/$(DOC_MODULE).devhelp2; then \
289                     $(INSTALL_DATA) $(builddir)/html/$(DOC_MODULE).devhelp2 \
290                     $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp2; \
291           fi; \
292           (which gtkdoc-rebase >/dev/null && \
293             gtkdoc-rebase --relative --dest-dir=$(DESTDIR) --html-dir=$(DESTDIR)$(TARGET_DIR)) || true ; \
294         fi)
295 uninstall-local:
296         if test -d $(DESTDIR)$(TARGET_DIR); then \
297           rm -rf $(DESTDIR)$(TARGET_DIR)/*; \
298           rmdir -p $(DESTDIR)$(TARGET_DIR) 2>/dev/null || true; \
299         else \
300           echo '-- Nothing to uninstall' ; \
301         fi;
302
303 #
304 # Checks
305 #
306 if ENABLE_GTK_DOC
307 check-hierarchy: $(DOC_MODULE).hierarchy
308         @if grep '      ' $(DOC_MODULE).hierarchy; then \
309             echo "$(DOC_MODULE).hierarchy contains tabs, please fix"; \
310             /bin/false; \
311         fi
312
313 check: check-hierarchy
314 endif
315
316 # wildcard is apparently not portable to other makes, hence the use of find
317 inspect_files = $(shell find $(srcdir)/$(INSPECT_DIR) -name '*.xml')
318
319 check-inspected-versions:
320         @echo Checking plugin versions of inspected plugin data ...; \
321         fail=0 ; \
322         for each in $(inspect_files) ; do \
323           if (grep -H '<version>' $$each | grep -v '<version>$(VERSION)'); then \
324             echo $$each should be fixed to say version $(VERSION) or be removed ; \
325             echo "sed -i -e 's/<version.*version>/<version>$(VERSION)<\/version>/'" $$each; \
326             echo ; \
327             fail=1; \
328           fi ; \
329         done ; \
330         exit $$fail
331
332 check-outdated-docs:
333         $(AM_V_GEN)echo Checking for outdated plugin inspect data ...; \
334         fail=0 ; \
335         if [ -d $(top_srcdir)/.git/ ]; then \
336           files=`find $(srcdir)/inspect/ -name '*xml'`; \
337           for f in $$files; do \
338             ver=`grep '<version>$(PACKAGE_VERSION)</version>' $$f`; \
339             if test "x$$ver" = "x"; then \
340               plugin=`echo $$f | sed -e 's/^.*plugin-//' -e 's/.xml//'`; \
341               # echo "Checking $$plugin $$f"; \
342               pushd "$(top_srcdir)" >/dev/null; \
343               pinit=`git grep -A3 GST_PLUGIN_DEFINE -- ext/ gst/ sys/ | grep "\"$$plugin\""`; \
344               popd >/dev/null; \
345               # echo "[$$pinit]"; \
346               if test "x$$pinit" = "x"; then \
347                 printf " **** outdated docs for plugin %-15s: %s\n" $$plugin $$f; \
348                 fail=1; \
349               fi; \
350             fi; \
351           done; \
352         fi ; \
353         exit $$fail
354
355 #
356 # Require gtk-doc when making dist
357 #
358 if ENABLE_GTK_DOC
359 dist-check-gtkdoc:
360 else
361 dist-check-gtkdoc:
362         @echo "*** gtk-doc must be installed and enabled in order to make dist"
363         @false
364 endif
365
366 # FIXME: decide whether we want to dist generated html or not
367 # also this only works, if the project has been build before
368 # we could dist html only if its there, but that might lead to missing html in
369 # tarballs
370 dist-hook: dist-check-gtkdoc dist-hook-local
371         mkdir $(distdir)/html
372         cp html/* $(distdir)/html
373         -cp $(srcdir)/$(DOC_MODULE).types $(distdir)/
374         -cp $(srcdir)/$(DOC_MODULE)-sections.txt $(distdir)/
375         cd $(distdir) && rm -f $(DISTCLEANFILES)
376         -gtkdoc-rebase --online --relative --html-dir=$(distdir)/html
377
378 .PHONY : dist-hook-local docs check-outdated-docs inspect
379
380 # avoid spurious build errors when distchecking with -jN
381 .NOTPARALLEL: