Bug 1353640 - Use more targetted vpath instead of broad VPATH for preprocessor rules. r?mshal
VPATH applies to everything, but vpath applies to files matching the
pattern it's given.
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -1016,25 +1016,26 @@ ifneq (,$(filter %.i,$(MAKECMDGOALS)))
# of the full sources, as well as the $(notdir) version. So:
# foo.cpp sub/bar.cpp
# becomes:
# foo.cpp sub/bar.cpp bar.cpp
#
# This way we can match both 'make sub/bar.i' and 'make bar.i'
_group_srcs = $(sort $(patsubst %.$1,%.i,$(filter %.$1,$2 $(notdir $2))))
-# Hack up VPATH so we can reach the sources. Eg: 'make Parser.i' may need to
-# reach $(srcdir)/frontend/Parser.i
-VPATH += $(addprefix $(srcdir)/,$(sort $(dir $(CPPSRCS) $(CSRCS) $(CMMSRCS))))
-
define PREPROCESS_RULES
_PREPROCESSED_$1_FILES := $$(call _group_srcs,$1,$$($2))
# Make preprocessed files PHONY so they are always executed, since they are
# manual targets and we don't necessarily write to $@.
.PHONY: $$(_PREPROCESSED_$1_FILES)
+
+# Hack up VPATH so we can reach the sources. Eg: 'make Parser.i' may need to
+# reach $(srcdir)/frontend/Parser.i
+vpath %.$1 $$(addprefix $$(srcdir)/,$$(sort $$(dir $$($2))))
+
$$(_PREPROCESSED_$1_FILES): _DEPEND_CFLAGS=
$$(_PREPROCESSED_$1_FILES): %.i: %.$1
$$(REPORT_BUILD_VERBOSE)
$$(addprefix $$(MKDIR) -p ,$$(filter-out .,$$(@D)))
$$($3) -C $$(PREPROCESS_OPTION)$$@ $(foreach var,$4,$$($(var))) $$($$(notdir $$<)_FLAGS) $$(_VPATH_SRCS)
endef