d7dc4fdd42da65d58fdaa5a1f295c8d69dae7384
[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 "If you are a doc maintainer, run 'make update' to update"
6         @echo "the documentation files maintained in CVS"
7
8 # update the stuff maintained by doc maintainers
9 update:
10         make inspect-update
11         make scanobj-update
12
13 # We set GPATH here; this gives us semantics for GNU make
14 # which are more like other make's VPATH, when it comes to
15 # whether a source that is a target of one rule is then
16 # searched for in VPATH/GPATH.
17 #
18 GPATH = $(srcdir)
19
20 # thomas: make docs parallel installable
21 TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@
22
23 EXTRA_DIST =                            \
24         scanobj.stamp                   \
25         scanobj-build.stamp             \
26         $(srcdir)/inspect/*.xml         \
27         inspect.stamp                   \
28         inspect-build.stamp             \
29         $(SCANOBJ_FILES)                \
30         $(content_files)                \
31         $(extra_files)                  \
32         $(HTML_IMAGES)                  \
33         $(DOC_MAIN_SGML_FILE)           \
34         $(DOC_MODULE).types             \
35         $(DOC_OVERRIDES)                \
36         $(DOC_MODULE)-sections.txt
37
38 MAINTAINER_DOC_STAMPS =                 \
39         scanobj-build.stamp             \
40         inspect-build.stamp             \
41         inspect.stamp
42
43 # we don't add inspect-build.stamp and scanobj-build.stamp here since they are
44 # built manually by docs maintainers and result is commited to CVS
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).args
62
63 SCANOBJ_FILES_O =                       \
64         .libs/$(DOC_MODULE)-scan.o
65
66 # files generated/updated by gtkdoc-scan
67 SCAN_FILES =                            \
68         $(DOC_MODULE)-sections.txt      \
69         $(DOC_MODULE)-overrides.txt     \
70         $(DOC_MODULE)-undocumented.txt  \
71         $(DOC_MODULE)-decl.txt          \
72         $(DOC_MODULE)-decl-list.txt
73
74 if ENABLE_GTK_DOC
75 all-local: html-build.stamp
76
77 #### scan gobjects; done by documentation maintainer ####
78 scanobj-update:
79         -rm scanobj-build.stamp
80         make scanobj-build.stamp
81
82 # in the case of non-srcdir builds, the built gst directory gets added
83 # to gtk-doc scanning; but only then, to avoid duplicates
84 # FIXME: since we don't have the scan step as part of the build anymore,
85 # we could remove that
86 # TODO: finish elite script that updates the output files of this step
87 # instead of rewriting them, so that multiple maintainers can generate
88 # a collective set of args and signals
89 scanobj-build.stamp: $(HFILE_GLOB) $(SCANOBJ_DEPS) $(basefiles)
90         @echo '*** Scanning header files ***'
91         if test x"$(srcdir)" != x. ; then                               \
92             for f in $(SCANOBJ_FILES);                                  \
93             do                                                          \
94                 cp $(srcdir)/$$f . ;                                    \
95             done;                                                       \
96         else                                                            \
97             GST_PLUGIN_PATH=`cd $(top_builddir) && pwd`                 \
98             GST_PLUGIN_PATH_ONLY=1                                      \
99             CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)"                         \
100             CFLAGS="$(GTKDOC_CFLAGS)" LDFLAGS="$(GTKDOC_LIBS)"          \
101             $(GST_DOC_SCANOBJ) --type-init-func="gst_init(NULL,NULL)"   \
102                 --module=$(DOC_MODULE) --source=$(PACKAGE);                             \
103         fi
104         touch scanobj-build.stamp
105
106 $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(SCANOBJ_FILES_O): scan-build.stamp
107         @true
108
109 ### inspect GStreamer plug-ins; done by documentation maintainer ###
110
111 # only look at the plugins in this module when building inspect .xml stuff
112 INSPECT_REGISTRY=$(top_builddir)/docs/plugins/inspect-registry.xml
113 INSPECT_ENVIRONMENT=\
114         GST_PLUGIN_PATH_ONLY=yes \
115         GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/sys:$(top_builddir)/ext \
116         GST_REGISTRY=$(INSPECT_REGISTRY)
117
118 # update the element and plugin XML descriptions; store in inspect/
119 inspect:
120         mkdir inspect
121
122 inspect-update: inspect
123         -rm inspect-build.stamp
124         make inspect-build.stamp
125
126 # FIXME: inspect.stamp should be written to by gst-xmlinspect.py
127 # IFF the output changed; see gtkdoc-mktmpl
128 inspect-build.stamp:
129         @echo '*** Rebuilding plugin inspection files ***'
130         if test x"$(srcdir)" != x. ; then \
131             cp $(srcdir)/inspect.stamp . ; \
132             cp $(srcdir)/inspect-build.stamp . ; \
133         else \
134             $(INSPECT_ENVIRONMENT) $(PYTHON) \
135                 $(top_srcdir)/common/gst-xmlinspect.py $(PACKAGE) inspect && \
136             echo -n "timestamp" > inspect.stamp && \
137             touch inspect-build.stamp; \
138         fi
139
140 ### scan headers; done on every build ###
141 scan-build.stamp: $(HFILE_GLOB) $(EXTRA_HFILES) $(basefiles) scanobj-build.stamp inspect-build.stamp
142             if test "x$(top_srcdir)" != "x$(top_builddir)";             \
143             then                                                        \
144               export BUILT_OPTIONS="--source-dir=$(top_builddir)/gst";  \
145             fi;                                                         \
146             gtkdoc-scan                                                 \
147                 $(SCAN_OPTIONS) $(EXTRA_HFILES)                         \
148                 --module=$(DOC_MODULE)                                  \
149                 $$BUILT_OPTIONS                                         \
150                 --ignore-headers="$(IGNORE_HFILES)";                    \
151             touch scan-build.stamp
152
153 #### update templates; done on every build ####
154
155 ### FIXME: make this error out again when docs are fixed for 0.9
156 # in a non-srcdir build, we need to copy files from the previous step
157 # and the files from previous runs of this step
158 tmpl-build.stamp: $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_OVERRIDES)
159         @echo '*** Rebuilding template files ***'
160         if test x"$(srcdir)" != x. ; then                               \
161             for f in $(SCANOBJ_FILES) $(SCAN_FILES);                    \
162             do                                                          \
163                 if test -e $(srcdir)/$$f; then cp $(srcdir)/$$f . ; fi; \
164             done;                                                       \
165         fi
166         gtkdoc-mktmpl --module=$(DOC_MODULE) | tee tmpl-build.log
167         $(PYTHON) \
168                 $(top_srcdir)/common/mangle-tmpl.py $(srcdir)/inspect tmpl
169         @cat $(DOC_MODULE)-unused.txt
170         rm -f tmpl-build.log
171         touch tmpl-build.stamp
172
173 tmpl.stamp: tmpl-build.stamp
174         @true
175
176 #### build xml; done on every build ####
177
178 ### FIXME: make this error out again when docs are fixed for 0.9
179 sgml-build.stamp: tmpl.stamp inspect.stamp $(CFILE_GLOB) $(top_srcdir)/common/plugins.xsl
180         @echo '*** Building XML ***'
181         @-mkdir -p xml
182         @for a in $(srcdir)/inspect/*.xml; do \
183             xsltproc --stringparam module $(MODULE) \
184                 $(top_srcdir)/common/plugins.xsl $$a > xml/`basename $$a`; done
185         @for f in $(EXAMPLE_CFILES); do \
186                 $(PYTHON) $(top_srcdir)/common/c-to-xml.py $$f > xml/element-`basename $$f .c`.xml; done
187         gtkdoc-mkdb \
188                 --module=$(DOC_MODULE) \
189                 --source-dir=$(DOC_SOURCE_DIR) \
190                 --main-sgml-file=$(srcdir)/$(DOC_MAIN_SGML_FILE) \
191                 --output-format=xml \
192                 --ignore-files="$(IGNORE_HFILES) $(IGNORE_CFILES)" \
193                 $(MKDB_OPTIONS) \
194                 | tee sgml-build.log
195         @if grep "WARNING:" sgml-build.log > /dev/null; then true; fi # exit 1; fi
196         cp ../version.entities xml
197         rm sgml-build.log
198         touch sgml-build.stamp
199
200 sgml.stamp: sgml-build.stamp
201         @true
202
203 #### build html; done on every step ####
204
205 html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
206         @echo '*** Building HTML ***'
207         if test -d html; then rm -rf html; fi
208         mkdir html
209         cp $(srcdir)/$(DOC_MAIN_SGML_FILE) html
210         @for f in $(content_files); do cp $(srcdir)/$$f html; done
211         cp -pr xml html
212         cp ../version.entities html
213         cd html && gtkdoc-mkhtml $(DOC_MODULE) $(DOC_MAIN_SGML_FILE)
214         rm -f html/$(DOC_MAIN_SGML_FILE)
215         rm -rf html/xml
216         rm -f html/version.entities
217         test "x$(HTML_IMAGES)" = "x" || for i in "" $(HTML_IMAGES) ; do \
218             if test "$$i" != ""; then cp $(srcdir)/$$i html ; fi; done
219         @echo '-- Fixing Crossreferences' 
220         gtkdoc-fixxref --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
221         touch html-build.stamp
222 else
223 all-local:
224 endif
225
226 # FC3 seems to need -scan.c to be part of CLEANFILES for distcheck
227 # no idea why FC4 can do without
228 CLEANFILES = \
229         $(SCANOBJ_FILES_O) \
230         $(DOC_MODULE)-scan.c \
231         $(DOC_MODULE)-unused.txt \
232         $(DOC_STAMPS) \
233         inspect-registry.xml
234
235 # FIXME: these rules need a little cleaning up
236 clean-local:
237         rm -f *~ *.bak
238         rm -rf .libs
239 # clean files generated for tmpl build
240         -rm -rf tmpl
241 # clean files copied/generated for nonsrcdir tmpl build
242         if test x"$(srcdir)" != x. ; then \
243             rm -rf $(SCANOBJ_FILES) $(SCAN_FILES);                      \
244         fi
245 # clean files generated for xml build
246         -rm -rf xml
247 # clean files generate for html build
248         -rm -rf html
249
250 distclean-local: clean
251         rm -rf tmpl/*.sgml.bak
252         rm -f *.stamp || true
253         rm -rf *.o
254
255 # thomas: make docs parallel installable; devhelp requires majorminor too
256 install-data-local:
257         $(mkinstalldirs) $(DESTDIR)$(TARGET_DIR) 
258         (installfiles=`echo ./html/*.html`; \
259         if test "$$installfiles" = './html/*.html'; \
260         then echo '-- Nothing to install' ; \
261         else \
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           echo '-- Installing $(srcdir)/html/index.sgml' ; \
277           $(INSTALL_DATA) $(srcdir)/html/index.sgml $(DESTDIR)$(TARGET_DIR); \
278                 if test -e $(srcdir)/html/style.css; then \
279                         echo '-- Installing $(srcdir)/html/style.css' ; \
280                         $(INSTALL_DATA) $(srcdir)/html/style.css $(DESTDIR)$(TARGET_DIR); \
281                 fi; \
282         fi) 
283 uninstall-local:
284         (installfiles=`echo ./html/*.html`; \
285         if test "$$installfiles" = './html/*.html'; \
286         then echo '-- Nothing to uninstall' ; \
287         else \
288           for i in $$installfiles; do \
289             rmfile=`basename $$i` ; \
290             echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/'$$rmfile ; \
291             rm -f $(DESTDIR)$(TARGET_DIR)/$$rmfile; \
292           done; \
293           pngfiles=`echo ./html/*.png`; \
294           if test "$$pngfiles" != './html/*.png'; then \
295             for i in $$pngfiles; do \
296               rmfile=`basename $$i` ; \
297               echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/'$$rmfile ; \
298               rm -f $(DESTDIR)$(TARGET_DIR)/$$rmfile; \
299             done; \
300           fi; \
301           echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE).devhelp' ; \
302           rm -f $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp; \
303           echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/index.sgml' ; \
304           rm -f $(DESTDIR)$(TARGET_DIR)/index.sgml; \
305                 if test -e $(DESTDIR)$(TARGET_DIR)/style.css; then \
306                         echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/style.css' ; \
307                         rm -f $(DESTDIR)$(TARGET_DIR)/style.css; \
308                 fi; \
309         fi) 
310         if test -d $(DESTDIR)$(TARGET_DIR); then rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(TARGET_DIR) 2>/dev/null; fi; true
311
312 #
313 # Require gtk-doc when making dist
314 #
315 if ENABLE_GTK_DOC
316 dist-check-gtkdoc:
317 else
318 dist-check-gtkdoc:
319         @echo "*** gtk-doc must be installed and enabled in order to make dist"
320         @false
321 endif
322
323 # FIXME: decide whether we want to dist generated html or not
324 dist-hook: dist-check-gtkdoc dist-hook-local
325         mkdir $(distdir)/tmpl
326         mkdir $(distdir)/xml
327         mkdir $(distdir)/html
328         -cp $(srcdir)/tmpl/*.sgml $(distdir)/tmpl
329         -cp $(srcdir)/sgml/*.xml $(distdir)/xml
330         -cp $(srcdir)/html/index.sgml $(distdir)/html
331         -cp $(srcdir)/html/*.html $(srcdir)/html/*.css $(distdir)/html
332         -cp $(srcdir)/html/$(DOC_MODULE).devhelp $(distdir)/html
333
334         images=$(HTML_IMAGES) ;               \
335         for i in "" $$images ; do                     \
336           if test "$$i" != ""; then cp $(srcdir)/$$i $(distdir)/html ; fi; \
337         done
338
339 .PHONY : dist-hook-local