CROSS ?= riscv-none-elf-
QEMU ?= qemu-system-riscv32
PORT ?= 1234

probe.elf: probe.s memory.ld
	$(CROSS)gcc -march=rv32i -mabi=ilp32 -nostdlib -static -g -Wl,--no-relax -T memory.ld probe.s -o $@

.PHONY: run debug clean
run: probe.elf
	$(QEMU) -M virt -bios none -kernel probe.elf -display none -monitor none -serial none -S -gdb tcp:127.0.0.1:$(PORT)

debug: probe.elf
	$(CROSS)gdb -nx -q -ex "target remote 127.0.0.1:$(PORT)" probe.elf

clean:
	rm -f probe.elf
