Rev 183 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 183 | Rev 185 | ||
|---|---|---|---|
| Line 2... | Line 2... | ||
| 2 | # Copyright (C) 2004-2008 Tord Romstad (Glaurung author) |
2 | # Copyright (C) 2004-2008 Tord Romstad (Glaurung author) |
| 3 | # Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad |
3 | # Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad |
| 4 | # Copyright (C) 2015- |
4 | # Copyright (C) 2015-2019 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad |
| 5 | # |
5 | # |
| 6 | # Stockfish is free software: you can redistribute it and/or modify |
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 |
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 |
8 | # the Free Software Foundation, either version 3 of the License, or |
| 9 | # (at your option) any later version. |
9 | # (at your option) any later version. |
| Line 18... | Line 18... | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | ### ========================================================================== |
20 | ### ========================================================================== |
| 21 | ### Section 1. General Configuration |
21 | ### Section 1. General Configuration |
| 22 | ### ========================================================================== |
22 | ### ========================================================================== |
| 23 | - | ||
| 24 | ### Establish the operating system name |
- | |
| 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 |
- | |
| 33 | endif |
- | |
| 34 | 23 | ||
| 35 | ### Executable name |
24 | ### Executable name |
| 36 | # Pierre-Marie Baty -- on Windows, add the .exe extension |
- | |
| 37 | ifeq ($( |
25 | ifeq ($(COMP),mingw) |
| 38 |
|
26 | EXE = stockfish.exe |
| 39 | else |
27 | else |
| 40 |
|
28 | EXE = stockfish |
| 41 | endif |
29 | endif |
| 42 | 30 | ||
| 43 | ### Installation dir definitions |
31 | ### Installation dir definitions |
| 44 | PREFIX = /usr/local |
32 | PREFIX = /usr/local |
| 45 | BINDIR = $(PREFIX)/bin |
33 | BINDIR = $(PREFIX)/bin |
| Line 49... | Line 37... | ||
| 49 | 37 | ||
| 50 | ### Object files |
38 | ### Object files |
| 51 | OBJS = benchmark.o bitbase.o bitboard.o endgame.o evaluate.o main.o \ |
39 | 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 \ |
40 | 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 |
41 | search.o thread.o timeman.o tt.o uci.o ucioption.o syzygy/tbprobe.o |
| - | 42 | ||
| - | 43 | ### Establish the operating system name |
|
| - | 44 | KERNEL = $(shell uname -s) |
|
| - | 45 | ifeq ($(KERNEL),Linux) |
|
| - | 46 | OS = $(shell uname -o) |
|
| - | 47 | endif |
|
| 54 | 48 | ||
| 55 | ### ========================================================================== |
49 | ### ========================================================================== |
| 56 | ### Section 2. High-level Configuration |
50 | ### Section 2. High-level Configuration |
| 57 | ### ========================================================================== |
51 | ### ========================================================================== |
| 58 | # |
52 | # |
| Line 76... | Line 70... | ||
| 76 | # at the end of the line for flag values. |
70 | # at the end of the line for flag values. |
| 77 | 71 | ||
| 78 | ### 2.1. General and architecture defaults |
72 | ### 2.1. General and architecture defaults |
| 79 | optimize = yes |
73 | optimize = yes |
| 80 | debug = no |
74 | debug = no |
| 81 |
|
75 | sanitize = no |
| 82 | sanitize = address |
- | |
| 83 | bits = 32 |
76 | bits = 32 |
| 84 | prefetch = no |
77 | prefetch = no |
| 85 | popcnt = no |
78 | popcnt = no |
| 86 | sse = no |
79 | sse = no |
| 87 | pext = no |
80 | pext = no |
| Line 150... | Line 143... | ||
| 150 | ### Section 3. Low-level configuration |
143 | ### Section 3. Low-level configuration |
| 151 | ### ========================================================================== |
144 | ### ========================================================================== |
| 152 | 145 | ||
| 153 | ### 3.1 Selecting compiler (default = gcc) |
146 | ### 3.1 Selecting compiler (default = gcc) |
| 154 | 147 | ||
| 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 |
- | |
| 157 | CXXFLAGS += -Xclang -flto-visibility-public-std -Wall -Wcast-qual -std=c++14 $(EXTRACXXFLAGS) |
- | |
| 158 | # -fno-exceptions |
- | |
| 159 | DEPENDFLAGS += -std=c++14 |
- | |
| 160 | else |
- | |
| 161 | CXXFLAGS += -Wall -Wcast-qual -fno-exceptions -std=c++11 $(EXTRACXXFLAGS) |
148 | CXXFLAGS += -Wall -Wcast-qual -fno-exceptions -std=c++11 $(EXTRACXXFLAGS) |
| 162 | DEPENDFLAGS += -std=c++11 |
149 | DEPENDFLAGS += -std=c++11 |
| 163 | endif |
- | |
| 164 | LDFLAGS += $(EXTRALDFLAGS) |
150 | LDFLAGS += $(EXTRALDFLAGS) |
| 165 | 151 | ||
| 166 |
|
152 | ifeq ($(COMP),) |
| 167 |
|
153 | COMP=gcc |
| 168 |
|
154 | endif |
| 169 | COMP=clang |
- | |
| 170 | 155 | ||
| 171 | ifeq ($(COMP),gcc) |
156 | ifeq ($(COMP),gcc) |
| 172 | comp=gcc |
157 | comp=gcc |
| 173 | CXX=g++ |
158 | CXX=g++ |
| 174 | CXXFLAGS += -pedantic -Wextra -Wshadow |
159 | CXXFLAGS += -pedantic -Wextra -Wshadow |
| Line 221... | Line 206... | ||
| 221 | 206 | ||
| 222 | ifeq ($(COMP),clang) |
207 | ifeq ($(COMP),clang) |
| 223 | comp=clang |
208 | comp=clang |
| 224 | CXX=clang++ |
209 | CXX=clang++ |
| 225 | CXXFLAGS += -pedantic -Wextra -Wshadow |
210 | CXXFLAGS += -pedantic -Wextra -Wshadow |
| 226 | # Pierre-Marie Baty -- also add the test case for Windows |
- | |
| 227 | ifneq ($(OS),Windows_NT) |
- | |
| - | 211 | ||
| 228 | ifneq ($(KERNEL),Darwin) |
212 | ifneq ($(KERNEL),Darwin) |
| 229 | ifneq ($(KERNEL),OpenBSD) |
213 | ifneq ($(KERNEL),OpenBSD) |
| 230 | LDFLAGS += -latomic |
214 | LDFLAGS += -latomic |
| 231 | endif |
- | |
| 232 | endif |
215 | endif |
| 233 | endif |
216 | endif |
| 234 | 217 | ||
| 235 | ifeq ($(ARCH),armv7) |
218 | ifeq ($(ARCH),armv7) |
| 236 | ifeq ($(OS),Android) |
219 | ifeq ($(OS),Android) |
| 237 | CXXFLAGS += -m$(bits) |
220 | CXXFLAGS += -m$(bits) |
| 238 | LDFLAGS += -m$(bits) |
221 | LDFLAGS += -m$(bits) |
| Line 271... | Line 254... | ||
| 271 | CXX=$(COMPCXX) |
254 | CXX=$(COMPCXX) |
| 272 | endif |
255 | endif |
| 273 | 256 | ||
| 274 | ### On mingw use Windows threads, otherwise POSIX |
257 | ### On mingw use Windows threads, otherwise POSIX |
| 275 | ifneq ($(comp),mingw) |
258 | ifneq ($(comp),mingw) |
| 276 | # Pierre-Marie Baty -- also add the test case for Windows |
- | |
| 277 | ifneq ($(OS),Windows_NT) |
- | |
| 278 |
|
259 | # On Android Bionic's C library comes with its own pthread implementation bundled in |
| 279 |
|
260 | ifneq ($(OS),Android) |
| 280 |
|
261 | # Haiku has pthreads in its libroot, so only link it in on other platforms |
| 281 |
|
262 | ifneq ($(KERNEL),Haiku) |
| 282 |
|
263 | LDFLAGS += -lpthread |
| 283 | endif |
- | |
| 284 | endif |
264 | endif |
| 285 | endif |
265 | endif |
| 286 | endif |
266 | endif |
| 287 | 267 | ||
| 288 | ### 3.2.1 Debugging |
268 | ### 3.2.1 Debugging |
| Line 292... | Line 272... | ||
| 292 | CXXFLAGS += -g |
272 | CXXFLAGS += -g |
| 293 | endif |
273 | endif |
| 294 | 274 | ||
| 295 | ### 3.2.2 Debugging with undefined behavior sanitizers |
275 | ### 3.2.2 Debugging with undefined behavior sanitizers |
| 296 | ifneq ($(sanitize),no) |
276 | ifneq ($(sanitize),no) |
| 297 | CXXFLAGS += -g3 -fsanitize=$(sanitize) |
277 | CXXFLAGS += -g3 -fsanitize=$(sanitize) -fuse-ld=gold |
| 298 | LDFLAGS += -fsanitize=$(sanitize) |
278 | LDFLAGS += -fsanitize=$(sanitize) -fuse-ld=gold |
| 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 |
- | |
| 304 | endif |
279 | endif |
| 305 | 280 | ||
| 306 | ### 3.3 Optimization |
281 | ### 3.3 Optimization |
| 307 | ifeq ($(optimize),yes) |
282 | ifeq ($(optimize),yes) |
| 308 | 283 | ||
| 309 | CXXFLAGS += -O3 |
284 | CXXFLAGS += -O3 |
| 310 | 285 | ||
| 311 | ifeq ($(comp),gcc) |
286 | ifeq ($(comp),gcc) |
| 312 | - | ||
| 313 | ifeq ($(KERNEL),Darwin) |
- | |
| 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 | - | ||
| 322 | ifeq ($(OS), Android) |
287 | ifeq ($(OS), Android) |
| 323 | CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp |
288 | CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp |
| 324 | endif |
289 | endif |
| 325 | endif |
290 | endif |
| 326 | 291 | ||
| 327 | ifeq ($(comp) |
292 | ifeq ($(comp),$(filter $(comp),gcc clang icc)) |
| 328 | ifeq ($(KERNEL),Darwin) |
293 | ifeq ($(KERNEL),Darwin) |
| 329 | CXXFLAGS += -mdynamic-no-pic |
294 | CXXFLAGS += -mdynamic-no-pic |
| 330 | endif |
- | |
| 331 | endif |
- | |
| 332 | - | ||
| 333 | ifeq ($(comp),clang) |
- | |
| 334 | ifeq ($(KERNEL),Darwin) |
- | |
| 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 |
295 | endif |
| 344 | endif |
296 | endif |
| 345 | endif |
297 | endif |
| 346 | 298 | ||
| 347 | ### 3.4 Bits |
299 | ### 3.4 Bits |
| Line 377... | Line 329... | ||
| 377 | endif |
329 | endif |
| 378 | 330 | ||
| 379 | ### 3.8 Link Time Optimization, it works since gcc 4.5 but not on mingw under Windows. |
331 | ### 3.8 Link Time Optimization, it works since gcc 4.5 but not on mingw under Windows. |
| 380 | ### This is a mix of compile and link time options because the lto link phase |
332 | ### This is a mix of compile and link time options because the lto link phase |
| 381 | ### needs access to the optimization flags. |
333 | ### needs access to the optimization flags. |
| 382 | ifeq ($(comp),gcc) |
- | |
| 383 |
|
334 | ifeq ($(optimize),yes) |
| 384 |
|
335 | ifeq ($(debug), no) |
| - | 336 | ifeq ($(comp),$(filter $(comp),gcc clang)) |
|
| 385 | CXXFLAGS += -flto |
337 | CXXFLAGS += -flto |
| 386 | LDFLAGS += $(CXXFLAGS) |
338 | LDFLAGS += $(CXXFLAGS) |
| 387 | endif |
339 | endif |
| 388 | endif |
- | |
| 389 | endif |
- | |
| 390 | 340 | ||
| 391 | ifeq ($(comp),mingw) |
341 | ifeq ($(comp),mingw) |
| 392 | ifeq ($(KERNEL),Linux) |
342 | ifeq ($(KERNEL),Linux) |
| 393 | ifeq ($(optimize),yes) |
- | |
| 394 | ifeq ($(debug),no) |
- | |
| 395 | CXXFLAGS += -flto |
343 | CXXFLAGS += -flto |
| 396 | LDFLAGS += $(CXXFLAGS) |
344 | LDFLAGS += $(CXXFLAGS) |
| 397 | endif |
345 | endif |
| 398 | endif |
346 | endif |
| 399 |
|
347 | endif |
| 400 | endif |
348 | endif |
| 401 | 349 | ||
| 402 | ### 3.9 Android 5 can only run position independent executables. Note that this |
350 | ### 3.9 Android 5 can only run position independent executables. Note that this |
| 403 | ### breaks Android 4.0 and earlier. |
351 | ### breaks Android 4.0 and earlier. |
| 404 | ifeq ($(OS), Android) |
352 | ifeq ($(OS), Android) |
| Line 487... | Line 435... | ||
| 487 | -cp $(EXE) $(BINDIR) |
435 | -cp $(EXE) $(BINDIR) |
| 488 | -strip $(BINDIR)/$(EXE) |
436 | -strip $(BINDIR)/$(EXE) |
| 489 | 437 | ||
| 490 | #clean all |
438 | #clean all |
| 491 | clean: objclean profileclean |
439 | clean: objclean profileclean |
| 492 | ifneq ($(OS),Windows_NT) |
- | |
| 493 | @rm -f .depend *~ core |
440 | @rm -f .depend *~ core |
| 494 | else |
- | |
| 495 | @del /f .depend *~ core > nul 2>&1 |
- | |
| 496 | endif |
- | |
| 497 | 441 | ||
| 498 | # clean binaries and objects |
442 | # clean binaries and objects |
| 499 | objclean: |
443 | objclean: |
| 500 | ifneq ($(OS),Windows_NT) |
- | |
| 501 | @rm -f $(EXE) |
444 | @rm -f $(EXE) *.o ./syzygy/*.o |
| 502 | else |
- | |
| 503 | @del /f $(EXE) $(EXE).exe *.o .\syzygy\*.o > nul 2>&1 |
- | |
| 504 | endif |
- | |
| 505 | 445 | ||
| 506 | # clean auxiliary profiling files |
446 | # clean auxiliary profiling files |
| 507 | profileclean: |
447 | profileclean: |
| 508 | ifneq ($(OS),Windows_NT) |
- | |
| 509 | @rm -rf profdir |
448 | @rm -rf profdir |
| 510 | @rm -f bench.txt *.gcda ./syzygy/*.gcda *.gcno ./syzygy/*.gcno |
449 | @rm -f bench.txt *.gcda ./syzygy/*.gcda *.gcno ./syzygy/*.gcno |
| 511 | @rm -f stockfish.profdata *.profraw |
450 | @rm -f stockfish.profdata *.profraw |
| 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 |
- | |
| 517 | 451 | ||
| 518 | default: |
452 | default: |
| 519 | help |
453 | help |
| 520 | 454 | ||
| 521 | ### ========================================================================== |
455 | ### ========================================================================== |
| Line 542... | Line 476... | ||
| 542 | @echo "Flags:" |
476 | @echo "Flags:" |
| 543 | @echo "CXX: $(CXX)" |
477 | @echo "CXX: $(CXX)" |
| 544 | @echo "CXXFLAGS: $(CXXFLAGS)" |
478 | @echo "CXXFLAGS: $(CXXFLAGS)" |
| 545 | @echo "LDFLAGS: $(LDFLAGS)" |
479 | @echo "LDFLAGS: $(LDFLAGS)" |
| 546 | @echo "" |
480 | @echo "" |
| 547 | # Pierre-Marie Baty -- "test" doesn't exist on Windows, so just skip that |
- | |
| 548 | ifneq ($(OS),Windows_NT) |
- | |
| 549 | @echo "Testing config sanity. If this fails, try 'make help' ..." |
481 | @echo "Testing config sanity. If this fails, try 'make help' ..." |
| 550 | @echo "" |
482 | @echo "" |
| 551 | @test "$(debug)" = "yes" || test "$(debug)" = "no" |
483 | @test "$(debug)" = "yes" || test "$(debug)" = "no" |
| 552 | @test "$(sanitize)" = "undefined" || test "$(sanitize)" = "thread" || test "$(sanitize)" = "no" |
484 | @test "$(sanitize)" = "undefined" || test "$(sanitize)" = "thread" || test "$(sanitize)" = "no" |
| 553 | @test "$(optimize)" = "yes" || test "$(optimize)" = "no" |
485 | @test "$(optimize)" = "yes" || test "$(optimize)" = "no" |
| Line 557... | Line 489... | ||
| 557 | @test "$(prefetch)" = "yes" || test "$(prefetch)" = "no" |
489 | @test "$(prefetch)" = "yes" || test "$(prefetch)" = "no" |
| 558 | @test "$(popcnt)" = "yes" || test "$(popcnt)" = "no" |
490 | @test "$(popcnt)" = "yes" || test "$(popcnt)" = "no" |
| 559 | @test "$(sse)" = "yes" || test "$(sse)" = "no" |
491 | @test "$(sse)" = "yes" || test "$(sse)" = "no" |
| 560 | @test "$(pext)" = "yes" || test "$(pext)" = "no" |
492 | @test "$(pext)" = "yes" || test "$(pext)" = "no" |
| 561 | @test "$(comp)" = "gcc" || test "$(comp)" = "icc" || test "$(comp)" = "mingw" || test "$(comp)" = "clang" |
493 | @test "$(comp)" = "gcc" || test "$(comp)" = "icc" || test "$(comp)" = "mingw" || test "$(comp)" = "clang" |
| 562 | endif |
- | |
| 563 | 494 | ||
| 564 | $(EXE): $(OBJS) |
495 | $(EXE): $(OBJS) |
| 565 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) |
496 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) |
| 566 | 497 | ||
| 567 | clang-profile-make: |
498 | clang-profile-make: |