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