-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
84 lines (68 loc) · 1.46 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
.DEFAULT_GOAL := all
# name of the OS
NAME = davos
# kernel binary
BIN = $(NAME).elf
# bootable CD-ROM
ISO = $(NAME).iso
# compiler target
TARGET = x86_64-elf
# directory containing architecture specific source files (kernel/<ARCH_DIR>)
ARCH_DIR = x86-64
# modules (sub-projects) contained in this project
MODULES = kernel
CXXFLAGS = -Wall -Werror -Wpedantic -g
########## NON-CONFIGURABLE STUFF BELOW ##########
# popoulate the following variables with the module.mk files from each module
OBJS :=
LIBS :=
INCLUDE_DIRS :=
LIB_DIRS :=
LIB_NAMES :=
CLEAN :=
include $(patsubst %, %/module.mk, $(MODULES))
CPPFLAGS += $(addprefix -I, $(INCLUDE_DIRS))
CXXFLAGS += \
-std=c++20 \
-ffreestanding \
-fstack-protector \
-fno-stack-check \
-fno-lto \
-fno-pie \
-fno-pic \
-fno-use-cxa-atexit \
-fno-exceptions \
-m64 \
-march=x86-64 \
-mabi=sysv \
-mno-80387 \
-mno-mmx \
-mno-sse \
-mno-sse2 \
-mno-red-zone \
-mcmodel=kernel \
-MMD \
-MP \
LDFLAGS += $(addprefix -L, $(LIB_DIRS))
LDFLAGS += $(addprefix -l, $(LIB_NAMES))
LDFLAGS += \
-nostdlib \
-static \
-melf_x86_64 \
-z max-page-size=0x1000 \
-T kernel/arch/$(ARCH_DIR)/linker.ld \
HEADER_DEPS = $(OBJS:.o=.d)
CXX = $(TARGET)-g++
AR = $(TARGET)-ar
LD = $(TARGET)-ld
include phony.mk
all: $(BIN)
$(BIN): $(OBJS) $(LIBS)
$(LD) $^ $(LDFLAGS) -o $@
%.o: %.cpp
$(CXX) -c $< $(CXXFLAGS) $(CPPFLAGS) -o $@
%.o: %.S
$(CXX) -c $< $(CXXFLAGS) $(CPPFLAGS) -o $@
%.a:
$(AR) rcs $@ $^
-include $(HEADER_DEPS)