diff options
author | Danny Holman <dholman@gymli.org> | 2025-10-19 21:20:37 -0500 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2025-10-19 21:20:37 -0500 |
commit | ef4c73ac58f4aae29e47b680808570e2203b9713 (patch) | |
tree | 8644bb01e53bb03d9ab8562cff0778fbabbedb40 /kernel/Makefile | |
parent | bootstrap: stage2: create build files (diff) | |
download | box-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 '')
-rw-r--r-- | kernel/Makefile | 125 |
1 files changed, 57 insertions, 68 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 |