35 lines
756 B
Makefile
35 lines
756 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
|
|
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)
|
|
|
|
all:kernel.bin
|
|
|
|
kernel.elf: $(cobj) $(gasmobj) $(LDSCRIPT)
|
|
$(LD) $(LDFLAGS) -o $@ $(cobj) $(gasmobj) -T$(LDSCRIPT) -Map kernel.map
|
|
|
|
kernel.bin: kernel.elf
|
|
$(CROSS)objcopy -O binary $< $@
|
|
|
|
clean:
|
|
rm -rf $(cobj) $(gasmobj) $(deps) *.bin *.elf *.map
|
|
|
|
run: kernel.bin
|
|
qemu-system-aarch64 -machine raspi3b -kernel $<
|
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
-include $(deps)
|
|
endif
|