diff options
Diffstat (limited to '')
-rw-r--r-- | kernel/Makefile | 125 | ||||
-rw-r--r-- | kernel/arch/x86_64/make.conf (renamed from modules.conf) | 39 | ||||
-rw-r--r-- | kernel/arch/x86_64/make.config | 14 |
3 files changed, 70 insertions, 108 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/modules.conf b/kernel/arch/x86_64/make.conf index d850fa0..b41be94 100644 --- a/modules.conf +++ b/kernel/arch/x86_64/make.conf @@ -15,29 +15,16 @@ # You should have received a copy of the GNU General Public License along with # BoxOS; if not, see <https://www.gnu.org/licenses/>. -############################## -# Kernel drivers and modules # -############################## - -# Kernel configuration -DEBUG = YES - -# File systems -FS_FAT = MOD -FS_UFS = MOD - -# Firmware -EFI = MOD - -# Bus -PCI = MOD -SATA = MOD -USB = MOD - -# Block - -# Network - -# Graphics - -# Input +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 \ |