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
52 PGOBENCH = $(WINE_PATH) ./$(EXE) bench
54 ### Source and object files
55 SRCS = benchmark.cpp bitboard.cpp evaluate.cpp main.cpp \
56 misc.cpp movegen.cpp movepick.cpp position.cpp psqt.cpp \
57 search.cpp thread.cpp timeman.cpp tt.cpp uci.cpp ucioption.cpp tune.cpp syzygy/tbprobe.cpp \
58 nnue/evaluate_nnue.cpp nnue/features/half_ka_v2_hm.cpp
60 OBJS = $(notdir $(SRCS:.cpp=.o))
62 VPATH = syzygy:nnue:nnue/features
64 ### ==========================================================================
65 ### Section 2. High-level Configuration
66 ### ==========================================================================
68 # flag --- Comp switch --- Description
69 # ----------------------------------------------------------------------------
71 # debug = yes/no --- -DNDEBUG --- Enable/Disable debug mode
72 # sanitize = none/<sanitizer> ... (-fsanitize )
73 # --- ( undefined ) --- enable undefined behavior checks
74 # --- ( thread ) --- enable threading error checks
75 # --- ( address ) --- enable memory access checks
76 # --- ...etc... --- see compiler documentation for supported sanitizers
77 # optimize = yes/no --- (-O3/-fast etc.) --- Enable/Disable optimizations
78 # arch = (name) --- (-arch) --- Target architecture
79 # bits = 64/32 --- -DIS_64BIT --- 64-/32-bit operating system
80 # prefetch = yes/no --- -DUSE_PREFETCH --- Use prefetch asm-instruction
81 # popcnt = yes/no --- -DUSE_POPCNT --- Use popcnt asm-instruction
82 # pext = yes/no --- -DUSE_PEXT --- Use pext x86_64 asm-instruction
83 # sse = yes/no --- -msse --- Use Intel Streaming SIMD Extensions
84 # mmx = yes/no --- -mmmx --- Use Intel MMX instructions
85 # sse2 = yes/no --- -msse2 --- Use Intel Streaming SIMD Extensions 2
86 # ssse3 = yes/no --- -mssse3 --- Use Intel Supplemental Streaming SIMD Extensions 3
87 # sse41 = yes/no --- -msse4.1 --- Use Intel Streaming SIMD Extensions 4.1
88 # avx2 = yes/no --- -mavx2 --- Use Intel Advanced Vector Extensions 2
89 # avxvnni = yes/no --- -mavxvnni --- Use Intel Vector Neural Network Instructions AVX
90 # avx512 = yes/no --- -mavx512bw --- Use Intel Advanced Vector Extensions 512
91 # vnni256 = yes/no --- -mavx256vnni --- Use Intel Vector Neural Network Instructions 512 with 256bit operands
92 # vnni512 = yes/no --- -mavx512vnni --- Use Intel Vector Neural Network Instructions 512
93 # neon = yes/no --- -DUSE_NEON --- Use ARM SIMD architecture
94 # dotprod = yes/no --- -DUSE_NEON_DOTPROD --- Use ARM advanced SIMD Int8 dot product instructions
96 # Note that Makefile is space sensitive, so when adding new architectures
97 # or modifying existing flags, you have to make sure there are no extra spaces
98 # at the end of the line for flag values.
100 # Example of use for these flags:
101 # make build ARCH=x86-64-avx512 debug=yes sanitize="address undefined"
104 ### 2.1. General and architecture defaults
108 help_skip_sanity = yes
110 # explicitly check for the list of supported architectures (as listed with make help),
111 # the user can override with `make ARCH=x86-32-vnni256 SUPPORTED_ARCH=true`
112 ifeq ($(ARCH), $(filter $(ARCH), \
113 x86-64-vnni512 x86-64-vnni256 x86-64-avx512 x86-64-avxvnni x86-64-bmi2 \
114 x86-64-avx2 x86-64-sse41-popcnt x86-64-modern x86-64-ssse3 x86-64-sse3-popcnt \
115 x86-64 x86-32-sse41-popcnt x86-32-sse2 x86-32 ppc-64 ppc-32 e2k \
116 armv7 armv7-neon armv8 armv8-dotprod apple-silicon general-64 general-32 riscv64))
144 ### 2.2 Architecture specific
146 ifeq ($(findstring x86,$(ARCH)),x86)
150 ifeq ($(findstring x86-32,$(ARCH)),x86-32)
161 ifeq ($(findstring -sse,$(ARCH)),-sse)
165 ifeq ($(findstring -popcnt,$(ARCH)),-popcnt)
169 ifeq ($(findstring -mmx,$(ARCH)),-mmx)
173 ifeq ($(findstring -sse2,$(ARCH)),-sse2)
178 ifeq ($(findstring -ssse3,$(ARCH)),-ssse3)
184 ifeq ($(findstring -sse41,$(ARCH)),-sse41)
191 ifeq ($(findstring -modern,$(ARCH)),-modern)
192 $(warning *** ARCH=$(ARCH) is deprecated, defaulting to ARCH=x86-64-sse41-popcnt. Execute `make help` for a list of available architectures. ***)
201 ifeq ($(findstring -avx2,$(ARCH)),-avx2)
210 ifeq ($(findstring -avxvnni,$(ARCH)),-avxvnni)
221 ifeq ($(findstring -bmi2,$(ARCH)),-bmi2)
231 ifeq ($(findstring -avx512,$(ARCH)),-avx512)
242 ifeq ($(findstring -vnni256,$(ARCH)),-vnni256)
253 ifeq ($(findstring -vnni512,$(ARCH)),-vnni512)
269 # 64-bit pext is not available on x86-32
276 # all other architectures
278 ifeq ($(ARCH),general-32)
283 ifeq ($(ARCH),general-64)
294 ifeq ($(ARCH),armv7-neon)
311 ifeq ($(ARCH),armv8-dotprod)
320 ifeq ($(ARCH),apple-silicon)
329 ifeq ($(ARCH),ppc-32)
334 ifeq ($(ARCH),ppc-64)
340 ifeq ($(findstring e2k,$(ARCH)),e2k)
351 ifeq ($(ARCH),riscv64)
357 ### ==========================================================================
358 ### Section 3. Low-level Configuration
359 ### ==========================================================================
361 ### 3.1 Selecting compiler (default = gcc)
362 ifeq ($(MAKELEVEL),0)
363 export ENV_CXXFLAGS := $(CXXFLAGS)
364 export ENV_DEPENDFLAGS := $(DEPENDFLAGS)
365 export ENV_LDFLAGS := $(LDFLAGS)
368 CXXFLAGS = $(ENV_CXXFLAGS) -Wall -Wcast-qual -fno-exceptions -std=c++17 $(EXTRACXXFLAGS)
369 DEPENDFLAGS = $(ENV_DEPENDFLAGS) -std=c++17
370 LDFLAGS = $(ENV_LDFLAGS) $(EXTRALDFLAGS)
379 CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-declarations
381 ifeq ($(arch),$(filter $(arch),armv7 armv8 riscv64))
383 CXXFLAGS += -m$(bits)
386 ifeq ($(ARCH),riscv64)
390 CXXFLAGS += -m$(bits)
394 ifeq ($(arch),$(filter $(arch),armv7))
398 ifneq ($(KERNEL),Darwin)
399 LDFLAGS += -Wl,--no-as-needed
403 ifeq ($(target_windows),yes)
411 ifeq ($(shell which x86_64-w64-mingw32-c++-posix 2> /dev/null),)
412 CXX=x86_64-w64-mingw32-c++
414 CXX=x86_64-w64-mingw32-c++-posix
417 ifeq ($(shell which i686-w64-mingw32-c++-posix 2> /dev/null),)
418 CXX=i686-w64-mingw32-c++
420 CXX=i686-w64-mingw32-c++-posix
423 CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-declarations
429 CXXFLAGS += --intel -pedantic -Wextra -Wshadow -Wmissing-prototypes \
430 -Wconditional-uninitialized -Wabi -Wdeprecated
436 ifeq ($(target_windows),yes)
437 CXX=x86_64-w64-mingw32-clang++
440 CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-prototypes \
441 -Wconditional-uninitialized
443 ifeq ($(filter $(KERNEL),Darwin OpenBSD FreeBSD),)
444 ifeq ($(target_windows),)
445 ifneq ($(RTLIB),compiler-rt)
451 ifeq ($(arch),$(filter $(arch),armv7 armv8 riscv64))
453 CXXFLAGS += -m$(bits)
456 ifeq ($(ARCH),riscv64)
460 CXXFLAGS += -m$(bits)
465 ifeq ($(KERNEL),Darwin)
466 CXXFLAGS += -mmacosx-version-min=10.14
467 LDFLAGS += -mmacosx-version-min=10.14
469 CXXFLAGS += -arch $(arch)
470 LDFLAGS += -arch $(arch)
475 # To cross-compile for Android, NDK version r21 or later is recommended.
476 # In earlier NDK versions, you'll need to pass -fno-addrsig if using GNU binutils.
477 # Currently we don't know how to make PGO builds with the NDK yet.
479 CXXFLAGS += -stdlib=libc++ -fPIE
482 CXX=armv7a-linux-androideabi16-clang++
483 CXXFLAGS += -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon
484 ifneq ($(shell which arm-linux-androideabi-strip 2>/dev/null),)
485 STRIP=arm-linux-androideabi-strip
491 CXX=aarch64-linux-android21-clang++
492 ifneq ($(shell which aarch64-linux-android-strip 2>/dev/null),)
493 STRIP=aarch64-linux-android-strip
498 LDFLAGS += -static-libstdc++ -pie -lm -latomic
502 profile_make = icx-profile-make
503 profile_use = icx-profile-use
504 else ifeq ($(comp),clang)
505 profile_make = clang-profile-make
506 profile_use = clang-profile-use
508 profile_make = gcc-profile-make
509 profile_use = gcc-profile-use
510 ifeq ($(KERNEL),Darwin)
511 EXTRAPROFILEFLAGS = -fvisibility=hidden
515 ### Travis CI script uses COMPILER to overwrite CXX
520 ### Allow overwriting CXX from command line
525 ### Sometimes gcc is really clang
527 gccversion = $(shell $(CXX) --version 2>/dev/null)
528 gccisclang = $(findstring clang,$(gccversion))
529 ifneq ($(gccisclang),)
530 profile_make = clang-profile-make
531 profile_use = clang-profile-use
535 ### On mingw use Windows threads, otherwise POSIX
536 ifneq ($(comp),mingw)
537 CXXFLAGS += -DUSE_PTHREADS
538 # On Android Bionic's C library comes with its own pthread implementation bundled in
539 ifneq ($(OS),Android)
540 # Haiku has pthreads in its libroot, so only link it in on other platforms
541 ifneq ($(KERNEL),Haiku)
556 ### 3.2.2 Debugging with undefined behavior sanitizers
557 ifneq ($(sanitize),none)
558 CXXFLAGS += -g3 $(addprefix -fsanitize=,$(sanitize))
559 LDFLAGS += $(addprefix -fsanitize=,$(sanitize))
563 ifeq ($(optimize),yes)
568 ifeq ($(OS), Android)
569 CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp
573 ifeq ($(KERNEL),Darwin)
574 ifeq ($(comp),$(filter $(comp),clang icx))
575 CXXFLAGS += -mdynamic-no-pic
579 ifneq ($(arch),arm64)
580 CXXFLAGS += -mdynamic-no-pic
586 clangmajorversion = $(shell $(CXX) -dumpversion 2>/dev/null | cut -f1 -d.)
587 ifeq ($(shell expr $(clangmajorversion) \< 16),1)
588 CXXFLAGS += -fexperimental-new-pass-manager
595 CXXFLAGS += -DIS_64BIT
598 ### 3.5 prefetch and popcount
599 ifeq ($(prefetch),yes)
604 CXXFLAGS += -DNO_PREFETCH
608 ifeq ($(arch),$(filter $(arch),ppc64 armv7 armv8 arm64))
609 CXXFLAGS += -DUSE_POPCNT
611 CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT
615 ### 3.6 SIMD architectures
617 CXXFLAGS += -DUSE_AVX2
618 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
619 CXXFLAGS += -mavx2 -mbmi
623 ifeq ($(avxvnni),yes)
624 CXXFLAGS += -DUSE_VNNI -DUSE_AVXVNNI
625 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
626 CXXFLAGS += -mavxvnni
631 CXXFLAGS += -DUSE_AVX512
632 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
633 CXXFLAGS += -mavx512f -mavx512bw
637 ifeq ($(vnni256),yes)
638 CXXFLAGS += -DUSE_VNNI
639 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
640 CXXFLAGS += -mavx512f -mavx512bw -mavx512vnni -mavx512dq -mavx512vl -mprefer-vector-width=256
644 ifeq ($(vnni512),yes)
645 CXXFLAGS += -DUSE_VNNI
646 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
647 CXXFLAGS += -mavx512f -mavx512bw -mavx512vnni -mavx512dq -mavx512vl -mprefer-vector-width=512
652 CXXFLAGS += -DUSE_SSE41
653 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
659 CXXFLAGS += -DUSE_SSSE3
660 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
666 CXXFLAGS += -DUSE_SSE2
667 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
673 CXXFLAGS += -DUSE_MMX
674 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
680 CXXFLAGS += -DUSE_NEON=$(arm_version)
681 ifeq ($(KERNEL),Linux)
683 ifneq ($(arch),armv8)
684 CXXFLAGS += -mfpu=neon
690 ifeq ($(dotprod),yes)
691 CXXFLAGS += -march=armv8.2-a+dotprod -DUSE_NEON_DOTPROD
696 CXXFLAGS += -DUSE_PEXT
697 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
702 ### 3.7.1 Try to include git commit sha for versioning
703 GIT_SHA = $(shell git rev-parse HEAD 2>/dev/null | cut -c 1-8)
705 CXXFLAGS += -DGIT_SHA=$(GIT_SHA)
708 ### 3.7.2 Try to include git commit date for versioning
709 GIT_DATE = $(shell git show -s --date=format:'%Y%m%d' --format=%cd HEAD 2>/dev/null)
710 ifneq ($(GIT_DATE), )
711 CXXFLAGS += -DGIT_DATE=$(GIT_DATE)
714 ### 3.8 Link Time Optimization
715 ### This is a mix of compile and link time options because the lto link phase
716 ### needs access to the optimization flags.
717 ifeq ($(optimize),yes)
719 ifeq ($(comp),$(filter $(comp),clang icx))
720 CXXFLAGS += -flto=full
722 CXXFLAGS += -fwhole-program-vtables
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 > deprecated, 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 "icx > Intel oneAPI DPC++/C++ 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-sse41-popcnt # 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-avxvnni"
822 @echo "make -j profile-build ARCH=x86-64-avxvnni COMP=gcc COMPCXX=g++-12.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 \
837 icx-profile-use icx-profile-make \
838 gcc-profile-use gcc-profile-make \
839 clang-profile-use clang-profile-make FORCE
841 build: net config-sanity
842 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all
844 profile-build: net config-sanity objclean profileclean
846 @echo "Step 1/4. Building instrumented executable ..."
847 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make)
849 @echo "Step 2/4. Running benchmark for pgo-build ..."
850 $(PGOBENCH) > PGOBENCH.out 2>&1
851 tail -n 4 PGOBENCH.out
853 @echo "Step 3/4. Building optimized executable ..."
854 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean
855 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use)
857 @echo "Step 4/4. Deleting profile data ..."
858 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean
864 -mkdir -p -m 755 $(BINDIR)
866 $(STRIP) $(BINDIR)/$(EXE)
869 clean: objclean profileclean
870 @rm -f .depend *~ core
872 # evaluation network (nnue)
874 $(eval nnuenet := $(shell grep EvalFileDefaultName evaluate.h | grep define | sed 's/.*\(nn-[a-z0-9]\{12\}.nnue\).*/\1/'))
875 @echo "Default net: $(nnuenet)"
876 $(eval nnuedownloadurl1 := https://tests.stockfishchess.org/api/nn/$(nnuenet))
877 $(eval nnuedownloadurl2 := https://github.com/official-stockfish/networks/raw/master/$(nnuenet))
878 $(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))
879 @if [ "x$(curl_or_wget)" = "x" ]; then \
880 echo "Neither curl nor wget is installed. Install one of these tools unless the net has been downloaded manually"; \
882 $(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))
883 @if [ "x$(shasum_command)" = "x" ]; then \
884 echo "shasum / sha256sum not found, skipping net validation"; \
886 @for nnuedownloadurl in "$(nnuedownloadurl1)" "$(nnuedownloadurl2)"; do \
887 if test -f "$(nnuenet)"; then \
888 echo "$(nnuenet) available."; \
890 if [ "x$(curl_or_wget)" != "x" ]; then \
891 echo "Downloading $${nnuedownloadurl}"; $(curl_or_wget) $${nnuedownloadurl} > $(nnuenet);\
893 echo "No net found and download not possible"; exit 1;\
896 if [ "x$(shasum_command)" != "x" ]; then \
897 if [ "$(nnuenet)" != "nn-"`$(shasum_command) $(nnuenet) | cut -c1-12`".nnue" ]; then \
898 echo "Removing failed download"; rm -f $(nnuenet); \
900 echo "Network validated"; break; \
904 @if ! test -f "$(nnuenet)"; then \
905 echo "Failed to download $(nnuenet)."; \
908 # clean binaries and objects
910 @rm -f stockfish stockfish.exe *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o
912 # clean auxiliary profiling files
915 @rm -f bench.txt *.gcda *.gcno ./syzygy/*.gcda ./nnue/*.gcda ./nnue/features/*.gcda *.s PGOBENCH.out
916 @rm -f stockfish.profdata *.profraw
917 @rm -f stockfish.*args*
918 @rm -f stockfish.*lt*
920 @rm -f ./-lstdc++.res
925 ### ==========================================================================
926 ### Section 5. Private Targets
927 ### ==========================================================================
934 @echo "debug: '$(debug)'"
935 @echo "sanitize: '$(sanitize)'"
936 @echo "optimize: '$(optimize)'"
937 @echo "arch: '$(arch)'"
938 @echo "bits: '$(bits)'"
939 @echo "kernel: '$(KERNEL)'"
941 @echo "prefetch: '$(prefetch)'"
942 @echo "popcnt: '$(popcnt)'"
943 @echo "pext: '$(pext)'"
944 @echo "sse: '$(sse)'"
945 @echo "mmx: '$(mmx)'"
946 @echo "sse2: '$(sse2)'"
947 @echo "ssse3: '$(ssse3)'"
948 @echo "sse41: '$(sse41)'"
949 @echo "avx2: '$(avx2)'"
950 @echo "avxvnni: '$(avxvnni)'"
951 @echo "avx512: '$(avx512)'"
952 @echo "vnni256: '$(vnni256)'"
953 @echo "vnni512: '$(vnni512)'"
954 @echo "neon: '$(neon)'"
955 @echo "dotprod: '$(dotprod)'"
956 @echo "arm_version: '$(arm_version)'"
957 @echo "target_windows: '$(target_windows)'"
961 @echo "CXXFLAGS: $(CXXFLAGS)"
962 @echo "LDFLAGS: $(LDFLAGS)"
964 @echo "Testing config sanity. If this fails, try 'make help' ..."
966 @test "$(debug)" = "yes" || test "$(debug)" = "no"
967 @test "$(optimize)" = "yes" || test "$(optimize)" = "no"
968 @test "$(SUPPORTED_ARCH)" = "true"
969 @test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \
970 test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || test "$(arch)" = "e2k" || \
971 test "$(arch)" = "armv7" || test "$(arch)" = "armv8" || test "$(arch)" = "arm64" || test "$(arch)" = "riscv64"
972 @test "$(bits)" = "32" || test "$(bits)" = "64"
973 @test "$(prefetch)" = "yes" || test "$(prefetch)" = "no"
974 @test "$(popcnt)" = "yes" || test "$(popcnt)" = "no"
975 @test "$(pext)" = "yes" || test "$(pext)" = "no"
976 @test "$(sse)" = "yes" || test "$(sse)" = "no"
977 @test "$(mmx)" = "yes" || test "$(mmx)" = "no"
978 @test "$(sse2)" = "yes" || test "$(sse2)" = "no"
979 @test "$(ssse3)" = "yes" || test "$(ssse3)" = "no"
980 @test "$(sse41)" = "yes" || test "$(sse41)" = "no"
981 @test "$(avx2)" = "yes" || test "$(avx2)" = "no"
982 @test "$(avx512)" = "yes" || test "$(avx512)" = "no"
983 @test "$(vnni256)" = "yes" || test "$(vnni256)" = "no"
984 @test "$(vnni512)" = "yes" || test "$(vnni512)" = "no"
985 @test "$(neon)" = "yes" || test "$(neon)" = "no"
986 @test "$(comp)" = "gcc" || test "$(comp)" = "icx" || test "$(comp)" = "mingw" || test "$(comp)" = "clang" \
987 || test "$(comp)" = "armv7a-linux-androideabi16-clang" || test "$(comp)" = "aarch64-linux-android21-clang"
990 +$(CXX) -o $@ $(OBJS) $(LDFLAGS)
992 # Force recompilation to ensure version info is up-to-date
997 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
998 EXTRACXXFLAGS='-fprofile-instr-generate ' \
999 EXTRALDFLAGS=' -fprofile-instr-generate' \
1003 $(XCRUN) llvm-profdata merge -output=stockfish.profdata *.profraw
1004 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1005 EXTRACXXFLAGS='-fprofile-instr-use=stockfish.profdata' \
1006 EXTRALDFLAGS='-fprofile-use ' \
1011 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1012 EXTRACXXFLAGS='-fprofile-generate=profdir' \
1013 EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
1014 EXTRALDFLAGS='-lgcov' \
1018 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1019 EXTRACXXFLAGS='-fprofile-use=profdir -fno-peel-loops -fno-tracer' \
1020 EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
1021 EXTRALDFLAGS='-lgcov' \
1025 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1026 EXTRACXXFLAGS='-fprofile-instr-generate ' \
1027 EXTRALDFLAGS=' -fprofile-instr-generate' \
1031 $(XCRUN) llvm-profdata merge -output=stockfish.profdata *.profraw
1032 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1033 EXTRACXXFLAGS='-fprofile-instr-use=stockfish.profdata' \
1034 EXTRALDFLAGS='-fprofile-use ' \
1038 -@$(CXX) $(DEPENDFLAGS) -MM $(SRCS) > $@ 2> /dev/null
1040 ifeq (, $(filter $(MAKECMDGOALS), help strip install clean net objclean profileclean config-sanity))