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