common/: a simple py script to generate valid xml from a C example probably also...
[platform/upstream/gst-common.git] / gtk-doc-plugins.mak
1 ###########################################################################
2 # Everything below here is generic and you shouldn't need to change it.
3 ###########################################################################
4 # thomas: except of course that we did
5
6 # thomas: copied from glib-2
7 # We set GPATH here; this gives us semantics for GNU make
8 # which are more like other make's VPATH, when it comes to
9 # whether a source that is a target of one rule is then
10 # searched for in VPATH/GPATH.
11 #
12 GPATH = $(srcdir)
13
14 # thomas: make docs parallel installable
15 TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@
16
17 EXTRA_DIST =                            \
18         inspect.stamp                   \
19         inspect-build.stamp             \
20         $(srcdir)/inspect/*.xml         \
21         $(content_files)                \
22         $(extra_files)                  \
23         $(HTML_IMAGES)                  \
24         $(DOC_MAIN_SGML_FILE)           \
25         $(DOC_MODULE).types             \
26         $(DOC_OVERRIDES)                \
27         $(DOC_MODULE)-sections.txt
28
29 # we don't add inspect-build.stamp here since this is run manually
30 # by docs maintainers and result is commited to CVS
31 DOC_STAMPS =                            \
32         scan-build.stamp                \
33         tmpl-build.stamp                \
34         sgml-build.stamp                \
35         html-build.stamp                \
36         $(srcdir)/tmpl.stamp            \
37         $(srcdir)/sgml.stamp            \
38         $(srcdir)/html.stamp
39
40 SCANOBJ_FILES =                         \
41         $(DOC_MODULE).args              \
42         $(DOC_MODULE).hierarchy         \
43         $(DOC_MODULE).interfaces        \
44         $(DOC_MODULE).prerequisites     \
45         .libs/$(DOC_MODULE)-scan.o      \
46         $(DOC_MODULE).signals
47
48 # FC3 seems to need -scan.c to be part of CLEANFILES for distcheck
49 # no idea why FC4 can do without
50 CLEANFILES = $(SCANOBJ_FILES) $(DOC_MODULE)-unused.txt $(DOC_STAMPS) $(DOC_MODULE)-scan.c
51
52 if ENABLE_GTK_DOC
53 all-local: html-build.stamp
54
55 #### scan ####
56
57 # in the case of non-srcdir builds, the built gst directory gets added
58 # to gtk-doc scanning; but only then, to avoid duplicates
59 scan-build.stamp: $(HFILE_GLOB) $(SCANOBJ_DEPS) $(basefiles)
60         @echo '*** Scanning header files ***'
61             if test x"$(srcdir)" != x. ; then                           \
62                 cp $(srcdir)/$(DOC_MODULE).types . ;                    \
63                 chmod u+w $(DOC_MODULE).types ;                         \
64             fi ;                                                        \
65             GST_PLUGIN_PATH=`cd $(top_builddir) && pwd`                 \
66             GST_PLUGIN_PATH_ONLY=1                                      \
67             CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)"                         \
68             CFLAGS="$(GTKDOC_CFLAGS)" LDFLAGS="$(GTKDOC_LIBS)"          \
69             $(GST_DOC_SCANOBJ) --type-init-func="gst_init(NULL,NULL)"   \
70                 --module=$(DOC_MODULE) ;                                \
71         if test "x$(top_srcdir)" != "x$(top_builddir)";                 \
72         then                                                            \
73           export BUILT_OPTIONS="--source-dir=$(top_builddir)/gst";      \
74         fi;                                                             \
75         gtkdoc-scan                                                     \
76                 $(SCAN_OPTIONS) $(EXTRA_HFILES)                         \
77                 --module=$(DOC_MODULE)                                  \
78                 $$BUILT_OPTIONS                                         \
79                 --ignore-headers="$(IGNORE_HFILES)"
80         touch scan-build.stamp
81
82 $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES): scan-build.stamp
83         @true
84
85 #### templates ####
86
87 ### FIXME: make this error out again when docs are fixed for 0.9
88 tmpl-build.stamp: $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_OVERRIDES)
89         @echo '*** Rebuilding template files ***'
90         if test x"$(srcdir)" != x. ; then \
91             cp $(srcdir)/$(DOC_MODULE)-sections.txt . ; \
92             touch $(DOC_MODULE)-decl.txt ; \
93         fi
94         gtkdoc-mktmpl --module=$(DOC_MODULE) | tee tmpl-build.log
95         @cat $(DOC_MODULE)-unused.txt
96         @if ! test -z "`grep -v GstPoptOption $(DOC_MODULE)-unused.txt`"; then \
97             true; fi # exit 1; fi
98         rm -f tmpl-build.log
99         touch tmpl-build.stamp
100
101 tmpl.stamp: tmpl-build.stamp
102         @true
103
104 #### inspect stuff ####
105 # this is stuff that should be built/updated manually by people that work
106 # on docs
107
108 # only look at the plugins in this module when building inspect .xml stuff
109 INSPECT_REGISTRY=$(top_builddir)/docs/plugins/inspect-registry.xml
110 INSPECT_ENVIRONMENT=\
111         GST_PLUGIN_PATH_ONLY=yes \
112         GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/sys:$(top_builddir)/ext \
113         GST_REGISTRY=$(INSPECT_REGISTRY)
114
115
116 # update the element and plugin XML descriptions; store in inspect/
117 inspect:
118         mkdir inspect
119
120 inspect-update:
121         rm inspect-build.stamp
122         make inspect-build.stamp
123
124 # FIXME: inspect.timestamp should be written to by gst-xmlinspect.py
125 # IFF the output changed; see gtkdoc-mktmpl
126 inspect-build.stamp: inspect
127         @echo '*** Rebuilding plugin inspection files ***'
128         if test x"$(srcdir)" != x. ; then \
129             cp $(srcdir)/inspect.stamp . ; \
130             cp $(srcdir)/inspect-build.stamp . ; \
131         else \
132             $(INSPECT_ENVIRONMENT) $(PYTHON) \
133                 $(top_srcdir)/common/gst-xmlinspect.py $(PACKAGE) inspect; \
134             $(INSPECT_ENVIRONMENT) $(PYTHON) \
135                 $(top_srcdir)/common/mangle-tmpl.py tmpl; \
136             echo -n "timestamp" > inspect.stamp; \
137             touch inspect-build.stamp; \
138         fi
139
140 inspect.stamp: inspect-build.stamp
141         @true
142
143 #### xml ####
144
145 ### FIXME: make this error out again when docs are fixed for 0.9
146 # first convert inspect/*.xml to xml
147 sgml-build.stamp: tmpl.stamp inspect.stamp $(CFILE_GLOB) $(top_srcdir)/common/plugins.xsl
148         @echo '*** Building XML ***'
149         @-mkdir -p xml
150         @for a in $(srcdir)/inspect/*.xml; do \
151             xsltproc --stringparam module $(MODULE) \
152                 $(top_srcdir)/common/plugins.xsl $$a > xml/`basename $$a`; done
153         @for f in $(EXAMPLE_CFILES); do \
154                 $(PYTHON) $(top_srcdir)/common/c-to-xml.py $$f > xml/element-`basename $$f .c`.xml; done
155         gtkdoc-mkdb \
156                 --module=$(DOC_MODULE) \
157                 --source-dir=$(DOC_SOURCE_DIR) \
158                 --main-sgml-file=$(srcdir)/$(DOC_MAIN_SGML_FILE) \
159                 --output-format=xml \
160                 --ignore-files="$(IGNORE_HFILES) $(IGNORE_CFILES)" \
161                 $(MKDB_OPTIONS) \
162                 | tee sgml-build.log
163         @if grep "WARNING:" sgml-build.log > /dev/null; then true; fi # exit 1; fi
164         cp ../version.entities xml
165         rm sgml-build.log
166         touch sgml-build.stamp
167
168 sgml.stamp: sgml-build.stamp
169         @true
170
171 #### html ####
172
173 html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(top_srcdir)/common/plugins.xsl
174         @echo '*** Building HTML ***'
175         if test -d html; then rm -rf html; fi
176         mkdir html
177         cp $(srcdir)/$(DOC_MAIN_SGML_FILE) html
178         @for f in $(content_files); do cp $(srcdir)/$$f html; done
179         cp -pr xml html
180         cp ../version.entities html
181         cd html && gtkdoc-mkhtml $(DOC_MODULE) $(DOC_MAIN_SGML_FILE)
182         rm -f html/$(DOC_MAIN_SGML_FILE)
183         rm -rf html/xml
184         rm -f html/version.entities
185         test "x$(HTML_IMAGES)" = "x" || for i in "" $(HTML_IMAGES) ; do \
186             if test "$$i" != ""; then cp $(srcdir)/$$i html ; fi; done
187         @echo '-- Fixing Crossreferences' 
188         gtkdoc-fixxref --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
189         touch html-build.stamp
190 else
191 all-local:
192 endif
193
194 clean-local:
195         rm -f *~ *.bak
196         rm -rf xml html
197         rm -rf .libs
198
199 maintainer-clean-local: clean
200         cd $(srcdir) && rm -rf xml html $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
201
202 # company: don't delete .sgml and -sections.txt as they're in CVS
203 # FIXME : thomas added all sgml files and some other things to make
204 # make distcheck work
205 distclean-local: clean
206         rm -f $(DOC_MODULE)-decl-list.txt
207         rm -f $(DOC_MODULE)-decl.txt
208         rm -f $(DOC_MODULE)-undocumented.txt
209         rm -f $(DOC_MODULE)-unused.txt
210         rm -rf tmpl/*.sgml.bak
211         rm -f $(DOC_MODULE).hierarchy
212         rm -f *.stamp || true
213         if test x"$(srcdir)" != x. ; then \
214             rm -f $(DOC_MODULE)-docs.sgml ; \
215             rm -f $(DOC_MODULE).types ; \
216             rm -f $(DOC_MODULE).interfaces ; \
217             rm -f $(DOC_MODULE)-overrides.txt ; \
218             rm -f $(DOC_MODULE).prerequisites ; \
219             rm -f $(DOC_MODULE)-sections.txt ; \
220             rm -rf tmpl/*.sgml ; \
221         fi
222         rm -rf *.o
223
224 # thomas: make docs parallel installable; devhelp requires majorminor too
225 install-data-local:
226         $(mkinstalldirs) $(DESTDIR)$(TARGET_DIR) 
227         (installfiles=`echo ./html/*.html`; \
228         if test "$$installfiles" = './html/*.html'; \
229         then echo '-- Nothing to install' ; \
230         else \
231           for i in $$installfiles; do \
232             echo '-- Installing '$$i ; \
233             $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
234           done; \
235           pngfiles=`echo ./html/*.png`; \
236           if test "$$pngfiles" != './html/*.png'; then \
237             for i in $$pngfiles; do \
238               echo '-- Installing '$$i ; \
239               $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
240             done; \
241           fi; \
242           echo '-- Installing $(srcdir)/html/$(DOC_MODULE).devhelp' ; \
243           $(INSTALL_DATA) $(srcdir)/html/$(DOC_MODULE).devhelp \
244             $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp; \
245           echo '-- Installing $(srcdir)/html/index.sgml' ; \
246           $(INSTALL_DATA) $(srcdir)/html/index.sgml $(DESTDIR)$(TARGET_DIR); \
247                 if test -e $(srcdir)/html/style.css; then \
248                         echo '-- Installing $(srcdir)/html/style.css' ; \
249                         $(INSTALL_DATA) $(srcdir)/html/style.css $(DESTDIR)$(TARGET_DIR); \
250                 fi; \
251         fi) 
252 uninstall-local:
253         (installfiles=`echo ./html/*.html`; \
254         if test "$$installfiles" = './html/*.html'; \
255         then echo '-- Nothing to uninstall' ; \
256         else \
257           for i in $$installfiles; do \
258             rmfile=`basename $$i` ; \
259             echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/'$$rmfile ; \
260             rm -f $(DESTDIR)$(TARGET_DIR)/$$rmfile; \
261           done; \
262           pngfiles=`echo ./html/*.png`; \
263           if test "$$pngfiles" != './html/*.png'; then \
264             for i in $$pngfiles; do \
265               rmfile=`basename $$i` ; \
266               echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/'$$rmfile ; \
267               rm -f $(DESTDIR)$(TARGET_DIR)/$$rmfile; \
268             done; \
269           fi; \
270           echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE).devhelp' ; \
271           rm -f $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp; \
272           echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/index.sgml' ; \
273           rm -f $(DESTDIR)$(TARGET_DIR)/index.sgml; \
274                 if test -e $(DESTDIR)$(TARGET_DIR)/style.css; then \
275                         echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/style.css' ; \
276                         rm -f $(DESTDIR)$(TARGET_DIR)/style.css; \
277                 fi; \
278         fi) 
279         if test -d $(DESTDIR)$(TARGET_DIR); then rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(TARGET_DIR) 2>/dev/null; fi; true
280
281 #
282 # Require gtk-doc when making dist
283 #
284 if ENABLE_GTK_DOC
285 dist-check-gtkdoc:
286 else
287 dist-check-gtkdoc:
288         @echo "*** gtk-doc must be installed and enabled in order to make dist"
289         @false
290 endif
291
292 dist-hook: dist-check-gtkdoc dist-hook-local
293         mkdir $(distdir)/tmpl
294         mkdir $(distdir)/xml
295         mkdir $(distdir)/html
296         -cp $(srcdir)/tmpl/*.sgml $(distdir)/tmpl
297         -cp $(srcdir)/sgml/*.xml $(distdir)/xml
298         -cp $(srcdir)/html/index.sgml $(distdir)/html
299         -cp $(srcdir)/html/*.html $(srcdir)/html/*.css $(distdir)/html
300         -cp $(srcdir)/html/$(DOC_MODULE).devhelp $(distdir)/html
301
302         images=$(HTML_IMAGES) ;               \
303         for i in "" $$images ; do                     \
304           if test "$$i" != ""; then cp $(srcdir)/$$i $(distdir)/html ; fi; \
305         done
306
307 .PHONY : dist-hook-local