From 80513bc18ca32f5cc6a5b72e3ad812de3db9a6da Mon Sep 17 00:00:00 2001 From: Lizzy Fleckenstein Date: Thu, 21 Dec 2023 02:32:20 +0100 Subject: make: track #include dependencies --- .gitignore | 1 + Makefile | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index dce403a..fd2c976 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.bin *.o +*.d *.img *.map *.dis.asm diff --git a/Makefile b/Makefile index 76ad53c..fc97bbf 100644 --- a/Makefile +++ b/Makefile @@ -9,20 +9,18 @@ override CFLAGS += \ -fno-stack-protector \ -nostartfiles \ -nodefaultlibs \ - -mgeneral-regs-only \ -Wall \ - -Wextra + -Wextra \ + -MMD -STAGE3 = \ +STAGE3_C = \ stage3/init.o \ stage3/main.o \ stage3/gfx.o \ stage3/halt.o \ stage3/interrupts.o \ - stage3/isr.o \ stage3/pic.o \ stage3/memory.o \ - stage3/paging.o \ stage3/heap.o \ stage3/font.o \ stage3/font_classic.o \ @@ -30,12 +28,16 @@ STAGE3 = \ stage3/string.o \ stage3/pci.o \ stage3/fs.o \ - stage3/yield.o \ stage3/ps2.o \ stage3/thread.o \ stage3/shell.o \ stage3/version.o +STAGE3 = $(STAGE3_C) \ + stage3/isr.o \ + stage3/yield.o \ + stage3/paging.o + PAD_BOUNDARY = pad() { truncate -s $$(echo "($$(du -b $$1 | cut -f1)+$$2-1)/$$2*$$2" | bc) $$1; }; pad DISAS = objdump -b binary -D -M intel -m i386:x86-64 stage3.bin --adjust-vma 0x9000 @@ -51,7 +53,7 @@ stage2.bin: stage2/main.asm stage2/mmap.asm stage2/paging.asm stage2/vesa.asm st nasm -f bin stage2/main.asm -o stage2.bin truncate -s 4608 stage2.bin -stage3.bin fs/dbg/kernel.map: $(STAGE3) stage3.ld +stage3.bin fs/dbg/kernel.map &: $(STAGE3) stage3.ld mkdir -p fs/dbg/ ld $(STAGE3) -T stage3.ld -Map=fs/dbg/kernel.map $(PAD_BOUNDARY) stage3.bin 512 @@ -66,6 +68,8 @@ stage3/%.o: stage3/%.asm stage3/%.o: stage3/%.c gcc $(CFLAGS) -c $< -o $@ +-include $(STAGE3_C:%.o=%.d) + GIT_VERSION := $(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD) .version-$(GIT_VERSION): @@ -96,7 +100,7 @@ qemu_slow: cuddles.img run: qemu clean: - rm -rf .version-* stage3/*.o *.bin *.img stage3/{isr.asm,version.c} fs.tar fs/dbg + rm -rf .version-* stage3/*.{o,d} *.bin *.img stage3/{isr.asm,version.c} fs.tar fs/dbg flash: cuddles.img dd if=cuddles.img of=$(DEV) -- cgit v1.2.3