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