gtk-doc.mak: Also cp the entities here to all xinlcude based docs (workaround for...
[platform/upstream/gst-common.git] / gtk-doc.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         $(content_files)                \
19         $(extra_files)                  \
20         $(HTML_IMAGES)                  \
21         $(DOC_MAIN_SGML_FILE)           \
22         $(DOC_MODULE).types             \
23         $(DOC_OVERRIDES)                \
24         $(DOC_MODULE)-sections.txt
25
26 DOC_STAMPS =                            \
27         scan-build.stamp                \
28         tmpl-build.stamp                \
29         sgml-build.stamp                \
30         html-build.stamp                \
31         $(srcdir)/tmpl.stamp            \
32         $(srcdir)/sgml.stamp            \
33         $(srcdir)/html.stamp
34
35 SCANOBJ_FILES =                         \
36         $(DOC_MODULE).args              \
37         $(DOC_MODULE).hierarchy         \
38         $(DOC_MODULE).interfaces                \
39         $(DOC_MODULE).prerequisites     \
40         $(DOC_MODULE).signals           \
41         .libs/$(DOC_MODULE)-scan.o
42
43 REPORT_FILES = \
44         $(DOC_MODULE)-undocumented.txt \
45         $(DOC_MODULE)-undeclared.txt \
46         $(DOC_MODULE)-unused.txt
47
48 CLEANFILES = $(SCANOBJ_FILES) $(REPORT_FILES) $(DOC_STAMPS) doc-registry.xml
49
50 if ENABLE_GTK_DOC
51 all-local: html-build.stamp
52
53 #### scan ####
54
55 # in the case of non-srcdir builds, the built gst directory gets added
56 # to gtk-doc scanning; but only then, to avoid duplicates
57 scan-build.stamp: $(HFILE_GLOB) $(SCANOBJ_DEPS) $(basefiles)
58         @echo '*** Scanning header files ***'
59         if grep -l '^..*$$' $(srcdir)/$(DOC_MODULE).types > /dev/null;  \
60         then                                                            \
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_SYSTEM_PATH=`cd $(top_builddir) && pwd`          \
66             GST_PLUGIN_PATH=                                            \
67             GST_REGISTRY=doc-registry.xml                               \
68             CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)"                         \
69             CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS)"                         \
70             LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)"                         \
71             gtkdoc-scangobj --type-init-func="gst_init(NULL,NULL)"      \
72                 --module=$(DOC_MODULE) ;                                \
73         else                                                            \
74             cd $(srcdir) ;                                              \
75             for i in $(SCANOBJ_FILES) ; do                              \
76                test -f $$i || touch $$i ;                               \
77             done                                                        \
78         fi
79         if test "x$(top_srcdir)" != "x$(top_builddir)";                 \
80         then                                                            \
81           export BUILT_OPTIONS="--source-dir=$(DOC_BUILD_DIR)";         \
82         fi;                                                             \
83         gtkdoc-scan                                                     \
84                 $(SCAN_OPTIONS) $(EXTRA_HFILES)                         \
85                 --module=$(DOC_MODULE)                                  \
86                 --source-dir=$(DOC_SOURCE_DIR)                          \
87                 $$BUILT_OPTIONS                                         \
88                 --ignore-headers="$(IGNORE_HFILES)"
89         touch scan-build.stamp
90
91 $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES): scan-build.stamp
92         @true
93
94 #### templates ####
95
96 tmpl-build.stamp: $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_OVERRIDES)
97         @echo '*** Rebuilding template files ***'
98         if test x"$(srcdir)" != x. ; then \
99             cp $(srcdir)/$(DOC_MODULE)-sections.txt . ; \
100             touch $(DOC_MODULE)-decl.txt ; \
101         fi
102         gtkdoc-mktmpl --module=$(DOC_MODULE) | tee tmpl-build.log
103         @if test -s $(DOC_MODULE)-unused.txt; then \
104             exit $(if $(DOCS_ARE_INCOMPLETE_PLEASE_FIXME),0,1); fi
105         rm -f tmpl-build.log
106         touch tmpl-build.stamp
107
108 tmpl.stamp: tmpl-build.stamp
109         @true
110
111 #### xml ####
112
113 ### FIXME: make this error out again when docs are complete
114 sgml-build.stamp: tmpl.stamp $(CFILE_GLOB)
115         @echo '*** Building XML ***'
116         gtkdoc-mkdb --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) --main-sgml-file=$(srcdir)/$(DOC_MAIN_SGML_FILE) --output-format=xml $(MKDB_OPTIONS) | tee sgml-build.log
117         @if grep "WARNING:" sgml-build.log > /dev/null; then true; fi # exit 1; fi
118         cp ../version.entities xml
119         rm sgml-build.log
120         touch sgml-build.stamp
121
122 sgml.stamp: sgml-build.stamp
123         @true
124
125 #### html ####
126
127 html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
128         @echo '*** Building HTML ***'
129         if test -d html; then rm -rf html; fi
130         mkdir html
131         cp $(srcdir)/$(DOC_MAIN_SGML_FILE) html
132         @for f in $(content_files); do cp $(srcdir)/$$f html; done
133         cp -pr xml html
134         cp ../version.entities html
135         cd html && gtkdoc-mkhtml $(DOC_MODULE) $(DOC_MAIN_SGML_FILE)
136         mv html/index.sgml html/index.sgml.bak
137         $(SED) "s/ href=\"$(DOC_MODULE)\// href=\"$(DOC_MODULE)-@GST_MAJORMINOR@\//g" html/index.sgml.bak >html/index.sgml
138         rm -f html/index.sgml.bak
139         rm -f html/$(DOC_MAIN_SGML_FILE)
140         rm -rf html/xml
141         rm -f html/version.entities
142         test "x$(HTML_IMAGES)" = "x" || for i in "" $(HTML_IMAGES) ; do \
143             if test "$$i" != ""; then cp $(srcdir)/$$i html ; fi; done
144         @echo '-- Fixing Crossreferences' 
145         gtkdoc-fixxref --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
146         touch html-build.stamp
147
148 clean-local-gtkdoc:
149         rm -rf xml tmpl html
150 # clean files copied for nonsrcdir templates build
151         if test x"$(srcdir)" != x. ; then \
152                 rm -rf $(DOC_MODULE).types; \
153         fi
154 else
155 all-local:
156 clean-local-gtkdoc:
157 endif
158
159 clean-local: clean-local-gtkdoc
160         rm -f *~ *.bak
161         rm -rf .libs
162
163 # company: don't delete .sgml and -sections.txt as they're in CVS
164 # FIXME : thomas added all sgml files and some other things to make
165 # make distcheck work
166 distclean-local: clean
167         rm -f $(REPORT_FILES) \
168                 $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
169         rm -rf tmpl/*.sgml.bak
170         rm -f $(DOC_MODULE).hierarchy
171         rm -f *.stamp || true
172         if test x"$(srcdir)" != x. ; then \
173             rm -f $(DOC_MODULE)-docs.sgml ; \
174             rm -f $(DOC_MODULE).types ; \
175             rm -f $(DOC_MODULE).interfaces ; \
176             rm -f $(DOC_MODULE)-overrides.txt ; \
177             rm -f $(DOC_MODULE).prerequisites ; \
178             rm -f $(DOC_MODULE)-sections.txt ; \
179             rm -rf tmpl/*.sgml ; \
180         fi
181         rm -rf *.o
182
183 maintainer-clean-local: clean
184         cd $(srcdir) && rm -rf html \
185                 xml $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
186
187 # thomas: make docs parallel installable; devhelp requires majorminor too
188 install-data-local:
189         (installfiles=`echo $(srcdir)/html/*.sgml $(srcdir)/html/*.html $(srcdir)/html/*.png $(srcdir)/html/*.css`; \
190         if test "$$installfiles" = '$(srcdir)/html/*.sgml $(srcdir)/html/*.html $(srcdir)/html/*.png $(srcdir)/html/*.css'; \
191         then echo '-- Nothing to install' ; \
192         else \
193           $(mkinstalldirs) $(DESTDIR)$(TARGET_DIR); \
194           for i in $$installfiles; do \
195             echo '-- Installing '$$i ; \
196             $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
197           done; \
198           echo '-- Installing $(srcdir)/html/$(DOC_MODULE).devhelp' ; \
199           $(INSTALL_DATA) $(srcdir)/html/$(DOC_MODULE).devhelp \
200             $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp; \
201           if test -e $(srcdir)/html/$(DOC_MODULE).devhelp2; then \
202                     $(INSTALL_DATA) $(srcdir)/html/$(DOC_MODULE).devhelp2 \
203                    $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp2; \
204           fi; \
205           (which gtkdoc-rebase >/dev/null && \
206             gtkdoc-rebase --relative --dest-dir=$(DESTDIR) --html-dir=$(DESTDIR)$(TARGET_DIR)) || true ; \
207         fi) 
208 uninstall-local:
209         (installfiles=`echo ./html/*.html`; \
210         if test "$$installfiles" = './html/*.html'; \
211         then echo '-- Nothing to uninstall' ; \
212         else \
213           for i in $$installfiles; do \
214             rmfile=`basename $$i` ; \
215             echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/'$$rmfile ; \
216             rm -f $(DESTDIR)$(TARGET_DIR)/$$rmfile; \
217           done; \
218           pngfiles=`echo ./html/*.png`; \
219           if test "$$pngfiles" != './html/*.png'; then \
220             for i in $$pngfiles; do \
221               rmfile=`basename $$i` ; \
222               echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/'$$rmfile ; \
223               rm -f $(DESTDIR)$(TARGET_DIR)/$$rmfile; \
224             done; \
225           fi; \
226           echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE).devhelp' ; \
227           rm -f $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp; \
228           if test -e $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp2; then \
229             rm -f $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp2; \
230           fi; \
231           echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/index.sgml' ; \
232           rm -f $(DESTDIR)$(TARGET_DIR)/index.sgml; \
233                 if test -e $(DESTDIR)$(TARGET_DIR)/style.css; then \
234                         echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/style.css' ; \
235                         rm -f $(DESTDIR)$(TARGET_DIR)/style.css; \
236                 fi; \
237         fi) 
238         if test -d $(DESTDIR)$(TARGET_DIR); then rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(TARGET_DIR) 2>/dev/null; fi; true
239
240 #
241 # Require gtk-doc when making dist
242 #
243 if ENABLE_GTK_DOC
244 dist-check-gtkdoc:
245 else
246 dist-check-gtkdoc:
247         @echo "*** gtk-doc must be installed and enabled in order to make dist"
248         @false
249 endif
250
251 dist-hook: dist-check-gtkdoc dist-hook-local
252         mkdir $(distdir)/html
253         cp $(srcdir)/html/* $(distdir)/html
254         -cp $(srcdir)/$(DOC_MODULE).types $(distdir)/
255         -cp $(srcdir)/$(DOC_MODULE)-sections.txt $(distdir)/
256         cd $(distdir) && rm -f $(DISTCLEANFILES)
257         -gtkdoc-rebase --online --relative --html-dir=$(distdir)/html
258
259 .PHONY : dist-hook-local docs