summaryrefslogtreecommitdiff
path: root/kernel/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/Makefile')
-rw-r--r--kernel/Makefile33
1 files changed, 33 insertions, 0 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
new file mode 100644
index 0000000..0f3ac41
--- /dev/null
+++ b/kernel/Makefile
@@ -0,0 +1,33 @@
+TARGET = kernel
+
+SRCS = $(wildcard *.c)
+ASMS = $(wildcard *.s)
+OBJS = $(SRCS:.c=.o) $(ASMS:.s=.o)
+
+CFLAGS = -m32 -I../include -ffreestanding -nostdinc -nostdlib -fno-stack-protector -gstabs+
+LDFLAGS = -m elf_i386 -Tlink.ld
+ASMFLAGS = -f elf32
+
+CC = gcc $(CFLAGS)
+LD = ld $(LDFLAGS)
+ASM = nasm $(ASMFLAGS)
+
+all: build
+
+build: $(TARGET)
+
+.s.o:
+ $(ASM) -o $*.o $^
+
+.c.o:
+ $(CC) -c -o $*.o $^
+
+$(TARGET): $(OBJS)
+ $(LD) -o $(TARGET) $(OBJS)
+
+clean:
+ rm -f $(OBJS)
+ rm -f $(TARGET)
+
+run: $(TARGET)
+ qemu-system-x86_64 -s -kernel $(TARGET)