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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
ifndef DPP_ROOT
$(error DPP_ROOT is undefined)
endif
ifndef BUILD_NATIVE
$(error BUILD_NATIVE is _NOT_ defined, include Makefile.inc)
endif
NAME_SUFFIX := -native
Q = @
ifeq ($(Q),)
CMAKE_Q = VERBOSE=1
endif
DPP_ROOT = $(realpath .)
INSTALL = install
CMAKE = cmake
CC = /usr/bin/cc
CXX = /usr/bin/c++
CFLAGS := -Wall -Wextra -Wno-sign-compare -Wno-strict-aliasing -Wno-c++20-compat \
-m64 -fPIC -fvisibility=hidden \
-ffunction-sections -fdata-sections \
-I$(DPP_ROOT)/CRT
ifneq ($(WERROR),)
CFLAGS += -Werror
endif
CXXFLAGS := -fno-exceptions -fno-rtti -fuse-cxa-atexit
EASTL_CXXFLAGS := -I$(DPP_ROOT)/EASTL/include -I$(DPP_ROOT)/EASTL/test/packages/EABase/include/Common \
-DEASTL_THREAD_SUPPORT_AVAILABLE=0 \
-DEASTL_EXCEPTIONS_ENABLED=0 \
-DEASTL_ASSERT_ENABLED=0 \
-DEA_COMPILER_NO_EXCEPTIONS=1 \
-DEA_COMPILER_MANAGED_CPP=1 \
-Wno-unknown-pragmas \
-Wno-deprecated-copy
USER_LDFLAGS := -Wl,--gc-sections
EASTL_BUILDDIR := EASTL-native-build
LIBCRT_BUILD_DIR := $(DPP_ROOT)/CRT-native-build
is_set = \
$(if $1,, \
$(error ERROR: $(if $2,$2)))
path_exists = \
$(if $(realpath $1),, \
$(error ERROR: $1 does not exist, run `make -C $(DPP_ROOT) deps` first.))
define CHECK_REQUIRED_PATHS
$(call path_exists,$(CC))
$(call path_exists,$(CXX))
$(call path_exists,$(EASTL_STATIC_LIB))
$(call path_exists,$(LIBUSERCRT_STATIC_LIB))
endef
define BUILD_C_OBJECT
$(call CHECK_REQUIRED_PATHS)
$(call is_set,$(1),First argument: Source file missing)
$(call is_set,$(2),Second argument: Output object file missing)
$(Q)$(CC) -std=c99 $(CFLAGS) -c $(1) -o $(2)
@echo 'CC $(2)'
endef
define BUILD_CPP_OBJECT
$(call CHECK_REQUIRED_PATHS)
$(call is_set,$(1),First argument: Source file missing)
$(call is_set,$(2),Second argument: Output object file missing)
$(Q)$(CXX) $(CFLAGS) $(CXXFLAGS) $(EASTL_CXXFLAGS) -c $(1) -o $(2)
@echo 'CXX $@'
endef
define LINK_C_KERNEL_TARGET
$(error BUILD_NATIVE does not support kernel targets.)
endef
define LINK_C_USER_TARGET
$(call CHECK_REQUIRED_PATHS)
$(call is_set,$(1),First argument: Object files missing)
$(call is_set,$(2),Second argument: Output object file missing)
$(Q)$(CC) \
$(CFLAGS) \
-o '$(2)' \
$(1) \
$(EASTL_STATIC_LIB) \
@echo 'LD $(2)'
endef
define LINK_CPP_KERNEL_TARGET
$(error BUILD_NATIVE does not support kernel targets.)
endef
define LINK_CPP_USER_TARGET
$(call CHECK_REQUIRED_PATHS)
$(call is_set,$(1),First argument: Object files missing)
$(call is_set,$(2),Second argument: Output object file missing)
$(Q)$(CXX) \
$(CFLAGS) \
$(CXXFLAGS) \
$(EASTL_CXXFLAGS) \
$(USER_LDFLAGS) \
-o '$(2)' \
$(1) \
$(EASTL_STATIC_LIB) \
$(LIBUSERCRT_STATIC_LIB)
@echo 'LD $(2)'
endef
define INSTALL_EXEC
$(call is_set,$(1),First argument: Executables to install missing)
$(call is_set,$(DESTDIR),DESTDIR missing)
$(INSTALL) -d '$(DESTDIR)/'
for target in $(1); do \
$(INSTALL) -s "$$target" '$(DESTDIR)'; \
done
endef
define INSTALL_EXEC_SIGN
$(error BUILD_NATIVE does not support code signing.)
endef
define HELP_MAKE_OPTIONS
@echo 'Common make options for Makefile.native.inc:'
@echo -e '\tBUILD_NATIVE = yes'
@echo -e '\tCC = $(CC)'
@echo -e '\tCXX = $(CXX)'
@echo -e '\tDPP_ROOT = $(DPP_ROOT)'
endef
|