diff --git a/target/snitch_cluster/sw/apps/common.mk b/target/snitch_cluster/sw/apps/common.mk index 6de824952a..e670014c88 100644 --- a/target/snitch_cluster/sw/apps/common.mk +++ b/target/snitch_cluster/sw/apps/common.mk @@ -19,19 +19,22 @@ ifeq ($(SELECT_RUNTIME), banshee) $(APP)_RISCV_CFLAGS += -DBIST endif -$(APP)_LIBS += $(SNRT_BUILDDIR)/libsnRuntime.a +$(APP)_LIBS += $(SNRT_LIB) $(APP)_LIBDIRS = $(dir $($(APP)_LIBS)) $(APP)_LIBNAMES = $(patsubst lib%,%,$(notdir $(basename $($(APP)_LIBS)))) +BASE_LD = $(SNRT_DIR)/base.ld MEMORY_LD ?= $(ROOT)/target/snitch_cluster/sw/runtime/memory.ld $(APP)_RISCV_LDFLAGS += $(RISCV_LDFLAGS) $(APP)_RISCV_LDFLAGS += -L$(dir $(MEMORY_LD)) -$(APP)_RISCV_LDFLAGS += -T$(abspath $(SNRT_DIR)/base.ld) +$(APP)_RISCV_LDFLAGS += -T$(BASE_LD) $(APP)_RISCV_LDFLAGS += $(addprefix -L,$($(APP)_LIBDIRS)) $(APP)_RISCV_LDFLAGS += $(addprefix -l,$($(APP)_LIBNAMES)) +LD_DEPS = $(MEMORY_LD) $(BASE_LD) $(APP)_LIBS + ########### # Outputs # ########### @@ -74,7 +77,7 @@ $(ELF): RISCV_LDFLAGS := $($(APP)_RISCV_LDFLAGS) $(DEP): $(SRCS) | $($(APP)_BUILD_DIR) $($(APP)_HEADERS) $(RISCV_CC) $(RISCV_CFLAGS) -MM -MT '$(ELF)' $< > $@ -$(ELF): $(SRCS) $(DEP) $($(APP)_LIBS) | $($(APP)_BUILD_DIR) +$(ELF): $(SRCS) $(DEP) $(LD_DEPS) | $($(APP)_BUILD_DIR) $(RISCV_CC) $(RISCV_CFLAGS) $(RISCV_LDFLAGS) $(SRCS) -o $@ $(DUMP): $(ELF) | $($(APP)_BUILD_DIR) diff --git a/target/snitch_cluster/sw/tests/tests.mk b/target/snitch_cluster/sw/tests/tests.mk index 2806f3b033..ed1bef060a 100644 --- a/target/snitch_cluster/sw/tests/tests.mk +++ b/target/snitch_cluster/sw/tests/tests.mk @@ -18,12 +18,17 @@ TESTS_BUILDDIR = $(ROOT)/target/snitch_cluster/sw/tests/build TESTS_RISCV_CFLAGS += $(RISCV_CFLAGS) TESTS_RISCV_CFLAGS += $(addprefix -I,$(SNRT_INCDIRS)) +BASE_LD = $(SNRT_DIR)/base.ld +MEMORY_LD ?= $(ROOT)/target/snitch_cluster/sw/runtime/memory.ld + TESTS_RISCV_LDFLAGS += $(RISCV_LDFLAGS) -TESTS_RISCV_LDFLAGS += -L$(abspath $(SNRT_TARGET_DIR)/..) -TESTS_RISCV_LDFLAGS += -T$(abspath $(SNRT_DIR)/base.ld) -TESTS_RISCV_LDFLAGS += -L$(SNRT_TARGET_DIR)/build +TESTS_RISCV_LDFLAGS += -L$(dir $(MEMORY_LD)) +TESTS_RISCV_LDFLAGS += -T$(BASE_LD) +TESTS_RISCV_LDFLAGS += -L$(SNRT_BUILDDIR) TESTS_RISCV_LDFLAGS += -lsnRuntime +LD_DEPS = $(MEMORY_LD) $(BASE_LD) $(SNRT_LIB) + ########### # Outputs # ########### @@ -58,7 +63,7 @@ $(TESTS_BUILDDIR): $(TESTS_BUILDDIR)/%.d: $(TESTS_SRCDIR)/%.c | $(TESTS_BUILDDIR) $(RISCV_CC) $(TESTS_RISCV_CFLAGS) -MM -MT '$(TESTS_BUILDDIR)/$*.elf' $< > $@ -$(TESTS_BUILDDIR)/%.elf: $(TESTS_SRCDIR)/%.c $(SNRT_LIB) $(TESTS_BUILDDIR)/%.d | $(TESTS_BUILDDIR) +$(TESTS_BUILDDIR)/%.elf: $(TESTS_SRCDIR)/%.c $(LD_DEPS) $(TESTS_BUILDDIR)/%.d | $(TESTS_BUILDDIR) $(RISCV_CC) $(TESTS_RISCV_CFLAGS) $(TESTS_RISCV_LDFLAGS) $(TESTS_SRCDIR)/$*.c -o $@ $(TESTS_BUILDDIR)/%.dump: $(TESTS_BUILDDIR)/%.elf | $(TESTS_BUILDDIR)