2022-03-14 20:27:46 +01:00
|
|
|
# Used to generated .d file that deal with header dependencies
|
|
|
|
CPPFLAGS = -MMD
|
2022-03-14 07:46:32 +01:00
|
|
|
CROSS=aarch64-linux-gnu-
|
|
|
|
CC=$(CROSS)gcc
|
|
|
|
LD=$(CROSS)ld
|
|
|
|
CFLAGS=-Wall -Wextra -ffreestanding -march=armv8-a+crc -mcpu=cortex-a53
|
2022-03-15 20:56:42 +01:00
|
|
|
DEBUG_FLAGS += -g -Og -DDEBUG -fno-omit-frame-pointer -fno-inline
|
2022-03-14 07:46:32 +01:00
|
|
|
LDSCRIPT=rpi3.ld
|
|
|
|
|
|
|
|
OBJS=crt0.o uart.o hello.o
|
2022-03-14 20:27:46 +01:00
|
|
|
gasmsrc=$(wildcard *.S)
|
|
|
|
gasmobj=$(gasmsrc:%.S=%.o)
|
|
|
|
csrc=$(wildcard *.c)
|
|
|
|
cobj=$(csrc:%.c=%.o)
|
|
|
|
deps=$(csrc:%.c=%.d) $(gasmsrc:%.S=%.d)
|
2022-03-14 07:46:32 +01:00
|
|
|
|
2022-03-15 20:56:42 +01:00
|
|
|
KERNEL=kernel.bin
|
|
|
|
|
|
|
|
all:$(KERNEL)
|
2022-03-14 07:46:32 +01:00
|
|
|
|
2022-03-14 20:27:46 +01:00
|
|
|
kernel.elf: $(cobj) $(gasmobj) $(LDSCRIPT)
|
2022-03-15 20:56:42 +01:00
|
|
|
$(LD) $(LDFLAGS) -o $@ $(gasmobj) $(cobj) -T$(LDSCRIPT) -Map kernel.map
|
2022-03-14 07:46:32 +01:00
|
|
|
|
2022-03-15 20:56:42 +01:00
|
|
|
$(KERNEL): kernel.elf
|
2022-03-14 20:27:46 +01:00
|
|
|
$(CROSS)objcopy -O binary $< $@
|
2022-03-14 07:46:32 +01:00
|
|
|
|
|
|
|
clean:
|
2022-03-14 20:27:46 +01:00
|
|
|
rm -rf $(cobj) $(gasmobj) $(deps) *.bin *.elf *.map
|
2022-03-14 07:46:32 +01:00
|
|
|
|
2022-03-15 20:56:42 +01:00
|
|
|
run: $(KERNEL)
|
2022-03-15 23:09:55 +01:00
|
|
|
qemu-system-aarch64 -machine raspi3b -kernel $< -serial stdio
|
2022-03-14 07:46:32 +01:00
|
|
|
|
2022-03-15 20:56:42 +01:00
|
|
|
debug: CFLAGS += $(DEBUG_FLAGS)
|
|
|
|
debug: CXXFLAGS += $(DEBUG_FLAGS)
|
|
|
|
debug:$(KERNEL)
|
|
|
|
aarch64-linux-gnu-gdb -q -x debug.gdb
|
2022-03-14 20:27:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
|
|
-include $(deps)
|
|
|
|
endif
|