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

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

all: rv32imac_tests.bin

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

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

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

clean:
	rm -f rv32imac_tests.elf rv32imac_tests.bin

.PHONY: all run clean
