Clean up makefiles with a source grabber function
This commit is contained in:
6
Makefile
6
Makefile
@ -1,4 +1,4 @@
|
|||||||
.PHONY: clean prepare cleanall iso base kernel user
|
.PHONY: clean prepare cleanall iso base kernel user test
|
||||||
|
|
||||||
kernel:
|
kernel:
|
||||||
make -C kernel ROOT=$(PWD) all
|
make -C kernel ROOT=$(PWD) all
|
||||||
@ -18,8 +18,8 @@ cleanall:
|
|||||||
rm -rf limine
|
rm -rf limine
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
make -C kernel clean
|
make -C kernel ROOT=$(PWD) clean
|
||||||
make -C user clean
|
make -C user ROOT=$(PWD) clean
|
||||||
rm -f mop2.iso base.img
|
rm -f mop2.iso base.img
|
||||||
|
|
||||||
base:
|
base:
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
include $(ROOT)/mk/grabsrc.mk
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
||||||
ARCH ?= x86_64
|
ARCH ?= x86_64
|
||||||
@ -6,7 +8,7 @@ PUTCHAR_ ?= fb
|
|||||||
CFLAGS := -ffreestanding -Wall -Wextra -g -fcommon -nostdinc
|
CFLAGS := -ffreestanding -Wall -Wextra -g -fcommon -nostdinc
|
||||||
|
|
||||||
CFLAGS += -I. \
|
CFLAGS += -I. \
|
||||||
-I../limine \
|
-I$(ROOT)/limine \
|
||||||
-I./std/include \
|
-I./std/include \
|
||||||
-I./flanterm/src \
|
-I./flanterm/src \
|
||||||
-DPRINTF_INCLUDE_CONFIG_H=1 \
|
-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)
|
LDFLAGS += -nostdlib -static -T arch/$(ARCH)/link.ld $(shell $(CC) -print-libgcc-file-name)
|
||||||
|
|
||||||
SRCFILES := $(wildcard *.c) \
|
SRCFILES :=
|
||||||
$(wildcard printf/*.c) \
|
|
||||||
$(wildcard bitmap/*.c) \
|
SRCFILES += $(call GRABSRC, \
|
||||||
$(wildcard pmm/*.c) \
|
printf \
|
||||||
$(wildcard bootinfo/*.c) \
|
bitmap \
|
||||||
$(wildcard spinlock/*.c) \
|
pmm \
|
||||||
$(wildcard term/*.c) \
|
bootinfo \
|
||||||
$(wildcard vmm/*.c) \
|
spinlock \
|
||||||
$(wildcard dlmalloc/*.c) \
|
term \
|
||||||
$(wildcard vfs/*.c) \
|
vmm \
|
||||||
$(wildcard storedev/*.c) \
|
dlmalloc \
|
||||||
$(wildcard util/*.c) \
|
vfs \
|
||||||
$(wildcard fs/kvfs/*.c) \
|
storedev \
|
||||||
$(wildcard fs/littlefs/*.c) \
|
util \
|
||||||
$(wildcard fs/portlfs/*.c) \
|
fs/kvfs \
|
||||||
$(wildcard baseimg/*.c) \
|
fs/littlefs \
|
||||||
$(wildcard proc/*.c) \
|
fs/portlfs \
|
||||||
$(wildcard hal/*.c) \
|
baseimg \
|
||||||
$(wildcard hal/$(ARCH)/*.c) \
|
proc \
|
||||||
$(wildcard hal/$(ARCH)/*.S) \
|
hal \
|
||||||
$(wildcard paging/$(ARCH)/*.c) \
|
hal/$(ARCH) \
|
||||||
$(wildcard paging/*.c) \
|
std \
|
||||||
$(wildcard *.S) \
|
flanterm/src \
|
||||||
$(wildcard std/*.c) \
|
flanterm/src/flanterm_backends \
|
||||||
$(wildcard flanterm/src/*.c) \
|
)
|
||||||
$(wildcard flanterm/src/flanterm_backends/*.c)
|
|
||||||
|
|
||||||
ifeq ($(ARCH),x86_64)
|
ifeq ($(ARCH),x86_64)
|
||||||
SRCFILES += $(wildcard hal/x86_64/uACPI/source/*.c)
|
SRCFILES += $(call GRABSRC, hal/x86_64/uACPI/source)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFILES := $(filter %.c,$(SRCFILES))
|
CFILES := $(call GET_CFILES, $(SRCFILES))
|
||||||
ASFILES := $(filter %.S,$(SRCFILES))
|
ASFILES := $(call GET_ASFILES, $(SRCFILES))
|
||||||
OBJ := $(patsubst %.c,%.o,$(CFILES)) $(patsubst %.S,%.o,$(ASFILES))
|
OBJ := $(call GET_OBJ, $(SRCFILES))
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
18
mk/grabsrc.mk
Normal file
18
mk/grabsrc.mk
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
define GRABSRC
|
||||||
|
$(foreach item, $(1), $(wildcard $(item)/*.c) $(wildcard $(item)/*.S) $(wildcard $(item)/*.s))
|
||||||
|
endef
|
||||||
|
|
||||||
|
define GET_CFILES
|
||||||
|
$(filter %.c,$(1))
|
||||||
|
endef
|
||||||
|
|
||||||
|
define GET_ASFILES
|
||||||
|
$(filter %.S,$(1)) $(filter %.s,$(1))
|
||||||
|
endef
|
||||||
|
|
||||||
|
define GET_OBJ
|
||||||
|
$(patsubst %.c,%.o,$(filter %.c,$(1))) \
|
||||||
|
$(patsubst %.S,%.o,$(filter %.S,$(1))) \
|
||||||
|
$(patsubst %.s,%.o,$(filter %.s,$(1)))
|
||||||
|
endef
|
||||||
|
|
@ -7,7 +7,7 @@ APP_DIR := $(shell find . -mindepth 1 -maxdepth 1 -type d -not -path "./arch")
|
|||||||
all:
|
all:
|
||||||
rm -f FILES.txt
|
rm -f FILES.txt
|
||||||
touch FILES.txt
|
touch FILES.txt
|
||||||
for dir in $(APP_DIR); do make -C $$dir FILES=$(CURRENT_DIR)/FILES.txt all; done
|
for dir in $(APP_DIR); do make -C $$dir ROOT=$(ROOT) FILES=$(CURRENT_DIR)/FILES.txt all; done
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
for dir in $(APP_DIR); do make -C $$dir clean; done
|
for dir in $(APP_DIR); do make -C $$dir clean; done
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
|
include $(ROOT)/mk/grabsrc.mk
|
||||||
include ../Makefile.inc
|
include ../Makefile.inc
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
||||||
TARGET := hello
|
TARGET := hello
|
||||||
|
|
||||||
SRCFILES := $(wildcard *.s)
|
SRCFILES := $(call GRABSRC, .)
|
||||||
ASFILES := $(filter %.s,$(SRCFILES))
|
ASFILES := $(call GET_ASFILES, $(SRCFILES))
|
||||||
OBJ := $(patsubst %.s,%.o,$(ASFILES))
|
OBJ := $(call GET_OBJ, $(SRCFILES))
|
||||||
|
|
||||||
%.o: %.s
|
%.o: %.s
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
Reference in New Issue
Block a user