raspberry3_bare/Makefile

42 lines
973 B
Makefile

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