Rev 182 | 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 |
||
183 | pmbaty | 81 | #sanitize = no |
82 | sanitize = address |
||
96 | pmbaty | 83 | bits = 32 |
84 | prefetch = no |
||
85 | popcnt = no |
||
86 | sse = no |
||
87 | pext = no |
||
88 | |||
89 | ### 2.2 Architecture specific |
||
90 | |||
91 | ifeq ($(ARCH),general-32) |
||
92 | arch = any |
||
93 | endif |
||
94 | |||
95 | ifeq ($(ARCH),x86-32-old) |
||
96 | arch = i386 |
||
97 | endif |
||
98 | |||
99 | ifeq ($(ARCH),x86-32) |
||
100 | arch = i386 |
||
101 | prefetch = yes |
||
102 | sse = yes |
||
103 | endif |
||
104 | |||
105 | ifeq ($(ARCH),general-64) |
||
106 | arch = any |
||
107 | bits = 64 |
||
108 | endif |
||
109 | |||
110 | ifeq ($(ARCH),x86-64) |
||
111 | arch = x86_64 |
||
112 | bits = 64 |
||
113 | prefetch = yes |
||
114 | sse = yes |
||
115 | endif |
||
116 | |||
117 | ifeq ($(ARCH),x86-64-modern) |
||
118 | arch = x86_64 |
||
119 | bits = 64 |
||
120 | prefetch = yes |
||
121 | popcnt = yes |
||
122 | sse = yes |
||
123 | endif |
||
124 | |||
125 | ifeq ($(ARCH),x86-64-bmi2) |
||
126 | arch = x86_64 |
||
127 | bits = 64 |
||
128 | prefetch = yes |
||
129 | popcnt = yes |
||
130 | sse = yes |
||
131 | pext = yes |
||
132 | endif |
||
133 | |||
134 | ifeq ($(ARCH),armv7) |
||
135 | arch = armv7 |
||
136 | prefetch = yes |
||
137 | endif |
||
138 | |||
139 | ifeq ($(ARCH),ppc-32) |
||
140 | arch = ppc |
||
141 | endif |
||
142 | |||
143 | ifeq ($(ARCH),ppc-64) |
||
144 | arch = ppc64 |
||
145 | bits = 64 |
||
146 | endif |
||
147 | |||
148 | |||
149 | ### ========================================================================== |
||
150 | ### Section 3. Low-level configuration |
||
151 | ### ========================================================================== |
||
152 | |||
153 | ### 3.1 Selecting compiler (default = gcc) |
||
154 | |||
182 | pmbaty | 155 | ifeq ($(OS),Windows_NT) |
156 | # Pierre-Marie Baty -- we need two extra flags AND the C++14 standard when building with Clang against the Visual Studio 2015 SDK |
||
183 | pmbaty | 157 | CXXFLAGS += -Xclang -flto-visibility-public-std -Wall -Wcast-qual -std=c++14 $(EXTRACXXFLAGS) |
158 | # -fno-exceptions |
||
182 | pmbaty | 159 | DEPENDFLAGS += -std=c++14 |
160 | else |
||
169 | pmbaty | 161 | CXXFLAGS += -Wall -Wcast-qual -fno-exceptions -std=c++11 $(EXTRACXXFLAGS) |
96 | pmbaty | 162 | DEPENDFLAGS += -std=c++11 |
182 | pmbaty | 163 | endif |
96 | pmbaty | 164 | LDFLAGS += $(EXTRALDFLAGS) |
165 | |||
182 | pmbaty | 166 | #ifeq ($(COMP),) |
167 | # COMP=gcc |
||
168 | #endif |
||
169 | COMP=clang |
||
96 | pmbaty | 170 | |
171 | ifeq ($(COMP),gcc) |
||
172 | comp=gcc |
||
173 | CXX=g++ |
||
174 | CXXFLAGS += -pedantic -Wextra -Wshadow |
||
154 | pmbaty | 175 | |
176 | ifeq ($(ARCH),armv7) |
||
177 | ifeq ($(OS),Android) |
||
178 | CXXFLAGS += -m$(bits) |
||
169 | pmbaty | 179 | LDFLAGS += -m$(bits) |
154 | pmbaty | 180 | endif |
181 | else |
||
182 | CXXFLAGS += -m$(bits) |
||
169 | pmbaty | 183 | LDFLAGS += -m$(bits) |
154 | pmbaty | 184 | endif |
185 | |||
186 | ifneq ($(KERNEL),Darwin) |
||
96 | pmbaty | 187 | LDFLAGS += -Wl,--no-as-needed |
188 | endif |
||
189 | endif |
||
190 | |||
191 | ifeq ($(COMP),mingw) |
||
192 | comp=mingw |
||
193 | |||
154 | pmbaty | 194 | ifeq ($(KERNEL),Linux) |
96 | pmbaty | 195 | ifeq ($(bits),64) |
196 | ifeq ($(shell which x86_64-w64-mingw32-c++-posix),) |
||
197 | CXX=x86_64-w64-mingw32-c++ |
||
198 | else |
||
199 | CXX=x86_64-w64-mingw32-c++-posix |
||
200 | endif |
||
201 | else |
||
202 | ifeq ($(shell which i686-w64-mingw32-c++-posix),) |
||
203 | CXX=i686-w64-mingw32-c++ |
||
204 | else |
||
205 | CXX=i686-w64-mingw32-c++-posix |
||
206 | endif |
||
207 | endif |
||
208 | else |
||
209 | CXX=g++ |
||
210 | endif |
||
211 | |||
212 | CXXFLAGS += -Wextra -Wshadow |
||
213 | LDFLAGS += -static |
||
214 | endif |
||
215 | |||
216 | ifeq ($(COMP),icc) |
||
217 | comp=icc |
||
218 | CXX=icpc |
||
219 | CXXFLAGS += -diag-disable 1476,10120 -Wcheck -Wabi -Wdeprecated -strict-ansi |
||
220 | endif |
||
221 | |||
222 | ifeq ($(COMP),clang) |
||
223 | comp=clang |
||
224 | CXX=clang++ |
||
225 | CXXFLAGS += -pedantic -Wextra -Wshadow |
||
182 | pmbaty | 226 | # Pierre-Marie Baty -- also add the test case for Windows |
227 | ifneq ($(OS),Windows_NT) |
||
169 | pmbaty | 228 | ifneq ($(KERNEL),Darwin) |
229 | ifneq ($(KERNEL),OpenBSD) |
||
230 | LDFLAGS += -latomic |
||
231 | endif |
||
232 | endif |
||
182 | pmbaty | 233 | endif |
154 | pmbaty | 234 | |
235 | ifeq ($(ARCH),armv7) |
||
236 | ifeq ($(OS),Android) |
||
237 | CXXFLAGS += -m$(bits) |
||
238 | LDFLAGS += -m$(bits) |
||
239 | endif |
||
240 | else |
||
241 | CXXFLAGS += -m$(bits) |
||
242 | LDFLAGS += -m$(bits) |
||
243 | endif |
||
96 | pmbaty | 244 | endif |
245 | |||
246 | ifeq ($(comp),icc) |
||
247 | profile_make = icc-profile-make |
||
248 | profile_use = icc-profile-use |
||
249 | else |
||
169 | pmbaty | 250 | ifeq ($(comp),clang) |
251 | profile_make = clang-profile-make |
||
252 | profile_use = clang-profile-use |
||
253 | else |
||
96 | pmbaty | 254 | profile_make = gcc-profile-make |
255 | profile_use = gcc-profile-use |
||
256 | endif |
||
169 | pmbaty | 257 | endif |
96 | pmbaty | 258 | |
154 | pmbaty | 259 | ifeq ($(KERNEL),Darwin) |
96 | pmbaty | 260 | CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.9 |
261 | LDFLAGS += -arch $(arch) -mmacosx-version-min=10.9 |
||
262 | endif |
||
263 | |||
264 | ### Travis CI script uses COMPILER to overwrite CXX |
||
265 | ifdef COMPILER |
||
266 | COMPCXX=$(COMPILER) |
||
267 | endif |
||
268 | |||
269 | ### Allow overwriting CXX from command line |
||
270 | ifdef COMPCXX |
||
271 | CXX=$(COMPCXX) |
||
272 | endif |
||
273 | |||
183 | pmbaty | 274 | ### On mingw use Windows threads, otherwise POSIX |
275 | ifneq ($(comp),mingw) |
||
276 | # Pierre-Marie Baty -- also add the test case for Windows |
||
277 | ifneq ($(OS),Windows_NT) |
||
182 | pmbaty | 278 | # On Android Bionic's C library comes with its own pthread implementation bundled in |
279 | ifneq ($(OS),Android) |
||
280 | # Haiku has pthreads in its libroot, so only link it in on other platforms |
||
281 | ifneq ($(KERNEL),Haiku) |
||
282 | LDFLAGS += -lpthread |
||
283 | endif |
||
96 | pmbaty | 284 | endif |
285 | endif |
||
286 | endif |
||
287 | |||
154 | pmbaty | 288 | ### 3.2.1 Debugging |
96 | pmbaty | 289 | ifeq ($(debug),no) |
290 | CXXFLAGS += -DNDEBUG |
||
291 | else |
||
292 | CXXFLAGS += -g |
||
293 | endif |
||
294 | |||
154 | pmbaty | 295 | ### 3.2.2 Debugging with undefined behavior sanitizers |
169 | pmbaty | 296 | ifneq ($(sanitize),no) |
183 | pmbaty | 297 | CXXFLAGS += -g3 -fsanitize=$(sanitize) |
298 | LDFLAGS += -fsanitize=$(sanitize) |
||
299 | # Pierre-Marie Baty -- don't use any other linker than the system one on Windows |
||
300 | ifneq ($(OS),Windows_NT) |
||
301 | CXXFLAGS += -fuse-ld=gold |
||
302 | LDFLAGS += -fuse-ld=gold |
||
303 | endif |
||
154 | pmbaty | 304 | endif |
305 | |||
306 | ### 3.3 Optimization |
||
96 | pmbaty | 307 | ifeq ($(optimize),yes) |
308 | |||
154 | pmbaty | 309 | CXXFLAGS += -O3 |
310 | |||
96 | pmbaty | 311 | ifeq ($(comp),gcc) |
312 | |||
154 | pmbaty | 313 | ifeq ($(KERNEL),Darwin) |
96 | pmbaty | 314 | ifeq ($(arch),i386) |
315 | CXXFLAGS += -mdynamic-no-pic |
||
316 | endif |
||
317 | ifeq ($(arch),x86_64) |
||
318 | CXXFLAGS += -mdynamic-no-pic |
||
319 | endif |
||
320 | endif |
||
321 | |||
154 | pmbaty | 322 | ifeq ($(OS), Android) |
96 | pmbaty | 323 | CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp |
324 | endif |
||
325 | endif |
||
326 | |||
327 | ifeq ($(comp),icc) |
||
154 | pmbaty | 328 | ifeq ($(KERNEL),Darwin) |
329 | CXXFLAGS += -mdynamic-no-pic |
||
96 | pmbaty | 330 | endif |
331 | endif |
||
332 | |||
333 | ifeq ($(comp),clang) |
||
154 | pmbaty | 334 | ifeq ($(KERNEL),Darwin) |
96 | pmbaty | 335 | CXXFLAGS += -flto |
336 | LDFLAGS += $(CXXFLAGS) |
||
337 | ifeq ($(arch),i386) |
||
338 | CXXFLAGS += -mdynamic-no-pic |
||
339 | endif |
||
340 | ifeq ($(arch),x86_64) |
||
341 | CXXFLAGS += -mdynamic-no-pic |
||
342 | endif |
||
343 | endif |
||
344 | endif |
||
345 | endif |
||
346 | |||
154 | pmbaty | 347 | ### 3.4 Bits |
96 | pmbaty | 348 | ifeq ($(bits),64) |
349 | CXXFLAGS += -DIS_64BIT |
||
350 | endif |
||
351 | |||
154 | pmbaty | 352 | ### 3.5 prefetch |
96 | pmbaty | 353 | ifeq ($(prefetch),yes) |
354 | ifeq ($(sse),yes) |
||
355 | CXXFLAGS += -msse |
||
356 | DEPENDFLAGS += -msse |
||
357 | endif |
||
358 | else |
||
359 | CXXFLAGS += -DNO_PREFETCH |
||
360 | endif |
||
361 | |||
154 | pmbaty | 362 | ### 3.6 popcnt |
96 | pmbaty | 363 | ifeq ($(popcnt),yes) |
364 | ifeq ($(comp),icc) |
||
365 | CXXFLAGS += -msse3 -DUSE_POPCNT |
||
366 | else |
||
367 | CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT |
||
368 | endif |
||
369 | endif |
||
370 | |||
154 | pmbaty | 371 | ### 3.7 pext |
96 | pmbaty | 372 | ifeq ($(pext),yes) |
373 | CXXFLAGS += -DUSE_PEXT |
||
374 | ifeq ($(comp),$(filter $(comp),gcc clang mingw)) |
||
154 | pmbaty | 375 | CXXFLAGS += -mbmi2 |
96 | pmbaty | 376 | endif |
377 | endif |
||
378 | |||
154 | pmbaty | 379 | ### 3.8 Link Time Optimization, it works since gcc 4.5 but not on mingw under Windows. |
96 | pmbaty | 380 | ### This is a mix of compile and link time options because the lto link phase |
381 | ### needs access to the optimization flags. |
||
382 | ifeq ($(comp),gcc) |
||
383 | ifeq ($(optimize),yes) |
||
384 | ifeq ($(debug),no) |
||
385 | CXXFLAGS += -flto |
||
386 | LDFLAGS += $(CXXFLAGS) |
||
387 | endif |
||
388 | endif |
||
389 | endif |
||
390 | |||
391 | ifeq ($(comp),mingw) |
||
154 | pmbaty | 392 | ifeq ($(KERNEL),Linux) |
96 | pmbaty | 393 | ifeq ($(optimize),yes) |
394 | ifeq ($(debug),no) |
||
395 | CXXFLAGS += -flto |
||
396 | LDFLAGS += $(CXXFLAGS) |
||
397 | endif |
||
398 | endif |
||
399 | endif |
||
400 | endif |
||
401 | |||
154 | pmbaty | 402 | ### 3.9 Android 5 can only run position independent executables. Note that this |
96 | pmbaty | 403 | ### breaks Android 4.0 and earlier. |
154 | pmbaty | 404 | ifeq ($(OS), Android) |
96 | pmbaty | 405 | CXXFLAGS += -fPIE |
406 | LDFLAGS += -fPIE -pie |
||
407 | endif |
||
408 | |||
409 | |||
410 | ### ========================================================================== |
||
411 | ### Section 4. Public targets |
||
412 | ### ========================================================================== |
||
413 | |||
414 | help: |
||
415 | @echo "" |
||
416 | @echo "To compile stockfish, type: " |
||
417 | @echo "" |
||
418 | @echo "make target ARCH=arch [COMP=compiler] [COMPCXX=cxx]" |
||
419 | @echo "" |
||
420 | @echo "Supported targets:" |
||
421 | @echo "" |
||
422 | @echo "build > Standard build" |
||
423 | @echo "profile-build > PGO build" |
||
424 | @echo "strip > Strip executable" |
||
425 | @echo "install > Install executable" |
||
426 | @echo "clean > Clean up" |
||
427 | @echo "" |
||
428 | @echo "Supported archs:" |
||
429 | @echo "" |
||
430 | @echo "x86-64 > x86 64-bit" |
||
431 | @echo "x86-64-modern > x86 64-bit with popcnt support" |
||
432 | @echo "x86-64-bmi2 > x86 64-bit with pext support" |
||
433 | @echo "x86-32 > x86 32-bit with SSE support" |
||
434 | @echo "x86-32-old > x86 32-bit fall back for old hardware" |
||
435 | @echo "ppc-64 > PPC 64-bit" |
||
436 | @echo "ppc-32 > PPC 32-bit" |
||
437 | @echo "armv7 > ARMv7 32-bit" |
||
438 | @echo "general-64 > unspecified 64-bit" |
||
439 | @echo "general-32 > unspecified 32-bit" |
||
440 | @echo "" |
||
441 | @echo "Supported compilers:" |
||
442 | @echo "" |
||
443 | @echo "gcc > Gnu compiler (default)" |
||
444 | @echo "mingw > Gnu compiler with MinGW under Windows" |
||
445 | @echo "clang > LLVM Clang compiler" |
||
446 | @echo "icc > Intel compiler" |
||
447 | @echo "" |
||
448 | @echo "Simple examples. If you don't know what to do, you likely want to run: " |
||
449 | @echo "" |
||
450 | @echo "make build ARCH=x86-64 (This is for 64-bit systems)" |
||
451 | @echo "make build ARCH=x86-32 (This is for 32-bit systems)" |
||
452 | @echo "" |
||
453 | @echo "Advanced examples, for experienced users: " |
||
454 | @echo "" |
||
455 | @echo "make build ARCH=x86-64 COMP=clang" |
||
456 | @echo "make profile-build ARCH=x86-64-modern COMP=gcc COMPCXX=g++-4.8" |
||
457 | @echo "" |
||
458 | |||
459 | |||
169 | pmbaty | 460 | .PHONY: help build profile-build strip install clean objclean profileclean help \ |
461 | config-sanity icc-profile-use icc-profile-make gcc-profile-use gcc-profile-make \ |
||
462 | clang-profile-use clang-profile-make |
||
463 | |||
464 | build: config-sanity |
||
96 | pmbaty | 465 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all |
466 | |||
169 | pmbaty | 467 | profile-build: config-sanity objclean profileclean |
96 | pmbaty | 468 | @echo "" |
169 | pmbaty | 469 | @echo "Step 1/4. Building instrumented executable ..." |
96 | pmbaty | 470 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make) |
471 | @echo "" |
||
472 | @echo "Step 2/4. Running benchmark for pgo-build ..." |
||
473 | $(PGOBENCH) > /dev/null |
||
474 | @echo "" |
||
169 | pmbaty | 475 | @echo "Step 3/4. Building optimized executable ..." |
476 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean |
||
96 | pmbaty | 477 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use) |
478 | @echo "" |
||
479 | @echo "Step 4/4. Deleting profile data ..." |
||
169 | pmbaty | 480 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean |
96 | pmbaty | 481 | |
482 | strip: |
||
483 | strip $(EXE) |
||
484 | |||
485 | install: |
||
486 | -mkdir -p -m 755 $(BINDIR) |
||
487 | -cp $(EXE) $(BINDIR) |
||
488 | -strip $(BINDIR)/$(EXE) |
||
489 | |||
169 | pmbaty | 490 | #clean all |
491 | clean: objclean profileclean |
||
182 | pmbaty | 492 | ifneq ($(OS),Windows_NT) |
169 | pmbaty | 493 | @rm -f .depend *~ core |
182 | pmbaty | 494 | else |
495 | @del /f .depend *~ core > nul 2>&1 |
||
496 | endif |
||
96 | pmbaty | 497 | |
169 | pmbaty | 498 | # clean binaries and objects |
499 | objclean: |
||
182 | pmbaty | 500 | ifneq ($(OS),Windows_NT) |
169 | pmbaty | 501 | @rm -f $(EXE) $(EXE).exe *.o ./syzygy/*.o |
182 | pmbaty | 502 | else |
503 | @del /f $(EXE) $(EXE).exe *.o .\syzygy\*.o > nul 2>&1 |
||
504 | endif |
||
169 | pmbaty | 505 | |
506 | # clean auxiliary profiling files |
||
507 | profileclean: |
||
182 | pmbaty | 508 | ifneq ($(OS),Windows_NT) |
169 | pmbaty | 509 | @rm -rf profdir |
510 | @rm -f bench.txt *.gcda ./syzygy/*.gcda *.gcno ./syzygy/*.gcno |
||
511 | @rm -f stockfish.profdata *.profraw |
||
182 | pmbaty | 512 | else |
513 | @del /f /s /q profdir > nul 2>&1 |
||
514 | @del /f bench.txt *.gcda .\syzygy\*.gcda *.gcno .\syzygy\*.gcno > nul 2>&1 |
||
515 | @del /f stockfish.profdata *.profraw > nul 2>&1 |
||
516 | endif |
||
169 | pmbaty | 517 | |
96 | pmbaty | 518 | default: |
519 | help |
||
520 | |||
521 | ### ========================================================================== |
||
522 | ### Section 5. Private targets |
||
523 | ### ========================================================================== |
||
524 | |||
525 | all: $(EXE) .depend |
||
526 | |||
527 | config-sanity: |
||
528 | @echo "" |
||
529 | @echo "Config:" |
||
530 | @echo "debug: '$(debug)'" |
||
169 | pmbaty | 531 | @echo "sanitize: '$(sanitize)'" |
96 | pmbaty | 532 | @echo "optimize: '$(optimize)'" |
533 | @echo "arch: '$(arch)'" |
||
534 | @echo "bits: '$(bits)'" |
||
154 | pmbaty | 535 | @echo "kernel: '$(KERNEL)'" |
536 | @echo "os: '$(OS)'" |
||
96 | pmbaty | 537 | @echo "prefetch: '$(prefetch)'" |
538 | @echo "popcnt: '$(popcnt)'" |
||
539 | @echo "sse: '$(sse)'" |
||
540 | @echo "pext: '$(pext)'" |
||
541 | @echo "" |
||
542 | @echo "Flags:" |
||
543 | @echo "CXX: $(CXX)" |
||
544 | @echo "CXXFLAGS: $(CXXFLAGS)" |
||
545 | @echo "LDFLAGS: $(LDFLAGS)" |
||
546 | @echo "" |
||
182 | pmbaty | 547 | # Pierre-Marie Baty -- "test" doesn't exist on Windows, so just skip that |
548 | ifneq ($(OS),Windows_NT) |
||
96 | pmbaty | 549 | @echo "Testing config sanity. If this fails, try 'make help' ..." |
550 | @echo "" |
||
551 | @test "$(debug)" = "yes" || test "$(debug)" = "no" |
||
169 | pmbaty | 552 | @test "$(sanitize)" = "undefined" || test "$(sanitize)" = "thread" || test "$(sanitize)" = "no" |
96 | pmbaty | 553 | @test "$(optimize)" = "yes" || test "$(optimize)" = "no" |
554 | @test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \ |
||
555 | test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || test "$(arch)" = "armv7" |
||
556 | @test "$(bits)" = "32" || test "$(bits)" = "64" |
||
557 | @test "$(prefetch)" = "yes" || test "$(prefetch)" = "no" |
||
558 | @test "$(popcnt)" = "yes" || test "$(popcnt)" = "no" |
||
559 | @test "$(sse)" = "yes" || test "$(sse)" = "no" |
||
560 | @test "$(pext)" = "yes" || test "$(pext)" = "no" |
||
561 | @test "$(comp)" = "gcc" || test "$(comp)" = "icc" || test "$(comp)" = "mingw" || test "$(comp)" = "clang" |
||
182 | pmbaty | 562 | endif |
96 | pmbaty | 563 | |
564 | $(EXE): $(OBJS) |
||
565 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) |
||
566 | |||
169 | pmbaty | 567 | clang-profile-make: |
568 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
||
569 | EXTRACXXFLAGS='-fprofile-instr-generate ' \ |
||
570 | EXTRALDFLAGS=' -fprofile-instr-generate' \ |
||
571 | all |
||
96 | pmbaty | 572 | |
169 | pmbaty | 573 | clang-profile-use: |
574 | llvm-profdata merge -output=stockfish.profdata *.profraw |
||
575 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
||
576 | EXTRACXXFLAGS='-fprofile-instr-use=stockfish.profdata' \ |
||
577 | EXTRALDFLAGS='-fprofile-use ' \ |
||
578 | all |
||
579 | |||
96 | pmbaty | 580 | gcc-profile-make: |
581 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
||
582 | EXTRACXXFLAGS='-fprofile-generate' \ |
||
583 | EXTRALDFLAGS='-lgcov' \ |
||
584 | all |
||
585 | |||
586 | gcc-profile-use: |
||
587 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
||
588 | EXTRACXXFLAGS='-fprofile-use -fno-peel-loops -fno-tracer' \ |
||
589 | EXTRALDFLAGS='-lgcov' \ |
||
590 | all |
||
591 | |||
592 | icc-profile-make: |
||
169 | pmbaty | 593 | @mkdir -p profdir |
96 | pmbaty | 594 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
595 | EXTRACXXFLAGS='-prof-gen=srcpos -prof_dir ./profdir' \ |
||
596 | all |
||
597 | |||
598 | icc-profile-use: |
||
599 | $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
||
600 | EXTRACXXFLAGS='-prof_use -prof_dir ./profdir' \ |
||
601 | all |
||
602 | |||
603 | .depend: |
||
604 | -@$(CXX) $(DEPENDFLAGS) -MM $(OBJS:.o=.cpp) > $@ 2> /dev/null |
||
605 | |||
606 | -include .depend |
||
607 |