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