diff options
-rw-r--r-- | bin/Makefile | 39 | ||||
-rw-r--r-- | bootstrap/Makefile | 4 | ||||
-rw-r--r-- | bootstrap/TODO | 3 | ||||
-rw-r--r-- | bootstrap/stage1/Makefile | 1 | ||||
-rw-r--r-- | build.conf | 86 | ||||
-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 | ||||
-rw-r--r-- | lib/Makefile | 34 | ||||
-rw-r--r-- | patterns.mk | 2 | ||||
-rw-r--r-- | sbin/Makefile | 42 | ||||
-rw-r--r-- | usr.bin/Makefile | 36 | ||||
-rw-r--r-- | usr.sbin/Makefile | 36 |
13 files changed, 303 insertions, 158 deletions
diff --git a/bin/Makefile b/bin/Makefile index e23bd68..7654e40 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -1,17 +1,40 @@ -SUBDIRS:=cat \ - echo \ - login \ +# 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/>. -export ARCH VERSION PREFIX +ifeq ($(UTIL_DEBUG),YES) + AFLAGS+=-g + CFLAGS+=-g +endif -.PHONY: all clean $(SUBDIRS) +AFLAGS+=-fPIE -target $(ARCH)-boxos-elf +CFLAGS+=-fPIE -fstack-protector-all $(UTIL_OPLVL) -target $(ARCH)-boxos-elf -all: $(SUBDIRS) +SUBDIRS:= + +PREFIX:=/ + +export PREFIX AFLAGS CFLAGS -subdirs: $(SUBDIRS) +.PHONY: all clean install $(SUBDIRS) + +all: $(SUBDIRS) $(SUBDIRS): - $(MAKE) $(MAKECMDGOALS) -C $@ + $(MAKE) -j $(JOBS) $(MAKECMDGOALS) -C $@ clean: $(SUBDIRS) diff --git a/bootstrap/Makefile b/bootstrap/Makefile index 665a26d..f65f800 100644 --- a/bootstrap/Makefile +++ b/bootstrap/Makefile @@ -15,14 +15,12 @@ # 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)/build.conf - ifeq ($(BS_DEBUG),YES) AFLAGS+=-g CFLAGS+=-g endif -export VERSION ROOTDIR DESTDIR AFLAGS CFLAGS +export AFLAGS CFLAGS SUBDIRS:=stage1 \ stage2 \ diff --git a/bootstrap/TODO b/bootstrap/TODO new file mode 100644 index 0000000..0347757 --- /dev/null +++ b/bootstrap/TODO @@ -0,0 +1,3 @@ +* Make a common include directory for headers common to both stages +* Optimize the UEFI version of stage1 +* Overall decluttering and reformatting diff --git a/bootstrap/stage1/Makefile b/bootstrap/stage1/Makefile index b80a16b..3cf7437 100644 --- a/bootstrap/stage1/Makefile +++ b/bootstrap/stage1/Makefile @@ -45,6 +45,7 @@ all: $(BINARY) $(BINARY): $(OBJS) @$(LD) $(LDFLAGS) $^ + @echo [LD] $@ %.o: %.c @$(CC) -MD -c $< -o $@ $(CFLAGS) $(INCLUDE) @@ -15,19 +15,81 @@ # You should have received a copy of the GNU General Public License along with # BoxOS; if not, see <https://www.gnu.org/licenses/>. -############################### -# General build configuration # -############################### - # Compiler options -CC = clang -LD = ld.lld -DESTDIR = base-system -JOBS = 4 +CC = clang +LD = ld.lld +C_VER = c99 +DESTDIR = base-system +JOBS = 1 # General system parameters -ARCH = x86_64 -LOCAL_VER = "" +ARCH = x86_64 +FIRMWARE = efi +LOCAL_VER = + +# Kernel configuration +KERNEL_DEBUG = YES +KERNEL_PROFILE = NO +KERNEL_OPLVL = -O0 +KERNEL_TESTS = YES +KERNEL_ASSERT = YES +KERNEL_WERROR = NO +KERNEL_ADDR_SAN = NO +KERNEL_THREAD_SAN = NO +KERNEL_UB_SAN = NO + +# Kernel file systems +KERNEL_FAT = YES +KERNEL_UFS = YES + +# Kernel bus drivers +KERNEL_PCI = YES +KERNEL_SATA = YES + +# Kernel block drivers +KERNEL_VIRTIO_BLOCK = YES + +# Kernel network drivers +KERNEL_VIRTIO_NET = YES + +# Kernel firmware drivers +KERNEL_EFI = YES + +# Kernel security features +KERNEL_ASLR = NO +KERNEL_SEC_FS_HOOKS = NO +KERNEL_SEC_NET_HOOKS = NO +KERNEL_AMAC = NO +KERNEL_POSIX_ACL = NO +KERNEL_LOG_RESTRICT = NO +KERNEL_LOCKDOWN = NO + +# Bootstrap configuration +BS_DEBUG = YES +BS_OPLVL = -O0 +BS_TESTS = YES +BS_ASSERT = YES +BS_WERROR = NO + +# Bootstrap file systems +BS_FAT = YES +BS_UFS = YES + +# Bootstrap drivers +BS_EFIFB = YES +BS_SERIAL = YES + +# System library configuration +LIB_DEBUG = YES +LIB_PROFILE = NO +LIB_OPLVL = -O0 +LIB_TESTS = YES +LIB_THREADED = YES +LIB_ASSERT = YES -# Kernel parameters -KERNEL_DEBUG = YES +# System utilities configuration +UTIL_DEBUG = YES +UTIL_PROFILE = NO +UTIL_OPLVL = -O0 +UTIL_TESTS = YES +UTIL_ASSERT = YES 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 \ diff --git a/lib/Makefile b/lib/Makefile index c307643..ec93e98 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,12 +1,36 @@ -SUBDIRS:= +# 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/>. -export ARCH VERSION PREFIX +ifeq ($(LIB_DEBUG),YES) + AFLAGS+=-g + CFLAGS+=-g +endif -.PHONY: all clean $(SUBDIRS) +AFLAGS+=-fPIC -target $(ARCH)-box-elf +CFLAGS+=-fPIC -fstack-protector-all $(LIB_OPLVL) -target $(ARCH)-boxos-elf +LDFLAGS+=-shared -all: $(SUBDIRS) +export AFLAGS CFLAGS + +SUBDIRS:=libc \ -subdirs: $(SUBDIRS) +.PHONY: all clean install $(SUBDIRS) + +all: $(SUBDIRS) $(SUBDIRS): $(MAKE) $(MAKECMDGOALS) -C $@ diff --git a/patterns.mk b/patterns.mk index 1a6b2ce..60ac49d 100644 --- a/patterns.mk +++ b/patterns.mk @@ -31,6 +31,6 @@ $(BINARY): $(OBJS) @$(CC) -c $< -o $@ $(AFLAGS) $(INCLUDE) clean: - $(RM) $(BINARY) $(OBJS) $(OBJS:.o=.d) $(OBJS:.o=.gcno) + $(RM) $(BINARY) $(OBJS) $(OBJS:.o=.d) $(OBJS:.o=.gcno) $(OBJS:.o=.dwo) -include $(OBJS:.o=.d) diff --git a/sbin/Makefile b/sbin/Makefile index 73669f8..65d3a88 100644 --- a/sbin/Makefile +++ b/sbin/Makefile @@ -1,17 +1,41 @@ -SUBDIRS:=nologin \ - -export VERSION PREFIX - -.PHONY: all clean $(SUBDIRS) +# 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/>. + +ifeq ($(UTIL_DEBUG),YES) + AFLAGS+=-g + CFLAGS+=-g +endif + +AFLAGS+=-fPIE -target $(ARCH)-boxos-elf +CFLAGS+=-fPIE -fstack-protector-all $(UTIL_OPLVL) -target $(ARCH)-boxos-elf + +PREFIX:=/ + +export PREFIX AFLAGS CFLAGS + +SUBDIRS:= + +.PHONY: all clean install $(SUBDIRS) all: $(SUBDIRS) -subdirs: $(SUBDIRS) - $(SUBDIRS): - $(MAKE) $(MAKECMDGOALS) -C $@ + $(MAKE) -j $(JOBS) $(MAKECMDGOALS) -C $@ clean: $(SUBDIRS) install: $(SUBDIRS) - diff --git a/usr.bin/Makefile b/usr.bin/Makefile index 62e125c..6a9b4e4 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -1,17 +1,41 @@ +# 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/>. + +ifeq ($(UTIL_DEBUG),YES) + AFLAGS+=-g + CFLAGS+=-g +endif + +AFLAGS+=-fPIE -target $(ARCH)-boxos-elf +CFLAGS+=-fPIE -fstack-protector-all $(UTIL_OPLVL) -target $(ARCH)-boxos-elf + SUBDIRS:= -export ARCH VERSION PREFIX +PREFIX:=/usr/ -.PHONY: all clean $(SUBDIRS) +export PREFIX AFLAGS CFLAGS -all: $(SUBDIRS) +.PHONY: all clean install $(SUBDIRS) -subdirs: $(SUBDIRS) +all: $(SUBDIRS) $(SUBDIRS): - $(MAKE) $(MAKECMDGOALS) -C $@ + $(MAKE) -j $(JOBS) $(MAKECMDGOALS) -C $@ clean: $(SUBDIRS) install: $(SUBDIRS) - diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index c68d120..13639b1 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -1,16 +1,40 @@ -SUBDIRS:=bxpkg \ - gfdisk \ +# 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/>. -export ARCH VERSION PREFIX +ifeq ($(UTIL_DEBUG),YES) + AFLAGS+=-g + CFLAGS+=-g +endif + +AFLAGS+=-fPIE -target $(ARCH)-boxos-elf +CFLAGS+=-fPIE -fstack-protector-all $(UTIL_OPLVL) -target $(ARCH)-boxos-elf + +SUBDIRS:= + +PREFIX:=/usr + +export PREFIX AFLAGS CFLAGS .PHONY: all clean $(SUBDIRS) all: $(SUBDIRS) -subdirs: $(SUBDIRS) - $(SUBDIRS): - $(MAKE) $(MAKECMDGOALS) -C $@ + $(MAKE) -j $(JOBS) $(MAKECMDGOALS) -C $@ clean: $(SUBDIRS) |