aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv/linux/Makefile
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-11-20 15:40:31 +0000
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-12-05 16:02:50 +0100
commitbab3fdfd61b3488e1879bc3e53ac17f41d2e8b67 (patch)
treea2bcbd5f086d6b351b078a95efd08e7957e470e6 /arch/riscv/linux/Makefile
parent9a3324f50679177401eecdedcf80f25ddcdd9042 (diff)
downloadfarga-bab3fdfd61b3488e1879bc3e53ac17f41d2e8b67.tar.gz
farga-bab3fdfd61b3488e1879bc3e53ac17f41d2e8b67.zip
linux: Add a program to test the hwprobe syscall
RISC-V on Linux has a hwprobe system call which allows you to discover what is supported by the running kernel. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'arch/riscv/linux/Makefile')
-rw-r--r--arch/riscv/linux/Makefile60
1 files changed, 60 insertions, 0 deletions
diff --git a/arch/riscv/linux/Makefile b/arch/riscv/linux/Makefile
new file mode 100644
index 0000000..9b813ff
--- /dev/null
+++ b/arch/riscv/linux/Makefile
@@ -0,0 +1,60 @@
+##
+# By default everything is silent. If you want to change this behavior, simply
+# assign V=1 when calling make.
+
+V =
+ifeq ($(strip $(V)),)
+ E = @echo
+ Q = @
+else
+ E = @\#
+ Q =
+endif
+
+##
+# Compile options. You can use CROSS_COMPILE just like on the Linux Kernel. You
+# can also determine the ISA to be used, which defaults to my VisionFive2 board.
+# I did not go too much into the rabbit hole of platform-specific flags because
+# everything is in assembly anyways and everything is statically linked. Hence
+# no `-mcpu`, no `-mtune`, no funny business.
+
+CC = $(CROSS_COMPILE)gcc
+LD = $(CROSS_COMPILE)ld
+ISA ?= rv64imafdc_zicntr_zicsr_zifencei_zihpm_zca_zcd_zba_zbb
+WARNINGS = -Werror -Wpedantic -Wall -Wextra -Wcast-align -Wcast-qual -Winit-self \
+ -Wmissing-include-dirs -Wredundant-decls -Wshadow -Wsign-conversion \
+ -Wswitch-default -Wundef -Wunreachable-code -Wmissing-noreturn
+CCFLAGS = $(WARNINGS) -march=$(ISA)
+LDFLAGS =
+
+
+# You can pass an optional `DEBUG` variable to manipulate the build type.
+DEBUG =
+ifeq ($(strip $(DEBUG)),)
+ CCFLAGS += -O3
+else
+ CCFLAGS += -g
+endif
+
+##
+# Paths.
+
+SRC = $(wildcard *.c)
+EXES = $(SRC:.c=)
+
+##
+# Targets
+
+.PHONY: all
+all: clean $(EXES)
+
+.PHONY: build
+build: $(EXES)
+
+.c:
+ $(E) " CC " $(*F)
+ $(Q) $(CC) $(CCFLAGS) $< -o $@
+
+.PHONY: clean
+clean:
+ $(Q) rm -f $(EXES)