-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmakefile
104 lines (81 loc) · 2.08 KB
/
makefile
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
export PATH := $(shell toolchain/path.sh)
.DEFAULT_GOAL := all
rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
CREATE_DIRS = @mkdir -p $(@D)
ifeq ($(V),true)
override V :=
else
override V := @
endif
# release - no debugging info, maximum optimisation
# build - minimal debug info, maximum optimisation
# debug - includes full debug info including verbose logging, no optimisation
ifeq ($(filter release build debug,$(CONFIG)),)
override CONFIG := debug
endif
SYSTEM := ackos
VERSION := 0
ARCH := x86_64
BOOTLOADER := limine
DIST := $(SYSTEM)-$(ARCH)-$(BOOTLOADER)
OS_DIST := $(SYSTEM)-v$(VERSION)-$(CONFIG)-$(ARCH)-$(BOOTLOADER)
CC := $(ARCH)-$(SYSTEM)-gcc
CXX := $(ARCH)-$(SYSTEM)-g++
AS := $(ARCH)-$(SYSTEM)-as
OBJCOPY := $(ARCH)-$(SYSTEM)-objcopy
OBJDUMP := $(ARCH)-$(SYSTEM)-objdump
LD := $(ARCH)-$(SYSTEM)-ld
AR := $(ARCH)-$(SYSTEM)-ar
VM_MEMORY := 128
VM_LOGFILE := ackos.log
BIN_DIR := bin
OBJ_DIR := obj/$(OS_DIST)
CFLAGS := -ffreestanding \
-std=c11 \
-Wall \
-Werror \
-Wstrict-prototypes \
-Wno-unused-variable \
--warn-no-unused-function \
-D BUILD_CONFIG_$(shell echo $(CONFIG) | tr a-z A-Z) \
-D BUILD_VERSION=$(VERSION)
ASFLAGS :=
LDFLAGS := -nostdlib -static
STATIC_SYSROOT_DIR := sysroot
SYSROOT_DIR := $(OBJ_DIR)/sysroot
ifneq ($(filter release build,$(CONFIG)),)
CFLAGS += -O3
endif
ifneq ($(filter debug,$(CONFIG)),)
CFLAGS += -g
endif
KERNEL_BIN =
KERNEL_SYMS =
OS_IMAGE =
SOURCES =
include lib/build.mk
include kernel/build.mk
include config/emulators/qemu.mk
include config/emulators/bochs.mk
include config/dist/$(DIST)/build.mk
ifneq ($(filter debug,$(CONFIG)),)
include config/debug/gdb.mk
endif
all: $(OS_IMAGE)
clean:
@rm -rf bin
@rm -rf obj
$(OBJ_DIR)/%.c.o: %.c
$(CREATE_DIRS)
@echo "Building $<"
$(V)$(CC) $(CFLAGS) -c $< -o $@
$(OBJ_DIR)/%.s.o: %.s
$(CREATE_DIRS)
@echo "Building $<"
$(V)$(CC) $(CFLAGS) -c $< -o $@
build-sysroot: copy-headers-to-sysroot
$(V)cp -r sysroot/* $(SYSROOT_DIR) 2>/dev/null || :
cc-version:
@$(CC) --version
print-sysroot-dir:
@echo $(SYSROOT_DIR)