From 118cff9ecb669e0beea65ca9a31357d643ee3d27 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 31 Mar 2017 06:12:53 -0700 Subject: build: defend against $(top_srcdir) interference. * Makefile (tainted): New top target added in a situation when an out-of-tree build is tainted by a configuration in the original tree. The problem is that .c files which have an #include "y.tab.h" or #include "config.h" get these headers from the same directory where they reside. This is processed ahead of any -iquote directories. If a "config.h" exists in $(top_srcdir), files include that in spite of "-iquote ." on the compiler command line. --- Makefile | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index fce8e628..ec080d80 100644 --- a/Makefile +++ b/Makefile @@ -170,6 +170,17 @@ notconfigured: $(V)exit 1 endif +ifneq ($(top_srcdir),) +ifneq ($(wildcard $(top_srcdir)/config.h $(top_srcdir)/y.tab.h),) +.PHONY: tainted +tainted: + $(V)echo "Source directory $(top_srcdir) is in a configured state." + $(V)echo "Generated files there with interfere with the build here." + $(V)echo "Please do a \"make distclean\" in $(top_srcdir) first." + $(V)exit 1 +endif +endif + .PHONY: all all: $(BUILD_TARGETS) -- cgit v1.2.3