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.
$(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
$(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
$(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) $(@)
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)
$(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:
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