|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
CC = $(TARGET)-gcc
|
|
|
|
|
LD = $(TARGET)-ld
|
|
|
|
|
AS = $(TARGET)-gcc
|
|
|
|
|
OBJCOPY = $(TARGET)-objcopy
|
|
|
|
|
|
|
|
|
|
KERN_WARNINGS = -Wall -Wextra -Wpedantic -Wuninitialized -Wunused-result
|
|
|
|
|
KERN_FLAGS = -ffreestanding -nostartfiles -nostdlib -nodefaultlibs --std=gnu2x
|
|
|
|
@ -8,7 +9,7 @@ MACHINE_FLAGS = -march=rv64gc -mabi=lp64 -mcmodel=medany |
|
|
|
|
PATH_FLAGS = -I./
|
|
|
|
|
|
|
|
|
|
CFLAGS = ${MACHINE_FLAGS} -g -O0 ${KERN_WARNINGS} ${KERN_FLAGS} ${PATH_FLAGS}
|
|
|
|
|
LDFLAGS = -m elf64lriscv --gc-sections -T rv64-sifive_u.ld
|
|
|
|
|
LDFLAGS = -m elf64lriscv --gc-sections -nostdlib -T rv64-sifive_u.ld
|
|
|
|
|
ASFLAGS = ${CFLAGS}
|
|
|
|
|
|
|
|
|
|
.SUFFIXES: .c .o .S |
|
|
|
@ -19,9 +20,15 @@ ASFLAGS = ${CFLAGS} |
|
|
|
|
.S.o: |
|
|
|
|
${AS} ${ASFLAGS} -o $@ -c $<
|
|
|
|
|
|
|
|
|
|
.PHONY: all test clean |
|
|
|
|
all: kernel.elf kernel.sym |
|
|
|
|
|
|
|
|
|
kernel.elf: kernel.o crt0.o platform/FU740/uart.o platform/FU740/clock.o |
|
|
|
|
${LD} ${LDFLAGS} -o kernel.elf kernel.o crt0.o platform/FU740/uart.o platform/FU740/clock.o
|
|
|
|
|
|
|
|
|
|
kernel.sym: kernel.elf |
|
|
|
|
${OBJCOPY} --only-keep-debug kernel.elf kernel.sym
|
|
|
|
|
|
|
|
|
|
kernel.o: kernel.c |
|
|
|
|
|
|
|
|
|
platform/FU740/uart.o: platform/FU740/uart.c |
|
|
|
@ -30,9 +37,6 @@ platform/FU740/clock.o: platform/FU740/clock.c |
|
|
|
|
|
|
|
|
|
crt0.o: crt0.S |
|
|
|
|
|
|
|
|
|
.PHONY: all test clean |
|
|
|
|
all: kernel.img |
|
|
|
|
|
|
|
|
|
test: |
|
|
|
|
|
|
|
|
|
clean: |
|
|
|
|