--- /dev/null
+csrc = $(wildcard src/boot/*.c) $(wildcard src/*.c) $(wildcard src/klibc/*.c)
+asmsrc = $(wildcard src/boot/*.S) $(wildcard src/*.S) $(wildcard src/klibc/*.S)
+dep = $(asmsrc:.S=.d) $(csrc:.c=.d)
+obj = $(asmsrc:.S=.o) $(csrc:.c=.o)
+
+inc = -Isrc -Isrc/klibc -Isrc/boot -Iinclude
+
+CFLAGS = $(ccemu) -Wall -g -nostdinc -fno-builtin $(inc) -DKERNEL
+ASFLAGS = $(ccemu) -g -nostdinc -fno-builtin $(inc)
+
+bin = kernel.elf
+
+$(bin): $(obj)
+ ld $(ldemu) -o $@ -Ttext 0x8000 -e kentry $(obj) -Map link.map
+
+%.s: %.c
+ $(CC) $(CFLAGS) -S -o $@ $<
+
+-include $(dep)
+
+%.d: %.c
+ @$(CPP) $(CFLAGS) -MM -MT $(@:.d=.o) $< >$@
+
+%.d: %.S
+ @$(CPP) $(ASFLAGS) -MM -MT $(@:.d=.o) $< >$@
+
+.PHONY: clean
+clean:
+ rm -f $(obj) $(bin)
+
+.PHONY: cleandep
+cleandep:
+ rm -f $(dep)
--- /dev/null
+#define STACK_SIZE 0x4000
+
+ .text
+ .align 4
+
+ .globl kentry
+kentry:
+ ldr sp, =$(stack + STACK_SIZE)
+
+ bl kmain
+
+ .comm stack, STACK_SIZE