summaryrefslogtreecommitdiff
path: root/config.mk
blob: 334ca1e20e283deaff3d1530f1d727aa8c320512 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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