]> git.sesse.net Git - stockfish/blob - src/Makefile
Tuned pawn values
[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 endif
286
287 ifeq ($(COMP),mingw)
288         comp=mingw
289
290         ifeq ($(KERNEL),Linux)
291                 ifeq ($(bits),64)
292                         ifeq ($(shell which x86_64-w64-mingw32-c++-posix),)
293                                 CXX=x86_64-w64-mingw32-c++
294                         else
295                                 CXX=x86_64-w64-mingw32-c++-posix
296                         endif
297                 else
298                         ifeq ($(shell which i686-w64-mingw32-c++-posix),)
299                                 CXX=i686-w64-mingw32-c++
300                         else
301                                 CXX=i686-w64-mingw32-c++-posix
302                         endif
303                 endif
304         else
305                 CXX=g++
306         endif
307
308         CXXFLAGS += -Wextra -Wshadow
309         LDFLAGS += -static
310 endif
311
312 ifeq ($(COMP),icc)
313         comp=icc
314         CXX=icpc
315         CXXFLAGS += -diag-disable 1476,10120 -Wcheck -Wabi -Wdeprecated -strict-ansi
316 endif
317
318 ifeq ($(COMP),clang)
319         comp=clang
320         CXX=clang++
321         CXXFLAGS += -pedantic -Wextra -Wshadow
322
323         ifneq ($(KERNEL),Darwin)
324         ifneq ($(KERNEL),OpenBSD)
325                 LDFLAGS += -latomic
326         endif
327         endif
328
329         ifeq ($(ARCH),$(filter $(ARCH),armv7 armv8))
330                 ifeq ($(OS),Android)
331                         CXXFLAGS += -m$(bits)
332                         LDFLAGS += -m$(bits)
333                 endif
334         else
335                 CXXFLAGS += -m$(bits)
336                 LDFLAGS += -m$(bits)
337         endif
338 endif
339
340 ifeq ($(comp),icc)
341         profile_make = icc-profile-make
342         profile_use = icc-profile-use
343 else
344 ifeq ($(comp),clang)
345         profile_make = clang-profile-make
346         profile_use = clang-profile-use
347 else
348         profile_make = gcc-profile-make
349         profile_use = gcc-profile-use
350 endif
351 endif
352
353 ifeq ($(KERNEL),Darwin)
354         CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.15
355         LDFLAGS += -arch $(arch) -mmacosx-version-min=10.15
356 endif
357
358 ### Travis CI script uses COMPILER to overwrite CXX
359 ifdef COMPILER
360         COMPCXX=$(COMPILER)
361 endif
362
363 ### Allow overwriting CXX from command line
364 ifdef COMPCXX
365         CXX=$(COMPCXX)
366 endif
367
368 ### On mingw use Windows threads, otherwise POSIX
369 ifneq ($(comp),mingw)
370         # On Android Bionic's C library comes with its own pthread implementation bundled in
371         ifneq ($(OS),Android)
372                 # Haiku has pthreads in its libroot, so only link it in on other platforms
373                 ifneq ($(KERNEL),Haiku)
374                         LDFLAGS += -lpthread
375                 endif
376         endif
377 endif
378
379 ### 3.2.1 Debugging
380 ifeq ($(debug),no)
381         CXXFLAGS += -DNDEBUG
382 else
383         CXXFLAGS += -g
384 endif
385
386 ### 3.2.2 Debugging with undefined behavior sanitizers
387 ifneq ($(sanitize),no)
388         CXXFLAGS += -g3 -fsanitize=$(sanitize)
389         LDFLAGS += -fsanitize=$(sanitize)
390 endif
391
392 ### 3.3 Optimization
393 ifeq ($(optimize),yes)
394
395         CXXFLAGS += -O3
396
397         ifeq ($(comp),gcc)
398                 ifeq ($(OS), Android)
399                         CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp
400                 endif
401         endif
402
403         ifeq ($(comp),$(filter $(comp),gcc clang icc))
404                 ifeq ($(KERNEL),Darwin)
405                         CXXFLAGS += -mdynamic-no-pic
406                 endif
407         endif
408 endif
409
410 ### 3.4 Bits
411 ifeq ($(bits),64)
412         CXXFLAGS += -DIS_64BIT
413 endif
414
415 ### 3.5 prefetch
416 ifeq ($(prefetch),yes)
417         ifeq ($(sse),yes)
418                 CXXFLAGS += -msse
419                 DEPENDFLAGS += -msse
420         endif
421 else
422         CXXFLAGS += -DNO_PREFETCH
423 endif
424
425 ### 3.6 popcnt
426 ifeq ($(popcnt),yes)
427         ifeq ($(arch),$(filter $(arch),ppc64 armv8-a arm64))
428                 CXXFLAGS += -DUSE_POPCNT
429         else ifeq ($(comp),icc)
430                 CXXFLAGS += -msse3 -DUSE_POPCNT
431         else
432                 CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT
433         endif
434 endif
435
436 ifeq ($(avx2),yes)
437         CXXFLAGS += -DUSE_AVX2
438         ifeq ($(comp),$(filter $(comp),gcc clang mingw))
439                 CXXFLAGS += -mavx2
440         endif
441 endif
442
443 ifeq ($(avx512),yes)
444         CXXFLAGS += -DUSE_AVX512
445         ifeq ($(comp),$(filter $(comp),gcc clang mingw))
446                 CXXFLAGS += -mavx512bw
447         endif
448 endif
449
450 ifeq ($(sse42),yes)
451         CXXFLAGS += -DUSE_SSE42
452         ifeq ($(comp),$(filter $(comp),gcc clang mingw))
453                 CXXFLAGS += -msse4.2
454         endif
455 endif
456
457 ifeq ($(sse41),yes)
458         CXXFLAGS += -DUSE_SSE41
459         ifeq ($(comp),$(filter $(comp),gcc clang mingw))
460                 CXXFLAGS += -msse4.1
461         endif
462 endif
463
464 ifeq ($(ssse3),yes)
465         CXXFLAGS += -DUSE_SSSE3
466         ifeq ($(comp),$(filter $(comp),gcc clang mingw))
467                 CXXFLAGS += -mssse3
468         endif
469 endif
470
471 ifeq ($(sse3),yes)
472         CXXFLAGS += -DUSE_SSE3
473         ifeq ($(comp),$(filter $(comp),gcc clang mingw))
474                 CXXFLAGS += -msse3
475         endif
476 endif
477
478 ifeq ($(neon),yes)
479         CXXFLAGS += -DUSE_NEON
480 endif
481
482 ifeq ($(arch),x86_64)
483         CXXFLAGS += -DUSE_SSE2
484 endif
485
486 ### 3.7 pext
487 ifeq ($(pext),yes)
488         CXXFLAGS += -DUSE_PEXT
489         ifeq ($(comp),$(filter $(comp),gcc clang mingw))
490                 CXXFLAGS += -mbmi2
491         endif
492 endif
493
494 ### 3.8 Link Time Optimization
495 ### This is a mix of compile and link time options because the lto link phase
496 ### needs access to the optimization flags.
497 ifeq ($(optimize),yes)
498 ifeq ($(debug), no)
499         ifeq ($(comp),$(filter $(comp),gcc clang))
500                 CXXFLAGS += -flto
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         ifeq ($(comp),mingw)
508         ifeq ($(KERNEL),Linux)
509                 CXXFLAGS += -flto
510                 LDFLAGS += $(CXXFLAGS)
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 "build                   > Standard build"
536         @echo "profile-build           > Standard build with PGO"
537         @echo "strip                   > Strip executable"
538         @echo "install                 > Install executable"
539         @echo "clean                   > Clean up"
540         @echo "net                     > Download the default nnue net"
541         @echo ""
542         @echo "Supported archs:"
543         @echo ""
544         @echo "x86-64-avx512           > x86 64-bit with avx512 support"
545         @echo "x86-64-bmi2             > x86 64-bit with bmi2 support"
546         @echo "x86-64-avx2             > x86 64-bit with avx2 support"
547         @echo "x86-64-sse42            > x86 64-bit with sse42 support"
548         @echo "x86-64-modern           > x86 64-bit with sse41 support (x86-64-sse41)"
549         @echo "x86-64-sse41            > x86 64-bit with sse41 support"
550         @echo "x86-64-ssse3            > x86 64-bit with ssse3 support"
551         @echo "x86-64-sse3-popcnt      > x86 64-bit with sse3 and popcnt support"
552         @echo "x86-64-sse3             > x86 64-bit with sse3 support"
553         @echo "x86-64                  > x86 64-bit generic"
554         @echo "x86-32                  > x86 32-bit (also enables 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    (This is for 64-bit systems)"
574         @echo "make -j build ARCH=x86-32    (This is for 32-bit systems)"
575         @echo ""
576         @echo "Advanced examples, for experienced users: "
577         @echo ""
578         @echo "make -j build ARCH=x86-64-modern COMP=clang"
579         @echo "make -j profile-build ARCH=x86-64-bmi2 COMP=gcc COMPCXX=g++-4.8"
580         @echo ""
581         @echo "The selected architecture $(ARCH) enables the following configuration: "
582         @echo ""
583         @$(MAKE) ARCH=$(ARCH) COMP=$(COMP) config-sanity
584
585
586 .PHONY: help build profile-build strip install clean net objclean profileclean \
587         config-sanity icc-profile-use icc-profile-make gcc-profile-use gcc-profile-make \
588         clang-profile-use clang-profile-make
589
590 build: config-sanity
591         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all
592
593 profile-build: config-sanity objclean profileclean
594         @echo ""
595         @echo "Step 1/4. Building instrumented executable ..."
596         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make)
597         @echo ""
598         @echo "Step 2/4. Running benchmark for pgo-build ..."
599         $(PGOBENCH) > /dev/null
600         @echo ""
601         @echo "Step 3/4. Building optimized executable ..."
602         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean
603         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use)
604         @echo ""
605         @echo "Step 4/4. Deleting profile data ..."
606         $(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean
607
608 strip:
609         strip $(EXE)
610
611 install:
612         -mkdir -p -m 755 $(BINDIR)
613         -cp $(EXE) $(BINDIR)
614         -strip $(BINDIR)/$(EXE)
615
616 #clean all
617 clean: objclean profileclean
618         @rm -f .depend *~ core
619
620 net:
621         $(eval nnuenet := $(shell grep EvalFile ucioption.cpp | grep Option | sed 's/.*\(nn-[a-z0-9]\{12\}.nnue\).*/\1/'))
622         @echo "Default net: $(nnuenet)"
623         $(eval nnuedownloadurl := https://tests.stockfishchess.org/api/nn/$(nnuenet))
624         $(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))
625         @if test -f "$(nnuenet)"; then echo "Already available."; else echo "Downloading $(nnuedownloadurl)"; $(curl_or_wget) $(nnuedownloadurl) > $(nnuenet); fi
626
627 # clean binaries and objects
628 objclean:
629         @rm -f $(EXE) *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o
630
631 # clean auxiliary profiling files
632 profileclean:
633         @rm -rf profdir
634         @rm -f bench.txt *.gcda *.gcno ./syzygy/*.gcda ./nnue/*.gcda ./nnue/features/*.gcda
635         @rm -f stockfish.profdata *.profraw
636
637 default:
638         help
639
640 ### ==========================================================================
641 ### Section 5. Private Targets
642 ### ==========================================================================
643
644 all: $(EXE) .depend
645
646 config-sanity:
647         @echo ""
648         @echo "Config:"
649         @echo "debug: '$(debug)'"
650         @echo "sanitize: '$(sanitize)'"
651         @echo "optimize: '$(optimize)'"
652         @echo "arch: '$(arch)'"
653         @echo "bits: '$(bits)'"
654         @echo "kernel: '$(KERNEL)'"
655         @echo "os: '$(OS)'"
656         @echo "prefetch: '$(prefetch)'"
657         @echo "popcnt: '$(popcnt)'"
658         @echo "sse: '$(sse)'"
659         @echo "sse3: '$(sse3)'"
660         @echo "ssse3: '$(ssse3)'"
661         @echo "sse41: '$(sse41)'"
662         @echo "sse42: '$(sse42)'"
663         @echo "avx2: '$(avx2)'"
664         @echo "pext: '$(pext)'"
665         @echo "avx512: '$(avx512)'"
666         @echo "neon: '$(neon)'"
667         @echo ""
668         @echo "Flags:"
669         @echo "CXX: $(CXX)"
670         @echo "CXXFLAGS: $(CXXFLAGS)"
671         @echo "LDFLAGS: $(LDFLAGS)"
672         @echo ""
673         @echo "Testing config sanity. If this fails, try 'make help' ..."
674         @echo ""
675         @test "$(debug)" = "yes" || test "$(debug)" = "no"
676         @test "$(sanitize)" = "undefined" || test "$(sanitize)" = "thread" || test "$(sanitize)" = "address" || test "$(sanitize)" = "no"
677         @test "$(optimize)" = "yes" || test "$(optimize)" = "no"
678         @test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \
679          test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || \
680          test "$(arch)" = "armv7" || test "$(arch)" = "armv8-a" || test "$(arch)" = "arm64"
681         @test "$(bits)" = "32" || test "$(bits)" = "64"
682         @test "$(prefetch)" = "yes" || test "$(prefetch)" = "no"
683         @test "$(popcnt)" = "yes" || test "$(popcnt)" = "no"
684         @test "$(sse)" = "yes" || test "$(sse)" = "no"
685         @test "$(sse3)" = "yes" || test "$(sse3)" = "no"
686         @test "$(ssse3)" = "yes" || test "$(ssse3)" = "no"
687         @test "$(sse41)" = "yes" || test "$(sse41)" = "no"
688         @test "$(sse42)" = "yes" || test "$(sse42)" = "no"
689         @test "$(avx2)" = "yes" || test "$(avx2)" = "no"
690         @test "$(pext)" = "yes" || test "$(pext)" = "no"
691         @test "$(avx512)" = "yes" || test "$(avx512)" = "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