]> git.donarmstrong.com Git - lilypond.git/commitdiff
Build dependencies for .texi files (issue 1852).
authorJulien Rioux <jrioux@physics.utoronto.ca>
Mon, 26 Sep 2011 12:09:31 +0000 (08:09 -0400)
committerGraham Percival <graham@percival-music.ca>
Tue, 11 Oct 2011 17:28:11 +0000 (18:28 +0100)
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.

Documentation/GNUmakefile
stepmake/stepmake/texinfo-rules.make
stepmake/stepmake/texinfo-vars.make

index 9b598c923ac1f0107ae6e9feab0ee4eb36c85850..8f5006ef80a97c288aaa99908e426dc50c019840 100644 (file)
@@ -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) $(@)
index 53ff4bce5366bf564117c1387b69f41ae95d82d0..21e4a8ea039d7b7407845ad2c8faf456eaea097a 100644 (file)
@@ -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:
index cc4865cf3d0448b6986711a8a41ceb0b568308ed..2f2d801ab1210e1bc784306df498c5e84d5b553f 100644 (file)
@@ -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