1 # Stockfish, a UCI chess playing engine derived from Glaurung 2.1
2 # Copyright (C) 2004-2023 The Stockfish developers (see AUTHORS file)
4 # Stockfish is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # Stockfish is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 ### ==========================================================================
19 ### Section 1. General Configuration
20 ### ==========================================================================
22 ### Establish the operating system name
23 KERNEL = $(shell uname -s)
24 ifeq ($(KERNEL),Linux)
25 OS = $(shell uname -o)
29 ifeq ($(OS),Windows_NT)
33 else ifeq ($(COMP),mingw)
36 WINE_PATH = $(shell which wine)
41 ifeq ($(target_windows),yes)
47 ### Installation dir definitions
49 BINDIR = $(PREFIX)/bin
51 ### Built-in benchmark for pgo-builds
53 PGOBENCH = $(WINE_PATH) ./$(EXE) bench
55 PGOBENCH = $(SDE_PATH) -- $(WINE_PATH) ./$(EXE) bench
58 ### Source and object files
59 SRCS = benchmark.cpp bitbase.cpp bitboard.cpp endgame.cpp evaluate.cpp main.cpp \
60 material.cpp misc.cpp movegen.cpp movepick.cpp pawns.cpp position.cpp psqt.cpp \
61 search.cpp thread.cpp timeman.cpp tt.cpp uci.cpp ucioption.cpp tune.cpp syzygy/tbprobe.cpp \
62 nnue/evaluate_nnue.cpp nnue/features/half_ka_v2_hm.cpp
64 OBJS = $(notdir $(SRCS:.cpp=.o))
66 VPATH = syzygy:nnue:nnue/features
68 ### ==========================================================================
69 ### Section 2. High-level Configuration
70 ### ==========================================================================
72 # flag --- Comp switch --- Description
73 # ----------------------------------------------------------------------------
75 # debug = yes/no --- -DNDEBUG --- Enable/Disable debug mode
76 # sanitize = none/<sanitizer> ... (-fsanitize )
77 # --- ( undefined ) --- enable undefined behavior checks
78 # --- ( thread ) --- enable threading error checks
79 # --- ( address ) --- enable memory access checks
80 # --- ...etc... --- see compiler documentation for supported sanitizers
81 # optimize = yes/no --- (-O3/-fast etc.) --- Enable/Disable optimizations
82 # arch = (name) --- (-arch) --- Target architecture
83 # bits = 64/32 --- -DIS_64BIT --- 64-/32-bit operating system
84 # prefetch = yes/no --- -DUSE_PREFETCH --- Use prefetch asm-instruction
85 # popcnt = yes/no --- -DUSE_POPCNT --- Use popcnt asm-instruction
86 # pext = yes/no --- -DUSE_PEXT --- Use pext x86_64 asm-instruction
87 # sse = yes/no --- -msse --- Use Intel Streaming SIMD Extensions
88 # mmx = yes/no --- -mmmx --- Use Intel MMX instructions
89 # sse2 = yes/no --- -msse2 --- Use Intel Streaming SIMD Extensions 2
90 # ssse3 = yes/no --- -mssse3 --- Use Intel Supplemental Streaming SIMD Extensions 3
91 # sse41 = yes/no --- -msse4.1 --- Use Intel Streaming SIMD Extensions 4.1
92 # avx2 = yes/no --- -mavx2 --- Use Intel Advanced Vector Extensions 2
93 # avxvnni = yes/no --- -mavxvnni --- Use Intel Vector Neural Network Instructions AVX
94 # avx512 = yes/no --- -mavx512bw --- Use Intel Advanced Vector Extensions 512
95 # vnni256 = yes/no --- -mavx256vnni --- Use Intel Vector Neural Network Instructions 512 with 256bit operands
96 # vnni512 = yes/no --- -mavx512vnni --- Use Intel Vector Neural Network Instructions 512
97 # neon = yes/no --- -DUSE_NEON --- Use ARM SIMD architecture
98 # dotprod = yes/no --- -DUSE_NEON_DOTPROD --- Use ARM advanced SIMD Int8 dot product instructions
100 # Note that Makefile is space sensitive, so when adding new architectures
101 # or modifying existing flags, you have to make sure there are no extra spaces
102 # at the end of the line for flag values.
104 # Example of use for these flags:
105 # make build ARCH=x86-64-avx512 debug=yes sanitize="address undefined"
108 ### 2.1. General and architecture defaults
112 help_skip_sanity = yes
114 # explicitly check for the list of supported architectures (as listed with make help),
115 # the user can override with `make ARCH=x86-32-vnni256 SUPPORTED_ARCH=true`
116 ifeq ($(ARCH), $(filter $(ARCH), \
117 x86-64-vnni512 x86-64-vnni256 x86-64-avx512 x86-64-avxvnni x86-64-bmi2 \
118 x86-64-avx2 x86-64-sse41-popcnt x86-64-modern x86-64-ssse3 x86-64-sse3-popcnt \
119 x86-64 x86-32-sse41-popcnt x86-32-sse2 x86-32 ppc-64 ppc-32 e2k \
120 armv7 armv7-neon armv8 armv8-dotprod apple-silicon general-64 general-32 riscv64))
148 ### 2.2 Architecture specific
150 ifeq ($(findstring x86,$(ARCH)),x86)
154 ifeq ($(findstring x86-32,$(ARCH)),x86-32)
165 ifeq ($(findstring -sse,$(ARCH)),-sse)
169 ifeq ($(findstring -popcnt,$(ARCH)),-popcnt)
173 ifeq ($(findstring -mmx,$(ARCH)),-mmx)
177 ifeq ($(findstring -sse2,$(ARCH)),-sse2)
182 ifeq ($(findstring -ssse3,$(ARCH)),-ssse3)
188 ifeq ($(findstring -sse41,$(ARCH)),-sse41)
195 ifeq ($(findstring -modern,$(ARCH)),-modern)
203 ifeq ($(findstring -avx2,$(ARCH)),-avx2)
212 ifeq ($(findstring -avxvnni,$(ARCH)),-avxvnni)
223 ifeq ($(findstring -bmi2,$(ARCH)),-bmi2)
233 ifeq ($(findstring -avx512,$(ARCH)),-avx512)
244 ifeq ($(findstring -vnni256,$(ARCH)),-vnni256)
255 ifeq ($(findstring -vnni512,$(ARCH)),-vnni512)
271 # 64-bit pext is not available on x86-32
278 # all other architectures
280 ifeq ($(ARCH),general-32)
285 ifeq ($(ARCH),general-64)
296 ifeq ($(ARCH),armv7-neon)
313 ifeq ($(ARCH),armv8-dotprod)
322 ifeq ($(ARCH),apple-silicon)
331 ifeq ($(ARCH),ppc-32)
336 ifeq ($(ARCH),ppc-64)
342 ifeq ($(findstring e2k,$(ARCH)),e2k)
353 ifeq ($(ARCH),riscv64)
359 ### ==========================================================================
360 ### Section 3. Low-level Configuration
361 ### ==========================================================================
363 ### 3.1 Selecting compiler (default = gcc)
364 ifeq ($(MAKELEVEL),0)
365 export ENV_CXXFLAGS := $(CXXFLAGS)
366 export ENV_DEPENDFLAGS := $(DEPENDFLAGS)
367 export ENV_LDFLAGS := $(LDFLAGS)
370 CXXFLAGS = $(ENV_CXXFLAGS) -Wall -Wcast-qual -fno-exceptions -std=c++17 $(EXTRACXXFLAGS)
371 DEPENDFLAGS = $(ENV_DEPENDFLAGS) -std=c++17
372 LDFLAGS = $(ENV_LDFLAGS) $(EXTRALDFLAGS)
381 CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-declarations
383 ifeq ($(arch),$(filter $(arch),armv7 armv8 riscv64))
385 CXXFLAGS += -m$(bits)
388 ifeq ($(ARCH),riscv64)
392 CXXFLAGS += -m$(bits)
396 ifeq ($(arch),$(filter $(arch),armv7))
400 ifneq ($(KERNEL),Darwin)
401 LDFLAGS += -Wl,--no-as-needed
405 ifeq ($(target_windows),yes)
413 ifeq ($(shell which x86_64-w64-mingw32-c++-posix 2> /dev/null),)
414 CXX=x86_64-w64-mingw32-c++
416 CXX=x86_64-w64-mingw32-c++-posix
419 ifeq ($(shell which i686-w64-mingw32-c++-posix 2> /dev/null),)
420 CXX=i686-w64-mingw32-c++
422 CXX=i686-w64-mingw32-c++-posix
425 CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-declarations
431 CXXFLAGS += -diag-disable 1476,10120 -Wcheck -Wabi -Wdeprecated -strict-ansi
437 ifeq ($(target_windows),yes)
438 CXX=x86_64-w64-mingw32-clang++
441 CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-prototypes \
442 -Wconditional-uninitialized
444 ifeq ($(filter $(KERNEL),Darwin OpenBSD FreeBSD),)
445 ifeq ($(target_windows),)
446 ifneq ($(RTLIB),compiler-rt)
452 ifeq ($(arch),$(filter $(arch),armv7 armv8 riscv64))
454 CXXFLAGS += -m$(bits)
457 ifeq ($(ARCH),riscv64)
461 CXXFLAGS += -m$(bits)
466 ifeq ($(KERNEL),Darwin)
467 CXXFLAGS += -mmacosx-version-min=10.14
468 LDFLAGS += -mmacosx-version-min=10.14
470 CXXFLAGS += -arch $(arch)
471 LDFLAGS += -arch $(arch)
476 # To cross-compile for Android, NDK version r21 or later is recommended.
477 # In earlier NDK versions, you'll need to pass -fno-addrsig if using GNU binutils.
478 # Currently we don't know how to make PGO builds with the NDK yet.
480 CXXFLAGS += -stdlib=libc++ -fPIE
483 CXX=armv7a-linux-androideabi16-clang++
484 CXXFLAGS += -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon
485 ifneq ($(shell which arm-linux-androideabi-strip 2>/dev/null),)
486 STRIP=arm-linux-androideabi-strip
492 CXX=aarch64-linux-android21-clang++
493 ifneq ($(shell which aarch64-linux-android-strip 2>/dev/null),)
494 STRIP=aarch64-linux-android-strip
499 LDFLAGS += -static-libstdc++ -pie -lm -latomic
503 profile_make = icc-profile-make
504 profile_use = icc-profile-use
505 else ifeq ($(comp),clang)
506 profile_make = clang-profile-make
507 profile_use = clang-profile-use
509 profile_make = gcc-profile-make
510 profile_use = gcc-profile-use
511 ifeq ($(KERNEL),Darwin)
512 EXTRAPROFILEFLAGS = -fvisibility=hidden
516 ### Travis CI script uses COMPILER to overwrite CXX
521 ### Allow overwriting CXX from command line
526 ### Sometimes gcc is really clang
528 gccversion = $(shell $(CXX) --version 2>/dev/null)
529 gccisclang = $(findstring clang,$(gccversion))
530 ifneq ($(gccisclang),)
531 profile_make = clang-profile-make
532 profile_use = clang-profile-use
536 ### On mingw use Windows threads, otherwise POSIX
537 ifneq ($(comp),mingw)
538 CXXFLAGS += -DUSE_PTHREADS
539 # On Android Bionic's C library comes with its own pthread implementation bundled in
540 ifneq ($(OS),Android)
541 # Haiku has pthreads in its libroot, so only link it in on other platforms
542 ifneq ($(KERNEL),Haiku)
557 ### 3.2.2 Debugging with undefined behavior sanitizers
558 ifneq ($(sanitize),none)
559 CXXFLAGS += -g3 $(addprefix -fsanitize=,$(sanitize))
560 LDFLAGS += $(addprefix -fsanitize=,$(sanitize))
564 ifeq ($(optimize),yes)
569 ifeq ($(OS), Android)
570 CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp
574 ifeq ($(KERNEL),Darwin)
575 ifeq ($(comp),$(filter $(comp),clang icc))
576 CXXFLAGS += -mdynamic-no-pic
580 ifneq ($(arch),arm64)
581 CXXFLAGS += -mdynamic-no-pic
587 clangmajorversion = $(shell $(CXX) -dumpversion 2>/dev/null | cut -f1 -d.)
588 ifeq ($(shell expr $(clangmajorversion) \< 16),1)
589 CXXFLAGS += -fexperimental-new-pass-manager
596 CXXFLAGS += -DIS_64BIT
599 ### 3.5 prefetch and popcount
600 ifeq ($(prefetch),yes)
605 CXXFLAGS += -DNO_PREFETCH
609 ifeq ($(arch),$(filter $(arch),ppc64 armv7 armv8 arm64))
610 CXXFLAGS += -DUSE_POPCNT
611 else ifeq ($(comp),icc)
612 CXXFLAGS += -msse3 -DUSE_POPCNT
614 CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT
618 ### 3.6 SIMD architectures
620 CXXFLAGS += -DUSE_AVX2
621 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
622 CXXFLAGS += -mavx2 -mbmi
626 ifeq ($(avxvnni),yes)
627 CXXFLAGS += -DUSE_VNNI -DUSE_AVXVNNI
628 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
629 CXXFLAGS += -mavxvnni
634 CXXFLAGS += -DUSE_AVX512
635 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
636 CXXFLAGS += -mavx512f -mavx512bw
640 ifeq ($(vnni256),yes)
641 CXXFLAGS += -DUSE_VNNI
642 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
643 CXXFLAGS += -mavx512f -mavx512bw -mavx512vnni -mavx512dq -mavx512vl -mprefer-vector-width=256
647 ifeq ($(vnni512),yes)
648 CXXFLAGS += -DUSE_VNNI
649 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
650 CXXFLAGS += -mavx512vnni -mavx512dq -mavx512vl
655 CXXFLAGS += -DUSE_SSE41
656 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
662 CXXFLAGS += -DUSE_SSSE3
663 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
669 CXXFLAGS += -DUSE_SSE2
670 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
676 CXXFLAGS += -DUSE_MMX
677 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
683 CXXFLAGS += -DUSE_NEON=$(arm_version)
684 ifeq ($(KERNEL),Linux)
686 ifneq ($(arch),armv8)
687 CXXFLAGS += -mfpu=neon
693 ifeq ($(dotprod),yes)
694 CXXFLAGS += -march=armv8.2-a+dotprod -DUSE_NEON_DOTPROD
699 CXXFLAGS += -DUSE_PEXT
700 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
705 ### 3.7.1 Try to include git commit sha for versioning
706 GIT_SHA = $(shell git rev-parse --short HEAD 2>/dev/null)
708 CXXFLAGS += -DGIT_SHA=\"$(GIT_SHA)\"
711 ### 3.7.2 Try to include git commit date for versioning
712 GIT_DATE = $(shell git show -s --date=format:'%Y%m%d' --format=%cd HEAD 2>/dev/null)
713 ifneq ($(GIT_DATE), )
714 CXXFLAGS += -DGIT_DATE=\"$(GIT_DATE)\"
717 ### 3.8 Link Time Optimization
718 ### This is a mix of compile and link time options because the lto link phase
719 ### needs access to the optimization flags.
720 ifeq ($(optimize),yes)
723 CXXFLAGS += -flto=full
724 ifeq ($(target_windows),yes)
725 CXXFLAGS += -fuse-ld=lld
727 LDFLAGS += $(CXXFLAGS)
729 # GCC and CLANG use different methods for parallelizing LTO and CLANG pretends to be
730 # GCC on some systems.
731 else ifeq ($(comp),gcc)
732 ifeq ($(gccisclang),)
733 CXXFLAGS += -flto -flto-partition=one
734 LDFLAGS += $(CXXFLAGS) -flto=jobserver
736 CXXFLAGS += -flto=full
737 LDFLAGS += $(CXXFLAGS)
740 # To use LTO and static linking on Windows,
741 # the tool chain requires gcc version 10.1 or later.
742 else ifeq ($(comp),mingw)
743 CXXFLAGS += -flto -flto-partition=one
744 LDFLAGS += $(CXXFLAGS) -save-temps
749 ### 3.9 Android 5 can only run position independent executables. Note that this
750 ### breaks Android 4.0 and earlier.
751 ifeq ($(OS), Android)
753 LDFLAGS += -fPIE -pie
756 ### ==========================================================================
757 ### Section 4. Public Targets
758 ### ==========================================================================
763 @echo "To compile stockfish, type: "
765 @echo "make target ARCH=arch [COMP=compiler] [COMPCXX=cxx]"
767 @echo "Supported targets:"
769 @echo "help > Display architecture details"
770 @echo "profile-build > standard build with profile-guided optimization"
771 @echo "build > skip profile-guided optimization"
772 @echo "net > Download the default nnue net"
773 @echo "strip > Strip executable"
774 @echo "install > Install executable"
775 @echo "clean > Clean up"
777 @echo "Supported archs:"
779 @echo "x86-64-vnni512 > x86 64-bit with vnni 512bit support"
780 @echo "x86-64-vnni256 > x86 64-bit with vnni 512bit support, limit operands to 256bit wide"
781 @echo "x86-64-avx512 > x86 64-bit with avx512 support"
782 @echo "x86-64-avxvnni > x86 64-bit with vnni 256bit support"
783 @echo "x86-64-bmi2 > x86 64-bit with bmi2 support"
784 @echo "x86-64-avx2 > x86 64-bit with avx2 support"
785 @echo "x86-64-sse41-popcnt > x86 64-bit with sse41 and popcnt support"
786 @echo "x86-64-modern > common modern CPU, currently x86-64-sse41-popcnt"
787 @echo "x86-64-ssse3 > x86 64-bit with ssse3 support"
788 @echo "x86-64-sse3-popcnt > x86 64-bit with sse3 and popcnt support"
789 @echo "x86-64 > x86 64-bit generic (with sse2 support)"
790 @echo "x86-32-sse41-popcnt > x86 32-bit with sse41 and popcnt support"
791 @echo "x86-32-sse2 > x86 32-bit with sse2 support"
792 @echo "x86-32 > x86 32-bit generic (with mmx and sse support)"
793 @echo "ppc-64 > PPC 64-bit"
794 @echo "ppc-32 > PPC 32-bit"
795 @echo "armv7 > ARMv7 32-bit"
796 @echo "armv7-neon > ARMv7 32-bit with popcnt and neon"
797 @echo "armv8 > ARMv8 64-bit with popcnt and neon"
798 @echo "armv8-dotprod > ARMv8 64-bit with popcnt, neon and dot product support"
799 @echo "e2k > Elbrus 2000"
800 @echo "apple-silicon > Apple silicon ARM64"
801 @echo "general-64 > unspecified 64-bit"
802 @echo "general-32 > unspecified 32-bit"
803 @echo "riscv64 > RISC-V 64-bit"
805 @echo "Supported compilers:"
807 @echo "gcc > Gnu compiler (default)"
808 @echo "mingw > Gnu compiler with MinGW under Windows"
809 @echo "clang > LLVM Clang compiler"
810 @echo "icc > Intel compiler"
811 @echo "ndk > Google NDK to cross-compile for Android"
813 @echo "Simple examples. If you don't know what to do, you likely want to run one of: "
815 @echo "make -j profile-build ARCH=x86-64-avx2 # typically a fast compile for common systems "
816 @echo "make -j profile-build ARCH=x86-64-modern # A more portable compile for 64-bit systems "
817 @echo "make -j profile-build ARCH=x86-64 # A portable compile for 64-bit systems "
819 @echo "Advanced examples, for experienced users: "
821 @echo "make -j profile-build ARCH=x86-64-bmi2"
822 @echo "make -j profile-build ARCH=x86-64-bmi2 COMP=gcc COMPCXX=g++-9.0"
823 @echo "make -j build ARCH=x86-64-ssse3 COMP=clang"
825 @echo "-------------------------------"
826 ifeq ($(SUPPORTED_ARCH)$(help_skip_sanity), true)
827 @echo "The selected architecture $(ARCH) will enable the following configuration: "
828 @$(MAKE) ARCH=$(ARCH) COMP=$(COMP) config-sanity
830 @echo "Specify a supported architecture with the ARCH option for more details"
835 .PHONY: help build profile-build strip install clean net objclean profileclean \
836 config-sanity icc-profile-use icc-profile-make gcc-profile-use gcc-profile-make \
837 clang-profile-use clang-profile-make FORCE
839 build: net config-sanity
840 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all
842 profile-build: net config-sanity objclean profileclean
844 @echo "Step 1/4. Building instrumented executable ..."
845 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make)
847 @echo "Step 2/4. Running benchmark for pgo-build ..."
848 $(PGOBENCH) 2>&1 | tail -n 4
850 @echo "Step 3/4. Building optimized executable ..."
851 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean
852 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use)
854 @echo "Step 4/4. Deleting profile data ..."
855 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean
861 -mkdir -p -m 755 $(BINDIR)
863 $(STRIP) $(BINDIR)/$(EXE)
866 clean: objclean profileclean
867 @rm -f .depend *~ core
869 # evaluation network (nnue)
871 $(eval nnuenet := $(shell grep EvalFileDefaultName evaluate.h | grep define | sed 's/.*\(nn-[a-z0-9]\{12\}.nnue\).*/\1/'))
872 @echo "Default net: $(nnuenet)"
873 $(eval nnuedownloadurl1 := https://tests.stockfishchess.org/api/nn/$(nnuenet))
874 $(eval nnuedownloadurl2 := https://github.com/official-stockfish/networks/raw/master/$(nnuenet))
875 $(eval curl_or_wget := $(shell if hash curl 2>/dev/null; then echo "curl -skL"; elif hash wget 2>/dev/null; then echo "wget -qO-"; fi))
876 @if [ "x$(curl_or_wget)" = "x" ]; then \
877 echo "Neither curl nor wget is installed. Install one of these tools unless the net has been downloaded manually"; \
879 $(eval shasum_command := $(shell if hash shasum 2>/dev/null; then echo "shasum -a 256 "; elif hash sha256sum 2>/dev/null; then echo "sha256sum "; fi))
880 @if [ "x$(shasum_command)" = "x" ]; then \
881 echo "shasum / sha256sum not found, skipping net validation"; \
883 @for nnuedownloadurl in "$(nnuedownloadurl1)" "$(nnuedownloadurl2)"; do \
884 if test -f "$(nnuenet)"; then \
885 echo "$(nnuenet) available."; \
887 if [ "x$(curl_or_wget)" != "x" ]; then \
888 echo "Downloading $${nnuedownloadurl}"; $(curl_or_wget) $${nnuedownloadurl} > $(nnuenet);\
890 echo "No net found and download not possible"; exit 1;\
893 if [ "x$(shasum_command)" != "x" ]; then \
894 if [ "$(nnuenet)" != "nn-"`$(shasum_command) $(nnuenet) | cut -c1-12`".nnue" ]; then \
895 echo "Removing failed download"; rm -f $(nnuenet); \
897 echo "Network validated"; break; \
901 @if ! test -f "$(nnuenet)"; then \
902 echo "Failed to download $(nnuenet)."; \
905 # clean binaries and objects
907 @rm -f stockfish stockfish.exe *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o
909 # clean auxiliary profiling files
912 @rm -f bench.txt *.gcda *.gcno ./syzygy/*.gcda ./nnue/*.gcda ./nnue/features/*.gcda *.s
913 @rm -f stockfish.profdata *.profraw
914 @rm -f stockfish.*args*
915 @rm -f stockfish.*lt*
917 @rm -f ./-lstdc++.res
922 ### ==========================================================================
923 ### Section 5. Private Targets
924 ### ==========================================================================
931 @echo "debug: '$(debug)'"
932 @echo "sanitize: '$(sanitize)'"
933 @echo "optimize: '$(optimize)'"
934 @echo "arch: '$(arch)'"
935 @echo "bits: '$(bits)'"
936 @echo "kernel: '$(KERNEL)'"
938 @echo "prefetch: '$(prefetch)'"
939 @echo "popcnt: '$(popcnt)'"
940 @echo "pext: '$(pext)'"
941 @echo "sse: '$(sse)'"
942 @echo "mmx: '$(mmx)'"
943 @echo "sse2: '$(sse2)'"
944 @echo "ssse3: '$(ssse3)'"
945 @echo "sse41: '$(sse41)'"
946 @echo "avx2: '$(avx2)'"
947 @echo "avxvnni: '$(avxvnni)'"
948 @echo "avx512: '$(avx512)'"
949 @echo "vnni256: '$(vnni256)'"
950 @echo "vnni512: '$(vnni512)'"
951 @echo "neon: '$(neon)'"
952 @echo "arm_version: '$(arm_version)'"
956 @echo "CXXFLAGS: $(CXXFLAGS)"
957 @echo "LDFLAGS: $(LDFLAGS)"
959 @echo "Testing config sanity. If this fails, try 'make help' ..."
961 @test "$(debug)" = "yes" || test "$(debug)" = "no"
962 @test "$(optimize)" = "yes" || test "$(optimize)" = "no"
963 @test "$(SUPPORTED_ARCH)" = "true"
964 @test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \
965 test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || test "$(arch)" = "e2k" || \
966 test "$(arch)" = "armv7" || test "$(arch)" = "armv8" || test "$(arch)" = "arm64" || test "$(arch)" = "riscv64"
967 @test "$(bits)" = "32" || test "$(bits)" = "64"
968 @test "$(prefetch)" = "yes" || test "$(prefetch)" = "no"
969 @test "$(popcnt)" = "yes" || test "$(popcnt)" = "no"
970 @test "$(pext)" = "yes" || test "$(pext)" = "no"
971 @test "$(sse)" = "yes" || test "$(sse)" = "no"
972 @test "$(mmx)" = "yes" || test "$(mmx)" = "no"
973 @test "$(sse2)" = "yes" || test "$(sse2)" = "no"
974 @test "$(ssse3)" = "yes" || test "$(ssse3)" = "no"
975 @test "$(sse41)" = "yes" || test "$(sse41)" = "no"
976 @test "$(avx2)" = "yes" || test "$(avx2)" = "no"
977 @test "$(avx512)" = "yes" || test "$(avx512)" = "no"
978 @test "$(vnni256)" = "yes" || test "$(vnni256)" = "no"
979 @test "$(vnni512)" = "yes" || test "$(vnni512)" = "no"
980 @test "$(neon)" = "yes" || test "$(neon)" = "no"
981 @test "$(comp)" = "gcc" || test "$(comp)" = "icc" || test "$(comp)" = "mingw" || test "$(comp)" = "clang" \
982 || test "$(comp)" = "armv7a-linux-androideabi16-clang" || test "$(comp)" = "aarch64-linux-android21-clang"
985 +$(CXX) -o $@ $(OBJS) $(LDFLAGS)
987 # Force recompilation to ensure version info is up-to-date
992 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
993 EXTRACXXFLAGS='-fprofile-instr-generate ' \
994 EXTRALDFLAGS=' -fprofile-instr-generate' \
998 $(XCRUN) llvm-profdata merge -output=stockfish.profdata *.profraw
999 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1000 EXTRACXXFLAGS='-fprofile-instr-use=stockfish.profdata' \
1001 EXTRALDFLAGS='-fprofile-use ' \
1006 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1007 EXTRACXXFLAGS='-fprofile-generate=profdir' \
1008 EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
1009 EXTRALDFLAGS='-lgcov' \
1013 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1014 EXTRACXXFLAGS='-fprofile-use=profdir -fno-peel-loops -fno-tracer' \
1015 EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
1016 EXTRALDFLAGS='-lgcov' \
1021 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1022 EXTRACXXFLAGS='-prof-gen=srcpos -prof_dir ./profdir' \
1026 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1027 EXTRACXXFLAGS='-prof_use -prof_dir ./profdir' \
1031 -@$(CXX) $(DEPENDFLAGS) -MM $(SRCS) > $@ 2> /dev/null
1033 ifeq (, $(filter $(MAKECMDGOALS), help strip install clean net objclean profileclean config-sanity))