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