# Compiler and flags CC = clang CFLAGS = --target=riscv32 -march=rv64gc_zbb -mabi=lp64 -mno-relax -g # Directories and files BUILD_DIR = build ZOMUTILS_SRC = libzomutils.s ZOMUTILS_OBJ = $(BUILD_DIR)/libzomutils.o ZOMUTILS_LIB = $(BUILD_DIR)/libzomutils.a HELLO_SRC = hello.s HELLO_OBJ = $(BUILD_DIR)/hello.o HELLO_BIN = $(BUILD_DIR)/hello # Default target all: $(HELLO_BIN) # Ensure build directory exists $(BUILD_DIR): mkdir -p $(BUILD_DIR) # Build libzomutils object file $(ZOMUTILS_OBJ): $(ZOMUTILS_SRC) | $(BUILD_DIR) $(CC) $(CFLAGS) -c $< -o $@ # Create static library libzomutils.a $(ZOMUTILS_LIB): $(ZOMUTILS_OBJ) ar rcs $@ $^ # Build hello object file $(HELLO_OBJ): $(HELLO_SRC) | $(BUILD_DIR) $(CC) $(CFLAGS) -c $< -o $@ # Link hello executable with libzomutils.a $(HELLO_BIN): $(HELLO_OBJ) $(ZOMUTILS_LIB) $(CC) $(CFLAGS) -nostdlib $^ -o $@ # Clean up generated files clean: rm -rf $(BUILD_DIR) .PHONY: all clean