ifneq ($(shell which riscv64-unknown-elf-objdump 2> /dev/null),) TOOLPREFIX := riscv64-unknown-elf- else ifneq ($(shell which riscv64-linxu-gnu-objdump 2> /dev/null),) TOOLPREFIX := riscv64-linux-gnu- else $(error "Couldn't find an riscv64 version of GCC/binutils") endif endif CC := $(TOOLPREFIX)gcc LD := $(TOOLPREFIX)ld CFLAGS := -ffreestanding -fno-PIE -g -mcmodel=medany LDFLAGS := -Ttext=0x80000000 --no-relax KERNEL := hello.out all: $(KERNEL) $(KERNEL): start.o main.o $(LD) $(LDFLAGS) -o $@ $^ clean: -rm -f *.o $(KERNEL) qemu: $(KERNEL) qemu-system-riscv64 -machine virt -nographic -bios none -kernel $<