f75e79463d309aeed4f2c242c2d83b8cc691c724
[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         .libs/$(DOC_MODULE)-scan.o      \
41         $(DOC_MODULE).signals
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)
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             CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)"                         \
68             CFLAGS="$(GTKDOC_CFLAGS)" LDFLAGS="$(GTKDOC_LIBS)"          \
69             gtkdoc-scangobj --type-init-func="gst_init(NULL,NULL)"      \
70                 --module=$(DOC_MODULE) ;                                \
71         else                                                            \
72             cd $(srcdir) ;                                              \
73             for i in $(SCANOBJ_FILES) ; do                              \
74                test -f $$i || touch $$i ;                               \
75             done                                                        \
76         fi
77         if test "x$(top_srcdir)" != "x$(top_builddir)";                 \
78         then                                                            \
79           export BUILT_OPTIONS="--source-dir=$(DOC_BUILD_DIR)";         \
80         fi;                                                             \
81         gtkdoc-scan                                                     \
82                 $(SCAN_OPTIONS) $(EXTRA_HFILES)                         \
83                 --module=$(DOC_MODULE)                                  \
84                 --source-dir=$(DOC_SOURCE_DIR)                          \
85                 $$BUILT_OPTIONS                                         \
86                 --ignore-headers="$(IGNORE_HFILES)"
87         touch scan-build.stamp
88
89 $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES): scan-build.stamp
90         @true
91
92 #### templates ####
93
94 tmpl-build.stamp: $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_OVERRIDES)
95         @echo '*** Rebuilding template files ***'
96         if test x"$(srcdir)" != x. ; then \
97             cp $(srcdir)/$(DOC_MODULE)-sections.txt . ; \
98             touch $(DOC_MODULE)-decl.txt ; \
99         fi
100         gtkdoc-mktmpl --module=$(DOC_MODULE) | tee tmpl-build.log
101         @if test -s $(DOC_MODULE)-unused.txt; then \
102             exit $(if $(DOCS_ARE_INCOMPLETE_PLEASE_FIXME),0,1); fi
103         rm -f tmpl-build.log
104         touch tmpl-build.stamp
105
106 tmpl.stamp: tmpl-build.stamp
107         @true
108
109 #### xml ####
110
111 ### FIXME: make this error out again when docs are complete
112 sgml-build.stamp: tmpl.stamp $(CFILE_GLOB)
113         @echo '*** Building XML ***'
114         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
115         @if grep "WARNING:" sgml-build.log > /dev/null; then true; fi # exit 1; fi
116         rm sgml-build.log
117         touch sgml-build.stamp
118
119 sgml.stamp: sgml-build.stamp
120         @true
121
122 #### html ####
123
124 html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
125         @echo '*** Building HTML ***'
126         if test -d html; then rm -rf html; fi
127         mkdir html
128         cp $(srcdir)/$(DOC_MAIN_SGML_FILE) html
129         @for f in $(content_files); do cp $(srcdir)/$$f html; done
130         cp -pr xml html
131         cp ../version.entities html
132         cd html && gtkdoc-mkhtml $(DOC_MODULE) $(DOC_MAIN_SGML_FILE)
133         mv html/index.sgml html/index.sgml.bak
134         $(SED) "s/ href=\"$(DOC_MODULE)\// href=\"$(DOC_MODULE)-@GST_MAJORMINOR@\//g" html/index.sgml.bak >html/index.sgml
135         rm -f html/index.sgml.bak
136         rm -f html/$(DOC_MAIN_SGML_FILE)
137         rm -rf html/xml
138         rm -f html/version.entities
139         test "x$(HTML_IMAGES)" = "x" || for i in "" $(HTML_IMAGES) ; do \
140             if test "$$i" != ""; then cp $(srcdir)/$$i html ; fi; done
141         @echo '-- Fixing Crossreferences' 
142         gtkdoc-fixxref --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
143         touch html-build.stamp
144
145 clean-local-gtkdoc:
146         rm -rf xml tmpl html
147 # clean files copied for nonsrcdir templates build
148         if test x"$(srcdir)" != x. ; then \
149                 rm -rf $(DOC_MODULE).types; \
150         fi
151 else
152 all-local:
153 clean-local-gtkdoc:
154 endif
155
156 clean-local: clean-local-gtkdoc
157         rm -f *~ *.bak
158         rm -rf .libs
159
160 maintainer-clean-local: clean
161         cd $(srcdir) && rm -rf xml html $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
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 $(DOC_MODULE)-decl-list.txt
168         rm -f $(DOC_MODULE)-decl.txt
169         rm -f $(REPORT_FILES)
170         rm -rf tmpl/*.sgml.bak
171         rm -f $(DOC_MODULE).hierarchy
172         rm -f *.stamp || true
173         if test x"$(srcdir)" != x. ; then \
174             rm -f $(DOC_MODULE)-docs.sgml ; \
175             rm -f $(DOC_MODULE).types ; \
176             rm -f $(DOC_MODULE).interfaces ; \
177             rm -f $(DOC_MODULE)-overrides.txt ; \
178             rm -f $(DOC_MODULE).prerequisites ; \
179             rm -f $(DOC_MODULE)-sections.txt ; \
180             rm -rf tmpl/*.sgml ; \
181         fi
182         rm -rf *.o
183
184 # thomas: make docs parallel installable; devhelp requires majorminor too
185 install-data-local:
186         $(mkinstalldirs) $(DESTDIR)$(TARGET_DIR) 
187         (installfiles=`echo ./html/*.html`; \
188         if test "$$installfiles" = './html/*.html'; \
189         then echo '-- Nothing to install' ; \
190         else \
191           for i in $$installfiles; do \
192             echo '-- Installing '$$i ; \
193             $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
194           done; \
195           pngfiles=`echo ./html/*.png`; \
196           if test "$$pngfiles" != './html/*.png'; then \
197             for i in $$pngfiles; do \
198               echo '-- Installing '$$i ; \
199               $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
200             done; \
201           fi; \
202           echo '-- Installing $(srcdir)/html/$(DOC_MODULE).devhelp' ; \
203           $(INSTALL_DATA) $(srcdir)/html/$(DOC_MODULE).devhelp \
204             $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp; \
205           if test -e $(srcdir)/html/$(DOC_MODULE).devhelp2; then \
206                   $(INSTALL_DATA) $(srcdir)/html/$(DOC_MODULE).devhelp2 \
207                    $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp2; \
208           fi; \
209           echo '-- Installing $(srcdir)/html/index.sgml' ; \
210           $(INSTALL_DATA) $(srcdir)/html/index.sgml $(DESTDIR)$(TARGET_DIR); \
211                 if test -e $(srcdir)/html/style.css; then \
212                         echo '-- Installing $(srcdir)/html/style.css' ; \
213                         $(INSTALL_DATA) $(srcdir)/html/style.css $(DESTDIR)$(TARGET_DIR); \
214                 fi; \
215         fi) 
216 uninstall-local:
217         (installfiles=`echo ./html/*.html`; \
218         if test "$$installfiles" = './html/*.html'; \
219         then echo '-- Nothing to uninstall' ; \
220         else \
221           for i in $$installfiles; do \
222             rmfile=`basename $$i` ; \
223             echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/'$$rmfile ; \
224             rm -f $(DESTDIR)$(TARGET_DIR)/$$rmfile; \
225           done; \
226           pngfiles=`echo ./html/*.png`; \
227           if test "$$pngfiles" != './html/*.png'; then \
228             for i in $$pngfiles; do \
229               rmfile=`basename $$i` ; \
230               echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/'$$rmfile ; \
231               rm -f $(DESTDIR)$(TARGET_DIR)/$$rmfile; \
232             done; \
233           fi; \
234           echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE).devhelp' ; \
235           rm -f $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp; \
236           if test -e $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp2; then \
237             rm -f $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_MAJORMINOR@.devhelp2; \
238           fi; \
239           echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/index.sgml' ; \
240           rm -f $(DESTDIR)$(TARGET_DIR)/index.sgml; \
241                 if test -e $(DESTDIR)$(TARGET_DIR)/style.css; then \
242                         echo '-- Uninstalling $(DESTDIR)$(TARGET_DIR)/style.css' ; \
243                         rm -f $(DESTDIR)$(TARGET_DIR)/style.css; \
244                 fi; \
245         fi) 
246         if test -d $(DESTDIR)$(TARGET_DIR); then rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(TARGET_DIR) 2>/dev/null; fi; true
247
248 #
249 # Require gtk-doc when making dist
250 #
251 if ENABLE_GTK_DOC
252 dist-check-gtkdoc:
253 else
254 dist-check-gtkdoc:
255         @echo "*** gtk-doc must be installed and enabled in order to make dist"
256         @false
257 endif
258
259 dist-hook: dist-check-gtkdoc dist-hook-local
260         mkdir $(distdir)/tmpl
261         mkdir $(distdir)/xml
262         mkdir $(distdir)/html
263         -cp $(srcdir)/tmpl/*.sgml $(distdir)/tmpl
264         -cp $(srcdir)/sgml/*.xml $(distdir)/xml
265         -cp $(srcdir)/html/index.sgml $(distdir)/html
266         -cp $(srcdir)/html/*.html $(srcdir)/html/*.css $(distdir)/html
267         -cp $(srcdir)/html/$(DOC_MODULE).devhelp* $(distdir)/html
268
269         images=$(HTML_IMAGES) ;               \
270         for i in "" $$images ; do                     \
271           if test "$$i" != ""; then cp $(srcdir)/$$i $(distdir)/html ; fi; \
272         done
273
274 .PHONY : dist-hook-local