docs: further reduce delta to upstream makefiles
[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             echo '  DOC   Preparing build'; \
57             files=`echo $(DOC_MAIN_SGML_FILE) $(DOC_OVERRIDES) $(DOC_MODULE)-sections.txt $(DOC_MODULE).types $(content_files)`; \
58             if test "x$$files" != "x" ; then \
59                 for file in $$files ; do \
60                     test -f $(abs_srcdir)/$$file && \
61                         cp -pu $(abs_srcdir)/$$file $(abs_builddir)/ || true; \
62                 done; \
63             fi; \
64         fi
65         @touch setup-build.stamp
66
67 #### scan ####
68
69 # in the case of non-srcdir builds, the built gst directory gets added
70 # to gtk-doc scanning; but only then, to avoid duplicates
71 scan-build.stamp: $(HFILE_GLOB) $(CFILE_GLOB)
72         @echo '  DOC   Scanning header files'
73         @if test "x$(top_srcdir)" != "x$(top_builddir)";                        \
74         then                                                            \
75           export BUILT_OPTIONS="--source-dir=$(DOC_BUILD_DIR)";         \
76         fi;                                                             \
77         gtkdoc-scan                                                     \
78                 $(SCAN_OPTIONS) $(EXTRA_HFILES)                         \
79                 --module=$(DOC_MODULE)                                  \
80                 --source-dir=$(DOC_SOURCE_DIR)                          \
81                 $$BUILT_OPTIONS                                         \
82                 --ignore-headers="$(IGNORE_HFILES)"
83         @if grep -l '^..*$$' $(DOC_MODULE).types > /dev/null; then      \
84             echo "  DOC   Introspecting gobjects"; \
85             GST_PLUGIN_SYSTEM_PATH=`cd $(top_builddir) && pwd`          \
86             GST_PLUGIN_PATH=                                            \
87             GST_REGISTRY=doc-registry.xml                               \
88             $(GTKDOC_EXTRA_ENVIRONMENT)                                 \
89             CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)"                         \
90             CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS)"                         \
91             LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)"                         \
92             gtkdoc-scangobj --type-init-func="gst_init(NULL,NULL)"      \
93                 --module=$(DOC_MODULE) ;                                \
94         else                                                            \
95             for i in $(SCANOBJ_FILES) ; do                              \
96                test -f $$i || touch $$i ;                               \
97             done                                                        \
98         fi
99         @touch scan-build.stamp
100
101 $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt: scan-build.stamp
102         @true
103
104 #### xml ####
105
106 sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(expand_content_files)
107         @echo '  DOC   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 '  DOC   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 '  DOC   Fixing cross-references'
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).devhelp2' ; \
187           if test -e $(builddir)/html/$(DOC_MODULE).devhelp2; then \
188                     $(INSTALL_DATA) $(builddir)/html/$(DOC_MODULE).devhelp2 \
189                     $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp2; \
190           fi; \
191           (which gtkdoc-rebase >/dev/null && \
192             gtkdoc-rebase --relative --dest-dir=$(DESTDIR) --html-dir=$(DESTDIR)$(TARGET_DIR)) || true ; \
193         fi)
194 uninstall-local:
195         if test -d $(DESTDIR)$(TARGET_DIR); then \
196           rm -rf $(DESTDIR)$(TARGET_DIR)/*; \
197           rmdir -p $(DESTDIR)$(TARGET_DIR) 2>/dev/null || true; \
198         else \
199           echo '-- Nothing to uninstall' ; \
200         fi;
201
202
203 #
204 # Require gtk-doc when making dist
205 #
206 if ENABLE_GTK_DOC
207 dist-check-gtkdoc:
208 else
209 dist-check-gtkdoc:
210         @echo "*** gtk-doc must be installed and enabled in order to make dist"
211         @false
212 endif
213
214 dist-hook: dist-check-gtkdoc dist-hook-local
215         mkdir $(distdir)/html
216         cp html/* $(distdir)/html
217         -cp $(srcdir)/$(DOC_MODULE).types $(distdir)/
218         -cp $(srcdir)/$(DOC_MODULE)-sections.txt $(distdir)/
219         cd $(distdir) && rm -f $(DISTCLEANFILES)
220         -gtkdoc-rebase --online --relative --html-dir=$(distdir)/html
221
222 .PHONY : dist-hook-local docs
223
224 # avoid spurious build errors when distchecking with -jN
225 .NOTPARALLEL: