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