# Kernel Makefile # try `make help` for more information echo=$(shell which echo) -e # Default target .DEFAULT_GOAL = all # Kernel source files LINKER_SCRIPT = compiler/sections.ld CC_SOURCES = $(shell find * -name "*.cc" -a ! -name '.*' -a ! -path 'test*' -a ! -path 'fs/tool/*' -a ! -path 'assets/*' -a ! -path 'tools/*') ASM_SOURCES = $(shell find * -name "*.asm" -a ! -name '.*') # Target files KERNEL = $(BUILDDIR)/system KERNEL64 = $(KERNEL)64 ISOFILE = $(BUILDDIR)/stubs.iso KERNEL_LINK = $(ROOTBUILDDIR)/system.img # Include global variables and standard recipes include ../tools/common.mk all: $(KERNEL) # Linking the system image # We use the C++ compiler (which calls the actual linker) $(KERNEL64): $(ASM_OBJECTS) $(CC_OBJECTS) $(LINKER_SCRIPT) $(MAKEFILE_LIST) @echo "LD $@" @mkdir -p $(@D) $(VERBOSE) $(CXX) $(CXXFLAGS) -Wl,-T $(LINKER_SCRIPT) -o $@ $(LDFLAGS) $(ASM_OBJECTS) $(CC_OBJECTS) @echo "LN $(KERNEL_LINK)" $(VERBOSE) ln -sf $(@:$(ROOTBUILDDIR)/%=%) "$(KERNEL_LINK)" # The kernel must be a 32bit elf for multiboot compliance $(KERNEL): $(KERNEL64) $(VERBOSE) $(OBJCOPY) -I elf64-x86-64 -O elf32-i386 $< $@