summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-10-01 18:28:43 +0200
committerRichard Braun <rbraun@sceen.net>2017-10-02 21:12:26 +0200
commit94b7a411a2aacc75ef823c15ffad52cbbabab738 (patch)
treef1d0ca09f73407b51362aa6bea278a2a8cbeeb1b
parent862e8347cbe776e08c5f89b8faa45e13e0b92ed4 (diff)
Makefile: generate the linker script dependencies
-rw-r--r--Makefile12
1 files 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,<linker_script>)
+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,<objects>)
@@ -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)