81 lines
1.8 KiB
Makefile
81 lines
1.8 KiB
Makefile
# This build script uses some GNU make specific extensions.
|
|
|
|
include config.mk
|
|
|
|
CFLAGS += -ggdb
|
|
|
|
# Kernel sources which are specific to the x86_64 architecture.
|
|
# Add new source files (C or Assembler) here,
|
|
# preferentially in alphabetical order.
|
|
KERNEL_SOURCES_x86_64 := \
|
|
src/x86_64/uart.c \
|
|
src/x86_64/mem.c \
|
|
src/x86_64/asm.c \
|
|
src/x86_64/sata.c \
|
|
# end of x86_64 specific kernel sources list
|
|
|
|
# Architecture-agnostic kernel sources.
|
|
# Add new source files (C or Assembler) here,
|
|
# preferentially in alphabetical order.
|
|
KERNEL_SOURCES := \
|
|
src/kernel.c \
|
|
src/pci.c \
|
|
src/tar.c \
|
|
src/std.c \
|
|
$(KERNEL_SOURCES_$(ARCH)) \
|
|
# end of kernel sources list
|
|
|
|
KERNEL_OBJECTS := $(KERNEL_SOURCES:.c=.o)
|
|
KERNEL_OBJECTS := $(KERNEL_OBJECTS:.S=.o)
|
|
KERNEL_OBJECTS := $(KERNEL_OBJECTS:%.o=build/%.o)
|
|
KERNEL_DEPFILES := $(KERNEL_OBJECTS:.o=.d)
|
|
KERNEL_OBJECTS += build/font.o
|
|
KERNEL_TARGET := build/boot/sys/core
|
|
|
|
.PHONY: all clean
|
|
|
|
all: build/disk.img drive.img
|
|
|
|
drive.img:
|
|
truncate -s 16M drive.img
|
|
|
|
clean:
|
|
rm -f $(KERNEL_OBJECTS)
|
|
rm -f $(KERNEL_DEPFILES)
|
|
rm -f $(KERNEL_TARGET)
|
|
|
|
build/src/%.o: src/%.[cS] | build/src
|
|
@printf "CC %s\n" $@
|
|
@"$(CC)" $(CFLAGS) -MMD -MP -c -o $@ $< $(CPPFLAGS)
|
|
|
|
build/src/$(ARCH)/%.o: src/$(ARCH)/%.[cS] | build/src/$(ARCH)
|
|
@printf "CC %s\n" $@
|
|
@"$(CC)" $(CFLAGS) -MMD -MP -c -o $@ $< $(CPPFLAGS)
|
|
|
|
build/font.o: font.psf
|
|
@printf "LD %s\n" $@
|
|
@"$(LD)" -r -b binary -z noexecstack -o $@ $^
|
|
|
|
$(KERNEL_TARGET): $(KERNEL_OBJECTS) kernel.ld | build/boot/sys
|
|
@printf "LD %s\n" $@
|
|
@"$(LD)" -T kernel.ld $(LDFLAGS) -o $@ $(KERNEL_OBJECTS)
|
|
|
|
build/disk.img: $(KERNEL_TARGET) kernel.json bootboot.cfg
|
|
$(MKBOOTIMG) kernel.json $@
|
|
|
|
build:
|
|
mkdir -p $@
|
|
|
|
build/src:
|
|
mkdir -p $@
|
|
|
|
build/src/$(ARCH):
|
|
mkdir -p $@
|
|
|
|
build/boot/sys:
|
|
mkdir -p $@
|
|
|
|
config.mk: | config.default.mk
|
|
cp config.default.mk $@
|
|
|
|
-include $(KERNEL_DEPFILES)
|