cc := clang
o :=
c :=
ldflags :=
cflags  :=
buildtype ?= release

include make/vars.mk
include make/flags.mk
include make/src.mk

all: build/kernel.elf

build/kernel.elf: $(o)
	$(cc) -o $@ $(ldflags) -T $(platform)/link.ld $^

%.o: %.c
	$(cc) -c -o $@ $(cflags) $<

%.o: %.S
	$(cc) -c -o $@ $(cflags) $<

clean:
	rm -f $(o) build/kernel.elf

format:
	clang-format -i $$(git ls-files '*.c' '*.h' \
		':!limine/limine.h' \
		':!c_headers/include/**' \
		':!uACPI/source/**' \
		':!uACPI/include/**' \
		':!uACPI/tests/**' \
		':!libk/printf*')

.PHONY: all clean format
