improve makefile
This commit is contained in:
parent
787b4617ae
commit
27e11dd6c7
21
Makefile
21
Makefile
@ -1,4 +1,5 @@
|
|||||||
#CROSS=aarch64-none-elf-
|
# Used to generated .d file that deal with header dependencies
|
||||||
|
CPPFLAGS = -MMD
|
||||||
CROSS=aarch64-linux-gnu-
|
CROSS=aarch64-linux-gnu-
|
||||||
CC=$(CROSS)gcc
|
CC=$(CROSS)gcc
|
||||||
LD=$(CROSS)ld
|
LD=$(CROSS)ld
|
||||||
@ -6,18 +7,28 @@ CFLAGS=-Wall -Wextra -ffreestanding -march=armv8-a+crc -mcpu=cortex-a53
|
|||||||
LDSCRIPT=rpi3.ld
|
LDSCRIPT=rpi3.ld
|
||||||
|
|
||||||
OBJS=crt0.o uart.o hello.o
|
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
|
all:kernel.bin
|
||||||
|
|
||||||
kernel.elf: $(OBJS) $(LDSCRIPT)
|
kernel.elf: $(cobj) $(gasmobj) $(LDSCRIPT)
|
||||||
$(LD) -o $@ $(OBJS) -T$(LDSCRIPT) -Map kernel.map
|
$(LD) $(LDFLAGS) -o $@ $(cobj) $(gasmobj) -T$(LDSCRIPT) -Map kernel.map
|
||||||
|
|
||||||
kernel.bin: kernel.elf
|
kernel.bin: kernel.elf
|
||||||
$(CROSS)objcopy -O binay -B aarch64 $< $@
|
$(CROSS)objcopy -O binary $< $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(OBJS) *.bin *.elf *.map
|
rm -rf $(cobj) $(gasmobj) $(deps) *.bin *.elf *.map
|
||||||
|
|
||||||
run: kernel.bin
|
run: kernel.bin
|
||||||
qemu-system-aarch64 -machine raspi3b -kernel $<
|
qemu-system-aarch64 -machine raspi3b -kernel $<
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ifneq ($(MAKECMDGOALS),clean)
|
||||||
|
-include $(deps)
|
||||||
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user