Rev 169 | Rev 183 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
96 | pmbaty | 1 | # Stockfish, a UCI chess playing engine derived from Glaurung 2.1 |
2 | # Copyright (C) 2004-2008 Tord Romstad (Glaurung author) |
||
3 | # Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad |
||
169 | pmbaty | 4 | # Copyright (C) 2015-2018 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad |
96 | pmbaty | 5 | # |
6 | # Stockfish is free software: you can redistribute it and/or modify |
||
7 | # it under the terms of the GNU General Public License as published by |
||
8 | # the Free Software Foundation, either version 3 of the License, or |
||
9 | # (at your option) any later version. |
||
10 | # |
||
11 | # Stockfish is distributed in the hope that it will be useful, |
||
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
14 | # GNU General Public License for more details. |
||
15 | # |
||
16 | # You should have received a copy of the GNU General Public License |
||
17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
18 | |||
19 | |||
20 | ### ========================================================================== |
||
21 | ### Section 1. General Configuration |
||
22 | ### ========================================================================== |
||
23 | |||
24 | ### Establish the operating system name |
||
182 | pmbaty | 25 | # Pierre-Marie Baty -- Windows doesn't know uname |
26 | ifeq ($(OS),Windows_NT) |
||
27 | KERNEL = Windows |
||
28 | else |
||
29 | KERNEL = $(shell uname -s) |
||
30 | ifeq ($(KERNEL),Linux) |
||
31 | OS = $(shell uname -o) |
||
32 | endif |
||
154 | pmbaty | 33 | endif |
96 | pmbaty | 34 | |
35 | ### Executable name |
||
182 | pmbaty | 36 | # Pierre-Marie Baty -- on Windows, add the .exe extension |
37 | ifeq ($(OS),Windows_NT) |
||
38 | EXE = stockfish.exe |
||
39 | else |
||
40 | EXE = stockfish |
||
41 | endif |
||
96 | pmbaty | 42 | |
43 | ### Installation dir definitions |
||
44 | PREFIX = /usr/local |
||
45 | BINDIR = $(PREFIX)/bin |
||
46 | |||
47 | ### Built-in benchmark for pgo-builds |
||
154 | pmbaty | 48 | PGOBENCH = ./$(EXE) bench |
96 | pmbaty | 49 | |
50 | ### Object files |
||
51 | OBJS = benchmark.o bitbase.o bitboard.o endgame.o evaluate.o main.o \ |
||
52 | material.o misc.o movegen.o movepick.o pawns.o position.o psqt.o \ |
||
53 | search.o thread.o timeman.o tt.o uci.o ucioption.o syzygy/tbprobe.o |
||
54 | |||
55 | ### ========================================================================== |
||
56 | ### Section 2. High-level Configuration |
||
57 | ### ========================================================================== |
||
58 | # |
||
59 | # flag --- Comp switch --- Description |
||
60 | # ---------------------------------------------------------------------------- |
||
61 | # |
||
62 | # debug = yes/no --- -DNDEBUG --- Enable/Disable debug mode |
||
169 | pmbaty | 63 | # sanitize = undefined/thread/no (-fsanitize ) |
64 | # --- ( undefined ) --- enable undefined behavior checks |
||
65 | # --- ( thread ) --- enable threading error checks |
||
96 | pmbaty | 66 | # optimize = yes/no --- (-O3/-fast etc.) --- Enable/Disable optimizations |
67 | # arch = (name) --- (-arch) --- Target architecture |
||
68 | # bits = 64/32 --- -DIS_64BIT --- 64-/32-bit operating system |
||
154 | pmbaty | 69 | # prefetch = yes/no --- -DUSE_PREFETCH --- Use prefetch asm-instruction |
70 | # popcnt = yes/no --- -DUSE_POPCNT --- Use popcnt asm-instruction |
||
96 | pmbaty | 71 | # sse = yes/no --- -msse --- Use Intel Streaming SIMD Extensions |
72 | # pext = yes/no --- -DUSE_PEXT --- Use pext x86_64 asm-instruction |
||
73 | # |
||
74 | # Note that Makefile is space sensitive, so when adding new architectures |
||
75 | # or modifying existing flags, you have to make sure there are no extra spaces |
||
76 | # at the end of the line for flag values. |
||
77 | |||
78 | ### 2.1. General and architecture defaults |
||
79 | optimize = yes |
||
80 | debug = no |
||
154 | pmbaty | 81 | sanitize = no |
96 | pmbaty | 82 | bits = 32 |
83 | prefetch = no |
||
84 | popcnt = no |
||
85 | sse = no |
||
86 | pext = no |
||
87 | |||
88 | ### 2.2 Architecture specific |
||
89 | |||
90 | ifeq ($(ARCH),general-32) |
||
91 | arch = any |
||
92 | endif |
||
93 | |||
94 | ifeq ($(ARCH),x86-32-old) |
||
95 | arch = i386 |
||
96 | endif |
||
97 | |||
98 | ifeq ($(ARCH),x86-32) |
||
99 | arch = i386 |
||
100 | prefetch = yes |
||
101 | sse = yes |
||
102 | endif |
||
103 | |||
104 | ifeq ($(ARCH),general-64) |
||
105 | arch = any |
||
106 | bits = 64 |
||
107 | endif |
||
108 | |||
109 | ifeq ($(ARCH),x86-64) |
||
110 | arch = x86_64 |
||
111 | bits = 64 |
||
112 | prefetch = yes |
||
113 | sse = yes |
||
114 | endif |
||
115 | |||
116 | ifeq ($(ARCH),x86-64-modern) |
||
117 | arch = x86_64 |
||
118 | bits = 64 |
||
119 | prefetch = yes |
||
120 | popcnt = yes |
||
121 | sse = yes |
||
122 | endif |
||
123 | |||
124 | ifeq ($(ARCH),x86-64-bmi2) |
||
125 | arch = x86_64 |
||
126 | bits = 64 |
||
127 | prefetch = yes |
||
128 | popcnt = yes |
||
129 | sse = yes |
||
130 | pext = yes |
||
131 | endif |
||
132 | |||
133 | ifeq ($(ARCH),armv7) |
||
134 | arch = armv7 |
||
135 | prefetch = yes |
||
136 | endif |
||
137 | |||
138 | ifeq ($(ARCH),ppc-32) |
||
139 | arch = ppc |
||
140 | endif |
||
141 | |||
142 | ifeq ($(ARCH),ppc-64) |
||
143 | arch = ppc64 |
||
144 | bits = 64 |
||
145 | endif |
||
146 | |||
147 | |||
148 | ### ========================================================================== |
||
149 | ### Section 3. Low-level configuration |
||
150 | ### ========================================================================== |
||
151 | |||
152 | ### 3.1 Selecting compiler (default = gcc) |
||
153 | |||
182 | pmbaty | 154 | ifeq ($(OS),Windows_NT) |
155 | # Pierre-Marie Baty -- we need two extra flags AND the C++14 standard when building with Clang against the Visual Studio 2015 SDK |
||
156 | CXXFLAGS += -Xclang -flto-visibility-public-std -Wall -Wcast-qual -fno-exceptions -std=c++14 $(EXTRACXXFLAGS) |
||
157 | DEPENDFLAGS += -std=c++14 |
||
158 | else |
||
169 | pmbaty | 159 | CXXFLAGS += -Wall -Wcast-qual -fno-exceptions -std=c++11 $(EXTRACXXFLAGS) |
96 | pmbaty | 160 | DEPENDFLAGS += -std=c++11 |
182 | pmbaty | 161 | endif |
96 | pmbaty | 162 | LDFLAGS += $(EXTRALDFLAGS) |
163 | |||
182 | pmbaty | 164 | #ifeq ($(COMP),) |
165 | # COMP=gcc |
||
166 | #endif |
||
167 | COMP=clang |
||
96 | pmbaty | 168 | |
169 | ifeq ($(COMP),gcc) |
||
170 | comp=gcc |
||
171 | CXX=g++ |
||
172 | CXXFLAGS += -pedantic -Wextra -Wshadow |
||
154 | pmbaty | 173 | |
174 | ifeq ($(ARCH),armv7) |
||
175 | ifeq ($(OS),Android) |
||
176 | CXXFLAGS += -m$(bits) |
||
169 | pmbaty | 177 | LDFLAGS += -m$(bits) |
154 | pmbaty | 178 | endif |
179 | else |
||
180 | CXXFLAGS += -m$(bits) |
||
169 | pmbaty | 181 | LDFLAGS += -m$(bits) |
154 | pmbaty | 182 | endif |
183 | |||
184 | ifneq ($(KERNEL),Darwin) |
||
96 | pmbaty | 185 | LDFLAGS += -Wl,--no-as-needed |
186 | endif |
||
187 | endif |
||
188 | |||
189 | ifeq ($(COMP),mingw) |
||
190 | comp=mingw |
||
191 | |||
154 | pmbaty | 192 | ifeq ($(KERNEL),Linux) |
96 | pmbaty | 193 | ifeq ($(bits),64) |
194 | ifeq ($(shell which x86_64-w64-mingw32-c++-posix),) |
||
195 | CXX=x86_64-w64-mingw32-c++ |
||
196 | else |
||
197 | CXX=x86_64-w64-mingw32-c++-posix |
||
198 | endif |
||
199 | else |
||
200 | ifeq ($(shell which i686-w64-mingw32-c++-posix),) |
||
201 | CXX=i686-w64-mingw32-c++ |
||
202 | else |
||
203 | CXX=i686-w64-mingw32-c++-posix |
||
204 | endif |
||
205 | endif |
||
206 | else |
||
207 | CXX=g++ |
||
208 | endif |
||
209 | |||
210 | CXXFLAGS += -Wextra -Wshadow |
||
211 | LDFLAGS += -static |
||
212 | endif |
||
213 | |||
214 | ifeq ($(COMP),icc) |
||
215 | comp=icc |
||
216 | CXX=icpc |
||
217 | CXXFLAGS += -diag-disable 1476,10120 -Wcheck -Wabi -Wdeprecated -strict-ansi |
||
218 | endif |
||
219 | |||
220 | ifeq ($(COMP),clang) |
||
221 | comp=clang |
||
222 | CXX=clang++ |
||
223 | CXXFLAGS += -pedantic -Wextra -Wshadow |
||
182 | pmbaty | 224 | # Pierre-Marie Baty -- also add the test case for Windows |
225 | ifneq ($(OS),Windows_NT) |
||
169 | pmbaty | 226 | ifneq ($(KERNEL),Darwin) |
227 | ifneq ($(KERNEL),OpenBSD) |
||
228 | LDFLAGS += -latomic |
||
229 | endif |
||
230 | endif |
||
182 | pmbaty | 231 | endif |
154 | pmbaty | 232 | |
233 | ifeq ($(ARCH),armv7) |
||
234 | ifeq ($(OS),Android) |
||
235 | CXXFLAGS += -m$(bits) |
||
236 | LDFLAGS += -m$(bits) |
||
237 | endif |
||
238 | else |
||
239 | CXXFLAGS += -m$(bits) |
||
240 | LDFLAGS += -m$(bits) |
||
241 | endif |
||
96 | pmbaty | 242 | endif |
243 | |||
244 | ifeq ($(comp),icc) |
||
245 | profile_make = icc-profile-make |
||
246 | profile_use = icc-profile-use |
||
247 | else |
||
169 | pmbaty | 248 | ifeq ($(comp),clang) |
249 | profile_make = clang-profile-make |
||
250 | profile_use = clang-profile-use |
||
251 | else |
||
96 | pmbaty | 252 | profile_make = gcc-profile-make |
253 | profile_use = gcc-profile-use |
||
254 | endif |
||
169 | pmbaty | 255 | endif |
96 | pmbaty | 256 | |
154 | pmbaty | 257 | ifeq ($(KERNEL),Darwin) |
96 | pmbaty | 258 | CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.9 |
259 | LDFLAGS += -arch $(arch) -mmacosx-version-min=10.9 |
||
260 | endif |
||
261 | |||
262 | ### Travis CI script uses COMPILER to overwrite CXX |
||
263 | ifdef COMPILER |
||
264 | COMPCXX=$(COMPILER) |
||
265 | endif |
||
266 | |||
267 | ### Allow overwriting CXX from command line |
||
268 | ifdef COMPCXX |
||
269 | CXX=$(COMPCXX) |
||
270 | endif |
||
271 | |||
182 | pmbaty | 272 | # Pierre-Marie Baty -- also add the test case for Windows |
273 | ifneq ($(OS),Windows_NT) |
||
274 | ### On mingw use Windows threads, otherwise POSIX |
||
275 | ifneq ($(comp),mingw) |
||
276 | # On Android Bionic's C library comes with its own pthread implementation bundled in |
||
277 | ifneq ($(OS),Android) |
||
278 | # Haiku has pthreads in its libroot, so only link it in on other platforms |
||
279 | ifneq ($(KERNEL),Haiku) |
||
280 | LDFLAGS += -lpthread |
||
281 | endif |
||
96 | pmbaty | 282 | endif |
283 | endif |
||
284 | endif |
||
285 | |||
154 | pmbaty | 286 | ### 3.2.1 Debugging |
96 | pmbaty | 287 | ifeq ($(debug),no) |
288 | CXXFLAGS += -DNDEBUG |
||
289 | else |
||
290 | CXXFLAGS += -g |
||
291 | endif |
||
292 | |||
154 | pmbaty | 293 | ### 3.2.2 Debugging with undefined behavior sanitizers |
169 | pmbaty | 294 | ifneq ($(sanitize),no) |
295 | CXXFLAGS += -g3 -fsanitize=$(sanitize) -fuse-ld=gold |
||
296 | LDFLAGS += -fsanitize=$(sanitize) -fuse-ld=gold |
||
154 | pmbaty | 297 | endif |
298 | |||
299 | ### 3.3 Optimization |
||
96 | pmbaty | 300 | ifeq ($(optimize),yes) |
301 | |||
154 | pmbaty | 302 | CXXFLAGS += -O3 |
303 | |||
96 | pmbaty | 304 | ifeq ($(comp),gcc) |
305 | |||
154 | pmbaty | 306 | ifeq ($(KERNEL),Darwin) |
96 | pmbaty | 307 | ifeq ($(arch),i386) |
308 | CXXFLAGS += -mdynamic-no-pic |
||
309 | endif |
||
310 | ifeq ($(arch),x86_64) |
||
311 | CXXFLAGS += -mdynamic-no-pic |
||
312 | endif |
||
313 | endif |
||
314 | |||
154 | pmbaty | 315 | ifeq ($(OS), Android) |
96 | pmbaty | 316 | CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp |
317 | endif |
||
318 | endif |
||
319 | |||
320 | ifeq ($(comp),icc) |
||
154 | pmbaty | 321 | ifeq ($(KERNEL),Darwin) |
322 | CXXFLAGS += -mdynamic-no-pic |
||
96 | pmbaty | 323 | endif |
324 | endif |
||
325 | |||
326 | ifeq ($(comp),clang) |
||
154 | pmbaty | 327 | ifeq ($(KERNEL),Darwin) |
96 | pmbaty | 328 | CXXFLAGS += -flto |
329 | LDFLAGS += $(CXXFLAGS) |
||
330 | ifeq ($(arch),i386) |
||
331 | CXXFLAGS += -mdynamic-no-pic |
||
332 | endif |
||
333 | ifeq ($(arch),x86_64) |
||
334 | CXXFLAGS += -mdynamic-no-pic |
||
335 | endif |
||
336 | endif |
||
337 | endif |
||
338 | endif |
||
339 | |||
154 | pmbaty | 340 | ### 3.4 Bits |
96 | pmbaty | 341 | ifeq ($(bits),64) |
342 | CXXFLAGS += -DIS_64BIT |
||
343 | endif |
||
344 | |||
154 | pmbaty | 345 | ### 3.5 prefetch |
96 | pmbaty | 346 | ifeq ($(prefetch),yes) |
347 | ifeq ($(sse),yes) |
||
348 | CXXFLAGS += -msse |
||
349 | DEPENDFLAGS += -msse |
||
350 | endif |
||
351 | else |
||
352 | CXXFLAGS += -DNO_PREFETCH |
||
353 | endif |
||
354 | |||
154 | pmbaty | 355 | ### 3.6 popcnt |
96 | pmbaty | 356 | ifeq ($(popcnt),yes) |
357 | ifeq ($(comp),icc) |
||
358 | CXXFLAGS += -msse3 -DUSE_POPCNT |
||
359 | else |
||
360 | CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT |
||
361 | endif |
||
362 | endif |
||
363 | |||
154 | pmbaty | 364 | ### 3.7 pext |
96 | pmbaty | 365 | ifeq ($(pext),yes) |
366 | CXXFLAGS += -DUSE_PEXT |
||
367 | ifeq ($(comp),$(filter $(comp),gcc clang mingw)) |
||
154 | pmbaty | 368 | CXXFLAGS += -mbmi2 |
96 | pmbaty | 369 | endif |
370 | endif |
||
371 | |||
154 | pmbaty | 372 | ### 3.8 Link Time Optimization, it works since gcc 4.5 but not on mingw under Windows. |
96 | pmbaty | 373 | ### This is a mix of compile and link time options because the lto link phase |
374 | ### needs access to the optimization flags. |
||
375 | ifeq ($(comp),gcc) |
||
376 | ifeq ($(optimize),yes) |
||
377 | ifeq ($(debug),no) |
||
378 | CXXFLAGS += -flto |
||
379 | LDFLAGS += $(CXXFLAGS) |
||
380 | endif |
||
381 | endif |
||
382 | endif |
||
383 | |||
384 | ifeq ($(comp),mingw) |
||
154 | pmbaty | 385 | ifeq ($(KERNEL),Linux) |
96 | pmbaty | 386 | ifeq ($(optimize),yes) |
387 | ifeq ($(debug),no) |
||
388 | CXXFLAGS += -flto |
||
389 | LDFLAGS += $(CXXFLAGS) |
||
390 | endif |
||
391 | endif |
||
392 | endif |
||
393 | endif |
||
394 | |||
154 | pmbaty | 395 | ### 3.9 Android 5 can only run position independent executables. Note that this |
96 | pmbaty | 396 | ### breaks Android 4.0 and earlier. |
154 | pmbaty | 397 | ifeq ($(OS), Android) |
96 | pmbaty | 398 | CXXFLAGS += -fPIE |
399 | LDFLAGS += -fPIE -pie |
||
400 | endif |
||
401 | |||
402 | |||
403 | ### ========================================================================== |
||
404 | ### Section 4. Public targets |
||
405 | ### ========================================================================== |
||
406 | |||
407 | help: |
||
408 | @echo "" |
||
409 | @echo "To compile stockfish, type: " |
||
410 | @echo "" |
||
411 | @echo "make target ARCH=arch [COMP=compiler] [COMPCXX=cxx]" |
||
412 | @echo "" |
||
413 | @echo "Supported targets:" |
||
414 | @echo "" |
||
415 | @echo "build > Standard build" |
||
416 | @echo "profile-build > PGO build" |
||
417 | @echo "strip > Strip executable" |
||
418 | @echo "install > Install executable" |
||
419 | @echo "clean > Clean up" |
||
420 | @echo "" |
||
421 | @echo "Supported archs:" |
||
422 | @echo "" |
||
423 | @echo "x86-64 > x86 64-bit" |
||
424 | @echo "x86-64-modern > x86 64-bit with popcnt support" |
||
425 | @echo "x86-64-bmi2 > x86 64-bit with pext support" |
||
426 | @echo "x86-32 > x86 32-bit with SSE support" |
||
427 | @echo "x86-32-old > x86 32-bit fall back for old hardware" |
||
428 | @echo "ppc-64 > PPC 64-bit" |
||
429 | @echo "ppc-32 > PPC 32-bit" |
||
430 | @echo "armv7 > ARMv7 32-bit" |
||
431 | @echo "general-64 > unspecified 64-bit" |
||
432 | @echo "general-32 > unspecified 32-bit" |
||
433 | @echo "" |
||
434 | @echo "Supported compilers:" |
||
435 | @echo "" |
||
436 | @echo "gcc > Gnu compiler (default)" |
||
437 | @echo "mingw > Gnu compiler with MinGW under Windows" |
||
438 | @echo "clang > LLVM Clang compiler" |
||
439 | @echo "icc > Intel compiler" |
||
440 | @echo "" |
||
441 | @echo "Simple examples. If you don't know what to do, you likely want to run: " |
||
442 | @echo "" |
||
443 | @echo "make build ARCH=x86-64 (This is for 64-bit systems)" |
||
444 | @echo "make build ARCH=x86-32 (This is for 32-bit systems)" |
||
445 | @echo "" |
||
446 | @echo "Advanced examples, for experienced users: " |
||
447 | @echo "" |
||
448 | @echo "make build ARCH=x86-64 COMP=clang" |
||
449 | @echo "make profile-build ARCH=x86-64-modern COMP=gcc COMPCXX=g++-4.8" |
||
450 | @echo "" |
||
451 | |||
452 | |||
169 | pmbaty | 453 | .PHONY: help build profile-build strip install clean objclean profileclean help \ |
454 | config-sanity icc-profile-use icc-profile-make gcc-profile-use gcc-profile-make \ |
||
455 | clang-profile-use clang-profile-make |
||
456 | |||
457 | build: config-sanity |
||
96 | pmbaty | 458 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all |
459 | |||
169 | pmbaty | 460 | profile-build: config-sanity objclean profileclean |
96 | pmbaty | 461 | @echo "" |
169 | pmbaty | 462 | @echo "Step 1/4. Building instrumented executable ..." |
96 | pmbaty | 463 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make) |
464 | @echo "" |
||
465 | @echo "Step 2/4. Running benchmark for pgo-build ..." |
||
466 | $(PGOBENCH) > /dev/null |
||
467 | @echo "" |
||
169 | pmbaty | 468 | @echo "Step 3/4. Building optimized executable ..." |
469 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean |
||
96 | pmbaty | 470 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use) |
471 | @echo "" |
||
472 | @echo "Step 4/4. Deleting profile data ..." |
||
169 | pmbaty | 473 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean |
96 | pmbaty | 474 | |
475 | strip: |
||
476 | strip $(EXE) |
||
477 | |||
478 | install: |
||
479 | -mkdir -p -m 755 $(BINDIR) |
||
480 | -cp $(EXE) $(BINDIR) |
||
481 | -strip $(BINDIR)/$(EXE) |
||
482 | |||
169 | pmbaty | 483 | #clean all |
484 | clean: objclean profileclean |
||
182 | pmbaty | 485 | ifneq ($(OS),Windows_NT) |
169 | pmbaty | 486 | @rm -f .depend *~ core |
182 | pmbaty | 487 | else |
488 | @del /f .depend *~ core > nul 2>&1 |
||
489 | endif |
||
96 | pmbaty | 490 | |
169 | pmbaty | 491 | # clean binaries and objects |
492 | objclean: |
||
182 | pmbaty | 493 | ifneq ($(OS),Windows_NT) |
169 | pmbaty | 494 | @rm -f $(EXE) $(EXE).exe *.o ./syzygy/*.o |
182 | pmbaty | 495 | else |
496 | @del /f $(EXE) $(EXE).exe *.o .\syzygy\*.o > nul 2>&1 |
||
497 | endif |
||
169 | pmbaty | 498 | |
499 | # clean auxiliary profiling files |
||
500 | profileclean: |
||
182 | pmbaty | 501 | ifneq ($(OS),Windows_NT) |
169 | pmbaty | 502 | @rm -rf profdir |
503 | @rm -f bench.txt *.gcda ./syzygy/*.gcda *.gcno ./syzygy/*.gcno |
||
504 | @rm -f stockfish.profdata *.profraw |
||
182 | pmbaty | 505 | else |
506 | @del /f /s /q profdir > nul 2>&1 |
||
507 | @del /f bench.txt *.gcda .\syzygy\*.gcda *.gcno .\syzygy\*.gcno > nul 2>&1 |
||
508 | @del /f stockfish.profdata *.profraw > nul 2>&1 |
||
509 | endif |
||
169 | pmbaty | 510 | |
96 | pmbaty | 511 | default: |
512 | help |
||
513 | |||
514 | ### ========================================================================== |
||
515 | ### Section 5. Private targets |
||
516 | ### ========================================================================== |
||
517 | |||
518 | all: $(EXE) .depend |
||
519 | |||
520 | config-sanity: |
||
521 | @echo "" |
||
522 | @echo "Config:" |
||
523 | @echo "debug: '$(debug)'" |
||
169 | pmbaty | 524 | @echo "sanitize: '$(sanitize)'" |
96 | pmbaty | 525 | @echo "optimize: '$(optimize)'" |
526 | @echo "arch: '$(arch)'" |
||
527 | @echo "bits: '$(bits)'" |
||
154 | pmbaty | 528 | @echo "kernel: '$(KERNEL)'" |
529 | @echo "os: '$(OS)'" |
||
96 | pmbaty | 530 | @echo "prefetch: '$(prefetch)'" |
531 | @echo "popcnt: '$(popcnt)'" |
||
532 | @echo "sse: '$(sse)'" |
||
533 | @echo "pext: '$(pext)'" |
||
534 | @echo "" |
||
535 | @echo "Flags:" |
||
536 | @echo "CXX: $(CXX)" |
||
537 | @echo "CXXFLAGS: $(CXXFLAGS)" |
||
538 | @echo "LDFLAGS: $(LDFLAGS)" |
||
539 | @echo "" |
||
182 | pmbaty | 540 | # Pierre-Marie Baty -- "test" doesn't exist on Windows, so just skip that |
541 | ifneq ($(OS),Windows_NT) |
||
96 | pmbaty | 542 | @echo "Testing config sanity. If this fails, try 'make help' ..." |
543 | @echo "" |
||
544 | @test "$(debug)" = "yes" || test "$(debug)" = "no" |
||
169 | pmbaty | 545 | @test "$(sanitize)" = "undefined" || test "$(sanitize)" = "thread" || test "$(sanitize)" = "no" |
96 | pmbaty | 546 | @test "$(optimize)" = "yes" || test "$(optimize)" = "no" |
547 | @test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \ |
||
548 | test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || test "$(arch)" = "armv7" |
||
549 | @test "$(bits)" = "32" || test "$(bits)" = "64" |
||
550 | @test "$(prefetch)" = "yes" || test "$(prefetch)" = "no" |
||
551 | @test "$(popcnt)" = "yes" || test "$(popcnt)" = "no" |
||
552 | @test "$(sse)" = "yes" || test "$(sse)" = "no" |
||
553 | @test "$(pext)" = "yes" || test "$(pext)" = "no" |
||
554 | @test "$(comp)" = "gcc" || test "$(comp)" = "icc" || test "$(comp)" = "mingw" || test "$(comp)" = "clang" |
||
182 | pmbaty | 555 | endif |
96 | pmbaty | 556 | |
557 | $(EXE): $(OBJS) |
||
558 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) |
||
559 | |||
169 | pmbaty | 560 | clang-profile-make: |
561 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
||
562 | EXTRACXXFLAGS='-fprofile-instr-generate ' \ |
||
563 | EXTRALDFLAGS=' -fprofile-instr-generate' \ |
||
564 | all |
||
96 | pmbaty | 565 | |
169 | pmbaty | 566 | clang-profile-use: |
567 | llvm-profdata merge -output=stockfish.profdata *.profraw |
||
568 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
||
569 | EXTRACXXFLAGS='-fprofile-instr-use=stockfish.profdata' \ |
||
570 | EXTRALDFLAGS='-fprofile-use ' \ |
||
571 | all |
||
572 | |||
96 | pmbaty | 573 | gcc-profile-make: |
574 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
||
575 | EXTRACXXFLAGS='-fprofile-generate' \ |
||
576 | EXTRALDFLAGS='-lgcov' \ |
||
577 | all |
||
578 | |||
579 | gcc-profile-use: |
||
580 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
||
581 | EXTRACXXFLAGS='-fprofile-use -fno-peel-loops -fno-tracer' \ |
||
582 | EXTRALDFLAGS='-lgcov' \ |
||
583 | all |
||
584 | |||
585 | icc-profile-make: |
||
169 | pmbaty | 586 | @mkdir -p profdir |
96 | pmbaty | 587 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
588 | EXTRACXXFLAGS='-prof-gen=srcpos -prof_dir ./profdir' \ |
||
589 | all |
||
590 | |||
591 | icc-profile-use: |
||
592 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
||
593 | EXTRACXXFLAGS='-prof_use -prof_dir ./profdir' \ |
||
594 | all |
||
595 | |||
596 | .depend: |
||
597 | -@$(CXX) $(DEPENDFLAGS) -MM $(OBJS:.o=.cpp) > $@ 2> /dev/null |
||
598 | |||
599 | -include .depend |
||
600 |