forked from SevenChords/CipesAtHome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.mk
326 lines (299 loc) · 9 KB
/
configuration.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# Configuration logic for the Makefile, because it was getting _WAY_ too big for the Makefile proper.
# See the documentation of parameters in Makefile for what this is operating on.
# Now get the standard library versions of C and C++
#DEFAULT_C_VERSION=$(shell $(CC) $(CFLAGS) -x c -E -dM -< /dev/null | grep __STDC_VERSION__ | grep -E --only-matching '[[:digit:]]+')
#ifneq ($(.SHELLSTATUS),0)
# DEFAULT_C_VERSION=0
#endif
#DEFAULT_CXX_VERSION=$(shell $(CXX) $(CXXFLAGS) -x c++ -E -dM -< /dev/null | grep __cplusplus | grep -P --only-matching '[[:digit:]]+(?=L)')
#ifneq ($(.SHELLSTATUS),0)
# DEFAULT_CXX_VERSION=0
#endif
#
#
#ifeq ($(shell test $(DEFAULT_C_VERSION) -ge 201112 && echo true),true)
#DEFAULT_C_VERSION_AT_LEAST_C11=1
#endif
#
#ifeq ($(shell test $(DEFAULT_CXX_VERSION) -ge 201112 && echo true),true)
#DEFAULT_C_VERSION_AT_LEAST_C17=1
#endif
DEBUG_EXPLICIT=0
ifneq (,$(filter $(RECOGNIZED_TRUE), $(USE_LTO)))
USE_LTO=1
endif
ifneq (,$(filter $(RECOGNIZED_TRUE), $(EXPERIMENTAL_OPTIMIZATIONS)))
EXPERIMENTAL_OPTIMIZATIONS=1
endif
ifneq (,$(filter $(RECOGNIZED_TRUE), $(FAST_CFLAGS_BUT_NO_VERIFICATION)))
FAST_CFLAGS_BUT_NO_VERIFICATION=1
endif
ifneq (,$(filter $(RECOGNIZED_TRUE), $(PROFILE_GENERATE)))
PROFILE_GENERATE=1
endif
ifneq (,$(filter $(RECOGNIZED_TRUE), $(PROFILE_USE)))
PROFILE_USE=1
endif
ifneq (,$(filter $(RECOGNIZED_TRUE), $(PERFORMANCE_PROFILING)))
PERFORMANCE_PROFILING=1
endif
ifneq (,$(filter $(RECOGNIZED_TRUE), $(DEBUG)))
DEBUG=1
DEBUG_EXPLICIT=1
endif
ifneq (,$(filter $(RECOGNIZED_TRUE), $(DEBUG_EXTRA)))
DEBUG_EXTRA=1
DEBUG=1
DEBUG_EXPLICIT=1
endif
ifneq (,$(filter $(RECOGNIZED_TRUE), $(DEBUG_VERIFY_PROFILING)))
DEBUG_VERIFY_PROFILING=1
endif
ifneq (,$(filter $(RECOGNIZED_TRUE), $(USE_GOOGLE_PERFTOOLS)))
USE_GOOGLE_PERFTOOLS=1
else
USE_GOOGLE_PERFTOOLS=0
endif
ifneq (,$(filter $(RECOGNIZED_TRUE), $(USE_DEPENDENCY_FILES)))
USE_DEPENDENCY_FILES=1
endif
ifneq (,$(filter $(RECOGNIZED_TRUE), $(FOR_DISTRIBUTION)))
FOR_DISTRIBUTION=1
endif
# See https://www.phoronix.com/scan.php?page=news_item&px=GCC-11-x86-64-Feature-Levels
# The base x86_64 arch supports CMOV, CMPXCHG8B, FPU, FXSR, MMX, FXSR, SCE, SSE, SSE2
ifneq (,$(filter $(RECOGNIZED_TRUE), $(ASSUME_X86_64_V2)))
# Assume support for CMPXCHG16B, LAHF-SAHF, POPCNT, SSE3, SSE4.1, SSE4.2, SSSE3 (close to Nehalem)
ASSUME_X86_64_V2=1
endif
ifneq (,$(filter $(RECOGNIZED_TRUE), $(ASSUME_X86_64_V3)))
# Assume support for AVX, AVX2, BMI1, BMI2, F16C, FMA, LZCNT, MOVBE, XSAVE (close to Haswell)
ASSUME_X86_64_V3=1
endif
ifneq (,$(filter $(RECOGNIZED_TRUE), $(RNG_ALWAYS_USE_32_BIT_CHOICE)))
RNG_ALWAYS_USE_32_BIT_CHOICE=1
else
RNG_ALWAYS_USE_32_BIT_CHOICE=0
endif
ifeq ($(PROFILE_GENERATE) $(PROFILE_USE), 1 1)
$(error Cannot set both PROFILE_GENERATE and PROFILE_USE to true)
endif
UNAME:=$(shell uname)
CC_WAS_UNSET=0
ifneq ($(IS_CC_EXACTLY_CC) $(IS_CC_EMPTY), 0 0)
CC_WAS_UNSET=1
ifeq ($(UNAME), Linux)
CC=gcc
endif
ifeq ($(UNAME), Darwin)
MACPREFIX:=$(shell brew --prefix)
CC:=$(MACPREFIX)/opt/llvm/bin/clang
CFLAGS_BASE+=-I$(MACPREFIX)/include -L$(MACPREFIX)/lib
endif
endif
ifneq ($(IS_CXX_EXACTLY_CXX) $(IS_CXX_EMPTY), 0 0)
CXX_WAS_UNSET=1
ifeq ($(CC_WAS_UNSET), 0)
ifeq ($(UNAME), Linux)
CXX=g++
endif
ifeq ($(UNAME), Darwin)
MACPREFIX:=$(shell brew --prefix)
CXX:=$(MACPREFIX)/opt/llvm/bin/clang++
endif
endif
endif
ifeq ($(CC_WAS_UNSET) $(CXX_WAS_UNSET),0 1)
# CC set but not CXX. Assume CXX is CC, because usually a C compiler can tell if a file is C++ and switch to C++ compiling mode.
CXX=$(CC)
endif
_64_BIT_MINGW=x86_64-w64-mingw
_32_BIT_MINGW=i686-w64-mingw
_HAS_M64_CFLAG=$(findstring -m64,$(CFLAGS))
_HAS_M32_CFLAG=$(findstring -m32,$(CFLAGS))
IS_WINDOWS=0
IS_WINDOWS_32=0
IS_WINDOWS_64=0
ifneq (,$(and $(findstring $(_32_BIT_MINGW),$(CC)),$(_HAS_M64_CFLAG)))
$(error Can't use "-m64" on a 32-bit MinGW compiler. Use the right compiler for bitness (should start with $(_64_BIT_MINGW)))
else ifneq (,$(and $(findstring $(_64_BIT_MINGW),$(CC)),$(_HAS_M32_CFLAG)))
$(error Can't use "-m32" on a 64-bit MinGW compiler. Use the right compiler for bitness (should start with $(_32_BIT_MINGW)))
endif
ifneq (,$(findstring $(_64_BIT_MINGW),$(CC)))
COMPILER=gcc
IS_WINDOWS=1
IS_WINDOWS_64=1
else ifneq (,$(findstring $(_32_BIT_MINGW),$(CC)))
COMPILER=gcc
IS_WINDOWS=1
IS_WINDOWS_32=1
else ifneq (,$(findstring gcc, $(CC)))
COMPILER=gcc
else ifneq (,$(findstring g++, $(CC)))
COMPILER=gcc
else ifneq (,$(findstring clang,$(CC)))
COMPILER=clang
else ifneq (,$(filter icc icl icpc icx, $(CC)))
COMPILER=icc
else
COMPILER=unknown
endif
ifeq (clang,$(COMPILER))
WARNINGS_AND_ERRORS:=$(CLANG_ONLY_WARNINGS) $(WARNINGS_AND_ERRORS)
endif
ifeq (1,$(FOR_DISTRIBUTION))
ifeq (1,$(IS_WINDOWS))
# FINAL_STATIC_LINKS+=
# FINAL_TARGET_CFLAGS+=
EXTERNAL_LIBS+=-Iinclude_manually_provided -Llib_manually_provided/win
endif
ifeq (1,$(IS_WINDOWS_64))
ifeq (1,$(ASSUME_X86_64_V2)
ifeq (,$(DISTRIBUTION_DIR))
DISTRIBUTION_DIR=win64-sse4
endif
ifeq (true, $(shell if [ -d lib_manually_provided/win64-sse4 -a -f lib_manually_provided/win64-sse4/libcurl.dll ]; then echo "true"; fi))
EXTERNAL_LIBS+=-Llib_manually_provided/win64-sse4
endif
else ifeq (1,$(ASSUME_X86_64_V3))
ifeq (,$(DISTRIBUTION_DIR))
DISTRIBUTION_DIR=win64-avx2
endif
ifeq (true,$(shell if [ -d lib_manually_provided/win64-avx2 -a -f lib_manually_provided/win64-avx2/libcurl.dll ]; then echo "true"; fi))
EXTERNAL_LIBS+=-Llib_manually_provided/win64-avx2
endif
else
ifeq (,$(DISTRIBUTION_DIR))
DISTRIBUTION_DIR=win64
endif
EXTERNAL_LIBS+=-Llib_manually_provided/win64
endif
endif
ifeq (1,$(IS_WINDOWS_32))
ifeq (,$(DISTRIBUTION_DIR))
DISTRIBUTION_DIR=win32
endif
EXTERNAL_LIBS+=-Llib_manually_provided/win32
# Format strings for size_t don't line up, and not really an easy way to fix it.
# Demote mismatching args to a warning
WARNINGS_AND_ERRORS+=--warn-format
endif
endif
ifeq (1,$(IS_WINDOWS_32))
# Format strings for size_t don't line up, and not really an easy way to fix it.
# Demote mismatching args to a warning
WARNINGS_AND_ERRORS:=$(filter-out -Werror=format,$(WARNINGS_AND_ERRORS))
endif
CFLAGS_BASE:=$(CFLAGS_BASE)
ifeq (1,$(ASSUME_X86_64_V2))
CFLAGS_OPT:=$(SSE4_BUILD_CFLAGS) $(CFLAGS_OPT)
else ifeq (1,$(ASSUME_X86_64_V3))
CFLAGS_OPT:=$(AVX2_BUILD_CFLAGS) $(CFLAGS_OPT)
endif
ifeq (1,$(FOR_DISTRIBUTION))
ifeq (,$(DISTRIBUTION_DIR))
DISTRIBUTION_DIR=$(shell $(CC) $(CFLAGS) -dumpmachine)
endif
endif
ifeq (gcc,$(COMPILER))
HIGH_OPT_CFLAGS+=$(GCC_ONLY_HIGH_OPT_CFLAGS)
endif
ifeq (1,$(FAST_CFLAGS_BUT_NO_VERIFICATION))
CFLAGS_OPT+=$(FAST_CFLAGS_BUT_NO_VERIFY)
ifeq (gcc,$(COMPILER))
CFLAGS_OPT+=$(GCC_ONLY_FAST_CFLAGS_BUT_NO_VERIFY)
else ifeq (clang,$(COMPILER))
CFLAGS_OPT+=$(CLANG_ONLY_FAST_CFLAGS_BUT_NO_VERIFY)
endif
endif
ifeq (1,$(EXPERIMENTAL_OPTIMIZATIONS))
CFLAGS_OPT+=$(EXPERIMENTAL_OPT_CFLAGS)
endif
ifeq (1,$(USE_GOOGLE_PERFTOOLS))
ifeq (1,$(PERFORMANCE_PROFILING))
DEBUG?=1
EXTERNAL_LIBS+=-ltcmalloc_and_profiler
else ifeq (1,$(DEBUG))
EXTERNAL_LIBS+=-ltcmalloc
else
EXTERNAL_LIBS+=-ltcmalloc_minimal
endif
else
ifeq (1,$(PERFORMANCE_PROFILING))
DEBUG?=1
CFLAGS_OPT+=-pg
endif
endif
ifeq ($(COMPILER), $(filter gcc clang icc, $(COMPILER)))
_RECOGNIZES_STANDARD_DEPFLAGS?=1
endif
ifeq (,$(USE_DEPENDENCY_FILES))
ifneq (,$(_RECOGNIZES_STANDARD_DEPFLAGS))
USE_DEPENDENCY_FILES=1
endif
endif
ifeq (1,$(USE_DEPENDENCY_FILES))
ifneq (,$(_RECOGNIZES_STANDARD_DEPFLAGS))
DEP_FLAGS?=$(GCC_SYNTAX_DEP_FLAGS)
endif
ifeq (,$(DEP_FLAGS))
$(warning DEP_FLAGS is empty, but USE_DEPENDENCY_FILES=1; this will probably fail)
endif
DEPS:=$(DEPDIR)/%.dep
ifeq (,$(DEPDIR))
MAKE_DEPDIR_COMMAND:=
else ifeq (.,$(DEPDIR))
MAKE_DEPDIR_COMMAND:=
else ifeq (./,$(DEPDIR))
MAKE_DEPDIR_COMMAND:=
else ifeq (.\,$(DEPDIR))
MAKE_DEPDIR_COMMAND:=
else
MAKE_DEPDIR_COMMAND:=@mkdir -p $(DEPDIR)
endif
else
DEPS:=$(HEADERS) $(RANDOM_HEADERS)
MAKE_DEPDIR_COMMAND:=
endif
ifeq (1,$(USE_LTO))
ifeq (gcc,$(COMPILER))
DEBUG_CFLAGS+=-ffat-lto-objects
CFLAGS_OPT+=-fuse-ld=gold -flto=jobserver
else
CFLAGS_OPT+=-flto
endif
endif
ifeq (1,$(PROFILE_GENERATE))
DEBUG?=1
ifeq (clang,$(COMPILER))
CFLAGS_PROF+=-fcs-profile-generate=$(PROF_DIR)
else ifeq (gcc,$(COMPILER))
CFLAGS_PROF+=-fprofile-generate=$(PROF_DIR) -fprofile-update=prefer-atomic
else
$(warning Unrecognized compiler "$(CC)". Profile generation might not work, disable "PROFILE_GENERATE" if you get build errors about unrecognized flags)
CFLAGS_PROF+=-fprofile-generate=$(PROF_DIR)
endif
endif
ifeq (1,$(PROFILE_GENERATE))
MAKE_PROF_DIR_COMMAND=@mkdir -p $(PROF_DIR)
else
MAKE_PROF_DIR_COMMAND=
endif
ifeq (1,$(PROFILE_USE))
ifeq (clang,$(COMPILER))
CFLAGS_PROF+=-fprofile-use=$(CLANG_PROF_MERGED)
else
ifeq (gcc,$(COMPILER))
CFLAGS_PROF+=-fprofile-use=$(PROF_DIR) -fprofile-correction
else
CFLAGS_PROF+=-fprofile-use=$(PROF_DIR)
endif
endif
endif
ifeq (1 clang, $(PROFILE_USE) $(COMPILER))
PROF_FINISH_COMMAND=$(LLVM_PROFDATA) merge -output=$(CLANG_PROF_MERGED) $(PROF_DIR)
else
PROF_FINISH_COMMAND=
endif
include configuration_rng.mk
HEADERS+=$(RANDOM_HEADERS)