From 94b7a411a2aacc75ef823c15ffad52cbbabab738 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sun, 1 Oct 2017 18:28:43 +0200 Subject: Makefile: generate the linker script dependencies --- Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5371c7ac..a324fae8 100644 --- a/Makefile +++ b/Makefile @@ -71,9 +71,16 @@ define xbuild_compile $(COMPILE) -MMD -MP -c -o $@ $< endef +# $(call xbuild_gen_linker_script_depfile,) +define xbuild_gen_linker_script_depfile +$(call xbuild_replace_source_suffix,d,$(1)) +endef + define xbuild_gen_linker_script $(call xbuild_action,LDS,$@) \ - $(CPP) $(XBUILD_CPPFLAGS) -P -o $@ $< + $(CPP) $(XBUILD_CPPFLAGS) -MMD -MP \ + -MF $(call xbuild_gen_linker_script_depfile,$<) \ + -MT $@ -P -o $@ $< endef # $(call xbuild_link,) @@ -281,6 +288,7 @@ COMPILE := $(CC) $(XBUILD_CPPFLAGS) $(XBUILD_CFLAGS) x15_SOURCES := $(x15_SOURCES-y) x15_OBJDEPS := $(call xbuild_replace_source_suffix,d,$(x15_SOURCES)) x15_OBJECTS := $(call xbuild_replace_source_suffix,o,$(x15_SOURCES)) +x15_LDS_D := $(call xbuild_gen_linker_script_depfile,$(x15_LDS_S)) x15_LDS := $(basename $(x15_LDS_S)) XBUILD_LDFLAGS += -Xlinker -T $(x15_LDS) @@ -300,7 +308,7 @@ x15_DEPS := $(x15_LDS) .x15.sorted_init_ops # rules file doesn't exist, the main source file is enough to trigger a # rebuild. Afterwards, the dependency rules file is included here and the # rules provide correct incremental compilation. --include $(x15_OBJDEPS) +-include $(x15_OBJDEPS) $(x15_LDS_D) %.o: %.c include/generated/autoconf.h $(xbuild_compile) -- cgit v1.2.3