Clean up makefiles with a source grabber function

This commit is contained in:
2025-09-02 00:10:07 +02:00
parent 2015e0e0aa
commit 4e3c386942
5 changed files with 58 additions and 38 deletions

View File

@ -1,3 +1,5 @@
include $(ROOT)/mk/grabsrc.mk
.PHONY: all clean
ARCH ?= x86_64
@ -6,7 +8,7 @@ PUTCHAR_ ?= fb
CFLAGS := -ffreestanding -Wall -Wextra -g -fcommon -nostdinc
CFLAGS += -I. \
-I../limine \
-I$(ROOT)/limine \
-I./std/include \
-I./flanterm/src \
-DPRINTF_INCLUDE_CONFIG_H=1 \
@ -31,40 +33,39 @@ include extconf/extra.mk
LDFLAGS += -nostdlib -static -T arch/$(ARCH)/link.ld $(shell $(CC) -print-libgcc-file-name)
SRCFILES := $(wildcard *.c) \
$(wildcard printf/*.c) \
$(wildcard bitmap/*.c) \
$(wildcard pmm/*.c) \
$(wildcard bootinfo/*.c) \
$(wildcard spinlock/*.c) \
$(wildcard term/*.c) \
$(wildcard vmm/*.c) \
$(wildcard dlmalloc/*.c) \
$(wildcard vfs/*.c) \
$(wildcard storedev/*.c) \
$(wildcard util/*.c) \
$(wildcard fs/kvfs/*.c) \
$(wildcard fs/littlefs/*.c) \
$(wildcard fs/portlfs/*.c) \
$(wildcard baseimg/*.c) \
$(wildcard proc/*.c) \
$(wildcard hal/*.c) \
$(wildcard hal/$(ARCH)/*.c) \
$(wildcard hal/$(ARCH)/*.S) \
$(wildcard paging/$(ARCH)/*.c) \
$(wildcard paging/*.c) \
$(wildcard *.S) \
$(wildcard std/*.c) \
$(wildcard flanterm/src/*.c) \
$(wildcard flanterm/src/flanterm_backends/*.c)
SRCFILES :=
SRCFILES += $(call GRABSRC, \
printf \
bitmap \
pmm \
bootinfo \
spinlock \
term \
vmm \
dlmalloc \
vfs \
storedev \
util \
fs/kvfs \
fs/littlefs \
fs/portlfs \
baseimg \
proc \
hal \
hal/$(ARCH) \
std \
flanterm/src \
flanterm/src/flanterm_backends \
)
ifeq ($(ARCH),x86_64)
SRCFILES += $(wildcard hal/x86_64/uACPI/source/*.c)
SRCFILES += $(call GRABSRC, hal/x86_64/uACPI/source)
endif
CFILES := $(filter %.c,$(SRCFILES))
ASFILES := $(filter %.S,$(SRCFILES))
OBJ := $(patsubst %.c,%.o,$(CFILES)) $(patsubst %.S,%.o,$(ASFILES))
CFILES := $(call GET_CFILES, $(SRCFILES))
ASFILES := $(call GET_ASFILES, $(SRCFILES))
OBJ := $(call GET_OBJ, $(SRCFILES))
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@