aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2021-03-30 22:49:06 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2021-03-30 22:49:06 +0300
commit6eefbd0e736c3334e9b1b8141feb0430a5f247c1 (patch)
tree8866b0cc2b555016e23fabaa869ddc54036a1c0e /src
parentMove MemoryAllocator to libk (diff)
downloadkernel.cpp-master.tar.xz
Makefile: build targets properly from subdirsHEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/makefile24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/makefile b/src/makefile
index d1e2147..731e948 100644
--- a/src/makefile
+++ b/src/makefile
@@ -1,5 +1,7 @@
+include ../common.mk
+
AS_OBJ = boot.o idt/stubs.o
-AS_OBJ := $(addprefix $(OBJ_DIR)/, $(AS_OBJ))
+AS_OBJ := $(addprefix $(OBJ_DIR)/glitch/, $(AS_OBJ))
CXX_OBJ = kernel.o \
kernel/dump_gdt.o kernel/dump_multiboot.o kernel/multiboot.o \
@@ -10,11 +12,15 @@ CXX_OBJ = kernel.o \
idt/exception.o idt/interruptgate.o idt/interrupthandler.o \
vmm.o \
scheduler.o scheduler/task.o
-CXX_OBJ := $(addprefix $(OBJ_DIR)/, $(CXX_OBJ))
+CXX_OBJ := $(addprefix $(OBJ_DIR)/glitch/, $(CXX_OBJ))
CXX_DEP = $(CXX_OBJ:%.o=%.d)
CXX_JSON = $(CXX_OBJ:.o=.json)
-cpu/irq.h: $(OBJ_DIR)/idt/stubs.o
+.PHONY: all test clean
+all: $(OBJ_DIR)/glitch.elf
+test: $(TEST_CXX_OBJ)
+
+cpu/irq.h: $(OBJ_DIR)/glitch/idt/stubs.o
@echo " GEN $@"
@echo '#pragma once' > $@
@echo 'extern "C" {' >> $@
@@ -24,28 +30,24 @@ cpu/irq.h: $(OBJ_DIR)/idt/stubs.o
autogen := $(autogen) cpu/irq.h
-.PHONY: all test clean
-all: $(OBJ_DIR)/kernel.a
-test: $(TEST_CXX_OBJ)
-
-$(AS_OBJ): $(OBJ_DIR)/%.o: %.S
+$(AS_OBJ): $(OBJ_DIR)/glitch/%.o: %.S
@mkdir -p $(@D)
@echo " AS $<"
@$(AS) -target $(TARGET) $(AS_FLAGS) $(CXX_INCLUDE) -c $^ -o $@
-include $(CXX_DEP)
-$(CXX_OBJ) : $(OBJ_DIR)/%.o : %.cc
+$(CXX_OBJ) : $(OBJ_DIR)/glitch/%.o : %.cc
@mkdir -p $(@D)
@echo " CXX $<"
@$(CXX) -target $(TARGET) $(CXX_FLAGS) $(CXX_INCLUDE) -MMD -MJ$(subst .o,.json,$@) -c $< -o $@
$(OBJ_DIR)/glitch.elf: $(autogen) $(AS_OBJ) $(CXX_OBJ) linker.ld
@echo " LD $(@F)"
- @$(LD) $(LD_FLAGS) -o $@ $(AS_OBJ) $(CXX_OBJ) -lk -ld
+ @$(LD) $(LD_FLAGS) --library-path $(OBJ_DIR) -o $@ $(AS_OBJ) $(CXX_OBJ) -lk -ld
# constexpr tests
-include $(TEST_CXX_DEP)
-$(TEST_CXX_OBJ): $(OBJ_DIR)/%.o : %.cc
+$(TEST_CXX_OBJ): $(OBJ_DIR)/glitch/%.o : %.cc
@mkdir -p $(@D)
@echo " TEST $<"
@$(TEST_CXX) -target $(TARGET) $(TEST_CXX_FLAGS) $(CXX_INCLUDE) -MMD -c $< -o $@