Subversion Repositories Games.Chess Giants

Rev

Rev 96 | Rev 169 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 96 Rev 154
Line 20... Line 20...
20
### ==========================================================================
20
### ==========================================================================
21
### Section 1. General Configuration
21
### Section 1. General Configuration
22
### ==========================================================================
22
### ==========================================================================
23
 
23
 
24
### Establish the operating system name
24
### Establish the operating system name
25
UNAME = $(shell uname)
25
KERNEL = $(shell uname -s)
-
 
26
ifeq ($(KERNEL),Linux)
-
 
27
	OS = $(shell uname -o)
-
 
28
endif
26
 
29
 
27
### Executable name
30
### Executable name
28
EXE = stockfish
31
EXE = stockfish
29
 
32
 
30
### Installation dir definitions
33
### Installation dir definitions
31
PREFIX = /usr/local
34
PREFIX = /usr/local
32
BINDIR = $(PREFIX)/bin
35
BINDIR = $(PREFIX)/bin
33
 
36
 
34
### Built-in benchmark for pgo-builds
37
### Built-in benchmark for pgo-builds
35
PGOBENCH = ./$(EXE) bench 16 1 1000 default time
38
PGOBENCH = ./$(EXE) bench
36
 
39
 
37
### Object files
40
### Object files
38
OBJS = benchmark.o bitbase.o bitboard.o endgame.o evaluate.o main.o \
41
OBJS = benchmark.o bitbase.o bitboard.o endgame.o evaluate.o main.o \
39
	material.o misc.o movegen.o movepick.o pawns.o position.o psqt.o \
42
	material.o misc.o movegen.o movepick.o pawns.o position.o psqt.o \
40
	search.o thread.o timeman.o tt.o uci.o ucioption.o syzygy/tbprobe.o
43
	search.o thread.o timeman.o tt.o uci.o ucioption.o syzygy/tbprobe.o
Line 45... Line 48...
45
#
48
#
46
# flag                --- Comp switch --- Description
49
# flag                --- Comp switch --- Description
47
# ----------------------------------------------------------------------------
50
# ----------------------------------------------------------------------------
48
#
51
#
49
# debug = yes/no      --- -DNDEBUG         --- Enable/Disable debug mode
52
# debug = yes/no      --- -DNDEBUG         --- Enable/Disable debug mode
-
 
53
# sanitize = yes/no   --- (-fsanitize )    --- enable undefined behavior checks
50
# optimize = yes/no   --- (-O3/-fast etc.) --- Enable/Disable optimizations
54
# optimize = yes/no   --- (-O3/-fast etc.) --- Enable/Disable optimizations
51
# arch = (name)       --- (-arch)          --- Target architecture
55
# arch = (name)       --- (-arch)          --- Target architecture
52
# bits = 64/32        --- -DIS_64BIT       --- 64-/32-bit operating system
56
# bits = 64/32        --- -DIS_64BIT       --- 64-/32-bit operating system
53
# prefetch = yes/no   --- -DUSE_PREFETCH   --- Use prefetch x86 asm-instruction
57
# prefetch = yes/no   --- -DUSE_PREFETCH   --- Use prefetch asm-instruction
54
# bsfq = yes/no       --- -DUSE_BSFQ       --- Use bsfq x86_64 asm-instruction (only
-
 
55
#                                              with GCC and ICC 64-bit)
-
 
56
# popcnt = yes/no     --- -DUSE_POPCNT     --- Use popcnt x86_64 asm-instruction
58
# popcnt = yes/no     --- -DUSE_POPCNT     --- Use popcnt asm-instruction
57
# sse = yes/no        --- -msse            --- Use Intel Streaming SIMD Extensions
59
# sse = yes/no        --- -msse            --- Use Intel Streaming SIMD Extensions
58
# pext = yes/no       --- -DUSE_PEXT       --- Use pext x86_64 asm-instruction
60
# pext = yes/no       --- -DUSE_PEXT       --- Use pext x86_64 asm-instruction
59
#
61
#
60
# Note that Makefile is space sensitive, so when adding new architectures
62
# Note that Makefile is space sensitive, so when adding new architectures
61
# or modifying existing flags, you have to make sure there are no extra spaces
63
# or modifying existing flags, you have to make sure there are no extra spaces
62
# at the end of the line for flag values.
64
# at the end of the line for flag values.
63
 
65
 
64
### 2.1. General and architecture defaults
66
### 2.1. General and architecture defaults
65
optimize = yes
67
optimize = yes
66
debug = no
68
debug = no
-
 
69
sanitize = no
67
bits = 32
70
bits = 32
68
prefetch = no
71
prefetch = no
69
bsfq = no
-
 
70
popcnt = no
72
popcnt = no
71
sse = no
73
sse = no
72
pext = no
74
pext = no
73
 
75
 
74
### 2.2 Architecture specific
76
### 2.2 Architecture specific
Line 94... Line 96...
94
 
96
 
95
ifeq ($(ARCH),x86-64)
97
ifeq ($(ARCH),x86-64)
96
	arch = x86_64
98
	arch = x86_64
97
	bits = 64
99
	bits = 64
98
	prefetch = yes
100
	prefetch = yes
99
	bsfq = yes
-
 
100
	sse = yes
101
	sse = yes
101
endif
102
endif
102
 
103
 
103
ifeq ($(ARCH),x86-64-modern)
104
ifeq ($(ARCH),x86-64-modern)
104
	arch = x86_64
105
	arch = x86_64
105
	bits = 64
106
	bits = 64
106
	prefetch = yes
107
	prefetch = yes
107
	bsfq = yes
-
 
108
	popcnt = yes
108
	popcnt = yes
109
	sse = yes
109
	sse = yes
110
endif
110
endif
111
 
111
 
112
ifeq ($(ARCH),x86-64-bmi2)
112
ifeq ($(ARCH),x86-64-bmi2)
113
	arch = x86_64
113
	arch = x86_64
114
	bits = 64
114
	bits = 64
115
	prefetch = yes
115
	prefetch = yes
116
	bsfq = yes
-
 
117
	popcnt = yes
116
	popcnt = yes
118
	sse = yes
117
	sse = yes
119
	pext = yes
118
	pext = yes
120
endif
119
endif
121
 
120
 
122
ifeq ($(ARCH),armv7)
121
ifeq ($(ARCH),armv7)
123
	arch = armv7
122
	arch = armv7
124
	prefetch = yes
123
	prefetch = yes
125
	bsfq = yes
-
 
126
endif
124
endif
127
 
125
 
128
ifeq ($(ARCH),ppc-32)
126
ifeq ($(ARCH),ppc-32)
129
	arch = ppc
127
	arch = ppc
130
endif
128
endif
Line 151... Line 149...
151
 
149
 
152
ifeq ($(COMP),gcc)
150
ifeq ($(COMP),gcc)
153
	comp=gcc
151
	comp=gcc
154
	CXX=g++
152
	CXX=g++
155
	CXXFLAGS += -pedantic -Wextra -Wshadow
153
	CXXFLAGS += -pedantic -Wextra -Wshadow
-
 
154
 
-
 
155
	ifeq ($(ARCH),armv7)
-
 
156
		ifeq ($(OS),Android)
-
 
157
			CXXFLAGS += -m$(bits)
-
 
158
		endif
-
 
159
	else
-
 
160
		CXXFLAGS += -m$(bits)
-
 
161
	endif
-
 
162
 
156
	ifneq ($(UNAME),Darwin)
163
	ifneq ($(KERNEL),Darwin)
157
	   LDFLAGS += -Wl,--no-as-needed
164
	   LDFLAGS += -Wl,--no-as-needed
158
	endif
165
	endif
159
endif
166
endif
160
 
167
 
161
ifeq ($(COMP),mingw)
168
ifeq ($(COMP),mingw)
162
	comp=mingw
169
	comp=mingw
163
 
170
 
164
	ifeq ($(UNAME),Linux)
171
	ifeq ($(KERNEL),Linux)
165
		ifeq ($(bits),64)
172
		ifeq ($(bits),64)
166
			ifeq ($(shell which x86_64-w64-mingw32-c++-posix),)
173
			ifeq ($(shell which x86_64-w64-mingw32-c++-posix),)
167
				CXX=x86_64-w64-mingw32-c++
174
				CXX=x86_64-w64-mingw32-c++
168
			else
175
			else
169
				CXX=x86_64-w64-mingw32-c++-posix
176
				CXX=x86_64-w64-mingw32-c++-posix
Line 191... Line 198...
191
 
198
 
192
ifeq ($(COMP),clang)
199
ifeq ($(COMP),clang)
193
	comp=clang
200
	comp=clang
194
	CXX=clang++
201
	CXX=clang++
195
	CXXFLAGS += -pedantic -Wextra -Wshadow
202
	CXXFLAGS += -pedantic -Wextra -Wshadow
-
 
203
 
-
 
204
	ifeq ($(ARCH),armv7)
-
 
205
		ifeq ($(OS),Android)
-
 
206
			CXXFLAGS += -m$(bits)
-
 
207
			LDFLAGS += -m$(bits)
-
 
208
		endif
-
 
209
	else
-
 
210
		CXXFLAGS += -m$(bits)
-
 
211
		LDFLAGS += -m$(bits)
-
 
212
	endif
-
 
213
 
196
	ifeq ($(UNAME),Darwin)
214
	ifeq ($(KERNEL),Darwin)
197
		CXXFLAGS += -stdlib=libc++
215
		CXXFLAGS += -stdlib=libc++
198
		DEPENDFLAGS += -stdlib=libc++
216
		DEPENDFLAGS += -stdlib=libc++
199
	endif
217
	endif
200
endif
218
endif
201
 
219
 
Line 209... Line 227...
209
	profile_make = gcc-profile-make
227
	profile_make = gcc-profile-make
210
	profile_use = gcc-profile-use
228
	profile_use = gcc-profile-use
211
	profile_clean = gcc-profile-clean
229
	profile_clean = gcc-profile-clean
212
endif
230
endif
213
 
231
 
214
ifeq ($(UNAME),Darwin)
232
ifeq ($(KERNEL),Darwin)
215
	CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.9
233
	CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.9
216
	LDFLAGS += -arch $(arch) -mmacosx-version-min=10.9
234
	LDFLAGS += -arch $(arch) -mmacosx-version-min=10.9
217
endif
235
endif
218
 
236
 
219
### Travis CI script uses COMPILER to overwrite CXX
237
### Travis CI script uses COMPILER to overwrite CXX
Line 227... Line 245...
227
endif
245
endif
228
 
246
 
229
### On mingw use Windows threads, otherwise POSIX
247
### On mingw use Windows threads, otherwise POSIX
230
ifneq ($(comp),mingw)
248
ifneq ($(comp),mingw)
231
	# On Android Bionic's C library comes with its own pthread implementation bundled in
249
	# On Android Bionic's C library comes with its own pthread implementation bundled in
232
	ifneq ($(arch),armv7)
250
	ifneq ($(OS),Android)
233
		# Haiku has pthreads in its libroot, so only link it in on other platforms
251
		# Haiku has pthreads in its libroot, so only link it in on other platforms
234
		ifneq ($(UNAME),Haiku)
252
		ifneq ($(KERNEL),Haiku)
235
			LDFLAGS += -lpthread
253
			LDFLAGS += -lpthread
236
		endif
254
		endif
237
	endif
255
	endif
238
endif
256
endif
239
 
257
 
240
### 3.4 Debugging
258
### 3.2.1 Debugging
241
ifeq ($(debug),no)
259
ifeq ($(debug),no)
242
	CXXFLAGS += -DNDEBUG
260
	CXXFLAGS += -DNDEBUG
243
else
261
else
244
	CXXFLAGS += -g
262
	CXXFLAGS += -g
245
endif
263
endif
246
 
264
 
-
 
265
### 3.2.2 Debugging with undefined behavior sanitizers
-
 
266
ifeq ($(sanitize),yes)
-
 
267
	CXXFLAGS += -g3 -fsanitize=undefined
-
 
268
endif
-
 
269
 
247
### 3.5 Optimization
270
### 3.3 Optimization
248
ifeq ($(optimize),yes)
271
ifeq ($(optimize),yes)
-
 
272
 
-
 
273
	CXXFLAGS += -O3
249
 
274
 
250
	ifeq ($(comp),gcc)
275
	ifeq ($(comp),gcc)
251
		CXXFLAGS += -O3
-
 
252
 
276
 
253
		ifeq ($(UNAME),Darwin)
277
		ifeq ($(KERNEL),Darwin)
254
			ifeq ($(arch),i386)
278
			ifeq ($(arch),i386)
255
				CXXFLAGS += -mdynamic-no-pic
279
				CXXFLAGS += -mdynamic-no-pic
256
			endif
280
			endif
257
			ifeq ($(arch),x86_64)
281
			ifeq ($(arch),x86_64)
258
				CXXFLAGS += -mdynamic-no-pic
282
				CXXFLAGS += -mdynamic-no-pic
259
			endif
283
			endif
260
		endif
284
		endif
261
 
285
 
262
		ifeq ($(arch),armv7)
286
		ifeq ($(OS), Android)
263
			CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp
287
			CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp
264
		endif
288
		endif
265
	endif
-
 
266
 
-
 
267
	ifeq ($(comp),mingw)
-
 
268
		CXXFLAGS += -O3
-
 
269
	endif
289
	endif
270
 
290
 
271
	ifeq ($(comp),icc)
291
	ifeq ($(comp),icc)
272
		ifeq ($(UNAME),Darwin)
292
		ifeq ($(KERNEL),Darwin)
273
			CXXFLAGS += -fast -mdynamic-no-pic
293
			CXXFLAGS += -mdynamic-no-pic
274
		else
-
 
275
			CXXFLAGS += -fast
-
 
276
		endif
294
		endif
277
	endif
295
	endif
278
 
296
 
279
	ifeq ($(comp),clang)
297
	ifeq ($(comp),clang)
280
		CXXFLAGS += -O3
-
 
281
 
-
 
282
		ifeq ($(UNAME),Darwin)
298
		ifeq ($(KERNEL),Darwin)
283
			ifeq ($(pext),no)
299
			ifeq ($(pext),no)
284
				CXXFLAGS += -flto
300
				CXXFLAGS += -flto
285
				LDFLAGS += $(CXXFLAGS)
301
				LDFLAGS += $(CXXFLAGS)
286
			endif
302
			endif
287
			ifeq ($(arch),i386)
303
			ifeq ($(arch),i386)
Line 292... Line 308...
292
			endif
308
			endif
293
		endif
309
		endif
294
	endif
310
	endif
295
endif
311
endif
296
 
312
 
297
### 3.6. Bits
313
### 3.4 Bits
298
ifeq ($(bits),64)
314
ifeq ($(bits),64)
299
	CXXFLAGS += -DIS_64BIT
315
	CXXFLAGS += -DIS_64BIT
300
endif
316
endif
301
 
317
 
302
### 3.7 prefetch
318
### 3.5 prefetch
303
ifeq ($(prefetch),yes)
319
ifeq ($(prefetch),yes)
304
	ifeq ($(sse),yes)
320
	ifeq ($(sse),yes)
305
		CXXFLAGS += -msse
321
		CXXFLAGS += -msse
306
		DEPENDFLAGS += -msse
322
		DEPENDFLAGS += -msse
307
	endif
323
	endif
308
else
324
else
309
	CXXFLAGS += -DNO_PREFETCH
325
	CXXFLAGS += -DNO_PREFETCH
310
endif
326
endif
311
 
327
 
312
### 3.8 bsfq
-
 
313
ifeq ($(bsfq),yes)
-
 
314
	CXXFLAGS += -DUSE_BSFQ
-
 
315
endif
-
 
316
 
-
 
317
### 3.9 popcnt
328
### 3.6 popcnt
318
ifeq ($(popcnt),yes)
329
ifeq ($(popcnt),yes)
319
	ifeq ($(comp),icc)
330
	ifeq ($(comp),icc)
320
		CXXFLAGS += -msse3 -DUSE_POPCNT
331
		CXXFLAGS += -msse3 -DUSE_POPCNT
321
	else
332
	else
322
		CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT
333
		CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT
323
	endif
334
	endif
324
endif
335
endif
325
 
336
 
326
### 3.10 pext
337
### 3.7 pext
327
ifeq ($(pext),yes)
338
ifeq ($(pext),yes)
328
	CXXFLAGS += -DUSE_PEXT
339
	CXXFLAGS += -DUSE_PEXT
329
	ifeq ($(comp),$(filter $(comp),gcc clang mingw))
340
	ifeq ($(comp),$(filter $(comp),gcc clang mingw))
330
		CXXFLAGS += -mbmi -mbmi2
341
		CXXFLAGS += -mbmi2
331
	endif
342
	endif
332
endif
343
endif
333
 
344
 
334
### 3.11 Link Time Optimization, it works since gcc 4.5 but not on mingw under Windows.
345
### 3.8 Link Time Optimization, it works since gcc 4.5 but not on mingw under Windows.
335
### This is a mix of compile and link time options because the lto link phase
346
### This is a mix of compile and link time options because the lto link phase
336
### needs access to the optimization flags.
347
### needs access to the optimization flags.
337
ifeq ($(comp),gcc)
348
ifeq ($(comp),gcc)
338
	ifeq ($(optimize),yes)
349
	ifeq ($(optimize),yes)
339
	ifeq ($(debug),no)
350
	ifeq ($(debug),no)
Line 342... Line 353...
342
	endif
353
	endif
343
	endif
354
	endif
344
endif
355
endif
345
 
356
 
346
ifeq ($(comp),mingw)
357
ifeq ($(comp),mingw)
347
	ifeq ($(UNAME),Linux)
358
	ifeq ($(KERNEL),Linux)
348
	ifeq ($(optimize),yes)
359
	ifeq ($(optimize),yes)
349
	ifeq ($(debug),no)
360
	ifeq ($(debug),no)
350
		CXXFLAGS += -flto
361
		CXXFLAGS += -flto
351
		LDFLAGS += $(CXXFLAGS)
362
		LDFLAGS += $(CXXFLAGS)
352
	endif
363
	endif
353
	endif
364
	endif
354
	endif
365
	endif
355
endif
366
endif
356
 
367
 
357
### 3.12 Android 5 can only run position independent executables. Note that this
368
### 3.9 Android 5 can only run position independent executables. Note that this
358
### breaks Android 4.0 and earlier.
369
### breaks Android 4.0 and earlier.
359
ifeq ($(arch),armv7)
370
ifeq ($(OS), Android)
360
	CXXFLAGS += -fPIE
371
	CXXFLAGS += -fPIE
361
	LDFLAGS += -fPIE -pie
372
	LDFLAGS += -fPIE -pie
362
endif
373
endif
363
 
374
 
364
 
375
 
Line 462... Line 473...
462
	@echo "Config:"
473
	@echo "Config:"
463
	@echo "debug: '$(debug)'"
474
	@echo "debug: '$(debug)'"
464
	@echo "optimize: '$(optimize)'"
475
	@echo "optimize: '$(optimize)'"
465
	@echo "arch: '$(arch)'"
476
	@echo "arch: '$(arch)'"
466
	@echo "bits: '$(bits)'"
477
	@echo "bits: '$(bits)'"
-
 
478
	@echo "kernel: '$(KERNEL)'"
-
 
479
	@echo "os: '$(OS)'"
467
	@echo "prefetch: '$(prefetch)'"
480
	@echo "prefetch: '$(prefetch)'"
468
	@echo "bsfq: '$(bsfq)'"
-
 
469
	@echo "popcnt: '$(popcnt)'"
481
	@echo "popcnt: '$(popcnt)'"
470
	@echo "sse: '$(sse)'"
482
	@echo "sse: '$(sse)'"
471
	@echo "pext: '$(pext)'"
483
	@echo "pext: '$(pext)'"
472
	@echo ""
484
	@echo ""
473
	@echo "Flags:"
485
	@echo "Flags:"
Line 481... Line 493...
481
	@test "$(optimize)" = "yes" || test "$(optimize)" = "no"
493
	@test "$(optimize)" = "yes" || test "$(optimize)" = "no"
482
	@test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \
494
	@test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \
483
	 test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || test "$(arch)" = "armv7"
495
	 test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || test "$(arch)" = "armv7"
484
	@test "$(bits)" = "32" || test "$(bits)" = "64"
496
	@test "$(bits)" = "32" || test "$(bits)" = "64"
485
	@test "$(prefetch)" = "yes" || test "$(prefetch)" = "no"
497
	@test "$(prefetch)" = "yes" || test "$(prefetch)" = "no"
486
	@test "$(bsfq)" = "yes" || test "$(bsfq)" = "no"
-
 
487
	@test "$(popcnt)" = "yes" || test "$(popcnt)" = "no"
498
	@test "$(popcnt)" = "yes" || test "$(popcnt)" = "no"
488
	@test "$(sse)" = "yes" || test "$(sse)" = "no"
499
	@test "$(sse)" = "yes" || test "$(sse)" = "no"
489
	@test "$(pext)" = "yes" || test "$(pext)" = "no"
500
	@test "$(pext)" = "yes" || test "$(pext)" = "no"
490
	@test "$(comp)" = "gcc" || test "$(comp)" = "icc" || test "$(comp)" = "mingw" || test "$(comp)" = "clang"
501
	@test "$(comp)" = "gcc" || test "$(comp)" = "icc" || test "$(comp)" = "mingw" || test "$(comp)" = "clang"
491
 
502