mittos65/src/kernel/Makefile
2022-01-04 11:25:12 +01:00

41 lines
838 B
Makefile

ifeq ($(BUILDROOT),)
$(error BUILDROOT IS NOT SET!)
endif
CC := ${TARGET}-gcc
SRC := $(wildcard **/*.[cS]*)
OBJ := $(patsubst %, %.o, $(basename $(basename $(SRC))))
CFLAGS := -Wall -Wextra -pedantic -ffreestanding -mcmodel=large
CFLAGS += -ggdb -O0
ASFLAGS += -ggdb
CPPFLAGS += -I include
LDFLAGS := -n -nostdlib -lgcc -T Link.ld
kernel: $(OBJ)
$(LINK.c) $^ -o $@
%.o: %.S.py
python3 $^ | $(COMPILE.S) $(DEPFLAGS) -x assembler-with-cpp - -o $@
# Automatic dependency tracking
DEP := $(OBJ:.o=.d)
DEPFLAGS = -MT $@ -MMD -MP -MF $*.d
$(OBJ): CPPFLAGS += $(DEPFLAGS)
%.d: ;
DESTDIR ?= $(BUILDROOT)/sysroot
$(DESTDIR)$(PREFIX)/kernel: kernel
install -D kernel $(DESTDIR)$(PREFIX)/kernel
install: $(DESTDIR)$(PREFIX)/kernel
clean:
rm -rf $(OBJ) $(DEP) kernel
.PHONY: install
# Include automatic dependency rules
include $(DEP)