aboutsummaryrefslogtreecommitdiff
path: root/kernel/Makefile
diff options
context:
space:
mode:
authorMarvin Borner2020-08-09 16:51:01 +0200
committerMarvin Borner2020-08-09 16:51:01 +0200
commit162d024a53e1e31e00ff0b6f47dd4590edebc551 (patch)
tree711d3886c300dfaddffdafaa89b690b45eb2101d /kernel/Makefile
parent79f2fa136f26a0b87917336e089485712ee49bd6 (diff)
Heavy restructuring of libc, kernel and apps
Diffstat (limited to 'kernel/Makefile')
-rw-r--r--kernel/Makefile43
1 files changed, 43 insertions, 0 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
new file mode 100644
index 0000000..bbf13af
--- /dev/null
+++ b/kernel/Makefile
@@ -0,0 +1,43 @@
+# MIT License, Copyright (c) 2020 Marvin Borner
+
+COBJS = main.o \
+ drivers/vesa.o \
+ drivers/cpu.o \
+ drivers/serial.o \
+ drivers/interrupts.o \
+ drivers/interrupts_asm.o \
+ drivers/keyboard.o \
+ drivers/ide.o \
+ drivers/timer.o \
+ features/fs.o \
+ features/psf.o \
+ features/gui.o \
+ features/load.o \
+ features/proc.o \
+ features/proc_asm.o \
+ features/syscall.o
+CC = ../cross/opt/bin/i686-elf-gcc
+LD = ../cross/opt/bin/i686-elf-ld
+OC = ../cross/opt/bin/i686-elf-objcopy
+AS = nasm
+
+# Flags to make the binary smaller TODO: Remove after indirect pointer support!
+CSFLAGS = -mpreferred-stack-boundary=2 -fno-asynchronous-unwind-tables -Os
+
+CFLAGS = $(CSFLAGS) -Wall -Wextra -nostdlib -nostdinc -ffreestanding -fno-builtin -mgeneral-regs-only -std=c99 -m32 -pedantic-errors -Wl,-ekernel_main -I../lib/inc/ -Iinc/
+
+ASFLAGS = -f elf32 -O3
+
+all: compile
+
+%.o: %.c
+ @$(CC) -c $(CFLAGS) $< -o $@
+
+%_asm.o: %.asm
+ @$(AS) $(ASFLAGS) $< -o $@
+
+compile: $(COBJS)
+ @mkdir -p ../build/
+ @$(AS) -f bin entry.asm -o ../build/boot.bin
+ @$(LD) -N -ekernel_main -Ttext 0x00050000 -o ../build/kernel.bin -L../build/ $+ -lc --oformat binary
+ @$(CC) $(CFLAGS) -o ../build/debug.o -L../build/ $+ -lc