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