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