summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile22
-rw-r--r--kernel/Makefile13
-rw-r--r--link.ld (renamed from kernel/link.ld)0
-rw-r--r--usrbin/Makefile (renamed from kernel/usrbin/Makefile)2
-rw-r--r--usrbin/lib.s (renamed from kernel/usrbin/lib.s)0
-rw-r--r--usrbin/link.ld (renamed from kernel/usrbin/link.ld)0
-rw-r--r--usrbin/main.c (renamed from kernel/usrbin/main.c)0
-rw-r--r--usrbin/print.c (renamed from kernel/usrbin/print.c)0
8 files changed, 22 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index 919e5f1..15f76ec 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,24 @@
+TARGET = kernel.elf
+
+LDFLAGS = -m elf_i386 -T link.ld
+
+LD = ld $(LDFLAGS)
+
all: build
-build:
- $(MAKE) -C kernel
+build: $(TARGET)
-run:
- $(MAKE) -C kernel run
+$(TARGET): .FORCE
+ $(MAKE) -C kernel
+ $(MAKE) -C usrbin
+ $(LD) -o $(TARGET) kernel/kernel.o usrbin/usrbin_blob.o
clean:
$(MAKE) -C kernel clean
+ $(MAKE) -C usrbin clean
+ rm -f $(TARGET)
+
+run:
+ qemu-system-x86_64 -s -kernel $(TARGET)
+
+.FORCE:
diff --git a/kernel/Makefile b/kernel/Makefile
index 6cf8ae4..c6cf24e 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -1,11 +1,11 @@
-TARGET = kernel
+TARGET = kernel.o
SRCS = $(wildcard *.c)
ASMS = $(wildcard *.s)
-OBJS = $(SRCS:.c=.o) $(ASMS:.s=.o) usrbin/usrbin_blob.o
+OBJS = $(SRCS:.c=.o) $(ASMS:.s=.o)
CFLAGS = -m32 -I../include -ffreestanding -nostdinc -nostdlib -fno-stack-protector -fno-pie -gstabs+
-LDFLAGS = -m elf_i386 -T link.ld
+LDFLAGS = -m elf_i386 -r
ASMFLAGS = -f elf32
CC = gcc $(CFLAGS)
@@ -16,9 +16,6 @@ all: build
build: $(TARGET)
-usrbin/usrbin_blob.o: $(wildcard usrbin/*.s) $(wildcard usrbin/*.c)
- $(MAKE) -C usrbin
-
.s.o:
$(ASM) -o $*.o $^
@@ -31,7 +28,3 @@ $(TARGET): $(OBJS)
clean:
rm -f $(OBJS)
rm -f $(TARGET)
- $(MAKE) -C usrbin clean
-
-run: $(TARGET)
- qemu-system-x86_64 -s -kernel $(TARGET)
diff --git a/kernel/link.ld b/link.ld
index 21c9b7c..21c9b7c 100644
--- a/kernel/link.ld
+++ b/link.ld
diff --git a/kernel/usrbin/Makefile b/usrbin/Makefile
index dd42909..16a607f 100644
--- a/kernel/usrbin/Makefile
+++ b/usrbin/Makefile
@@ -4,7 +4,7 @@ SRCS = $(wildcard *.c)
ASMS = $(wildcard *.s)
OBJS = $(SRCS:.c=.o) $(ASMS:.s=.o)
-CFLAGS = -m32 -I../../include -ffreestanding -nostdinc -nostdlib -fno-stack-protector -fno-pie
+CFLAGS = -m32 -I../include -ffreestanding -nostdinc -nostdlib -fno-stack-protector -fno-pie
LDFLAGS = -m elf_i386 -T link.ld
ASMFLAGS = -f elf32
diff --git a/kernel/usrbin/lib.s b/usrbin/lib.s
index ffe4f5f..ffe4f5f 100644
--- a/kernel/usrbin/lib.s
+++ b/usrbin/lib.s
diff --git a/kernel/usrbin/link.ld b/usrbin/link.ld
index c1a7a42..c1a7a42 100644
--- a/kernel/usrbin/link.ld
+++ b/usrbin/link.ld
diff --git a/kernel/usrbin/main.c b/usrbin/main.c
index 5cc7567..5cc7567 100644
--- a/kernel/usrbin/main.c
+++ b/usrbin/main.c
diff --git a/kernel/usrbin/print.c b/usrbin/print.c
index ea32cdf..ea32cdf 100644
--- a/kernel/usrbin/print.c
+++ b/usrbin/print.c