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-01 18:28:43 +0200
commit6a61a53ab79aeb611361c60f69543d7e7d9b8c62 (patch)
treecb6ce1312381e3df18fba4adbdbdeb3179256ef5
parent5c209f9abd290eaf9b29f98cfd4102ed2a93507f (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)