-TEXINFO_PAPERSIZE_OPTION= $(if $(findstring $(PAPERSIZE),a4),,-t @afourpaper)
+# 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 and @verbatiminclude, search for
+# included files within the texinfo include dirs, and return all dependencies.
+scan-texi = \
+$(foreach f, $(shell test -f $(1) && sed -ne "/^@\(verbatim\)\?include[[:space:]]/s/@\(verbatim\)\?include//p" $(1)), \
+ $(call find-texi,$(f)) \
+ $(call scan-texi,$(call find-texi,$(f))) \
+)