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