]> git.donarmstrong.com Git - lilypond.git/blobdiff - stepmake/stepmake/metafont-vars.make
Leave extension in .dep under mf/ , as we have multiple rules
[lilypond.git] / stepmake / stepmake / metafont-vars.make
index f4d5332a922e35fdb92db54f191ae6a619eb52eb..1e50a183f53e912a9edcb64764177b8c9f8980e9 100644 (file)
@@ -1,6 +1,4 @@
-
 MF_FILES := $(call src-wildcard,*.mf)
-EXTRA_DIST_FILES += $(MF_FILES)
 MF_TFM_FILES = $(addprefix $(outdir)/, $(FONT_FILES:.mf=.tfm))
 MF_DVI_FILES = $(addprefix $(outdir)/, $(FONT_FILES:.mf=.dvi))
 MF_LOG_FILES = $(addprefix $(outdir)/, $(FONT_FILES:.mf=.log))
@@ -17,3 +15,25 @@ METAFONT_QUIET = >/dev/null
 else
 METAFONT_QUIET =
 endif
+
+# Find the metafont file $(1) within the source dirs and return its path.
+# If not found, return $(outdir)/$(1) assuming that it is a generated file.
+find-mf = \
+$(firstword \
+       $(wildcard $(src-dir)/$(1)) \
+       $(wildcard $(top-src-dir)/mf/$(1)) \
+       $(outdir)/$(1) \
+)
+
+# Recursively scan the metafont .mf file $(1) for "input X;"
+# and return all dependencies.
+scan-mf = \
+$(foreach f, $(shell test -f $(1) && sed -ne "/^[[:space:]]*input[[:space:]]/s/^[[:space:]]*input\([^.;]*\)\(.mf;\|;\)/\1.mf/p" $(1)), \
+       $(call find-mf,$(f)) \
+       $(call scan-mf,$(call find-mf,$(f))) \
+)
+
+# Find dependencies for the target $@, based on the metafont source file $<,
+# and write the dependencies to a .dep file. We cannot strip the extension of $@,
+# because we have multiple rules generating .dep files.
+DO_MF_DEP = ( echo ./$@: $(call scan-mf,$<) > $@.dep ) &&