cleanup: move 'cmake' to a subdir buildsystems
[gtk-doc.git] / gtk-doc.make
blob7d9a27f34be911330ec03d8c9915092c5956adde
1 # -*- mode: makefile -*-
3 # gtk-doc.make - make rules for gtk-doc
4 # Copyright (C) 2003 James Henstridge
5 # 2004-2007 Damon Chaplin
6 # 2007-2017 Stefan Sauer
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ####################################
22 # Everything below here is generic #
23 ####################################
25 if GTK_DOC_USE_LIBTOOL
26 GTKDOC_CC = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
27 GTKDOC_LD = $(LIBTOOL) --tag=CC --mode=link $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS)
28 GTKDOC_RUN = $(LIBTOOL) --mode=execute
29 else
30 GTKDOC_CC = $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
31 GTKDOC_LD = $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS)
32 GTKDOC_RUN =
33 endif
35 # We set GPATH here; this gives us semantics for GNU make
36 # which are more like other make's VPATH, when it comes to
37 # whether a source that is a target of one rule is then
38 # searched for in VPATH/GPATH.
40 GPATH = $(srcdir)
42 TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)
44 SETUP_FILES = \
45 $(content_files) \
46 $(expand_content_files) \
47 $(DOC_MAIN_SGML_FILE) \
48 $(DOC_MODULE)-sections.txt \
49 $(DOC_MODULE)-overrides.txt
51 EXTRA_DIST = \
52 $(HTML_IMAGES) \
53 $(SETUP_FILES)
55 DOC_STAMPS=setup-build.stamp scan-build.stamp sgml-build.stamp \
56 html-build.stamp pdf-build.stamp \
57 sgml.stamp html.stamp pdf.stamp
59 SCANOBJ_FILES = \
60 $(DOC_MODULE).args \
61 $(DOC_MODULE).hierarchy \
62 $(DOC_MODULE).interfaces \
63 $(DOC_MODULE).prerequisites \
64 $(DOC_MODULE).signals
66 REPORT_FILES = \
67 $(DOC_MODULE)-undocumented.txt \
68 $(DOC_MODULE)-undeclared.txt \
69 $(DOC_MODULE)-unused.txt
71 gtkdoc-check.test: Makefile
72 $(AM_V_GEN)echo "#!/bin/sh -e" > $@; \
73 echo "$(GTKDOC_CHECK_PATH) || exit 1" >> $@; \
74 chmod +x $@
76 CLEANFILES = $(SCANOBJ_FILES) $(REPORT_FILES) $(DOC_STAMPS) gtkdoc-check.test
78 if GTK_DOC_BUILD_HTML
79 HTML_BUILD_STAMP=html-build.stamp
80 else
81 HTML_BUILD_STAMP=
82 endif
83 if GTK_DOC_BUILD_PDF
84 PDF_BUILD_STAMP=pdf-build.stamp
85 else
86 PDF_BUILD_STAMP=
87 endif
89 all-gtk-doc: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP)
90 .PHONY: all-gtk-doc
92 if ENABLE_GTK_DOC
93 all-local: all-gtk-doc
94 endif
96 docs: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP)
98 $(REPORT_FILES): sgml-build.stamp
100 #### setup ####
102 GTK_DOC_V_SETUP=$(GTK_DOC_V_SETUP_@AM_V@)
103 GTK_DOC_V_SETUP_=$(GTK_DOC_V_SETUP_@AM_DEFAULT_V@)
104 GTK_DOC_V_SETUP_0=@echo " DOC Preparing build";
106 setup-build.stamp:
107 -$(GTK_DOC_V_SETUP)if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
108 files=`echo $(SETUP_FILES) $(DOC_MODULE).types`; \
109 if test "x$$files" != "x" ; then \
110 for file in $$files ; do \
111 destdir=`dirname $(abs_builddir)/$$file`; \
112 test -d "$$destdir" || mkdir -p "$$destdir"; \
113 test -f $(abs_srcdir)/$$file && \
114 cp -pf $(abs_srcdir)/$$file $(abs_builddir)/$$file || true; \
115 done; \
116 fi; \
118 $(AM_V_at)touch setup-build.stamp
120 #### scan ####
122 GTK_DOC_V_SCAN=$(GTK_DOC_V_SCAN_@AM_V@)
123 GTK_DOC_V_SCAN_=$(GTK_DOC_V_SCAN_@AM_DEFAULT_V@)
124 GTK_DOC_V_SCAN_0=@echo " DOC Scanning header files";
126 GTK_DOC_V_INTROSPECT=$(GTK_DOC_V_INTROSPECT_@AM_V@)
127 GTK_DOC_V_INTROSPECT_=$(GTK_DOC_V_INTROSPECT_@AM_DEFAULT_V@)
128 GTK_DOC_V_INTROSPECT_0=@echo " DOC Introspecting gobjects";
130 scan-build.stamp: setup-build.stamp $(HFILE_GLOB) $(CFILE_GLOB)
131 $(GTK_DOC_V_SCAN)_source_dir='' ; \
132 for i in $(DOC_SOURCE_DIR) ; do \
133 _source_dir="$${_source_dir} --source-dir=$$i" ; \
134 done ; \
135 gtkdoc-scan --module=$(DOC_MODULE) --ignore-headers="$(IGNORE_HFILES)" $${_source_dir} $(SCAN_OPTIONS) $(EXTRA_HFILES)
136 $(GTK_DOC_V_INTROSPECT)if grep -l '^..*$$' $(DOC_MODULE).types > /dev/null 2>&1 ; then \
137 scanobj_options=""; \
138 gtkdoc-scangobj 2>&1 --help | grep >/dev/null "\-\-verbose"; \
139 if test "$$?" = "0"; then \
140 if test "x$(V)" = "x1"; then \
141 scanobj_options="--verbose"; \
142 fi; \
143 fi; \
144 CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)" RUN="$(GTKDOC_RUN)" CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS)" LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)" \
145 gtkdoc-scangobj $(SCANGOBJ_OPTIONS) $$scanobj_options --module=$(DOC_MODULE); \
146 else \
147 for i in $(SCANOBJ_FILES) ; do \
148 test -f $$i || touch $$i ; \
149 done \
151 $(AM_V_at)touch scan-build.stamp
153 $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt: scan-build.stamp
154 @true
156 #### xml ####
158 GTK_DOC_V_XML=$(GTK_DOC_V_XML_@AM_V@)
159 GTK_DOC_V_XML_=$(GTK_DOC_V_XML_@AM_DEFAULT_V@)
160 GTK_DOC_V_XML_0=@echo " DOC Building XML";
162 sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(HFILE_GLOB) $(CFILE_GLOB) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt $(expand_content_files) xml/gtkdocentities.ent
163 $(GTK_DOC_V_XML)_source_dir='' ; \
164 for i in $(DOC_SOURCE_DIR) ; do \
165 _source_dir="$${_source_dir} --source-dir=$$i" ; \
166 done ; \
167 gtkdoc-mkdb --module=$(DOC_MODULE) --output-format=xml --expand-content-files="$(expand_content_files)" --main-sgml-file=$(DOC_MAIN_SGML_FILE) $${_source_dir} $(MKDB_OPTIONS)
168 $(AM_V_at)touch sgml-build.stamp
170 sgml.stamp: sgml-build.stamp
171 @true
173 $(DOC_MAIN_SGML_FILE): sgml-build.stamp
174 @true
176 xml/gtkdocentities.ent: Makefile
177 $(GTK_DOC_V_XML)$(MKDIR_P) $(@D) && ( \
178 echo "<!ENTITY package \"$(PACKAGE)\">"; \
179 echo "<!ENTITY package_bugreport \"$(PACKAGE_BUGREPORT)\">"; \
180 echo "<!ENTITY package_name \"$(PACKAGE_NAME)\">"; \
181 echo "<!ENTITY package_string \"$(PACKAGE_STRING)\">"; \
182 echo "<!ENTITY package_tarname \"$(PACKAGE_TARNAME)\">"; \
183 echo "<!ENTITY package_url \"$(PACKAGE_URL)\">"; \
184 echo "<!ENTITY package_version \"$(PACKAGE_VERSION)\">"; \
185 ) > $@
187 #### html ####
189 GTK_DOC_V_HTML=$(GTK_DOC_V_HTML_@AM_V@)
190 GTK_DOC_V_HTML_=$(GTK_DOC_V_HTML_@AM_DEFAULT_V@)
191 GTK_DOC_V_HTML_0=@echo " DOC Building HTML";
193 GTK_DOC_V_XREF=$(GTK_DOC_V_XREF_@AM_V@)
194 GTK_DOC_V_XREF_=$(GTK_DOC_V_XREF_@AM_DEFAULT_V@)
195 GTK_DOC_V_XREF_0=@echo " DOC Fixing cross-references";
197 html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files)
198 $(GTK_DOC_V_HTML)rm -rf html && mkdir html && \
199 mkhtml_options=""; \
200 gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-verbose"; \
201 if test "$$?" = "0"; then \
202 if test "x$(V)" = "x1"; then \
203 mkhtml_options="$$mkhtml_options --verbose"; \
204 fi; \
205 fi; \
206 gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-path"; \
207 if test "$$?" = "0"; then \
208 mkhtml_options="$$mkhtml_options --path=\"$(abs_srcdir)\""; \
209 fi; \
210 cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
211 -@test "x$(HTML_IMAGES)" = "x" || \
212 for file in $(HTML_IMAGES) ; do \
213 test -f $(abs_srcdir)/$$file && cp $(abs_srcdir)/$$file $(abs_builddir)/html; \
214 test -f $(abs_builddir)/$$file && cp $(abs_builddir)/$$file $(abs_builddir)/html; \
215 test -f $$file && cp $$file $(abs_builddir)/html; \
216 done;
217 $(GTK_DOC_V_XREF)gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
218 $(AM_V_at)touch html-build.stamp
220 #### pdf ####
222 GTK_DOC_V_PDF=$(GTK_DOC_V_PDF_@AM_V@)
223 GTK_DOC_V_PDF_=$(GTK_DOC_V_PDF_@AM_DEFAULT_V@)
224 GTK_DOC_V_PDF_0=@echo " DOC Building PDF";
226 pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files)
227 $(GTK_DOC_V_PDF)rm -f $(DOC_MODULE).pdf && \
228 mkpdf_options=""; \
229 gtkdoc-mkpdf 2>&1 --help | grep >/dev/null "\-\-verbose"; \
230 if test "$$?" = "0"; then \
231 if test "x$(V)" = "x1"; then \
232 mkpdf_options="$$mkpdf_options --verbose"; \
233 fi; \
234 fi; \
235 if test "x$(HTML_IMAGES)" != "x"; then \
236 for img in $(HTML_IMAGES); do \
237 part=`dirname $$img`; \
238 echo $$mkpdf_options | grep >/dev/null "\-\-imgdir=$$part "; \
239 if test $$? != 0; then \
240 mkpdf_options="$$mkpdf_options --imgdir=$$part"; \
241 fi; \
242 done; \
243 fi; \
244 gtkdoc-mkpdf --path="$(abs_srcdir)" $$mkpdf_options $(DOC_MODULE) $(DOC_MAIN_SGML_FILE) $(MKPDF_OPTIONS)
245 $(AM_V_at)touch pdf-build.stamp
247 ##############
249 clean-local:
250 @rm -f *~ *.bak
251 @rm -rf .libs
252 @if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-types" ; then \
253 rm -f $(DOC_MODULE).types; \
255 @if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-sections" ; then \
256 rm -f $(DOC_MODULE)-sections.txt; \
259 distclean-local:
260 @rm -rf xml html $(REPORT_FILES) $(DOC_MODULE).pdf \
261 $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
262 @if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
263 rm -f $(SETUP_FILES) $(DOC_MODULE).types; \
266 maintainer-clean-local:
267 @rm -rf xml html
269 install-data-local:
270 @installfiles=`echo $(builddir)/html/*`; \
271 if test "$$installfiles" = '$(builddir)/html/*'; \
272 then echo 1>&2 'Nothing to install' ; \
273 else \
274 if test -n "$(DOC_MODULE_VERSION)"; then \
275 installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \
276 else \
277 installdir="$(DESTDIR)$(TARGET_DIR)"; \
278 fi; \
279 $(mkinstalldirs) $${installdir} ; \
280 for i in $$installfiles; do \
281 echo ' $(INSTALL_DATA) '$$i ; \
282 $(INSTALL_DATA) $$i $${installdir}; \
283 done; \
284 if test -n "$(DOC_MODULE_VERSION)"; then \
285 mv -f $${installdir}/$(DOC_MODULE).devhelp2 \
286 $${installdir}/$(DOC_MODULE)-$(DOC_MODULE_VERSION).devhelp2; \
287 fi; \
288 $(GTKDOC_REBASE) --relative --dest-dir=$(DESTDIR) --html-dir=$${installdir}; \
291 uninstall-local:
292 @if test -n "$(DOC_MODULE_VERSION)"; then \
293 installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \
294 else \
295 installdir="$(DESTDIR)$(TARGET_DIR)"; \
296 fi; \
297 rm -rf $${installdir}
300 # Require gtk-doc when making dist
302 if HAVE_GTK_DOC
303 dist-check-gtkdoc: docs
304 else
305 dist-check-gtkdoc:
306 @echo "*** gtk-doc is needed to run 'make dist'. ***"
307 @echo "*** gtk-doc was not found when 'configure' ran. ***"
308 @echo "*** please install gtk-doc and rerun 'configure'. ***"
309 @false
310 endif
312 dist-hook: dist-check-gtkdoc all-gtk-doc dist-hook-local
313 @mkdir $(distdir)/html
314 @cp ./html/* $(distdir)/html
315 @-cp ./$(DOC_MODULE).pdf $(distdir)/
316 @-cp ./$(DOC_MODULE).types $(distdir)/
317 @-cp ./$(DOC_MODULE)-sections.txt $(distdir)/
318 @cd $(distdir) && rm -f $(DISTCLEANFILES)
319 @$(GTKDOC_REBASE) --online --relative --html-dir=$(distdir)/html
321 .PHONY : dist-hook-local docs