gtk-doc.mak: update setup, cleanup rules
[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         setup-build.stamp               \
28         scan-build.stamp                \
29         sgml-build.stamp                \
30         html-build.stamp                \
31         sgml.stamp              \
32         html.stamp
33
34 SCANOBJ_FILES =                         \
35         $(DOC_MODULE).args              \
36         $(DOC_MODULE).hierarchy         \
37         $(DOC_MODULE).interfaces                \
38         $(DOC_MODULE).prerequisites     \
39         $(DOC_MODULE).signals           \
40         .libs/$(DOC_MODULE)-scan.o
41
42 REPORT_FILES = \
43         $(DOC_MODULE)-undocumented.txt \
44         $(DOC_MODULE)-undeclared.txt \
45         $(DOC_MODULE)-unused.txt
46
47 CLEANFILES = $(SCANOBJ_FILES) $(REPORT_FILES) $(DOC_STAMPS) doc-registry.xml
48
49 if ENABLE_GTK_DOC
50 all-local: html-build.stamp
51
52 #### setup ####
53
54 setup-build.stamp: $(content_files)
55         -@if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
56             files=`echo $(DOC_MAIN_SGML_FILE) $(DOC_OVERRIDES) $(DOC_MODULE)-sections.txt $(DOC_MODULE).types $(content_files)`; \
57             if test "x$$files" != "x" ; then \
58                 for file in $$files ; do \
59                     test -f $(abs_srcdir)/$$file && \
60                         cp -pu $(abs_srcdir)/$$file $(abs_builddir)/ || true; \
61                 done; \
62             fi; \
63         fi
64         @touch setup-build.stamp
65
66 #### scan ####
67
68 # in the case of non-srcdir builds, the built gst directory gets added
69 # to gtk-doc scanning; but only then, to avoid duplicates
70 scan-build.stamp: $(HFILE_GLOB) $(CFILE_GLOB)
71         @echo '*** Scanning header files ***'
72         @if grep -l '^..*$$' $(DOC_MODULE).types > /dev/null;   \
73         then                                                            \
74             GST_PLUGIN_SYSTEM_PATH=`cd $(top_builddir) && pwd`          \
75             GST_PLUGIN_PATH=                                            \
76             GST_REGISTRY=doc-registry.xml                               \
77             $(GTKDOC_EXTRA_ENVIRONMENT)                                 \
78             CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)"                         \
79             CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS)"                         \
80             LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)"                         \
81             gtkdoc-scangobj --type-init-func="gst_init(NULL,NULL)"      \
82                 --module=$(DOC_MODULE) ;                                \
83         else                                                            \
84             for i in $(SCANOBJ_FILES) ; do                              \
85                test -f $$i || touch $$i ;                               \
86             done                                                        \
87         fi
88         @if test "x$(top_srcdir)" != "x$(top_builddir)";                        \
89         then                                                            \
90           export BUILT_OPTIONS="--source-dir=$(DOC_BUILD_DIR)";         \
91         fi;                                                             \
92         gtkdoc-scan                                                     \
93                 $(SCAN_OPTIONS) $(EXTRA_HFILES)                         \
94                 --module=$(DOC_MODULE)                                  \
95                 --source-dir=$(DOC_SOURCE_DIR)                          \
96                 $$BUILT_OPTIONS                                         \
97                 --ignore-headers="$(IGNORE_HFILES)"
98         @touch scan-build.stamp
99
100 $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt: scan-build.stamp
101         @true
102
103 #### xml ####
104
105 ### FIXME: make this error out again when docs are complete
106 sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(expand_content_files)
107         @echo '*** Building XML ***'
108         @gtkdoc-mkdb --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR)  --expand-content-files="$(expand_content_files)" --main-sgml-file=$(DOC_MAIN_SGML_FILE) --output-format=xml $(MKDB_OPTIONS)
109         @cp ../version.entities xml
110         @touch sgml-build.stamp
111
112 sgml.stamp: sgml-build.stamp
113         @true
114
115 #### html ####
116
117 html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
118         @echo '*** Building HTML ***'
119         @rm -rf html
120         @mkdir html
121         @cp -pr xml html
122         @cp ../version.entities ./
123         @mkhtml_options=""; \
124         @gtkdoc-mkhtml 2>&1 --help | grep  >/dev/null "\-\-path"; \
125         if test "$(?)" = "0"; then \
126           mkhtml_options=--path="$(abs_srcdir)"; \
127         fi; \
128         cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
129         @mv html/index.sgml html/index.sgml.bak
130         @$(SED) "s/ href=\"$(DOC_MODULE)\// href=\"$(DOC_MODULE)-@GST_MAJORMINOR@\//g" html/index.sgml.bak >html/index.sgml
131         @rm -f html/index.sgml.bak
132         @rm -rf html/xml
133         @rm -f version.entities
134         @test "x$(HTML_IMAGES)" = "x" ||  ( cd $(srcdir) && cp $(HTML_IMAGES) $(abs_builddir)/html )
135         @echo '-- Fixing Crossreferences'
136         @gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
137         @touch html-build.stamp
138
139 clean-local-gtkdoc:
140         @rm -rf xml tmpl html
141 # clean files copied for nonsrcdir templates build
142         @if test x"$(srcdir)" != x. ; then \
143                 rm -rf $(DOC_MODULE).types; \
144         fi
145 else
146 all-local:
147 clean-local-gtkdoc:
148 endif
149
150 clean-local: clean-local-gtkdoc
151         @rm -f *~ *.bak
152         @rm -rf .libs
153
154 distclean-local:
155         @rm -f $(REPORT_FILES) \
156                 $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
157         @rm -rf tmpl/*.sgml.bak
158         @rm -f $(DOC_MODULE).hierarchy
159         @rm -f *.stamp || true
160         @if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
161             rm -f $(DOC_MAIN_SGML_FILE) ; \
162             rm -f $(DOC_OVERRIDES) ; \
163             rm -f $(DOC_MODULE).types ; \
164             rm -f $(DOC_MODULE).interfaces ; \
165             rm -f $(DOC_MODULE).prerequisites ; \
166             rm -f $(DOC_MODULE)-sections.txt ; \
167             rm -rf tmpl/*.sgml ; \
168         fi
169         @rm -rf *.o
170
171 maintainer-clean-local: clean
172         @cd $(srcdir) && rm -rf html \
173                 xml $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
174
175 # thomas: make docs parallel installable; devhelp requires majorminor too
176 install-data-local:
177         (installfiles=`echo $(builddir)/html/*.sgml $(builddir)/html/*.html $(builddir)/html/*.png $(builddir)/html/*.css`; \
178         if test "$$installfiles" = '$(builddir)/html/*.sgml $(builddir)/html/*.html $(builddir)/html/*.png $(builddir)/html/*.css'; \
179         then echo '-- Nothing to install' ; \
180         else \
181           $(mkinstalldirs) $(DESTDIR)$(TARGET_DIR); \
182           for i in $$installfiles; do \
183             echo '-- Installing '$$i ; \
184             $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
185           done; \
186           echo '-- Installing $(builddir)/html/$(DOC_MODULE).devhelp' ; \
187           $(INSTALL_DATA) $(builddir)/html/$(DOC_MODULE).devhelp \
188             $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp; \
189           if test -e $(builddir)/html/$(DOC_MODULE).devhelp2; then \
190                     $(INSTALL_DATA) $(builddir)/html/$(DOC_MODULE).devhelp2 \
191                     $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp2; \
192           fi; \
193           (which gtkdoc-rebase >/dev/null && \
194             gtkdoc-rebase --relative --dest-dir=$(DESTDIR) --html-dir=$(DESTDIR)$(TARGET_DIR)) || true ; \
195         fi)
196 uninstall-local:
197         if test -d $(DESTDIR)$(TARGET_DIR); then \
198           rm -rf $(DESTDIR)$(TARGET_DIR)/*; \
199           rmdir -p $(DESTDIR)$(TARGET_DIR) 2>/dev/null || true; \
200         else \
201           echo '-- Nothing to uninstall' ; \
202         fi;
203
204
205 #
206 # Require gtk-doc when making dist
207 #
208 if ENABLE_GTK_DOC
209 dist-check-gtkdoc:
210 else
211 dist-check-gtkdoc:
212         @echo "*** gtk-doc must be installed and enabled in order to make dist"
213         @false
214 endif
215
216 dist-hook: dist-check-gtkdoc dist-hook-local
217         mkdir $(distdir)/html
218         cp html/* $(distdir)/html
219         -cp $(srcdir)/$(DOC_MODULE).types $(distdir)/
220         -cp $(srcdir)/$(DOC_MODULE)-sections.txt $(distdir)/
221         cd $(distdir) && rm -f $(DISTCLEANFILES)
222         -gtkdoc-rebase --online --relative --html-dir=$(distdir)/html
223
224 .PHONY : dist-hook-local docs
225
226 # avoid spurious build errors when distchecking with -jN
227 .NOTPARALLEL: