Blame build/doc-reference.am

Packit 78284e
## Copyright (c) 2009, 2011  Openismus GmbH  <http://www.openismus.com/>
Packit 78284e
##
Packit 78284e
## This file is part of mm-common.
Packit 78284e
##
Packit 78284e
## mm-common is free software: you can redistribute it and/or modify
Packit 78284e
## it under the terms of the GNU General Public License as published
Packit 78284e
## by the Free Software Foundation, either version 2 of the License,
Packit 78284e
## or (at your option) any later version.
Packit 78284e
##
Packit 78284e
## mm-common is distributed in the hope that it will be useful,
Packit 78284e
## but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 78284e
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 78284e
## GNU General Public License for more details.
Packit 78284e
##
Packit 78284e
## You should have received a copy of the GNU General Public License
Packit 78284e
## along with mm-common.  If not, see <http://www.gnu.org/licenses/>.
Packit 78284e
Packit 78284e
## Parameters:  book_name
Packit 78284e
## Overrides:   doc_outdir, doc_config, book_title, htmlref_patterns,
Packit 78284e
##              doc_postprocess, doc_install, tagfile_to_devhelp2,
Packit 78284e
##              doxytagfile, devhelpfile
Packit 78284e
## Files:       doc_input
Packit 78284e
## Output:      dist_noinst_DATA, DISTCLEANFILES, MAINTAINERCLEANFILES
Packit 78284e
Packit 78284e
# The name of the sub-directory where the generated documentation
Packit 78284e
# will be placed.
Packit 78284e
doc_outdir ?= reference
Packit 78284e
Packit 78284e
# The name of the Doxygen configuration file.
Packit 78284e
doc_config ?= $(doc_outdir)/Doxyfile
Packit 78284e
Packit 78284e
# The title of the generated Devhelp book.
Packit 78284e
book_title ?= $(PACKAGE_NAME) Reference Manual
Packit 78284e
Packit 78284e
# A list of wildcard patterns matching the files from the HTML directory
Packit 78284e
# generated by Doxygen which should be distributed and installed.
Packit 78284e
htmlref_patterns ?= $(addprefix $(doc_outdir)/html/*.,css gif html js png)
Packit 78284e
Packit 78284e
# Locations of utilities shipped with glibmm.  Made overridable
Packit 78284e
# in case the installed utilities cannot be used for some reason.
Packit 78284e
doc_postprocess     ?= $(PERL) -- "$(MMDOCTOOLDIR)/doc-postprocess.pl"
Packit 78284e
doc_install         ?= $(PERL) -- "$(MMDOCTOOLDIR)/doc-install.pl"
Packit 78284e
tagfile_to_devhelp2 ?= "$(MMDOCTOOLDIR)/tagfile-to-devhelp2.xsl"
Packit 78284e
Packit 78284e
# Names of the main output files.
Packit 78284e
doxytagfile ?= $(doc_outdir)/$(book_name).tag
Packit 78284e
devhelpfile ?= $(doc_outdir)/$(book_name).devhelp2
Packit 78284e
Packit 78284e
# Function: $(call vpath_listall,PATTERN ...)
Packit 78284e
# Get all filenames which match a PATTERN from the list.  Look for files
Packit 78284e
# relative to either the current directory or $(srcdir).  Strip $(srcdir)/
Packit 78284e
# again before returning and remove any duplicates.
Packit 78284e
vpath_srclist = $(patsubst $(srcdir)/%,%,$(wildcard $(addprefix $(srcdir)/,$(1))))
Packit 78284e
vpath_listall = $(sort $(wildcard $(1)) $(if $(srcdir:.=),$(vpath_srclist)))
Packit 78284e
Packit 78284e
# Installation directories.
Packit 78284e
libdocdir    = $(datarootdir)/doc/$(book_name)
Packit 78284e
referencedir = $(libdocdir)/reference
Packit 78284e
htmlrefdir   = $(referencedir)/html
Packit 78284e
devhelpdir   = $(datadir)/devhelp/books/$(book_name)
Packit 78284e
Packit 78284e
# Optionally, the documentation utilities may be included in source tarballs
Packit 78284e
# so that mm-common is only required when building in maintainer mode.
Packit 78284e
if DIST_DOCTOOLS
Packit 78284e
doctools_dist_files = $(addprefix $(MMDOCTOOLDIR)/,doc-postprocess.pl doc-install.pl tagfile-to-devhelp2.xsl doxygen-extra.css)
Packit 78284e
else
Packit 78284e
doctools_dist_files =
Packit 78284e
endif
Packit 78284e
Packit 78284e
if ENABLE_DOCUMENTATION
Packit 78284e
doc_build_files  = $(doxytagfile) $(devhelpfile)
Packit 78284e
doc_inst_targets = install-htmlref install-devhelp
Packit 78284e
doc_inst_files   = $(doxytagfile)
Packit 78284e
doc_dist_files   = $(devhelpfile) $(call vpath_listall,$(htmlref_patterns))
Packit 78284e
else
Packit 78284e
doc_build_files  =
Packit 78284e
doc_inst_targets =
Packit 78284e
doc_inst_files   =
Packit 78284e
doc_dist_files   =
Packit 78284e
endif
Packit 78284e
Packit 78284e
dist_reference_DATA = $(strip $(doc_inst_files))
Packit 78284e
dist_noinst_DATA    = $(strip $(doctools_dist_files) $(doc_dist_files))
Packit 78284e
Packit 78284e
DISTCLEANFILES       = $(doc_outdir)/doxygen.log
Packit 78284e
MAINTAINERCLEANFILES = $(doxytagfile) $(devhelpfile) $(doc_outdir)/html/*
Packit 78284e
Packit 78284e
# The generic bit of the doc-install.pl command line.
Packit 78284e
doc_install_cmd = $(doc_install) --verbose --mode=0644
Packit 78284e
Packit 78284e
# Transform $(datarootdir) into a URI to match MM_ARG_WITH_TAGFILE_DOC().
Packit 78284e
datarootdir_esc = $(subst $(subst ,, ),%20,$(subst \,/,$(datarootdir)))
Packit 78284e
docdir_base_uri = file:///$(patsubst /%,%,$(datarootdir_esc:/=))/doc
Packit 78284e
Packit 78284e
# The command and options used to install the files from the HTML reference
Packit 78284e
# documentation.  The $(subst) magic translates external tag references from
Packit 78284e
# absolute to relative paths if the destination is on the local file system
Packit 78284e
# and installed under the same prefix as the package being built.
Packit 78284e
htmlref_relinst = $(subst @$(docdir_base_uri)/,@../../../,$(DOCINSTALL_FLAGS))
Packit 78284e
htmlref_install = $(doc_install_cmd) $(htmlref_relinst)
Packit 78284e
Packit 78284e
# The command and options used to install the Devhelp file.
Packit 78284e
devhelp_install = $(doc_install_cmd) --book-base='$(htmlrefdir:/=)'
Packit 78284e
Packit 78284e
# Helper variables to replicate each pattern with a $(srcdir)/ prefix.
Packit 78284e
# Also add quoting to prevent the shell from expanding the patterns.
Packit 78284e
htmlref_patterns_dup   = $(foreach item,$(htmlref_patterns),'$(item)' '$(srcdir)/$(item)')
Packit 78284e
htmlref_patterns_quote = $(patsubst %,'%',$(htmlref_patterns))
Packit 78284e
htmlref_patterns_vpath = $(if $(srcdir:.=),$(htmlref_patterns_dup),$(htmlref_patterns_quote))
Packit 78284e
Packit 78284e
# Expand to a list of -name 'PATTERN' arguments for use with 'find'.
Packit 78284e
htmlref_find_patterns = $(patsubst %,-name '%' -o,$(notdir $(htmlref_patterns))) -false
Packit 78284e
Packit 78284e
# The parameters to the Doxygen-to-Devhelp XSLT script
Packit 78284e
dh_xsl_params =	--stringparam book_title '$(book_title)' \
Packit 78284e
		--stringparam book_name '$(book_name)' \
Packit 78284e
		--stringparam book_base html
Packit 78284e
Packit 78284e
# Generated configuration files which, when updated, should cause the
Packit 78284e
# reference documentation to be rebuilt.
Packit 78284e
doc_config_deps = $(CONFIG_HEADER) $(srcdir)/$(doc_config).in $(srcdir)/Makefile.in
Packit 78284e
Packit 78284e
# Regenerate the documentation automatically only in maintainer mode.
Packit 78284e
# Depend on the generated configuration header files to trigger a rebuild
Packit 78284e
# if a configuration value changed.  The configuration header files only
Packit 78284e
# have their timestamp modified when the content actually changed, which
Packit 78284e
# is not the case for any other files generated by configure.
Packit 78284e
if MAINTAINER_MODE
Packit 78284e
doc_dependencies = $(doc_config_deps) $(doc_input)
Packit 78284e
else
Packit 78284e
doc_dependencies =
Packit 78284e
endif
Packit 78284e
Packit 78284e
# Export this variable for use in the Doxygen configuration file.
Packit 78284e
export MMDOCTOOLDIR
Packit 78284e
Packit 78284e
# Depend on files that we know shall be built.
Packit 78284e
# $(call vpath_listall,$(htmlref_patterns)) is not used as a prerequisite.
Packit 78284e
# It would expand to files that exist when the make command is issued,
Packit 78284e
# which is not necessarily the set of files that shall be built.
Packit 78284e
all-local: $(doc_build_files)
Packit 78284e
Packit 78284e
# Hook up custom rules for translating references to external documentation
Packit 78284e
# to the actual location at install time.
Packit 78284e
install-data-local: $(doc_inst_targets)
Packit 78284e
Packit 78284e
# Hook up corresponding custom uninstall rules.
Packit 78284e
uninstall-local: $(addprefix un,$(doc_inst_targets))
Packit 78284e
Packit 78284e
# Install the HTML reference documentation files with just one invocation
Packit 78284e
# of doc-install.pl to speed up the build process.  Make use of the --glob
Packit 78284e
# option, which tells it to perform filename globbing itself, like 'find'.
Packit 78284e
# This helps to avoid excessively long command lines, as some platforms
Packit 78284e
# have rather restrictive limits.
Packit 78284e
install-htmlref: $(doc_outdir)/html/index.html
Packit 78284e
	@$(NORMAL_INSTALL)
Packit 78284e
	$(MKDIR_P) '$(DESTDIR)$(htmlrefdir)'
Packit 78284e
	$(htmlref_install) -t '$(DESTDIR)$(htmlrefdir)' --glob -- $(htmlref_patterns_vpath)
Packit 78284e
Packit 78284e
# Delete files from the html installation directory.  Avoid recursive
Packit 78284e
# directory removal, and apply the same wildcard pattern as was used to
Packit 78284e
# select files for installation.
Packit 78284e
uninstall-htmlref:
Packit 78284e
	@$(NORMAL_UNINSTALL)
Packit 78284e
	(cd '$(DESTDIR)$(htmlrefdir)' 2>/dev/null || exit 0; \
Packit 78284e
	 find . -type f '(' $(htmlref_find_patterns) ')' -exec rm -f '{}' '+')
Packit 78284e
	-test ! -r '$(DESTDIR)$(htmlrefdir)' || rmdir '$(DESTDIR)$(htmlrefdir)'
Packit 78284e
Packit 78284e
# Install the Devhelp file, translating the base path on the fly.
Packit 78284e
install-devhelp: $(devhelpfile)
Packit 78284e
	@$(NORMAL_INSTALL)
Packit 78284e
	$(MKDIR_P) '$(DESTDIR)$(devhelpdir)'
Packit 78284e
	$(devhelp_install) -t '$(DESTDIR)$(devhelpdir)' -- $^
Packit 78284e
Packit 78284e
# Remove the installed Devhelp file and directory.
Packit 78284e
uninstall-devhelp:
Packit 78284e
	@$(NORMAL_UNINSTALL)
Packit 78284e
	rm -f '$(DESTDIR)$(devhelpdir)/$(notdir $(devhelpfile))'
Packit 78284e
	-test ! -r '$(DESTDIR)$(devhelpdir)' || rmdir '$(DESTDIR)$(devhelpdir)'
Packit 78284e
Packit 78284e
# Regenerate the Doxygen configuration file automatically.  In the
Packit 78284e
# top-level build directory Automake already takes care of this.
Packit 78284e
 ifneq ($(subdir),.)
Packit 78284e
$(doc_config): $(srcdir)/$(doc_config).in $(top_builddir)/config.status
Packit 78284e
	$(AM_V_GEN)cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
Packit 78284e
Packit 78284e
 endif
Packit 78284e
# Make sure that the documentation will always have been generated before
Packit 78284e
# executing commands of a rule that depends on files in $(doc_outdir)/html/.
Packit 78284e
$(doc_outdir)/html/%: | $(doxytagfile)
Packit 78284e
Packit 78284e
# Run Doxygen to build the reference documentation. The generated tag file
Packit 78284e
# also functions as time stamp target for the documentation as a whole.
Packit 78284e
$(doxytagfile): $(doc_dependencies) | $(doc_config)
Packit 78284e
	-$(AM_V_at)rm -f $@
Packit 78284e
	-$(AM_V_at)rm -fr $(doc_outdir)/html
Packit 78284e
	$(AM_V_GEN)(echo '@INCLUDE =' $(doc_config) && echo 'INPUT =' $(doc_input)) | "$(DOXYGEN)" -
Packit 78284e
	$(AM_V_at)$(doc_postprocess) '$(doc_outdir)/html/*.html'
Packit 78284e
Packit 78284e
# Run XSL transformation to generate a Devhelp book from a Doxygen tag file.
Packit 78284e
%.devhelp2: %.tag
Packit 78284e
	$(AM_V_GEN)$(XSLTPROC) $(dh_xsl_params) -o $@ $(tagfile_to_devhelp2) $<
Packit 78284e
Packit 78284e
.PHONY: install-htmlref uninstall-htmlref install-devhelp uninstall-devhelp
Packit 78284e
Packit 78284e
# Instruct GNU make to delete the targets of a rule after it failed, in
Packit 78284e
# order to avoid the complication of handling that situation manually.
Packit 78284e
.DELETE_ON_ERROR: