Files
my-os-project2/kernel/Makefile
2025-08-14 01:49:04 +02:00

61 lines
1.2 KiB
Makefile

.PHONY: all clean
ARCH ?= x86_64
PUTCHAR_ ?= fb
CFLAGS := -ffreestanding -Wall -Wextra -g -fcommon -nostdinc
CFLAGS += -I. \
-I../limine \
-I./std/include \
-I./flanterm/src \
-DPRINTF_INCLUDE_CONFIG_H=1 \
ifeq ($(PUTCHAR_),fb)
CFLAGS += -DPUTCHAR_=PUTCHAR_FB
else
CFLAGS += -DPUTCHAR_=PUTCHAR_SERIAL
endif
LDFLAGS := -nostdlib -static -T arch/$(ARCH)/link.ld
include arch/$(ARCH)/$(ARCH).mk
include extconf/extra.mk
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 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)
CFILES := $(filter %.c,$(SRCFILES))
ASFILES := $(filter %.S,$(SRCFILES))
OBJ := $(patsubst %.c,%.o,$(CFILES)) $(patsubst %.S,%.o,$(ASFILES))
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.S
$(CC) $(CFLAGS) -c $< -o $@
all: mop2
mop2: $(OBJ)
$(LD) $^ $(LDFLAGS) -o $@
clean:
rm -f $(OBJ) mop2