# Makefile for the Fusion operating system. # Make things fixable, not autocorrecting # TODO: Toolchain installation should be documented in the README # https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack TOOLPREFIX = riscv-none-elf CC = $(TOOLPREFIX)-gcc AS = $(TOOLPREFIX)-gas LD = $(TOOLPREFIX)-ld OBJCOPY = $(TOOLPREFIX)-objcopy OBJDUMP = $(TOOLPREFIX)-objdump # TODO: Document these options with clear descriptions, it should be readable # by people not intimately familiar with machine code and/or gcc tooling. CFLAGS = -Wall -Werror -O -fno-omit-frame-pointer -ggdb -gdwarf-2 CFLAGS += -MD CFLAGS += -mcmodel=medany CFLAGS += -ffreestanding -fno-common -nostdlib -mno-relax CFLAGS += -I. CFLAGS += -fno-pie -no-pie CFLAGS += -fno-stack-protector CFLAGS += -march=rv64gc -mabi=lp64 LDFLAGS = -z max-page-size=4096 LDFLAGS += -m elf64lriscv all: kernel.elf %.o: %.c @echo CC $@ @$(CC) $(CFLAGS) -nostdinc -I. -c $< -o $@ %.o: %.S @echo CC-AS $@ @$(CC) $(CFLAGS) -c $< -o $@ kernel.elf: trap.o kernelvec.o entry.o start.o kernel.o spinlock.o @echo LD $@ @$(LD) $(LDFLAGS) -T kernel.ld -o $@ $^ kernel.bin: kernel.elf $(OBJCOPY) -O binary $< $@ clean: rm -f *.o *.d *.elf *.bin -include *.d