summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordzwdz2021-07-10 16:37:45 +0200
committerdzwdz2021-07-10 16:37:45 +0200
commitd093a8eea6bfb0ff7e621e9ba3307dae698322aa (patch)
tree08a5272e2813cf8db8feda4ff91d919cb9ad7330
parent1faac72e2514c335e2d5721dce8c9fd1da722062 (diff)
separate the source code from object files; more modular Makefile
-rw-r--r--.gitignore4
-rw-r--r--Makefile42
-rw-r--r--src/kernel/gdt.c (renamed from kernel/gdt.c)0
-rw-r--r--src/kernel/gdt.h (renamed from kernel/gdt.h)0
-rw-r--r--src/kernel/idt.c (renamed from kernel/idt.c)0
-rw-r--r--src/kernel/idt.h (renamed from kernel/idt.h)0
-rw-r--r--src/kernel/isr.c (renamed from kernel/isr.c)0
-rw-r--r--src/kernel/isr.h (renamed from kernel/isr.h)0
-rw-r--r--src/kernel/main.c (renamed from kernel/main.c)0
-rw-r--r--src/kernel/mem.c (renamed from kernel/mem.c)0
-rw-r--r--src/kernel/mem.h (renamed from kernel/mem.h)0
-rw-r--r--src/kernel/panic.h (renamed from kernel/panic.h)0
-rw-r--r--src/kernel/proc.c (renamed from kernel/proc.c)0
-rw-r--r--src/kernel/proc.h (renamed from kernel/proc.h)0
-rw-r--r--src/kernel/tty.c (renamed from kernel/tty.c)0
-rw-r--r--src/kernel/tty.h (renamed from kernel/tty.h)0
-rw-r--r--src/kernel/util.c (renamed from kernel/util.c)0
-rw-r--r--src/kernel/util.h (renamed from kernel/util.h)0
-rw-r--r--src/platform/asm.h (renamed from platform/asm.h)0
-rw-r--r--src/platform/boot.s (renamed from platform/boot.s)0
-rw-r--r--src/platform/sysenter.s (renamed from platform/sysenter.s)0
21 files changed, 23 insertions, 23 deletions
diff --git a/.gitignore b/.gitignore
index eb837cc..89f9ac0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1 @@
-*.bin
-boot.iso
-*.o
+out/
diff --git a/Makefile b/Makefile
index da06cb5..35bb882 100644
--- a/Makefile
+++ b/Makefile
@@ -2,41 +2,43 @@ AS = i686-elf-as
CC = i686-elf-gcc
CFLAGS = -std=gnu99 -ffreestanding -O2 -Wall -Wextra
CFLAGS += -mgeneral-regs-only
-CFLAGS += -I.
+CFLAGS += -Isrc/
LFLAGS = -ffreestanding -O2 -nostdlib -lgcc
QFLAGS = -no-reboot -d guest_errors,int,pcall,cpu_reset
-OBJ = $(patsubst %.s,%.o,$(wildcard platform/*.s))
-OBJ += $(patsubst %.c,%.o,$(wildcard kernel/*.c))
+OBJ = $(patsubst src/%.s,out/obj/%.s.o,$(shell find src/ -type f -name '*.s'))
+OBJ += $(patsubst src/%.c,out/obj/%.c.o,$(shell find src/ -type f -name '*.c'))
.PHONY: boot debug clean
-boot: kernel.bin
- qemu-system-i386 -kernel kernel.bin $(QFLAGS) -no-shutdown
+boot: out/fs/boot/kernel.bin
+ qemu-system-i386 -kernel $< $(QFLAGS) -no-shutdown
debug: kernel.bin
- qemu-system-i386 -kernel kernel.bin $(QFLAGS) -s -S &
+ qemu-system-i386 -kernel $< $(QFLAGS) -s -S &
sleep 1
gdb
clean:
- rm -vf kernel.bin
- rm -vf **/*.o
-
-boot.iso: kernel.bin grub.cfg
- mkdir iso_tmp
- mkdir -p iso_tmp/boot/grub
- cp kernel.bin iso_tmp/boot
- cp grub.cfg iso_tmp/boot/grub
- grub-mkrescue -o $@ iso_tmp
- rm -rv iso_tmp
-
-kernel.bin: $(OBJ)
+ rm -rv out/
+
+
+out/boot.iso: out/fs/boot/kernel.bin out/fs/boot/grub/grub.cfg
+ grub-mkrescue -o $@ out/fs/
+
+out/fs/boot/grub/grub.cfg: grub.cfg
+ @mkdir -p $(@D)
+ cp $< $@
+
+out/fs/boot/kernel.bin: $(OBJ)
+ @mkdir -p $(@D)
$(CC) $(LFLAGS) -T linker.ld $^ -o $@
grub-file --is-x86-multiboot $@
-platform/%.o: platform/%.s
+out/obj/%.s.o: src/%.s
+ @mkdir -p $(@D)
$(AS) $^ -o $@
-%.o: %.c
+out/obj/%.c.o: src/%.c
+ @mkdir -p $(@D)
$(CC) $(CFLAGS) -c $^ -o $@
diff --git a/kernel/gdt.c b/src/kernel/gdt.c
index b0d6320..b0d6320 100644
--- a/kernel/gdt.c
+++ b/src/kernel/gdt.c
diff --git a/kernel/gdt.h b/src/kernel/gdt.h
index 9e5a6a5..9e5a6a5 100644
--- a/kernel/gdt.h
+++ b/src/kernel/gdt.h
diff --git a/kernel/idt.c b/src/kernel/idt.c
index 65f511f..65f511f 100644
--- a/kernel/idt.c
+++ b/src/kernel/idt.c
diff --git a/kernel/idt.h b/src/kernel/idt.h
index 5627657..5627657 100644
--- a/kernel/idt.h
+++ b/src/kernel/idt.h
diff --git a/kernel/isr.c b/src/kernel/isr.c
index b715de0..b715de0 100644
--- a/kernel/isr.c
+++ b/src/kernel/isr.c
diff --git a/kernel/isr.h b/src/kernel/isr.h
index 150fc46..150fc46 100644
--- a/kernel/isr.h
+++ b/src/kernel/isr.h
diff --git a/kernel/main.c b/src/kernel/main.c
index 0193514..0193514 100644
--- a/kernel/main.c
+++ b/src/kernel/main.c
diff --git a/kernel/mem.c b/src/kernel/mem.c
index 08eb285..08eb285 100644
--- a/kernel/mem.c
+++ b/src/kernel/mem.c
diff --git a/kernel/mem.h b/src/kernel/mem.h
index e8e6a4f..e8e6a4f 100644
--- a/kernel/mem.h
+++ b/src/kernel/mem.h
diff --git a/kernel/panic.h b/src/kernel/panic.h
index 7d2ea5f..7d2ea5f 100644
--- a/kernel/panic.h
+++ b/src/kernel/panic.h
diff --git a/kernel/proc.c b/src/kernel/proc.c
index 776238c..776238c 100644
--- a/kernel/proc.c
+++ b/src/kernel/proc.c
diff --git a/kernel/proc.h b/src/kernel/proc.h
index 976b275..976b275 100644
--- a/kernel/proc.h
+++ b/src/kernel/proc.h
diff --git a/kernel/tty.c b/src/kernel/tty.c
index 5c4c47d..5c4c47d 100644
--- a/kernel/tty.c
+++ b/src/kernel/tty.c
diff --git a/kernel/tty.h b/src/kernel/tty.h
index 3dc1525..3dc1525 100644
--- a/kernel/tty.h
+++ b/src/kernel/tty.h
diff --git a/kernel/util.c b/src/kernel/util.c
index da3ac9d..da3ac9d 100644
--- a/kernel/util.c
+++ b/src/kernel/util.c
diff --git a/kernel/util.h b/src/kernel/util.h
index 688ac63..688ac63 100644
--- a/kernel/util.h
+++ b/src/kernel/util.h
diff --git a/platform/asm.h b/src/platform/asm.h
index 6f72617..6f72617 100644
--- a/platform/asm.h
+++ b/src/platform/asm.h
diff --git a/platform/boot.s b/src/platform/boot.s
index d5bfda5..d5bfda5 100644
--- a/platform/boot.s
+++ b/src/platform/boot.s
diff --git a/platform/sysenter.s b/src/platform/sysenter.s
index 270dc08..270dc08 100644
--- a/platform/sysenter.s
+++ b/src/platform/sysenter.s