From 848b3174bbcdb6d21011ed17c1e14751abf9fba3 Mon Sep 17 00:00:00 2001 From: aqua Date: Tue, 1 Nov 2022 09:03:12 +0200 Subject: makefile: clean target shouldn't depend on OBJS --- Makefile | 6 +++++- devices/Makefile | 2 -- i686/Makefile | 2 -- lib/Makefile | 2 -- rules.mk | 6 +++--- src/Makefile | 2 -- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index da1daa4..aa6965e 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,11 @@ info: @echo " LD $(shell ${LD} --version | head -n1)" .PHONY: all run clean purge -all: lib/libk.a ${ARCH}/arch.a devices/devs.a src/kernel.a +all: + @${MAKE} ARCH=${ARCH} -C lib all + @${MAKE} ARCH=${ARCH} -C ${ARCH} all + @${MAKE} ARCH=${ARCH} -C devices all + @${MAKE} ARCH=${ARCH} -C src all run: glitch.iso qemu-system-i386 -cdrom glitch.iso -accel kvm diff --git a/devices/Makefile b/devices/Makefile index 0e07a83..a73645f 100644 --- a/devices/Makefile +++ b/devices/Makefile @@ -2,8 +2,6 @@ include ../${ARCH}/toolchain.mk CCFLAGS += -I. -I../${ARCH} -I../lib -all: devs.a - devs,SRCS = pic_8259.c uart_16550.c vga.c ps2_keyboard.c include ../rules.mk diff --git a/i686/Makefile b/i686/Makefile index d472ebe..04257dc 100644 --- a/i686/Makefile +++ b/i686/Makefile @@ -2,8 +2,6 @@ include ../${ARCH}/toolchain.mk CCFLAGS += -I../grub/include -I../lib -all: arch.a - arch,SRCS = boot.S init.s \ gdt.c lgdt.c \ lidt.c isr.c diff --git a/lib/Makefile b/lib/Makefile index 85d1f34..8645c45 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -2,8 +2,6 @@ include ../${ARCH}/toolchain.mk CCFLAGS += -I. -I.. -all: libk.a - libk,SRCS = memcpy.c memset.c stdio/printf.c string/itoa.c include ../rules.mk diff --git a/rules.mk b/rules.mk index 152cc74..e5ba185 100644 --- a/rules.mk +++ b/rules.mk @@ -1,9 +1,9 @@ -# generate ,OBJS variable for each ,SRCS +# for each target,SRCS, generate target,OBJS, target.a and add target,OBJS to all , = , $(foreach V,$(filter %$(,)SRCS, ${.VARIABLES}),\ $(eval $(V:$(,)SRCS=$(,)OBJS) += $(foreach f,$($(V)),$(addsuffix .o,$(basename $(f))))) \ $(eval $(V:$(,)SRCS=.a): $($(V:$(,)SRCS=$(,)OBJS))) \ - $(eval clean: $($(V:$(,)SRCS=$(,)OBJS))) \ + $(eval all: $($(V:$(,)SRCS=$(,)OBJS))) \ ) # Suffix rules @@ -27,4 +27,4 @@ $(foreach V,$(filter %$(,)SRCS, ${.VARIABLES}),\ # clean target .PHONY: clean clean: - @rm -rf $^ + @$(foreach V,$(filter %$(,)OBJS, ${.VARIABLES}), rm -rf $($(V))) diff --git a/src/Makefile b/src/Makefile index 881b7c2..e1fb529 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,8 +2,6 @@ include ../${ARCH}/toolchain.mk CCFLAGS += -I. -isystem../grub/include -I../${ARCH} -I../lib -I.. -all: kernel.a - conf.h: conf.h.in @cp conf.h.in conf.h @sed -i 's/@VERSION@/$(shell git describe)/' conf.h -- cgit v1.2.1