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