rebase: fix on-line location extraction from devhelp files
[gtk-doc.git] / gtk-doc.make
blobf87eaab9c60db5b36a74e493a442a2fad8869218
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 done;
216 $(GTK_DOC_V_XREF)gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
217 $(AM_V_at)touch html-build.stamp
219 #### pdf ####
221 GTK_DOC_V_PDF=$(GTK_DOC_V_PDF_@AM_V@)
222 GTK_DOC_V_PDF_=$(GTK_DOC_V_PDF_@AM_DEFAULT_V@)
223 GTK_DOC_V_PDF_0=@echo " DOC Building PDF";
225 pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files)
226 $(GTK_DOC_V_PDF)rm -f $(DOC_MODULE).pdf && \
227 mkpdf_options=""; \
228 gtkdoc-mkpdf 2>&1 --help | grep >/dev/null "\-\-verbose"; \
229 if test "$$?" = "0"; then \
230 if test "x$(V)" = "x1"; then \
231 mkpdf_options="$$mkpdf_options --verbose"; \
232 fi; \
233 fi; \
234 if test "x$(HTML_IMAGES)" != "x"; then \
235 for img in $(HTML_IMAGES); do \
236 part=`dirname $$img`; \
237 echo $$mkpdf_options | grep >/dev/null "\-\-imgdir=$$part "; \
238 if test $$? != 0; then \
239 mkpdf_options="$$mkpdf_options --imgdir=$$part"; \
240 fi; \
241 done; \
242 fi; \
243 gtkdoc-mkpdf --path="$(abs_srcdir)" $$mkpdf_options $(DOC_MODULE) $(DOC_MAIN_SGML_FILE) $(MKPDF_OPTIONS)
244 $(AM_V_at)touch pdf-build.stamp
246 ##############
248 clean-local:
249 @rm -f *~ *.bak
250 @rm -rf .libs
251 @if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-types" ; then \
252 rm -f $(DOC_MODULE).types; \
254 @if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-sections" ; then \
255 rm -f $(DOC_MODULE)-sections.txt; \
258 distclean-local:
259 @rm -rf xml html $(REPORT_FILES) $(DOC_MODULE).pdf \
260 $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
261 @if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
262 rm -f $(SETUP_FILES) $(DOC_MODULE).types; \
265 maintainer-clean-local:
266 @rm -rf xml html
268 install-data-local:
269 @installfiles=`echo $(builddir)/html/*`; \
270 if test "$$installfiles" = '$(builddir)/html/*'; \
271 then echo 1>&2 'Nothing to install' ; \
272 else \
273 if test -n "$(DOC_MODULE_VERSION)"; then \
274 installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \
275 else \
276 installdir="$(DESTDIR)$(TARGET_DIR)"; \
277 fi; \
278 $(mkinstalldirs) $${installdir} ; \
279 for i in $$installfiles; do \
280 echo ' $(INSTALL_DATA) '$$i ; \
281 $(INSTALL_DATA) $$i $${installdir}; \
282 done; \
283 if test -n "$(DOC_MODULE_VERSION)"; then \
284 mv -f $${installdir}/$(DOC_MODULE).devhelp2 \
285 $${installdir}/$(DOC_MODULE)-$(DOC_MODULE_VERSION).devhelp2; \
286 fi; \
287 $(GTKDOC_REBASE) --relative --dest-dir=$(DESTDIR) --html-dir=$${installdir}; \
290 uninstall-local:
291 @if test -n "$(DOC_MODULE_VERSION)"; then \
292 installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \
293 else \
294 installdir="$(DESTDIR)$(TARGET_DIR)"; \
295 fi; \
296 rm -rf $${installdir}
299 # Require gtk-doc when making dist
301 if HAVE_GTK_DOC
302 dist-check-gtkdoc: docs
303 else
304 dist-check-gtkdoc:
305 @echo "*** gtk-doc is needed to run 'make dist'. ***"
306 @echo "*** gtk-doc was not found when 'configure' ran. ***"
307 @echo "*** please install gtk-doc and rerun 'configure'. ***"
308 @false
309 endif
311 dist-hook: dist-check-gtkdoc all-gtk-doc dist-hook-local
312 @mkdir $(distdir)/html
313 @cp ./html/* $(distdir)/html
314 @-cp ./$(DOC_MODULE).pdf $(distdir)/
315 @-cp ./$(DOC_MODULE).types $(distdir)/
316 @-cp ./$(DOC_MODULE)-sections.txt $(distdir)/
317 @cd $(distdir) && rm -f $(DISTCLEANFILES)
318 @$(GTKDOC_REBASE) --online --relative --html-dir=$(distdir)/html
320 .PHONY : dist-hook-local docs