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