summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2025-10-19 21:20:37 -0500
committerDanny Holman <dholman@gymli.org>2025-10-19 21:20:37 -0500
commitef4c73ac58f4aae29e47b680808570e2203b9713 (patch)
tree8644bb01e53bb03d9ab8562cff0778fbabbedb40 /kernel
parentbootstrap: stage2: create build files (diff)
downloadbox-ef4c73ac58f4aae29e47b680808570e2203b9713.tar.gz
box-ef4c73ac58f4aae29e47b680808570e2203b9713.tar.zst
box-ef4c73ac58f4aae29e47b680808570e2203b9713.zip
build: align all build files
Align all the build makefiles so that the standard template is used OS-wide. Remove all the dangling files leftover from pre-standardization. Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/Makefile125
-rw-r--r--kernel/arch/x86_64/make.conf30
-rw-r--r--kernel/arch/x86_64/make.config14
3 files changed, 87 insertions, 82 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
index 955cb8d..7a4c599 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -1,78 +1,67 @@
-INCLUDE?=-Iinclude
-CFLAGS?=-O0 -ffreestanding -std=gnu11 -fstack-protector-all -target $(ARCH)-none-elf
-LDFLAGS?=-nostdlib
-
-INCLUDE:=$(INCLUDE) $(SYS_INCLUDE)
-CFLAGS:=$(CFLAGS) -Wall -Wextra -DVERSION=\"$(VERSION)\" -DARCH=\"$(ARCH)\" -g
-LDFLAGS:=$(LDFLAGS)
-
-ARCHDIR=arch/$(ARCH)
-
-include $(ARCHDIR)/make.config
-include $(ROOTDIR)/modules.conf
-
-INCLUDE:=$(INCLUDE) $(KERNEL_ARCH_INCLUDE)
-CFLAGS:=$(CFLAGS) $(KERNEL_ARCH_CFLAGS)
-LDFLAGS:=$(LDFLAGS) $(KERNEL_ARCH_LDFLAGS)
-
-KERNEL=vmbox
-BOOTDIR=/boot
-PREFIX=/usr
+# Copyright (C) 2025 Danny Holman <dholman@gymli.org>
+#
+# This file is part of BoxOS, a free and open-source Unix-like operating
+# system.
+#
+# BoxOS is free software; you can redistribute it and/or modify under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# BoxOS is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY;
+# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# BoxOS; if not, see <https://www.gnu.org/licenses/>.
+
+include $(ROOTDIR)/common.mk
+
+ifeq ($(KERNEL_DEBUG),YES)
+ AFLAGS+=-g
+ CFLAGS+=-g
+endif
+
+ifeq ($(KERNEL_PROFILE),YES)
+ CFLAGS+=-fprofile-arcs -ftest-coverage -DKERNEL_PROFILE
+endif
+
+ifeq ($(KERNEL_ASSERT),NO)
+ CFLAGS+=-DNDEBUG
+endif
+
+ifeq ($(KERNEL_WERROR),YES)
+ AFLAGS+=-Werror
+ CFLAGS+=-Werror
+endif
+
+INCLUDE+=-Iinclude
+CFLAGS+=-ffreestanding -fstack-protector-all $(KERNEL_OPLVL)
+LDFLAGS+=-nostdlib
+
+include $(ARCHDIR)/make.conf
+
+BINARY=vmbox
CORE_OBJS=core/init.o \
+ core/interrupt.o \
core/kprintf.o \
+ core/kthread.o \
core/panic.o \
+ core/sched.o \
core/stack_protector.o \
core/string.o \
+ core/vfs.o \
-KERNEL_OBJS=$(KERNEL_ARCH_OBJS) \
- $(CORE_OBJS) \
-
-MODULE_SUBDIRS=
-MODULE_OBJS=
-
-include drivers/make.config
-include fs/make.config
-
-OBJS=$(KERNEL_OBJS) \
- $(MODULE_OBJS) \
-
-.PHONY: all modules clean install install-headers install-kernel install-modules
-.SUFFIXES: .o .c .s
-
-all: $(KERNEL) modules
-
-$(KERNEL): $(KERNEL_OBJS)
- @$(LD) --script=$(ARCHDIR)/linker.ld $(LDFLAGS) -o $@ $^
- @echo [LD] $@
-
-modules: $(MODULE_SUBDIRS)
-
-$(MODULE_SUBDIRS):
- $(MAKE) $(MAKECMDGOALS) -C $@
-
-.c.o:
- @$(CC) -MD -c $< -o $@ $(CFLAGS) $(INCLUDE)
- @echo [CC] $@
-
-.s.o:
- @$(CC) -MD -c $< -o $@ $(CFLAGS) $(INCLUDE)
- @echo [AS] $@
-
-clean: $(MODULE_SUBDIRS)
- $(RM) $(KERNEL) $(OBJS) $(OBJS:.o=.d)
-
-install: install-headers install-kernel install-modules
-
-install-headers:
- install -d -m 0755 $(DESTDIR)$(PREFIX)/src/kernel/
- cp -R include $(DESTDIR)$(PREFIX)/src/kernel/
+DEBUG_OBJS=debug/assert.o \
+ debug/llvm_profile.o \
-install-kernel: $(KERNEL)
- install -m 0644 $(KERNEL) $(DESTDIR)$(BOOTDIR)
- install -m 0644 System.map-$(VERSION) $(DESTDIR)$(BOOTDIR)
+MEM_OBJS=mem/kmalloc.o \
+ mem/paging.o \
-install-modules: $(MODULE_SUBDIRS)
- $(MAKE) $(MAKECMDGOALS) -C $@
+OBJS=$(ARCH_OBJS) \
+ $(CORE_OBJS) \
+ $(DEBUG_OBJS) \
+ $(MEM_OBJS) \
--include $(OBJS:.o=.d)
+include $(ROOTDIR)/patterns.mk
diff --git a/kernel/arch/x86_64/make.conf b/kernel/arch/x86_64/make.conf
new file mode 100644
index 0000000..b41be94
--- /dev/null
+++ b/kernel/arch/x86_64/make.conf
@@ -0,0 +1,30 @@
+# Copyright (C) 2025 Danny Holman <dholman@gymli.org>
+#
+# This file is part of BoxOS, a free and open-source Unix-like operating
+# system.
+#
+# BoxOS is free software; you can redistribute it and/or modify under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# BoxOS is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY;
+# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# BoxOS; if not, see <https://www.gnu.org/licenses/>.
+
+INCLUDE+=-I$(ARCHDIR)/include
+AFLAGS+=-target $(ARCH)-none-elf
+CFLAGS+=-mno-red-zone -mno-mmx -mno-sse -mno-sse2 -target $(ARCH)-none-elf
+LDFLAGS+=--script=$(ARCHDIR)/linker.ld
+
+ARCH_OBJS=$(ARCHDIR)/asm/boot.o \
+ $(ARCHDIR)/asm/isr.o \
+ $(ARCHDIR)/asm/paging.o \
+ $(ARCHDIR)/asm/spinlock.o \
+ $(ARCHDIR)/asm/stack_trace.o \
+ $(ARCHDIR)/asm/switch_thread.o \
+ $(ARCHDIR)/kernel/serial.o \
+ $(ARCHDIR)/kernel/syscall.o \
diff --git a/kernel/arch/x86_64/make.config b/kernel/arch/x86_64/make.config
deleted file mode 100644
index 2347ce2..0000000
--- a/kernel/arch/x86_64/make.config
+++ /dev/null
@@ -1,14 +0,0 @@
-KERNEL_ARCH_INCLUDE=-I$(ARCHDIR)/include
-KERNEL_ARCH_CFLAGS=$(SYS_CFLAGS) -mno-red-zone -mno-mmx -mno-sse -mno-sse2
-KERNEL_ARCH_LDFLAGS=
-KERNEL_ARCH_LIBS=
-
-KERNEL_ARCH_OBJS=$(ARCHDIR)/asm/boot.o \
- $(ARCHDIR)/asm/isr.o \
- $(ARCHDIR)/asm/paging.o \
- $(ARCHDIR)/asm/spinlock.o \
- $(ARCHDIR)/asm/stack_trace.o \
- $(ARCHDIR)/asm/switch_thread.o \
- $(ARCHDIR)/kernel/serial.o \
- $(ARCHDIR)/kernel/syscall.o \
- $(ARCHDIR)/mem/gdt.o \