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