e4fe5dbd1820e618cc288903ced44e333839efa9
[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-build.stamp             \
25         $(srcdir)/inspect/*.xml         \
26         inspect.stamp                   \
27         inspect-build.stamp             \
28         $(SCANOBJ_FILES)                \
29         $(content_files)                \
30         $(extra_files)                  \
31         $(HTML_IMAGES)                  \
32         $(DOC_MAIN_SGML_FILE)           \
33         $(DOC_MODULE).types             \
34         $(DOC_OVERRIDES)                \
35         $(DOC_MODULE)-sections.txt
36
37 MAINTAINER_DOC_STAMPS =                 \
38         scanobj-build.stamp             \
39         inspect-build.stamp             \
40         inspect.stamp
41
42 # we don't add inspect-build.stamp and scanobj-build.stamp here since they are
43 # built manually by docs maintainers and result is commited to CVS
44 DOC_STAMPS =                            \
45         scan-build.stamp                \
46         tmpl-build.stamp                \
47         sgml-build.stamp                \
48         html-build.stamp                \
49         scan.stamp                      \
50         tmpl.stamp                      \
51         sgml.stamp                      \
52         html.stamp
53
54 # files generated/updated by gtkdoc-scangobj
55 SCANOBJ_FILES =                         \
56         $(DOC_MODULE).signals           \
57         $(DOC_MODULE).hierarchy         \
58         $(DOC_MODULE).interfaces        \
59         $(DOC_MODULE).prerequisites     \
60         $(DOC_MODULE).args
61
62 SCANOBJ_FILES_O =                       \
63         .libs/$(DOC_MODULE)-scan.o
64
65 # files generated/updated by gtkdoc-scan
66 SCAN_FILES =                            \
67         $(DOC_MODULE)-sections.txt      \
68         $(DOC_MODULE)-overrides.txt     \
69         $(DOC_MODULE)-undocumented.txt  \
70         $(DOC_MODULE)-decl.txt          \
71         $(DOC_MODULE)-decl-list.txt
72
73 if ENABLE_GTK_DOC
74 all-local: html-build.stamp
75
76 #### scan gobjects; done by documentation maintainer ####
77 scanobj-update:
78         -rm scanobj-build.stamp
79         make scanobj-build.stamp
80
81 # in the case of non-srcdir builds, the built gst directory gets added
82 # to gtk-doc scanning; but only then, to avoid duplicates
83 # FIXME: since we don't have the scan step as part of the build anymore,
84 # we could remove that
85 # TODO: finish elite script that updates the output files of this step
86 # instead of rewriting them, so that multiple maintainers can generate
87 # a collective set of args and signals
88 scanobj-build.stamp: $(SCANOBJ_DEPS) $(basefiles)
89         @echo '*** Scanning GObjects ***'
90         if test x"$(srcdir)" != x. ; then                               \
91             for f in $(SCANOBJ_FILES);                                  \
92             do                                                          \
93                 cp $(srcdir)/$$f . ;                                    \
94             done;                                                       \
95         else                                                            \
96             $(INSPECT_ENVIRONMENT)                                      \
97             CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)"                         \
98             CFLAGS="-g $(GTKDOC_CFLAGS)" LDFLAGS="$(GTKDOC_LIBS)"               \
99             $(GST_DOC_SCANOBJ) --type-init-func="gst_init(NULL,NULL)"   \
100                 --module=$(DOC_MODULE) --source=$(PACKAGE) &&           \
101                 $(PYTHON)                                               \
102                 $(top_srcdir)/common/scangobj-merge.py $(DOC_MODULE);   \
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_SYSTEM_PATH= \
115         GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/sys:$(top_builddir)/ext:$(top_builddir)/plugins:$(top_builddir)/src \
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_REGISTRY)
124         -rm inspect-build.stamp
125         make inspect-build.stamp
126
127 # FIXME: inspect.stamp should be written to by gst-xmlinspect.py
128 # IFF the output changed; see gtkdoc-mktmpl
129 inspect-build.stamp:
130         @echo '*** Rebuilding plugin inspection files ***'
131         if test x"$(srcdir)" != x. ; then \
132             cp $(srcdir)/inspect.stamp . ; \
133             cp $(srcdir)/inspect-build.stamp . ; \
134         else \
135             $(INSPECT_ENVIRONMENT) $(PYTHON) \
136                 $(top_srcdir)/common/gst-xmlinspect.py $(PACKAGE) inspect && \
137             echo -n "timestamp" > inspect.stamp && \
138             touch inspect-build.stamp; \
139         fi
140
141 ### scan headers; done on every build ###
142 scan-build.stamp: $(HFILE_GLOB) $(EXTRA_HFILES) $(basefiles) scanobj-build.stamp inspect-build.stamp
143         if test "x$(top_srcdir)" != "x$(top_builddir)" &&               \
144            test -d "$(top_builddir)/gst";                               \
145         then                                                            \
146             export BUILT_OPTIONS="--source-dir=$(top_builddir)/gst";    \
147         fi;                                                             \
148         gtkdoc-scan                                                     \
149             $(SCAN_OPTIONS) $(EXTRA_HFILES)                             \
150             --module=$(DOC_MODULE)                                      \
151             $$BUILT_OPTIONS                                             \
152             --ignore-headers="$(IGNORE_HFILES)";                        \
153         touch scan-build.stamp
154
155 #### update templates; done on every build ####
156
157 ### FIXME: make this error out again when docs are fixed for 0.9
158 # in a non-srcdir build, we need to copy files from the previous step
159 # and the files from previous runs of this step
160 tmpl-build.stamp: $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_OVERRIDES)
161         @echo '*** Rebuilding template files ***'
162         if test x"$(srcdir)" != x. ; then                               \
163             for f in $(SCANOBJ_FILES) $(SCAN_FILES);                    \
164             do                                                          \
165                 if test -e $(srcdir)/$$f; then cp $(srcdir)/$$f . ; fi; \
166             done;                                                       \
167         fi
168         gtkdoc-mktmpl --module=$(DOC_MODULE) | tee tmpl-build.log
169         $(PYTHON) \
170                 $(top_srcdir)/common/mangle-tmpl.py $(srcdir)/inspect tmpl
171         @cat $(DOC_MODULE)-unused.txt
172         rm -f tmpl-build.log
173         touch tmpl-build.stamp
174
175 tmpl.stamp: tmpl-build.stamp
176         @true
177
178 #### build xml; done on every build ####
179
180 ### FIXME: make this error out again when docs are fixed for 0.9
181 sgml-build.stamp: tmpl.stamp inspect.stamp $(CFILE_GLOB) $(top_srcdir)/common/plugins.xsl
182         @echo '*** Building XML ***'
183         @-mkdir -p xml
184         @for a in $(srcdir)/inspect/*.xml; do \
185             xsltproc --stringparam module $(MODULE) \
186                 $(top_srcdir)/common/plugins.xsl $$a > xml/`basename $$a`; done
187         @for f in $(EXAMPLE_CFILES); do \
188                 $(PYTHON) $(top_srcdir)/common/c-to-xml.py $$f > xml/element-`basename $$f .c`.xml; done
189         gtkdoc-mkdb \
190                 --module=$(DOC_MODULE) \
191                 --source-dir=$(DOC_SOURCE_DIR) \
192                 --main-sgml-file=$(srcdir)/$(DOC_MAIN_SGML_FILE) \
193                 --output-format=xml \
194                 --ignore-files="$(IGNORE_HFILES) $(IGNORE_CFILES)" \
195                 $(MKDB_OPTIONS) \
196                 | tee sgml-build.log
197         @if grep "WARNING:" sgml-build.log > /dev/null; then true; fi # exit 1; fi
198         cp ../version.entities xml
199         rm sgml-build.log
200         touch sgml-build.stamp
201
202 sgml.stamp: sgml-build.stamp
203         @true
204
205 #### build html; done on every step ####
206
207 html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
208         @echo '*** Building HTML ***'
209         if test -d html; then rm -rf html; fi
210         mkdir html
211         cp $(srcdir)/$(DOC_MAIN_SGML_FILE) html
212         @for f in $(content_files); do cp $(srcdir)/$$f html; done
213         cp -pr xml html
214         cp ../version.entities html
215         cd html && gtkdoc-mkhtml $(DOC_MODULE) $(DOC_MAIN_SGML_FILE) \
216             2>&1 | tee ../html-build.log
217         @if grep "warning:" html-build.log > /dev/null; then \
218                 echo "ERROR"; grep "warning:" html-build.log; exit 1; fi
219         @rm html-build.log
220         rm -f html/$(DOC_MAIN_SGML_FILE)
221         rm -rf html/xml
222         rm -f html/version.entities
223         test "x$(HTML_IMAGES)" = "x" || for i in "" $(HTML_IMAGES) ; do \
224             if test "$$i" != ""; then cp $(srcdir)/$$i html ; fi; done
225         @echo '-- Fixing Crossreferences' 
226         gtkdoc-fixxref --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
227         touch html-build.stamp
228 else
229 all-local:
230 endif
231
232 # FC3 seems to need -scan.c to be part of CLEANFILES for distcheck
233 # no idea why FC4 can do without
234 CLEANFILES = \
235         $(SCANOBJ_FILES_O) \
236         $(DOC_MODULE)-scan.c \
237         $(DOC_MODULE)-unused.txt \
238         $(DOC_STAMPS) \
239         inspect-registry.xml
240
241 # FIXME: these rules need a little cleaning up
242 clean-local:
243         rm -f *~ *.bak
244         rm -rf .libs
245 # clean files generated for tmpl build
246         -rm -rf tmpl
247 # clean files copied/generated for nonsrcdir tmpl build
248         if test x"$(srcdir)" != x. ; then \
249             rm -rf $(SCANOBJ_FILES) $(SCAN_FILES);                      \
250         fi
251 # clean files generated for xml build
252         -rm -rf xml
253 # clean files generate for html build
254         -rm -rf html
255
256 distclean-local: clean
257         rm -rf tmpl/*.sgml.bak
258         rm -f *.stamp || true
259         rm -rf *.o
260
261 # thomas: make docs parallel installable; devhelp requires majorminor too
262 install-data-local:
263         $(mkinstalldirs) $(DESTDIR)$(TARGET_DIR) 
264         (installfiles=`echo ./html/*.html`; \
265         if test "$$installfiles" = './html/*.html'; \
266         then echo '-- Nothing to install' ; \
267         else \
268           for i in $$installfiles; do \
269             echo '-- Installing '$$i ; \
270             $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
271           done; \
272           pngfiles=`echo ./html/*.png`; \
273           if test "$$pngfiles" != './html/*.png'; then \
274             for i in $$pngfiles; do \
275               echo '-- Installing '$$i ; \
276               $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
277             done; \
278           fi; \
279           echo '-- Installing $(srcdir)/html/$(DOC_MODULE).devhelp' ; \
280           $(INSTALL_DATA) $(srcdir)/html/$(DOC_MODULE).devhelp \
281             $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp; \
282           echo '-- Installing $(srcdir)/html/index.sgml' ; \
283           $(INSTALL_DATA) $(srcdir)/html/index.sgml $(DESTDIR)$(TARGET_DIR); \
284                 if test -e $(srcdir)/html/style.css; then \
285                         echo '-- Installing $(srcdir)/html/style.css' ; \
286                         $(INSTALL_DATA) $(srcdir)/html/style.css $(DESTDIR)$(TARGET_DIR); \
287                 fi; \
288         fi) 
289 uninstall-local:
290         (installfiles=`echo ./html/*.html`; \
291         if test "$$installfiles" = './html/*.html'; \
292         then echo '-- Nothing to uninstall' ; \
293         else \
294           for i in $$installfiles; do \
295             rmfile=`basename $$i` ; \
296             echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/'$$rmfile ; \
297             rm -f $(DESTDIR)$(TARGET_DIR)/$$rmfile; \
298           done; \
299           pngfiles=`echo ./html/*.png`; \
300           if test "$$pngfiles" != './html/*.png'; then \
301             for i in $$pngfiles; do \
302               rmfile=`basename $$i` ; \
303               echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/'$$rmfile ; \
304               rm -f $(DESTDIR)$(TARGET_DIR)/$$rmfile; \
305             done; \
306           fi; \
307           echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE).devhelp' ; \
308           rm -f $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp; \
309           echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/index.sgml' ; \
310           rm -f $(DESTDIR)$(TARGET_DIR)/index.sgml; \
311                 if test -e $(DESTDIR)$(TARGET_DIR)/style.css; then \
312                         echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/style.css' ; \
313                         rm -f $(DESTDIR)$(TARGET_DIR)/style.css; \
314                 fi; \
315         fi) 
316         if test -d $(DESTDIR)$(TARGET_DIR); then rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(TARGET_DIR) 2>/dev/null; fi; true
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)/tmpl
332         mkdir $(distdir)/xml
333         mkdir $(distdir)/html
334         -cp $(srcdir)/tmpl/*.sgml $(distdir)/tmpl
335         -cp $(srcdir)/sgml/*.xml $(distdir)/xml
336         -cp $(srcdir)/html/index.sgml $(distdir)/html
337         -cp $(srcdir)/html/*.html $(srcdir)/html/*.css $(distdir)/html
338         -cp $(srcdir)/html/$(DOC_MODULE).devhelp $(distdir)/html
339
340         images=$(HTML_IMAGES) ;               \
341         for i in "" $$images ; do                     \
342           if test "$$i" != ""; then cp $(srcdir)/$$i $(distdir)/html ; fi; \
343         done
344
345 .PHONY : dist-hook-local