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