aboutsummaryrefslogtreecommitdiff
path: root/arch_test_target/spike/device/Makefile_common.inc
diff options
context:
space:
mode:
authorNeel Gala <neelgala@incoresemi.com>2022-02-25 11:42:33 +0530
committerNeel Gala <neelgala@incoresemi.com>2022-02-25 11:42:33 +0530
commite78559f521c1cae445e02ec5cd43db15bb32d51e (patch)
tree188af22797ce9d22065dfb3b0265fb6a7e2cdd61 /arch_test_target/spike/device/Makefile_common.inc
parent8ca012a6cc7e5b9edfaacca2d04b5a0f267377cf (diff)
downloadspike-e78559f521c1cae445e02ec5cd43db15bb32d51e.zip
spike-e78559f521c1cae445e02ec5cd43db15bb32d51e.tar.gz
spike-e78559f521c1cae445e02ec5cd43db15bb32d51e.tar.bz2
clean up the the arch-test directory to avoid copypasta
- move all common stuff to a Makefile_common.inc - include this file in all individual Makefile.includes
Diffstat (limited to 'arch_test_target/spike/device/Makefile_common.inc')
-rw-r--r--arch_test_target/spike/device/Makefile_common.inc34
1 files changed, 34 insertions, 0 deletions
diff --git a/arch_test_target/spike/device/Makefile_common.inc b/arch_test_target/spike/device/Makefile_common.inc
new file mode 100644
index 0000000..c43222d
--- /dev/null
+++ b/arch_test_target/spike/device/Makefile_common.inc
@@ -0,0 +1,34 @@
+TARGET_SIM ?= spike
+TARGET_FLAGS ?= $(RISCV_TARGET_FLAGS)
+ifeq ($(shell command -v $(TARGET_SIM) 2> /dev/null),)
+ $(error Target simulator executable '$(TARGET_SIM)` not found)
+endif
+
+RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
+RISCV_GCC ?= $(RISCV_PREFIX)gcc
+RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump
+RISCV_GCC_OPTS ?= -g -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles $(RVTEST_DEFINES)
+
+COMPILE_CMD = $$(RISCV_GCC) $(1) $$(RISCV_GCC_OPTS) \
+ -I$(ROOTDIR)/riscv-test-suite/env/ \
+ -I$(TARGETDIR)/$(RISCV_TARGET)/ \
+ -T$(TARGETDIR)/$(RISCV_TARGET)/link.ld \
+ $$(<) -o $$@
+OBJ_CMD = $$(RISCV_OBJDUMP) $$@ -D > $$@.objdump; \
+ $$(RISCV_OBJDUMP) $$@ --source > $$@.debug
+
+
+COMPILE_TARGET=\
+ $(COMPILE_CMD); \
+ if [ $$$$? -ne 0 ] ; \
+ then \
+ echo "\e[31m$$(RISCV_GCC) failed for target $$(@) \e[39m" ; \
+ exit 1 ; \
+ fi ; \
+ $(OBJ_CMD); \
+ if [ $$$$? -ne 0 ] ; \
+ then \
+ echo "\e[31m $$(RISCV_OBJDUMP) failed for target $$(@) \e[39m" ; \
+ exit 1 ; \
+ fi ;
+