]> git.sesse.net Git - stockfish/blob - src/Makefile
LMR search tweak
[stockfish] / src / Makefile
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
4 # Copyright (C) 2015-2019 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad
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 ### Executable name
25 ifeq ($(COMP),mingw)
26 EXE = stockfish.exe
27 else
28 EXE = stockfish
29 endif
30
31 ### Installation dir definitions
32 PREFIX = /usr/local
33 BINDIR = $(PREFIX)/bin
34
35 ### Built-in benchmark for pgo-builds
36 PGOBENCH = ./$(EXE) bench
37
38 ### Source and object files
39 SRCS = benchmark.cpp bitbase.cpp bitboard.cpp endgame.cpp evaluate.cpp main.cpp \
40         material.cpp misc.cpp movegen.cpp movepick.cpp pawns.cpp position.cpp psqt.cpp \
41         search.cpp thread.cpp timeman.cpp tt.cpp uci.cpp ucioption.cpp tune.cpp syzygy/tbprobe.cpp \
42         nnue/evaluate_nnue.cpp nnue/features/half_kp.cpp
43
44 OBJS = $(notdir $(SRCS:.cpp=.o))
45
46 VPATH = syzygy:nnue:nnue/features
47
48 ### Establish the operating system name
49 KERNEL = $(shell uname -s)
50 ifeq ($(KERNEL),Linux)
51         OS = $(shell uname -o)
52 endif
53
54 ### ==========================================================================
55 ### Section 2. High-level Configuration
56 ### ==========================================================================
57 #
58 # flag                --- Comp switch      --- Description
59 # ----------------------------------------------------------------------------
60 #
61 # debug = yes/no      --- -DNDEBUG         --- Enable/Disable debug mode
62 # sanitize = undefined/thread/no (-fsanitize )
63 #                     --- ( undefined )    --- enable undefined behavior checks
64 #                     --- ( thread    )    --- enable threading error  checks
65 # optimize = yes/no   --- (-O3/-fast etc.) --- Enable/Disable optimizations
66 # arch = (name)       --- (-arch)          --- Target architecture
67 # bits = 64/32        --- -DIS_64BIT       --- 64-/32-bit operating system
68 # prefetch = yes/no   --- -DUSE_PREFETCH   --- Use prefetch asm-instruction
69 # popcnt = yes/no     --- -DUSE_POPCNT     --- Use popcnt asm-instruction
70 # sse = yes/no        --- -msse            --- Use Intel Streaming SIMD Extensions
71 # sse3 = yes/no       --- -msse3           --- Use Intel Streaming SIMD Extensions 3
72 # ssse3 = yes/no      --- -mssse3          --- Use Intel Supplemental Streaming SIMD Extensions 3
73 # sse41 = yes/no      --- -msse4.1         --- Use Intel Streaming SIMD Extensions 4.1
74 # sse42 = yes/no      --- -msse4.2         --- Use Intel Streaming SIMD Extensions 4.2
75 # avx2 = yes/no       --- -mavx2           --- Use Intel Advanced Vector Extensions 2
76 # pext = yes/no       --- -DUSE_PEXT       --- Use pext x86_64 asm-instruction
77 # avx512 = yes/no     --- -mavx512bw       --- Use Intel Advanced Vector Extensions 512
78 # neon = yes/no       --- -DUSE_NEON       --- Use ARM SIMD architecture
79 #
80 # Note that Makefile is space sensitive, so when adding new architectures
81 # or modifying existing flags, you have to make sure there are no extra spaces
82 # at the end of the line for flag values.
83
84 ### 2.1. General and architecture defaults
85 optimize = yes
86 debug = no
87 sanitize = no
88 bits = 64
89 prefetch = no
90 popcnt = no
91 sse = no
92 sse3 = no
93 ssse3 = no
94 sse41 = no
95 sse42 = no
96 avx2 = no
97 pext = no
98 avx512 = no
99 neon = no
100 ARCH = x86-64-modern
101
102 ### 2.2 Architecture specific
103 ifeq ($(ARCH),general-32)
104         arch = any
105         bits = 32
106 endif
107
108 ifeq ($(ARCH),x86-32-old)
109         arch = i386
110         bits = 32
111 endif
112
113 ifeq ($(ARCH),x86-32)
114         arch = i386
115         bits = 32
116         prefetch = yes
117         sse = yes
118 endif
119
120 ifeq ($(ARCH),general-64)
121         arch = any
122 endif
123
124 ifeq ($(ARCH),x86-64)
125         arch = x86_64
126         prefetch = yes
127         sse = yes
128 endif
129
130 ifeq ($(ARCH),x86-64-sse3)
131         arch = x86_64
132         prefetch = yes
133         sse = yes
134         sse3 = yes
135 endif
136
137 ifeq ($(ARCH),x86-64-sse3-popcnt)
138         arch = x86_64
139         prefetch = yes
140         sse = yes
141         sse3 = yes
142         popcnt = yes
143 endif
144
145 ifeq ($(ARCH),x86-64-ssse3)
146         arch = x86_64
147         prefetch = yes
148         sse = yes
149         sse3 = yes
150         ssse3 = yes
151 endif
152
153 ifeq ($(ARCH),x86-64-sse41)
154         arch = x86_64
155         prefetch = yes
156         popcnt = yes
157         sse = yes
158         sse3 = yes
159         ssse3 = yes
160         sse41 = yes
161 endif
162
163 ifeq ($(ARCH),x86-64-modern)
164         arch = x86_64
165         prefetch = yes
166         popcnt = yes
167         sse = yes
168         sse3 = yes
169         ssse3 = yes
170         sse41 = yes
171 endif
172
173 ifeq ($(ARCH),x86-64-sse42)
174         arch = x86_64
175         prefetch = yes
176         popcnt = yes
177         sse = yes
178         sse3 = yes
179         ssse3 = yes
180         sse41 = yes
181         sse42 = yes
182 endif
183
184 ifeq ($(ARCH),x86-64-avx2)
185         arch = x86_64
186         prefetch = yes
187         popcnt = yes
188         sse = yes
189         sse3 = yes
190         ssse3 = yes
191         sse41 = yes
192         sse42 = yes
193         avx2 = yes
194 endif
195
196 ifeq ($(ARCH),x86-64-bmi2)
197         arch = x86_64
198         prefetch = yes
199         popcnt = yes
200         sse = yes
201         sse3 = yes
202         ssse3 = yes
203         sse41 = yes
204         sse42 = yes
205         avx2 = yes
206         pext = yes
207 endif
208
209 ifeq ($(ARCH),x86-64-avx512)
210         arch = x86_64
211         prefetch = yes
212         popcnt = yes
213         sse = yes
214         sse3 = yes
215         ssse3 = yes
216         sse41 = yes
217         sse42 = yes
218         avx2 = yes
219         pext = yes
220         avx512 = yes
221 endif
222
223 ifeq ($(ARCH),armv7)
224         arch = armv7
225         prefetch = yes
226         bits = 32
227 endif
228
229 ifeq ($(ARCH),armv8)
230         arch = armv8-a
231         prefetch = yes
232         popcnt = yes
233         neon = yes
234 endif
235
236 ifeq ($(ARCH),apple-silicon)
237         arch = arm64
238         prefetch = yes
239         popcnt = yes
240         neon = yes
241 endif
242
243 ifeq ($(ARCH),ppc-32)
244         arch = ppc
245         bits = 32
246 endif
247
248 ifeq ($(ARCH),ppc-64)
249         arch = ppc64
250         popcnt = yes
251         prefetch = yes
252 endif
253
254 ### ==========================================================================
255 ### Section 3. Low-level Configuration
256 ### ==========================================================================
257
258 ### 3.1 Selecting compiler (default = gcc)
259 CXXFLAGS += -Wall -Wcast-qual -fno-exceptions -std=c++17 $(EXTRACXXFLAGS)
260 DEPENDFLAGS += -std=c++17
261 LDFLAGS += $(EXTRALDFLAGS)
262
263 ifeq ($(COMP),)
264         COMP=gcc
265 endif
266
267 ifeq ($(COMP),gcc)
268         comp=gcc
269         CXX=g++
270         CXXFLAGS += -pedantic -Wextra -Wshadow
271
272         ifeq ($(ARCH),$(filter $(ARCH),armv7 armv8))
273                 ifeq ($(OS),Android)
274                         CXXFLAGS += -m$(bits)
275                         LDFLAGS += -m$(bits)
276                 endif
277         else
278                 CXXFLAGS += -m$(bits)
279                 LDFLAGS += -m$(bits)
280         endif
281
282         ifneq ($(KERNEL),Darwin)
283            LDFLAGS += -Wl,--no-as-needed
284         endif
285         
286         gccversion = $(shell $(CXX) --version)
287         gccisclang = $(findstring clang,$(gccversion))
288 endif
289
290 ifeq ($(COMP),mingw)
291         comp=mingw
292
293         ifeq ($(KERNEL),Linux)
294                 ifeq ($(bits),64)
295                         ifeq ($(shell which x86_64-w64-mingw32-c++-posix),)
296                                 CXX=x86_64-w64-mingw32-c++
297                         else
298                                 CXX=x86_64-w64-mingw32-c++-posix
299                         endif
300                 else
301                         ifeq ($(shell which i686-w64-mingw32-c++-posix),)
302                                 CXX=i686-w64-mingw32-c++
303                         else
304                                 CXX=i686-w64-mingw32-c++-posix
305                         endif
306                 endif
307         else
308                 CXX=g++
309         endif
310
311         CXXFLAGS += -Wextra -Wshadow
312         LDFLAGS += -static
313 endif
314
315 ifeq ($(COMP),icc)
316         comp=icc
317         CXX=icpc
318         CXXFLAGS += -diag-disable 1476,10120 -Wcheck -Wabi -Wdeprecated -strict-ansi
319 endif
320
321 ifeq ($(COMP),clang)
322         comp=clang
323         CXX=clang++
324         CXXFLAGS += -pedantic -Wextra -Wshadow
325
326         ifneq ($(KERNEL),Darwin)
327         ifneq ($(KERNEL),OpenBSD)
328                 LDFLAGS += -latomic
329         endif
330         endif
331
332         ifeq ($(ARCH),$(filter $(ARCH),armv7 armv8))
333                 ifeq ($(OS),Android)
334                         CXXFLAGS += -m$(bits)
335                         LDFLAGS += -m$(bits)
336                 endif
337         else
338                 CXXFLAGS += -m$(bits)
339                 LDFLAGS += -m$(bits)
340         endif
341 endif
342
343 ifeq ($(comp),icc)
344         profile_make = icc-profile-make
345         profile_use = icc-profile-use
346 else
347 ifeq ($(comp),clang)
348         profile_make = clang-profile-make
349         profile_use = clang-profile-use
350 else
351         profile_make = gcc-profile-make
352         profile_use = gcc-profile-use
353 endif
354 endif
355
356 ifeq ($(KERNEL),Darwin)
357         CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.15
358         LDFLAGS += -arch $(arch) -mmacosx-version-min=10.15
359 endif
360
361 ### Travis CI script uses COMPILER to overwrite CXX
362 ifdef COMPILER
363         COMPCXX=$(COMPILER)
364 endif
365
366 ### Allow overwriting CXX from command line
367 ifdef COMPCXX
368         CXX=$(COMPCXX)
369 endif
370
371 ### On mingw use Windows threads, otherwise POSIX
372 ifneq ($(comp),mingw)
373         # On Android Bionic's C library comes with its own pthread implementation bundled in
374         ifneq ($(OS),Android)
375                 # Haiku has pthreads in its libroot, so only link it in on other platforms
376                 ifneq ($(KERNEL),Haiku)
377                         LDFLAGS += -lpthread
378                 endif
379         endif
380 endif
381
382 ### 3.2.1 Debugging
383 ifeq ($(debug),no)
384         CXXFLAGS += -DNDEBUG
385 else
386         CXXFLAGS += -g
387 endif
388
389 ### 3.2.2 Debugging with undefined behavior sanitizers
390 ifneq ($(sanitize),no)
391         CXXFLAGS += -g3 -fsanitize=$(sanitize)
392         LDFLAGS += -fsanitize=$(sanitize)
393 endif
394
395 ### 3.3 Optimization
396 ifeq ($(optimize),yes)
397
398         CXXFLAGS += -O3
399
400         ifeq ($(comp),gcc)
401                 ifeq ($(OS), Android)
402                         CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp
403                 endif
404         endif
405
406         ifeq ($(comp),$(filter $(comp),gcc clang icc))
407                 ifeq ($(KERNEL),Darwin)
408                         CXXFLAGS += -mdynamic-no-pic
409                 endif
410         endif
411 endif
412
413 ### 3.4 Bits
414 ifeq ($(bits),64)
415         CXXFLAGS += -DIS_64BIT
416 endif
417
418 ### 3.5 prefetch
419 ifeq ($(prefetch),yes)
420         ifeq ($(sse),yes)
421                 CXXFLAGS += -msse
422                 DEPENDFLAGS += -msse
423         endif
424 else
425         CXXFLAGS += -DNO_PREFETCH
426 endif
427
428 ### 3.6 popcnt
429 ifeq ($(popcnt),yes)
430         ifeq ($(arch),$(filter $(arch),ppc64 armv8-a arm64))
431                 CXXFLAGS += -DUSE_POPCNT
432         else ifeq ($(comp),icc)
433                 CXXFLAGS += -msse3 -DUSE_POPCNT
434         else
435                 CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT
436         endif
437 endif
438
439 ifeq ($(avx2),yes)
440         CXXFLAGS += -DUSE_AVX2
441         ifeq ($(comp),$(filter $(comp),gcc clang mingw))
442                 CXXFLAGS += -mavx2
443         endif
444 endif
445
446 ifeq ($(avx512),yes)
447         CXXFLAGS += -DUSE_AVX512
448         ifeq ($(comp),$(filter $(comp),gcc clang mingw))
449                 CXXFLAGS += -mavx512bw
450         endif
451 endif
452
453 ifeq ($(sse42),yes)
454         CXXFLAGS += -DUSE_SSE42
455         ifeq ($(comp),$(filter $(comp),gcc clang mingw))
456                 CXXFLAGS += -msse4.2
457         endif
458 endif
459
460 ifeq ($(sse41),yes)
461         CXXFLAGS += -DUSE_SSE41
462         ifeq ($(comp),$(filter $(comp),gcc clang mingw))
463                 CXXFLAGS += -msse4.1
464         endif
465 endif
466
467 ifeq ($(ssse3),yes)
468         CXXFLAGS += -DUSE_SSSE3
469         ifeq ($(comp),$(filter $(comp),gcc clang mingw))
470                 CXXFLAGS += -mssse3
471         endif
472 endif
473
474 ifeq ($(sse3),yes)
475         CXXFLAGS += -DUSE_SSE3
476         ifeq ($(comp),$(filter $(comp),gcc clang mingw))
477                 CXXFLAGS += -msse3
478         endif
479 endif
480
481 ifeq ($(neon),yes)
482         CXXFLAGS += -DUSE_NEON
483 endif
484
485 ifeq ($(arch),x86_64)
486         CXXFLAGS += -DUSE_SSE2
487 endif
488
489 ### 3.7 pext
490 ifeq ($(pext),yes)
491         CXXFLAGS += -DUSE_PEXT
492         ifeq ($(comp),$(filter $(comp),gcc clang mingw))
493                 CXXFLAGS += -mbmi2
494         endif
495 endif
496
497 ### 3.8 Link Time Optimization
498 ### This is a mix of compile and link time options because the lto link phase
499 ### needs access to the optimization flags.
500 ifeq ($(optimize),yes)
501 ifeq ($(debug), no)
502         ifeq ($(comp),clang)
503                 CXXFLAGS += -flto=thin
504                 LDFLAGS += $(CXXFLAGS)
505
506 # GCC and CLANG use different methods for parallelizing LTO and CLANG pretends to be
507 # GCC on some systems.
508         else ifeq ($(comp),gcc)
509         ifeq ($(gccisclang),)
510                 CXXFLAGS += -flto
511                 LDFLAGS += $(CXXFLAGS) -flto=jobserver
512         else
513                 CXXFLAGS += -flto=thin
514                 LDFLAGS += $(CXXFLAGS)
515         endif
516
517 # To use LTO and static linking on windows, the tool chain requires a recent gcc:
518 # gcc version 10.1 in msys2 or TDM-GCC version 9.2 are know to work, older might not.
519 # So, only enable it for a cross from Linux by default.
520         else ifeq ($(comp),mingw)
521         ifeq ($(KERNEL),Linux)
522                 CXXFLAGS += -flto
523                 LDFLAGS += $(CXXFLAGS) -flto=jobserver
524         endif
525         endif
526 endif
527 endif
528
529 ### 3.9 Android 5 can only run position independent executables. Note that this
530 ### breaks Android 4.0 and earlier.
531 ifeq ($(OS), Android)
532         CXXFLAGS += -fPIE
533         LDFLAGS += -fPIE -pie
534 endif
535
536 ### ==========================================================================
537 ### Section 4. Public Targets
538 ### ==========================================================================
539
540 help:
541         @echo ""
542         @echo "To compile stockfish, type: "
543         @echo ""
544         @echo "make target ARCH=arch [COMP=compiler] [COMPCXX=cxx]"
545         @echo ""
546         @echo "Supported targets:"
547         @echo ""
548         @echo "build                   > Standard build"
549         @echo "profile-build           > Standard build with PGO"
550         @echo "strip                   > Strip executable"
551         @echo "install                 > Install executable"
552         @echo "clean                   > Clean up"
553         @echo "net                     > Download the default nnue net"
554         @echo ""
555         @echo "Supported archs:"
556         @echo ""
557         @echo "x86-64-avx512           > x86 64-bit with avx512 support"
558         @echo "x86-64-bmi2             > x86 64-bit with bmi2 support"
559         @echo "x86-64-avx2             > x86 64-bit with avx2 support"
560         @echo "x86-64-sse42            > x86 64-bit with sse42 support"
561         @echo "x86-64-modern           > x86 64-bit with sse41 support (x86-64-sse41)"
562         @echo "x86-64-sse41            > x86 64-bit with sse41 support"
563         @echo "x86-64-ssse3            > x86 64-bit with ssse3 support"
564         @echo "x86-64-sse3-popcnt      > x86 64-bit with sse3 and popcnt support"
565         @echo "x86-64-sse3             > x86 64-bit with sse3 support"
566         @echo "x86-64                  > x86 64-bit generic"
567         @echo "x86-32                  > x86 32-bit (also enables SSE)"
568         @echo "x86-32-old              > x86 32-bit fall back for old hardware"
569         @echo "ppc-64                  > PPC 64-bit"
570         @echo "ppc-32                  > PPC 32-bit"
571         @echo "armv7                   > ARMv7 32-bit"
572         @echo "armv8                   > ARMv8 64-bit"
573         @echo "apple-silicon           > Apple silicon ARM64"
574         @echo "general-64              > unspecified 64-bit"
575         @echo "general-32              > unspecified 32-bit"
576         @echo ""
577         @echo "Supported compilers:"
578         @echo ""
579         @echo "gcc                     > Gnu compiler (default)"
580         @echo "mingw                   > Gnu compiler with MinGW under Windows"
581         @echo "clang                   > LLVM Clang compiler"
582         @echo "icc                     > Intel compiler"
583         @echo ""
584         @echo "Simple examples. If you don't know what to do, you likely want to run: "
585         @echo ""
586         @echo "make -j build ARCH=x86-64    (This is for 64-bit systems)"
587         @echo "make -j build ARCH=x86-32    (This is for 32-bit systems)"
588         @echo ""
589         @echo "Advanced examples, for experienced users: "
590         @echo ""
591         @echo "make -j build ARCH=x86-64-modern COMP=clang"
592         @echo "make -j profile-build ARCH=x86-64-bmi2 COMP=gcc COMPCXX=g++-4.8"
593         @echo ""
594         @echo "The selected architecture $(ARCH) enables the following configuration: "
595         @echo ""
596         @$(MAKE) ARCH=$(ARCH) COMP=$(COMP) config-sanity
597
598
599 .PHONY: help build profile-build strip install clean net objclean profileclean \
600         config-sanity icc-profile-use icc-profile-make gcc-profile-use gcc-profile-make \
601         clang-profile-use clang-profile-make
602
603 build: config-sanity
604         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all
605
606 profile-build: config-sanity objclean profileclean
607         @echo ""
608         @echo "Step 1/4. Building instrumented executable ..."
609         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make)
610         @echo ""
611         @echo "Step 2/4. Running benchmark for pgo-build ..."
612         $(PGOBENCH) > /dev/null
613         @echo ""
614         @echo "Step 3/4. Building optimized executable ..."
615         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean
616         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use)
617         @echo ""
618         @echo "Step 4/4. Deleting profile data ..."
619         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean
620
621 strip:
622         strip $(EXE)
623
624 install:
625         -mkdir -p -m 755 $(BINDIR)
626         -cp $(EXE) $(BINDIR)
627         -strip $(BINDIR)/$(EXE)
628
629 #clean all
630 clean: objclean profileclean
631         @rm -f .depend *~ core
632
633 net:
634         $(eval nnuenet := $(shell grep EvalFile ucioption.cpp | grep Option | sed 's/.*\(nn-[a-z0-9]\{12\}.nnue\).*/\1/'))
635         @echo "Default net: $(nnuenet)"
636         $(eval nnuedownloadurl := https://tests.stockfishchess.org/api/nn/$(nnuenet))
637         $(eval curl_or_wget := $(shell if hash curl 2>/dev/null; then echo "curl -sL"; elif hash wget 2>/dev/null; then echo "wget -qO-"; fi))
638         @if test -f "$(nnuenet)"; then echo "Already available."; else echo "Downloading $(nnuedownloadurl)"; $(curl_or_wget) $(nnuedownloadurl) > $(nnuenet); fi
639
640 # clean binaries and objects
641 objclean:
642         @rm -f $(EXE) *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o
643
644 # clean auxiliary profiling files
645 profileclean:
646         @rm -rf profdir
647         @rm -f bench.txt *.gcda *.gcno ./syzygy/*.gcda ./nnue/*.gcda ./nnue/features/*.gcda
648         @rm -f stockfish.profdata *.profraw
649
650 default:
651         help
652
653 ### ==========================================================================
654 ### Section 5. Private Targets
655 ### ==========================================================================
656
657 all: $(EXE) .depend
658
659 config-sanity:
660         @echo ""
661         @echo "Config:"
662         @echo "debug: '$(debug)'"
663         @echo "sanitize: '$(sanitize)'"
664         @echo "optimize: '$(optimize)'"
665         @echo "arch: '$(arch)'"
666         @echo "bits: '$(bits)'"
667         @echo "kernel: '$(KERNEL)'"
668         @echo "os: '$(OS)'"
669         @echo "prefetch: '$(prefetch)'"
670         @echo "popcnt: '$(popcnt)'"
671         @echo "sse: '$(sse)'"
672         @echo "sse3: '$(sse3)'"
673         @echo "ssse3: '$(ssse3)'"
674         @echo "sse41: '$(sse41)'"
675         @echo "sse42: '$(sse42)'"
676         @echo "avx2: '$(avx2)'"
677         @echo "pext: '$(pext)'"
678         @echo "avx512: '$(avx512)'"
679         @echo "neon: '$(neon)'"
680         @echo ""
681         @echo "Flags:"
682         @echo "CXX: $(CXX)"
683         @echo "CXXFLAGS: $(CXXFLAGS)"
684         @echo "LDFLAGS: $(LDFLAGS)"
685         @echo ""
686         @echo "Testing config sanity. If this fails, try 'make help' ..."
687         @echo ""
688         @test "$(debug)" = "yes" || test "$(debug)" = "no"
689         @test "$(sanitize)" = "undefined" || test "$(sanitize)" = "thread" || test "$(sanitize)" = "address" || test "$(sanitize)" = "no"
690         @test "$(optimize)" = "yes" || test "$(optimize)" = "no"
691         @test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \
692          test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || \
693          test "$(arch)" = "armv7" || test "$(arch)" = "armv8-a" || test "$(arch)" = "arm64"
694         @test "$(bits)" = "32" || test "$(bits)" = "64"
695         @test "$(prefetch)" = "yes" || test "$(prefetch)" = "no"
696         @test "$(popcnt)" = "yes" || test "$(popcnt)" = "no"
697         @test "$(sse)" = "yes" || test "$(sse)" = "no"
698         @test "$(sse3)" = "yes" || test "$(sse3)" = "no"
699         @test "$(ssse3)" = "yes" || test "$(ssse3)" = "no"
700         @test "$(sse41)" = "yes" || test "$(sse41)" = "no"
701         @test "$(sse42)" = "yes" || test "$(sse42)" = "no"
702         @test "$(avx2)" = "yes" || test "$(avx2)" = "no"
703         @test "$(pext)" = "yes" || test "$(pext)" = "no"
704         @test "$(avx512)" = "yes" || test "$(avx512)" = "no"
705         @test "$(neon)" = "yes" || test "$(neon)" = "no"
706         @test "$(comp)" = "gcc" || test "$(comp)" = "icc" || test "$(comp)" = "mingw" || test "$(comp)" = "clang"
707
708 $(EXE): $(OBJS)
709         +$(CXX) -o $@ $(OBJS) $(LDFLAGS)
710
711 clang-profile-make:
712         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
713         EXTRACXXFLAGS='-fprofile-instr-generate ' \
714         EXTRALDFLAGS=' -fprofile-instr-generate' \
715         all
716
717 clang-profile-use:
718         llvm-profdata merge -output=stockfish.profdata *.profraw
719         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
720         EXTRACXXFLAGS='-fprofile-instr-use=stockfish.profdata' \
721         EXTRALDFLAGS='-fprofile-use ' \
722         all
723
724 gcc-profile-make:
725         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
726         EXTRACXXFLAGS='-fprofile-generate' \
727         EXTRALDFLAGS='-lgcov' \
728         all
729
730 gcc-profile-use:
731         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
732         EXTRACXXFLAGS='-fprofile-use -fno-peel-loops -fno-tracer' \
733         EXTRALDFLAGS='-lgcov' \
734         all
735
736 icc-profile-make:
737         @mkdir -p profdir
738         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
739         EXTRACXXFLAGS='-prof-gen=srcpos -prof_dir ./profdir' \
740         all
741
742 icc-profile-use:
743         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
744         EXTRACXXFLAGS='-prof_use -prof_dir ./profdir' \
745         all
746
747 .depend:
748         -@$(CXX) $(DEPENDFLAGS) -MM $(SRCS) > $@ 2> /dev/null
749
750 -include .depend