summaryrefslogtreecommitdiff
path: root/config.mk
diff options
context:
space:
mode:
Diffstat (limited to 'config.mk')
-rw-r--r--config.mk70
1 files changed, 70 insertions, 0 deletions
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..334ca1e
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,70 @@
+# ============================================================================
+# config.mk - Shared Build Configuration
+# ============================================================================
+
+PROJECT_ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
+
+CC := clang
+CXX := clang++
+AS := clang
+LD := ld.lld
+OBJCOPY := llvm-objcopy
+AR := llvm-ar
+
+ifeq ($(ARCH),x86_64)
+ TARGET_TRIPLE := x86_64-elf
+ EFI_ARCH := x86_64
+ EFI_BINARY := BOOTX64.EFI
+ ARCH_CFLAGS := -target x86_64-unknown-elf \
+ -mno-red-zone \
+ -mno-sse -mno-sse2 -mno-avx \
+ -mcmodel=kernel
+ QEMU := qemu-system-x86_64
+else ifeq ($(ARCH),aarch64)
+ TARGET_TRIPLE := aarch64-elf
+ EFI_ARCH := aarch64
+ EFI_BINARY := BOOTAA64.EFI
+ ARCH_CFLAGS := -target aarch64-unknown-elf \
+ -mgeneral-regs-only
+ QEMU := qemu-system-aarch64
+else
+ $(error ARCH must be x86_64 or aarch64)
+endif
+
+COMMON_CXXFLAGS := \
+ -std=c++23 \
+ -ffreestanding \
+ -fno-exceptions \
+ -fno-rtti \
+ -fno-stack-protector \
+ -fno-threadsafe-statics \
+ -fno-use-cxa-atexit \
+ -fno-pic \
+ -fno-pie \
+ -nostdlib \
+ -nostdinc++ \
+ -Wall -Wextra -Wpedantic \
+ -Werror=return-type \
+ -O2 \
+ -g \
+ -include $(PROJECT_ROOT)/include/kernel/config.h
+
+COMMON_CFLAGS := \
+ -std=c17 \
+ -ffreestanding \
+ -fno-stack-protector \
+ -fno-pic \
+ -fno-pie \
+ -nostdlib \
+ -Wall -Wextra \
+ -O2 \
+ -g
+
+COMMON_ASFLAGS := \
+ -g \
+ -include $(PROJECT_ROOT)/include/kernel/config.h
+
+COMMON_LDFLAGS := \
+ -nostdlib \
+ --no-dynamic-linker \
+ -z noexecstack