-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.mk
112 lines (93 loc) · 2.48 KB
/
options.mk
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
105
106
107
108
109
110
-include $(ROOT_PROJECT_DIRECTORY)color.mk
BUILD=build
BUILD_DIRECTORY=$(ROOT_PROJECT_DIRECTORY)$(BUILD)/
BIN_DIRECTORY=$(BUILD_DIRECTORY)bin/
OBJ_DIRECTORY=$(BUILD_DIRECTORY)obj/
LIB_DIRECTORY=$(BUILD_DIRECTORY)lib/
GEN_DIRECTORY=$(BUILD_DIRECTORY)gen/
REL_PATH=$(shell realpath --relative-to $(ROOT_PROJECT_DIRECTORY) .)/
SRC_PATH=$(ROOT_PROJECT_DIRECTORY)$(REL_PATH)
OBJ_PATH=$(OBJ_DIRECTORY)$(REL_PATH)
# erase automatic vars
.SUFFIXES:
OS=$(shell uname)
ifeq ($(OS),Linux)
CC=/usr/bin/clang
CXX:=/usr/bin/clang++
LD:=$(CXX)
YACC=/usr/bin/bison
LEX=/usr/bin/flex
AR=/usr/bin/ar
RANLIB=/usr/bin/ranlib
PYTHON3=/usr/bin/python3
else ifeq ($(OS),Darwin)
CC=/usr/local/opt/llvm/bin/clang
CXX:=$(CC)
LD:=$(CC)
YACC=/usr/local/opt/bison/bin/bison
LEX=/usr/local/opt/flex/bin/flex
AR=/usr/local/opt/llvm/bin/llvm-ar
RANLIB=/usr/local/opt/llvm/bin/llvm-ranlib
PYTHON3=/usr/bin/python3
else
$(error Unsupported build on $(OS))
endif
AS=nasm
WASM=0
ifeq ($(WASM), 1)
CC=emcc
CXX=em++
LD:=$(CC)
AR=${EMSDK}/upstream/bin/llvm-ar
RANLIB=${EMSDK}/upstream/bin/llvm-ranlib
endif
VERBOSE=0
ifeq ($(VERBOSE),0)
AT=@
else
AT=
endif
define strip_root
$$(shell sed s%$(ROOT_PROJECT_DIRECTORY)%% <<< $1)
endef
define _generate_verbose_call
override $1_0=@printf "$(COLOR_GREEN)$(COLOR_BOLD)%s %s$(COLOR_RESET)\n" $1 $(call strip_root,$$@); $($1)
override $1_1=$($1)
override $1=$$($1_$(VERBOSE))
endef
define generate_verbose_call
$(eval $(call _generate_verbose_call,$1))
endef
map = $(foreach a,$(2),$(call $(1),$(a)))
$(call map,generate_verbose_call,CC CXX LD YACC LEX AR RANLIB PYTHON3)
COMPILE_FLAGS=
LINK_FLAGS=
COMPILE_FLAGS+= -Wno-comment
COMPILE_FLAGS+= -flto
LINK_FLAGS+= -flto
ifeq ($(DEBUG),1)
COMPILE_FLAGS+= -DDEBUG=1 -g -O0 -fstandalone-debug
LINK_FLAGS+= -g
else
# #warnings are for developers
COMPILE_FLAGS+= -O3 -Wno-\#warnings
endif
ifeq ($(WASM),1)
COMPILE_FLAGS+= -DWASM=1 -fwasm-exceptions
else
COMPILE_FLAGS+= -masm=intel
endif
override COMPILE_FLAGS+= -Wall -Wextra
ifdef LINKER
LINK_FLAGS+= -fuse-ld=$(LINKER)
endif
override OUT_OF_TREE_INST:= $(addprefix $(ROOT_PROJECT_DIRECTORY), $(OUT_OF_TREE_INST))
override OUT_OF_TREE_REG:= $(addprefix $(ROOT_PROJECT_DIRECTORY), $(OUT_OF_TREE_REG))
override OUT_OF_TREE_SYSCALL:= $(addprefix $(ROOT_PROJECT_DIRECTORY), $(OUT_OF_TREE_SYSCALL))
override CFLAGS+= $(COMPILE_FLAGS) -std=c11 -D_XOPEN_SOURCE=700
override CXXFLAGS+= $(COMPILE_FLAGS) -std=c++17
override ASFLAGS+=
override LDFLAGS+= $(LINK_FLAGS)
override INCLUDE+=
override YFLAGS+= -Wall
override LFLAGS+=