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