CC = riscv64-linux-gnu-gcc
OBJCOPY = riscv64-linux-gnu-objcopy
EMULATOR = ./amach

ASFLAGS = -march=rv32ima -mabi=ilp32 -nostdlib -static -fno-pic -fno-pie -mno-relax
LDFLAGS = -Wl,-Ttext=0x100b0 -Wl,--build-id=none

all: rv32ima_tests.bin

rv32ima_tests.elf: rv32ima_tests.s
	$(CC) $(ASFLAGS) $(LDFLAGS) rv32ima_tests.s -o rv32ima_tests.elf

rv32ima_tests.bin: rv32ima_tests.elf
	$(OBJCOPY) -O binary rv32ima_tests.elf rv32ima_tests.bin

run: rv32ima_tests.bin
	$(EMULATOR) rv32ima_tests.bin

clean:
	rm -f rv32ima_tests.elf rv32ima_tests.bin

.PHONY: all run clean
