Files
a-machine/Makefile
T

55 lines
2.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-19 08:09:18 +03:00
all: rv32imac_tests.bin rv32imac_syscall_tests.bin rv32imac_args_tests.bin rv32imac_tests.elf rv32imac_syscall_tests.elf rv32imac_args_tests.elf
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
2026-06-19 08:09:18 +03:00
rv32imac_args_tests.elf: rv32imac_args_tests.s
$(CC) $(ASFLAGS) $(LDFLAGS) rv32imac_args_tests.s -o rv32imac_args_tests.elf
rv32imac_args_tests.bin: rv32imac_args_tests.elf
$(OBJCOPY) -O binary rv32imac_args_tests.elf rv32imac_args_tests.bin
run: rv32imac_tests.bin rv32imac_syscall_tests.bin rv32imac_args_tests.bin rv32imac_tests.elf rv32imac_syscall_tests.elf rv32imac_args_tests.elf
2026-06-19 07:45:35 +03:00
@echo "Running CPU instruction tests (binary)..."
2026-06-18 19:10:32 +03:00
$(EMULATOR) rv32imac_tests.bin
2026-06-19 07:45:35 +03:00
@echo "Running CPU instruction tests (ELF)..."
$(EMULATOR) rv32imac_tests.elf
@echo "Running syscall tests (binary)..."
rm -rf test_dir test_link.txt test_output.txt test_output_new.txt
2026-06-18 19:54:49 +03:00
ln -sf test_output_new.txt test_link.txt
$(EMULATOR) rv32imac_syscall_tests.bin
2026-06-19 07:45:35 +03:00
@echo "Running syscall tests (ELF)..."
rm -rf test_dir test_link.txt test_output.txt test_output_new.txt
ln -sf test_output_new.txt test_link.txt
$(EMULATOR) rv32imac_syscall_tests.elf
2026-06-19 08:09:18 +03:00
@echo "Running command line arguments tests (binary)..."
$(EMULATOR) rv32imac_args_tests.bin arg1 arg2
@echo "Running command line arguments tests (ELF)..."
$(EMULATOR) rv32imac_args_tests.elf arg1 arg2
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-19 08:09:18 +03:00
rm -rf rv32imac_tests.elf rv32imac_tests.bin rv32imac_syscall_tests.elf rv32imac_syscall_tests.bin rv32imac_args_tests.elf rv32imac_args_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