Files
a-machine/Makefile
T

38 lines
1.4 KiB
Makefile
Raw Normal View History

2026-06-18 14:01:36 +03:00
CC = riscv64-linux-gnu-gcc
OBJCOPY = riscv64-linux-gnu-objcopy
EMULATOR = ./amach
2026-06-18 19:10:32 +03:00
ASFLAGS = -march=rv32imac -mabi=ilp32 -nostdlib -s -static -fno-pic -fno-pie -mno-relax
2026-06-18 14:01:36 +03:00
LDFLAGS = -Wl,-Ttext=0x100b0 -Wl,--build-id=none
2026-06-18 19:54:49 +03:00
all: rv32imac_tests.bin rv32imac_syscall_tests.bin
2026-06-18 14:01:36 +03:00
2026-06-18 19:10:32 +03:00
rv32imac_tests.elf: rv32imac_tests.s
$(CC) $(ASFLAGS) $(LDFLAGS) rv32imac_tests.s -o rv32imac_tests.elf
2026-06-18 14:01:36 +03:00
2026-06-18 19:10:32 +03:00
rv32imac_tests.bin: rv32imac_tests.elf
$(OBJCOPY) -O binary rv32imac_tests.elf rv32imac_tests.bin
2026-06-18 14:01:36 +03:00
2026-06-18 19:54:49 +03:00
rv32imac_syscall_tests.elf: rv32imac_syscall_tests.s
$(CC) $(ASFLAGS) $(LDFLAGS) rv32imac_syscall_tests.s -o rv32imac_syscall_tests.elf
rv32imac_syscall_tests.bin: rv32imac_syscall_tests.elf
$(OBJCOPY) -O binary rv32imac_syscall_tests.elf rv32imac_syscall_tests.bin
run: rv32imac_tests.bin rv32imac_syscall_tests.bin
@echo "Running CPU instruction tests..."
2026-06-18 19:10:32 +03:00
$(EMULATOR) rv32imac_tests.bin
2026-06-18 19:54:49 +03:00
@echo "Running syscall tests..."
ln -sf test_output_new.txt test_link.txt
$(EMULATOR) rv32imac_syscall_tests.bin
2026-06-18 19:34:05 +03:00
@echo "Testing standard ebreak..."
@echo "115 0 16 0" | awk -f amach.awk 2>&1 | grep -q "Fatal: EBREAK"
@echo "Testing compressed c.ebreak..."
@echo "2 144" | awk -f amach.awk 2>&1 | grep -q "Fatal: EBREAK"
2026-06-18 19:54:49 +03:00
@echo "All tests PASSED!"
2026-06-18 14:01:36 +03:00
clean:
2026-06-18 19:54:49 +03:00
rm -rf rv32imac_tests.elf rv32imac_tests.bin rv32imac_syscall_tests.elf rv32imac_syscall_tests.bin test_dir test_link.txt test_output.txt test_output_new.txt
2026-06-18 14:01:36 +03:00
.PHONY: all run clean