diff options
author | Julien Rioux <jrioux@physics.utoronto.ca> | 2011-09-26 08:09:31 -0400 |
---|---|---|
committer | Graham Percival <graham@percival-music.ca> | 2011-10-11 18:28:11 +0100 |
commit | d30221fa73101baffcb05ec49ec04d366a471824 (patch) | |
tree | 032a299b74d119151c79cd0d9b9aa2f45ce5c59f /stepmake | |
parent | 7aa6257a56d35226e88bab86fa17671751f580d1 (diff) |
Build dependencies for .texi files (issue 1852).
Write .dep files containing make dependency rules for .texi and .itexi files.
They allow to simply type `make' to process the doc after changing an included
file and have the manuals updated with the minimum amount of processing.
These .dep files are generated by recursively scanning for lines starting with
@include in the .texi files, and looking up these included files within the
include directories that we pass to texinfo. The same is done for .itexi files.
The .dep files are included into the build by stepmake/generic-targets.make.
With this we can clean up Documentation/GNUmakefile a bit:
- Remove the previous apparently unsuccessfull attempt at tracking
dependencies with a wildcard, and
- Remove dependencies that are caught automatically: only generated files
need an explicit dependency, which weblinks.itexi is an example, thus
- Add the explicit dependency for weblinks.itexi.
Diffstat (limited to 'stepmake')
-rw-r--r-- | stepmake/stepmake/texinfo-rules.make | 13 | ||||
-rw-r--r-- | stepmake/stepmake/texinfo-vars.make | 21 |
2 files changed, 30 insertions, 4 deletions
diff --git a/stepmake/stepmake/texinfo-rules.make b/stepmake/stepmake/texinfo-rules.make index 53ff4bce53..21e4a8ea03 100644 --- a/stepmake/stepmake/texinfo-rules.make +++ b/stepmake/stepmake/texinfo-rules.make @@ -23,8 +23,14 @@ ifneq ($(INFO_IMAGES_DIR),) endif touch $@ +# Copy files while tracking their dependencies. $(outdir)/%.texi: $(src-dir)/%.texi - cp -p $< $@ + mkdir -p $(dir $@) + $(DO_TEXI_DEP) cp -f $< $@ + +$(outdir)/%.itexi: $(src-dir)/%.itexi + mkdir -p $(dir $@) + $(DO_TEXI_DEP) cp -f $< $@ $(outdir)/%.info: $(outdir)/%.texi $(outdir)/$(INFO_IMAGES_DIR).info-images-dir-dep $(outdir)/version.itexi $(outdir)/weblinks.itexi ifeq ($(WEB_VERSION),yes) @@ -80,6 +86,5 @@ $(outdir)/version.%: $(top-src-dir)/VERSION $(outdir)/weblinks.%: $(top-src-dir)/VERSION $(PYTHON) $(top-src-dir)/scripts/build/create-weblinks-itexi.py > $@ -.SECONDARY: $(outdir)/version.itexi $(outdir)/version.texi \ - $(outdir)/$(INFO_IMAGES_DIR).info-images-dir-dep \ - $(outdir)/*.texi +# Keep this empty to prevent make from removing intermediate files. +.SECONDARY: diff --git a/stepmake/stepmake/texinfo-vars.make b/stepmake/stepmake/texinfo-vars.make index cc4865cf3d..2f2d801ab1 100644 --- a/stepmake/stepmake/texinfo-vars.make +++ b/stepmake/stepmake/texinfo-vars.make @@ -8,6 +8,27 @@ OMF_FILES += $(foreach format, html pdf, $(foreach f, $(TEXI_FILES), $(outdir)/$ GENERATE_OMF = $(buildscript-dir)/texi2omf --format $(1) --location $(webdir)$(tree-dir)/$(notdir $(basename $@)) --version $(TOPLEVEL_VERSION) $< > $@ +# Find the file $(1) within the texinfo include dirs and return its path. +# If not found, return $(outdir)/$(1) assuming that it is a generated file. +find-texi = \ +$(firstword \ + $(wildcard $(src-dir)/$(1)) \ + $(wildcard $(top-src-dir)/Documentation/$(1)) \ + $(outdir)/$(1) \ +) + +# Recursively scan the file $(1) for @include, search for included files +# within the texinfo include dirs, and return all dependencies. +scan-texi = \ +$(foreach f, $(shell sed -ne "/^@include[[:space:]]/s/@include//p" $(1)), \ + $(call find-texi,$(f)) \ + $(call scan-texi,$(call find-texi,$(f))) \ +) + +# Find dependencies for the target $@, based on the texinfo source file $<, +# and write the dependencies to a .dep file. +DO_TEXI_DEP = ( echo ./$@: $(call scan-texi,$<) > $(basename $@).dep ) && + TEXINFO_PAPERSIZE_OPTION= $(if $(findstring $(PAPERSIZE),a4),,-t @afourpaper) DOCUMENTATION_INCLUDES += -I $(top-src-dir)/Documentation |