You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

322 lines
10 KiB

  1. # -*- mode: makefile -*-
  2. #
  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
  7. #
  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.
  12. #
  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.
  17. #
  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/>.
  20. ####################################
  21. # Everything below here is generic #
  22. ####################################
  23. if GTK_DOC_USE_LIBTOOL
  24. GTKDOC_CC = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
  25. GTKDOC_LD = $(LIBTOOL) --tag=CC --mode=link $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS)
  26. GTKDOC_RUN = $(LIBTOOL) --mode=execute
  27. else
  28. GTKDOC_CC = $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
  29. GTKDOC_LD = $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS)
  30. GTKDOC_RUN =
  31. endif
  32. # We set GPATH here; this gives us semantics for GNU make
  33. # which are more like other make's VPATH, when it comes to
  34. # whether a source that is a target of one rule is then
  35. # searched for in VPATH/GPATH.
  36. #
  37. GPATH = $(srcdir)
  38. TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)
  39. SETUP_FILES = \
  40. $(content_files) \
  41. $(expand_content_files) \
  42. $(DOC_MAIN_SGML_FILE) \
  43. $(DOC_MODULE)-sections.txt \
  44. $(DOC_MODULE)-overrides.txt
  45. EXTRA_DIST = \
  46. $(HTML_IMAGES) \
  47. $(SETUP_FILES)
  48. DOC_STAMPS=setup-build.stamp scan-build.stamp sgml-build.stamp \
  49. html-build.stamp pdf-build.stamp \
  50. sgml.stamp html.stamp pdf.stamp
  51. SCANOBJ_FILES = \
  52. $(DOC_MODULE).args \
  53. $(DOC_MODULE).hierarchy \
  54. $(DOC_MODULE).interfaces \
  55. $(DOC_MODULE).prerequisites \
  56. $(DOC_MODULE).signals
  57. REPORT_FILES = \
  58. $(DOC_MODULE)-undocumented.txt \
  59. $(DOC_MODULE)-undeclared.txt \
  60. $(DOC_MODULE)-unused.txt
  61. gtkdoc-check.test: Makefile
  62. $(AM_V_GEN)echo "#!/bin/sh -e" > $@; \
  63. echo "$(GTKDOC_CHECK_PATH) || exit 1" >> $@; \
  64. chmod +x $@
  65. CLEANFILES = $(SCANOBJ_FILES) $(REPORT_FILES) $(DOC_STAMPS) gtkdoc-check.test
  66. if GTK_DOC_BUILD_HTML
  67. HTML_BUILD_STAMP=html-build.stamp
  68. else
  69. HTML_BUILD_STAMP=
  70. endif
  71. if GTK_DOC_BUILD_PDF
  72. PDF_BUILD_STAMP=pdf-build.stamp
  73. else
  74. PDF_BUILD_STAMP=
  75. endif
  76. all-gtk-doc: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP)
  77. .PHONY: all-gtk-doc
  78. if ENABLE_GTK_DOC
  79. all-local: all-gtk-doc
  80. endif
  81. docs: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP)
  82. $(REPORT_FILES): sgml-build.stamp
  83. #### setup ####
  84. GTK_DOC_V_SETUP=$(GTK_DOC_V_SETUP_@AM_V@)
  85. GTK_DOC_V_SETUP_=$(GTK_DOC_V_SETUP_@AM_DEFAULT_V@)
  86. GTK_DOC_V_SETUP_0=@echo " DOC Preparing build";
  87. setup-build.stamp:
  88. -$(GTK_DOC_V_SETUP)if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
  89. files=`echo $(SETUP_FILES) $(DOC_MODULE).types`; \
  90. if test "x$$files" != "x" ; then \
  91. for file in $$files ; do \
  92. destdir=`dirname $(abs_builddir)/$$file`; \
  93. test -d "$$destdir" || mkdir -p "$$destdir"; \
  94. test -f $(abs_srcdir)/$$file && \
  95. cp -pf $(abs_srcdir)/$$file $(abs_builddir)/$$file || true; \
  96. done; \
  97. fi; \
  98. fi
  99. $(AM_V_at)touch setup-build.stamp
  100. #### scan ####
  101. GTK_DOC_V_SCAN=$(GTK_DOC_V_SCAN_@AM_V@)
  102. GTK_DOC_V_SCAN_=$(GTK_DOC_V_SCAN_@AM_DEFAULT_V@)
  103. GTK_DOC_V_SCAN_0=@echo " DOC Scanning header files";
  104. GTK_DOC_V_INTROSPECT=$(GTK_DOC_V_INTROSPECT_@AM_V@)
  105. GTK_DOC_V_INTROSPECT_=$(GTK_DOC_V_INTROSPECT_@AM_DEFAULT_V@)
  106. GTK_DOC_V_INTROSPECT_0=@echo " DOC Introspecting gobjects";
  107. scan-build.stamp: setup-build.stamp $(HFILE_GLOB) $(CFILE_GLOB)
  108. $(GTK_DOC_V_SCAN)_source_dir='' ; \
  109. for i in $(DOC_SOURCE_DIR) ; do \
  110. _source_dir="$${_source_dir} --source-dir=$$i" ; \
  111. done ; \
  112. gtkdoc-scan --module=$(DOC_MODULE) --ignore-headers="$(IGNORE_HFILES)" $${_source_dir} $(SCAN_OPTIONS) $(EXTRA_HFILES)
  113. $(GTK_DOC_V_INTROSPECT)if grep -l '^..*$$' $(DOC_MODULE).types > /dev/null 2>&1 ; then \
  114. scanobj_options=""; \
  115. gtkdoc-scangobj 2>&1 --help | grep >/dev/null "\-\-verbose"; \
  116. if test "$$?" = "0"; then \
  117. if test "x$(V)" = "x1"; then \
  118. scanobj_options="--verbose"; \
  119. fi; \
  120. fi; \
  121. CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)" RUN="$(GTKDOC_RUN)" CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS)" LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)" \
  122. gtkdoc-scangobj $(SCANGOBJ_OPTIONS) $$scanobj_options --module=$(DOC_MODULE); \
  123. else \
  124. for i in $(SCANOBJ_FILES) ; do \
  125. test -f $$i || touch $$i ; \
  126. done \
  127. fi
  128. $(AM_V_at)touch scan-build.stamp
  129. $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt: scan-build.stamp
  130. @true
  131. #### xml ####
  132. GTK_DOC_V_XML=$(GTK_DOC_V_XML_@AM_V@)
  133. GTK_DOC_V_XML_=$(GTK_DOC_V_XML_@AM_DEFAULT_V@)
  134. GTK_DOC_V_XML_0=@echo " DOC Building XML";
  135. 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
  136. $(GTK_DOC_V_XML)_source_dir='' ; \
  137. for i in $(DOC_SOURCE_DIR) ; do \
  138. _source_dir="$${_source_dir} --source-dir=$$i" ; \
  139. done ; \
  140. 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)
  141. $(AM_V_at)touch sgml-build.stamp
  142. sgml.stamp: sgml-build.stamp
  143. @true
  144. $(DOC_MAIN_SGML_FILE): sgml-build.stamp
  145. @true
  146. xml/gtkdocentities.ent: Makefile
  147. $(GTK_DOC_V_XML)$(MKDIR_P) $(@D) && ( \
  148. echo "<!ENTITY package \"$(PACKAGE)\">"; \
  149. echo "<!ENTITY package_bugreport \"$(PACKAGE_BUGREPORT)\">"; \
  150. echo "<!ENTITY package_name \"$(PACKAGE_NAME)\">"; \
  151. echo "<!ENTITY package_string \"$(PACKAGE_STRING)\">"; \
  152. echo "<!ENTITY package_tarname \"$(PACKAGE_TARNAME)\">"; \
  153. echo "<!ENTITY package_url \"$(PACKAGE_URL)\">"; \
  154. echo "<!ENTITY package_version \"$(PACKAGE_VERSION)\">"; \
  155. ) > $@
  156. #### html ####
  157. GTK_DOC_V_HTML=$(GTK_DOC_V_HTML_@AM_V@)
  158. GTK_DOC_V_HTML_=$(GTK_DOC_V_HTML_@AM_DEFAULT_V@)
  159. GTK_DOC_V_HTML_0=@echo " DOC Building HTML";
  160. GTK_DOC_V_XREF=$(GTK_DOC_V_XREF_@AM_V@)
  161. GTK_DOC_V_XREF_=$(GTK_DOC_V_XREF_@AM_DEFAULT_V@)
  162. GTK_DOC_V_XREF_0=@echo " DOC Fixing cross-references";
  163. html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files)
  164. $(GTK_DOC_V_HTML)rm -rf html && mkdir html && \
  165. mkhtml_options=""; \
  166. gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-verbose"; \
  167. if test "$$?" = "0"; then \
  168. if test "x$(V)" = "x1"; then \
  169. mkhtml_options="$$mkhtml_options --verbose"; \
  170. fi; \
  171. fi; \
  172. gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-path"; \
  173. if test "$$?" = "0"; then \
  174. mkhtml_options="$$mkhtml_options --path=\"$(abs_srcdir)\""; \
  175. fi; \
  176. cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
  177. -@test "x$(HTML_IMAGES)" = "x" || \
  178. for file in $(HTML_IMAGES) ; do \
  179. test -f $(abs_srcdir)/$$file && cp $(abs_srcdir)/$$file $(abs_builddir)/html; \
  180. test -f $(abs_builddir)/$$file && cp $(abs_builddir)/$$file $(abs_builddir)/html; \
  181. test -f $$file && cp $$file $(abs_builddir)/html; \
  182. done;
  183. $(GTK_DOC_V_XREF)gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
  184. $(AM_V_at)touch html-build.stamp
  185. #### pdf ####
  186. GTK_DOC_V_PDF=$(GTK_DOC_V_PDF_@AM_V@)
  187. GTK_DOC_V_PDF_=$(GTK_DOC_V_PDF_@AM_DEFAULT_V@)
  188. GTK_DOC_V_PDF_0=@echo " DOC Building PDF";
  189. pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files)
  190. $(GTK_DOC_V_PDF)rm -f $(DOC_MODULE).pdf && \
  191. mkpdf_options=""; \
  192. gtkdoc-mkpdf 2>&1 --help | grep >/dev/null "\-\-verbose"; \
  193. if test "$$?" = "0"; then \
  194. if test "x$(V)" = "x1"; then \
  195. mkpdf_options="$$mkpdf_options --verbose"; \
  196. fi; \
  197. fi; \
  198. if test "x$(HTML_IMAGES)" != "x"; then \
  199. for img in $(HTML_IMAGES); do \
  200. part=`dirname $$img`; \
  201. echo $$mkpdf_options | grep >/dev/null "\-\-imgdir=$$part "; \
  202. if test $$? != 0; then \
  203. mkpdf_options="$$mkpdf_options --imgdir=$$part"; \
  204. fi; \
  205. done; \
  206. fi; \
  207. gtkdoc-mkpdf --path="$(abs_srcdir)" $$mkpdf_options $(DOC_MODULE) $(DOC_MAIN_SGML_FILE) $(MKPDF_OPTIONS)
  208. $(AM_V_at)touch pdf-build.stamp
  209. ##############
  210. clean-local:
  211. @rm -f *~ *.bak
  212. @rm -rf .libs
  213. @if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-types" ; then \
  214. rm -f $(DOC_MODULE).types; \
  215. fi
  216. @if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-sections" ; then \
  217. rm -f $(DOC_MODULE)-sections.txt; \
  218. fi
  219. distclean-local:
  220. @rm -rf xml html $(REPORT_FILES) $(DOC_MODULE).pdf \
  221. $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
  222. @if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
  223. rm -f $(SETUP_FILES) $(DOC_MODULE).types; \
  224. fi
  225. maintainer-clean-local:
  226. @rm -rf xml html
  227. install-data-local:
  228. @installfiles=`echo $(builddir)/html/*`; \
  229. if test "$$installfiles" = '$(builddir)/html/*'; \
  230. then echo 1>&2 'Nothing to install' ; \
  231. else \
  232. if test -n "$(DOC_MODULE_VERSION)"; then \
  233. installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \
  234. else \
  235. installdir="$(DESTDIR)$(TARGET_DIR)"; \
  236. fi; \
  237. $(mkinstalldirs) $${installdir} ; \
  238. for i in $$installfiles; do \
  239. echo ' $(INSTALL_DATA) '$$i ; \
  240. $(INSTALL_DATA) $$i $${installdir}; \
  241. done; \
  242. if test -n "$(DOC_MODULE_VERSION)"; then \
  243. mv -f $${installdir}/$(DOC_MODULE).devhelp2 \
  244. $${installdir}/$(DOC_MODULE)-$(DOC_MODULE_VERSION).devhelp2; \
  245. fi; \
  246. $(GTKDOC_REBASE) --relative --dest-dir=$(DESTDIR) --html-dir=$${installdir}; \
  247. fi
  248. uninstall-local:
  249. @if test -n "$(DOC_MODULE_VERSION)"; then \
  250. installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \
  251. else \
  252. installdir="$(DESTDIR)$(TARGET_DIR)"; \
  253. fi; \
  254. rm -rf $${installdir}
  255. #
  256. # Require gtk-doc when making dist
  257. #
  258. if HAVE_GTK_DOC
  259. dist-check-gtkdoc: docs
  260. else
  261. dist-check-gtkdoc:
  262. @echo "*** gtk-doc is needed to run 'make dist'. ***"
  263. @echo "*** gtk-doc was not found when 'configure' ran. ***"
  264. @echo "*** please install gtk-doc and rerun 'configure'. ***"
  265. @false
  266. endif
  267. dist-hook: dist-check-gtkdoc all-gtk-doc dist-hook-local
  268. @mkdir $(distdir)/html
  269. @cp ./html/* $(distdir)/html
  270. @-cp ./$(DOC_MODULE).pdf $(distdir)/
  271. @-cp ./$(DOC_MODULE).types $(distdir)/
  272. @-cp ./$(DOC_MODULE)-sections.txt $(distdir)/
  273. @cd $(distdir) && rm -f $(DISTCLEANFILES)
  274. @$(GTKDOC_REBASE) --online --relative --html-dir=$(distdir)/html
  275. .PHONY : dist-hook-local docs