include toolchain.makefile include .config OBJ_DIR != echo $(CONFIG_OBJ_DIR) .PHONY: default clean test todo run default: $(OBJ_DIR)/glitch.elf include libk/makefile include src/makefile include drivers/makefile AS_OBJ := $(addprefix $(OBJ_DIR)/, $(AS_OBJ)) CXX_OBJ := $(addprefix $(OBJ_DIR)/, $(CXX_OBJ)) CXX_DEP = $(CXX_OBJ:%.o=%.d) CXX_TEST_OBJ := $(addprefix $(OBJ_DIR)/, $(CXX_TEST_OBJ)) CXX_INCLUDE := $(addprefix -I, $(CXX_INCLUDE)) CXX_SYSTEM_INCLUDE := $(addprefix -isystem, $(CXX_SYSTEM_INCLUDE)) $(OBJ_DIR)/glitch.elf: $(autogen) $(AS_OBJ) $(CXX_OBJ) linker.ld @echo " LD $@" @$(LD) $(LD_FLAGS) -o $@ $(AS_OBJ) $(CXX_OBJ) -T $(CURDIR)/linker.ld $(AS_OBJ): $(OBJ_DIR)/%.o: %.S @mkdir -p $(@D) @echo " AS $<" @$(AS) -target $(TARGET) -nostdlib -Wall -Wextra -c $^ -o $@ -include $(CXX_DEP) $(CXX_OBJ): $(OBJ_DIR)/%.o : %.cc @mkdir -p $(@D) @echo " CXX $<" @$(CXX) -target $(TARGET) $(CXX_FLAGS) $(CXX_INCLUDE) $(CXX_SYSTEM_INCLUDE) -MMD -c $< -o $@ $(CXX_TEST_OBJ): $(OBJ_DIR)/%.o : %.cc @mkdir -p $(@D) @echo " TEST $<" @$(TEST_CXX) -target $(TARGET) $(CXX_TEST_FLAGS) $(CXX_INCLUDE) -MMD -c $< -o $@ clean: @rm -rf $(autogen) $(AS_OBJ) $(CXX_OBJ) $(CXX_DEP) $(CXX_TEST_OBJ) $(OBJ_DIR)/glitch.elf $(OBJ_DIR)/isodir # testing test: $(CXX_TEST_OBJ) todo: @grep TODO -r libk/ src/ drivers/ # disk image $(OBJ_DIR)/glitch.iso: $(OBJ_DIR)/glitch.elf grub/grub.cfg @mkdir -p $(OBJ_DIR)/isodir/boot/grub $(GRUB_FILE) --is-x86-multiboot2 $< @cp $< $(OBJ_DIR)/isodir/boot/glitch.elf $(GRUB_SCRIPT) grub/grub.cfg @cp grub/grub.cfg $(OBJ_DIR)/isodir/boot/grub/grub.cfg @$(GRUB_MKRESCUE) -o $@ $(OBJ_DIR)/isodir run: $(OBJ_DIR)/glitch.iso @$(EMU) $< -no-reboot -no-shutdown -monitor stdio