summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Rioux <jrioux@physics.utoronto.ca>2011-09-26 08:09:31 -0400
committerGraham Percival <graham@percival-music.ca>2011-10-11 18:28:11 +0100
commitd30221fa73101baffcb05ec49ec04d366a471824 (patch)
tree032a299b74d119151c79cd0d9b9aa2f45ce5c59f
parent7aa6257a56d35226e88bab86fa17671751f580d1 (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.
-rw-r--r--Documentation/GNUmakefile17
-rw-r--r--stepmake/stepmake/texinfo-rules.make13
-rw-r--r--stepmake/stepmake/texinfo-vars.make21
3 files changed, 35 insertions, 16 deletions
diff --git a/Documentation/GNUmakefile b/Documentation/GNUmakefile
index 9b598c923a..8f5006ef80 100644
--- a/Documentation/GNUmakefile
+++ b/Documentation/GNUmakefile
@@ -214,6 +214,9 @@ txt-to-html:
$(foreach a, $(README_TOP_FILES), cp $(top-src-dir)/$(a) $(outdir)/$(a).txt && ) true
$(PYTHON) $(step-bindir)/text2html.py $(OUT_TXT_FILES)
+# Explicitly list the dependencies on generated content
+$(outdir)/web.texi: $(outdir)/we-wrote.itexi $(outdir)/others-did.itexi $(outdir)/weblinks.itexi
+
ifeq ($(out),www)
## Extra images dependencies
$(OUT_TEXINFO_MANUALS): $(outdir)/pictures
@@ -222,18 +225,13 @@ $(outdir)/pictures:
$(MAKE) -C pictures WWW-1
ln -sf ../pictures/$(outdir) $@
+$(outdir)/web.texi: $(outdir)/ly-examples
+
$(outdir)/ly-examples:
$(MAKE) -C web/ly-examples
ln -sf ../web/ly-examples/$(outdir) $@
endif
-ifeq ($(out),www)
-$(outdir)/web.texi: $(outdir)/ly-examples $(outdir)/we-wrote.itexi $(outdir)/others-did.itexi
-else
-# duplicate (without ly-examples)
-$(outdir)/web.texi: $(outdir)/we-wrote.itexi $(outdir)/others-did.itexi
-endif
-
# Ugh, using '%' twice not possible
$(outdir)/notation/notation.xml: $(outdir)/notation.texi
@@ -246,11 +244,6 @@ $(outdir)/internals/internals.xml: $(outdir)/internals.texi
$(outdir)/learning.texi $(outdir)/notation.texi: $(OUT_PDF_IMAGES)
-$(foreach manual, $(MANUAL_SUBDIRS),\
-$(eval $(outdir)/(manual).texi: $(call src-wildcard,$(manual)/*.ite??)))
-
-
-
$(outdir)/source:
@rm -f $(@)
ln -sf $(depth) $(@)
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