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 += --intel -pedantic -Wextra -Wshadow -Wmissing-prototypes \
432 -Wconditional-uninitialized -Wabi -Wdeprecated
438 ifeq ($(target_windows),yes)
439 CXX=x86_64-w64-mingw32-clang++
442 CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-prototypes \
443 -Wconditional-uninitialized
445 ifeq ($(filter $(KERNEL),Darwin OpenBSD FreeBSD),)
446 ifeq ($(target_windows),)
447 ifneq ($(RTLIB),compiler-rt)
453 ifeq ($(arch),$(filter $(arch),armv7 armv8 riscv64))
455 CXXFLAGS += -m$(bits)
458 ifeq ($(ARCH),riscv64)
462 CXXFLAGS += -m$(bits)
467 ifeq ($(KERNEL),Darwin)
468 CXXFLAGS += -mmacosx-version-min=10.14
469 LDFLAGS += -mmacosx-version-min=10.14
471 CXXFLAGS += -arch $(arch)
472 LDFLAGS += -arch $(arch)
477 # To cross-compile for Android, NDK version r21 or later is recommended.
478 # In earlier NDK versions, you'll need to pass -fno-addrsig if using GNU binutils.
479 # Currently we don't know how to make PGO builds with the NDK yet.
481 CXXFLAGS += -stdlib=libc++ -fPIE
484 CXX=armv7a-linux-androideabi16-clang++
485 CXXFLAGS += -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon
486 ifneq ($(shell which arm-linux-androideabi-strip 2>/dev/null),)
487 STRIP=arm-linux-androideabi-strip
493 CXX=aarch64-linux-android21-clang++
494 ifneq ($(shell which aarch64-linux-android-strip 2>/dev/null),)
495 STRIP=aarch64-linux-android-strip
500 LDFLAGS += -static-libstdc++ -pie -lm -latomic
504 profile_make = icx-profile-make
505 profile_use = icx-profile-use
506 else ifeq ($(comp),clang)
507 profile_make = clang-profile-make
508 profile_use = clang-profile-use
510 profile_make = gcc-profile-make
511 profile_use = gcc-profile-use
512 ifeq ($(KERNEL),Darwin)
513 EXTRAPROFILEFLAGS = -fvisibility=hidden
517 ### Travis CI script uses COMPILER to overwrite CXX
522 ### Allow overwriting CXX from command line
527 ### Sometimes gcc is really clang
529 gccversion = $(shell $(CXX) --version 2>/dev/null)
530 gccisclang = $(findstring clang,$(gccversion))
531 ifneq ($(gccisclang),)
532 profile_make = clang-profile-make
533 profile_use = clang-profile-use
537 ### On mingw use Windows threads, otherwise POSIX
538 ifneq ($(comp),mingw)
539 CXXFLAGS += -DUSE_PTHREADS
540 # On Android Bionic's C library comes with its own pthread implementation bundled in
541 ifneq ($(OS),Android)
542 # Haiku has pthreads in its libroot, so only link it in on other platforms
543 ifneq ($(KERNEL),Haiku)
558 ### 3.2.2 Debugging with undefined behavior sanitizers
559 ifneq ($(sanitize),none)
560 CXXFLAGS += -g3 $(addprefix -fsanitize=,$(sanitize))
561 LDFLAGS += $(addprefix -fsanitize=,$(sanitize))
565 ifeq ($(optimize),yes)
570 ifeq ($(OS), Android)
571 CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp
575 ifeq ($(KERNEL),Darwin)
576 ifeq ($(comp),$(filter $(comp),clang icx))
577 CXXFLAGS += -mdynamic-no-pic
581 ifneq ($(arch),arm64)
582 CXXFLAGS += -mdynamic-no-pic
588 clangmajorversion = $(shell $(CXX) -dumpversion 2>/dev/null | cut -f1 -d.)
589 ifeq ($(shell expr $(clangmajorversion) \< 16),1)
590 CXXFLAGS += -fexperimental-new-pass-manager
597 CXXFLAGS += -DIS_64BIT
600 ### 3.5 prefetch and popcount
601 ifeq ($(prefetch),yes)
606 CXXFLAGS += -DNO_PREFETCH
610 ifeq ($(arch),$(filter $(arch),ppc64 armv7 armv8 arm64))
611 CXXFLAGS += -DUSE_POPCNT
613 CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT
617 ### 3.6 SIMD architectures
619 CXXFLAGS += -DUSE_AVX2
620 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
621 CXXFLAGS += -mavx2 -mbmi
625 ifeq ($(avxvnni),yes)
626 CXXFLAGS += -DUSE_VNNI -DUSE_AVXVNNI
627 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
628 CXXFLAGS += -mavxvnni
633 CXXFLAGS += -DUSE_AVX512
634 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
635 CXXFLAGS += -mavx512f -mavx512bw
639 ifeq ($(vnni256),yes)
640 CXXFLAGS += -DUSE_VNNI
641 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
642 CXXFLAGS += -mavx512f -mavx512bw -mavx512vnni -mavx512dq -mavx512vl -mprefer-vector-width=256
646 ifeq ($(vnni512),yes)
647 CXXFLAGS += -DUSE_VNNI
648 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
649 CXXFLAGS += -mavx512f -mavx512bw -mavx512vnni -mavx512dq -mavx512vl -mprefer-vector-width=512
654 CXXFLAGS += -DUSE_SSE41
655 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
661 CXXFLAGS += -DUSE_SSSE3
662 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
668 CXXFLAGS += -DUSE_SSE2
669 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
675 CXXFLAGS += -DUSE_MMX
676 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
682 CXXFLAGS += -DUSE_NEON=$(arm_version)
683 ifeq ($(KERNEL),Linux)
685 ifneq ($(arch),armv8)
686 CXXFLAGS += -mfpu=neon
692 ifeq ($(dotprod),yes)
693 CXXFLAGS += -march=armv8.2-a+dotprod -DUSE_NEON_DOTPROD
698 CXXFLAGS += -DUSE_PEXT
699 ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
704 ### 3.7.1 Try to include git commit sha for versioning
705 GIT_SHA = $(shell git rev-parse HEAD 2>/dev/null | cut -c 1-8)
707 CXXFLAGS += -DGIT_SHA=$(GIT_SHA)
710 ### 3.7.2 Try to include git commit date for versioning
711 GIT_DATE = $(shell git show -s --date=format:'%Y%m%d' --format=%cd HEAD 2>/dev/null)
712 ifneq ($(GIT_DATE), )
713 CXXFLAGS += -DGIT_DATE=$(GIT_DATE)
716 ### 3.8 Link Time Optimization
717 ### This is a mix of compile and link time options because the lto link phase
718 ### needs access to the optimization flags.
719 ifeq ($(optimize),yes)
721 ifeq ($(comp),$(filter $(comp),clang icx))
722 CXXFLAGS += -flto=full
724 CXXFLAGS += -fwhole-program-vtables
726 ifeq ($(target_windows),yes)
727 CXXFLAGS += -fuse-ld=lld
729 LDFLAGS += $(CXXFLAGS)
731 # GCC and CLANG use different methods for parallelizing LTO and CLANG pretends to be
732 # GCC on some systems.
733 else ifeq ($(comp),gcc)
734 ifeq ($(gccisclang),)
735 CXXFLAGS += -flto -flto-partition=one
736 LDFLAGS += $(CXXFLAGS) -flto=jobserver
738 CXXFLAGS += -flto=full
739 LDFLAGS += $(CXXFLAGS)
742 # To use LTO and static linking on Windows,
743 # the tool chain requires gcc version 10.1 or later.
744 else ifeq ($(comp),mingw)
745 CXXFLAGS += -flto -flto-partition=one
746 LDFLAGS += $(CXXFLAGS) -save-temps
751 ### 3.9 Android 5 can only run position independent executables. Note that this
752 ### breaks Android 4.0 and earlier.
753 ifeq ($(OS), Android)
755 LDFLAGS += -fPIE -pie
758 ### ==========================================================================
759 ### Section 4. Public Targets
760 ### ==========================================================================
765 @echo "To compile stockfish, type: "
767 @echo "make target ARCH=arch [COMP=compiler] [COMPCXX=cxx]"
769 @echo "Supported targets:"
771 @echo "help > Display architecture details"
772 @echo "profile-build > standard build with profile-guided optimization"
773 @echo "build > skip profile-guided optimization"
774 @echo "net > Download the default nnue net"
775 @echo "strip > Strip executable"
776 @echo "install > Install executable"
777 @echo "clean > Clean up"
779 @echo "Supported archs:"
781 @echo "x86-64-vnni512 > x86 64-bit with vnni 512bit support"
782 @echo "x86-64-vnni256 > x86 64-bit with vnni 512bit support, limit operands to 256bit wide"
783 @echo "x86-64-avx512 > x86 64-bit with avx512 support"
784 @echo "x86-64-avxvnni > x86 64-bit with vnni 256bit support"
785 @echo "x86-64-bmi2 > x86 64-bit with bmi2 support"
786 @echo "x86-64-avx2 > x86 64-bit with avx2 support"
787 @echo "x86-64-sse41-popcnt > x86 64-bit with sse41 and popcnt support"
788 @echo "x86-64-modern > common modern CPU, currently x86-64-sse41-popcnt"
789 @echo "x86-64-ssse3 > x86 64-bit with ssse3 support"
790 @echo "x86-64-sse3-popcnt > x86 64-bit with sse3 and popcnt support"
791 @echo "x86-64 > x86 64-bit generic (with sse2 support)"
792 @echo "x86-32-sse41-popcnt > x86 32-bit with sse41 and popcnt support"
793 @echo "x86-32-sse2 > x86 32-bit with sse2 support"
794 @echo "x86-32 > x86 32-bit generic (with mmx and sse support)"
795 @echo "ppc-64 > PPC 64-bit"
796 @echo "ppc-32 > PPC 32-bit"
797 @echo "armv7 > ARMv7 32-bit"
798 @echo "armv7-neon > ARMv7 32-bit with popcnt and neon"
799 @echo "armv8 > ARMv8 64-bit with popcnt and neon"
800 @echo "armv8-dotprod > ARMv8 64-bit with popcnt, neon and dot product support"
801 @echo "e2k > Elbrus 2000"
802 @echo "apple-silicon > Apple silicon ARM64"
803 @echo "general-64 > unspecified 64-bit"
804 @echo "general-32 > unspecified 32-bit"
805 @echo "riscv64 > RISC-V 64-bit"
807 @echo "Supported compilers:"
809 @echo "gcc > Gnu compiler (default)"
810 @echo "mingw > Gnu compiler with MinGW under Windows"
811 @echo "clang > LLVM Clang compiler"
812 @echo "icx > Intel oneAPI DPC++/C++ Compiler"
813 @echo "ndk > Google NDK to cross-compile for Android"
815 @echo "Simple examples. If you don't know what to do, you likely want to run one of: "
817 @echo "make -j profile-build ARCH=x86-64-avx2 # typically a fast compile for common systems "
818 @echo "make -j profile-build ARCH=x86-64-modern # A more portable compile for 64-bit systems "
819 @echo "make -j profile-build ARCH=x86-64 # A portable compile for 64-bit systems "
821 @echo "Advanced examples, for experienced users: "
823 @echo "make -j profile-build ARCH=x86-64-bmi2"
824 @echo "make -j profile-build ARCH=x86-64-bmi2 COMP=gcc COMPCXX=g++-9.0"
825 @echo "make -j build ARCH=x86-64-ssse3 COMP=clang"
827 @echo "-------------------------------"
828 ifeq ($(SUPPORTED_ARCH)$(help_skip_sanity), true)
829 @echo "The selected architecture $(ARCH) will enable the following configuration: "
830 @$(MAKE) ARCH=$(ARCH) COMP=$(COMP) config-sanity
832 @echo "Specify a supported architecture with the ARCH option for more details"
837 .PHONY: help build profile-build strip install clean net objclean profileclean \
839 icx-profile-use icx-profile-make \
840 gcc-profile-use gcc-profile-make \
841 clang-profile-use clang-profile-make FORCE
843 build: net config-sanity
844 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all
846 profile-build: net config-sanity objclean profileclean
848 @echo "Step 1/4. Building instrumented executable ..."
849 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make)
851 @echo "Step 2/4. Running benchmark for pgo-build ..."
852 $(PGOBENCH) 2>&1 | tail -n 4
854 @echo "Step 3/4. Building optimized executable ..."
855 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean
856 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use)
858 @echo "Step 4/4. Deleting profile data ..."
859 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean
865 -mkdir -p -m 755 $(BINDIR)
867 $(STRIP) $(BINDIR)/$(EXE)
870 clean: objclean profileclean
871 @rm -f .depend *~ core
873 # evaluation network (nnue)
875 $(eval nnuenet := $(shell grep EvalFileDefaultName evaluate.h | grep define | sed 's/.*\(nn-[a-z0-9]\{12\}.nnue\).*/\1/'))
876 @echo "Default net: $(nnuenet)"
877 $(eval nnuedownloadurl1 := https://tests.stockfishchess.org/api/nn/$(nnuenet))
878 $(eval nnuedownloadurl2 := https://github.com/official-stockfish/networks/raw/master/$(nnuenet))
879 $(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))
880 @if [ "x$(curl_or_wget)" = "x" ]; then \
881 echo "Neither curl nor wget is installed. Install one of these tools unless the net has been downloaded manually"; \
883 $(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))
884 @if [ "x$(shasum_command)" = "x" ]; then \
885 echo "shasum / sha256sum not found, skipping net validation"; \
887 @for nnuedownloadurl in "$(nnuedownloadurl1)" "$(nnuedownloadurl2)"; do \
888 if test -f "$(nnuenet)"; then \
889 echo "$(nnuenet) available."; \
891 if [ "x$(curl_or_wget)" != "x" ]; then \
892 echo "Downloading $${nnuedownloadurl}"; $(curl_or_wget) $${nnuedownloadurl} > $(nnuenet);\
894 echo "No net found and download not possible"; exit 1;\
897 if [ "x$(shasum_command)" != "x" ]; then \
898 if [ "$(nnuenet)" != "nn-"`$(shasum_command) $(nnuenet) | cut -c1-12`".nnue" ]; then \
899 echo "Removing failed download"; rm -f $(nnuenet); \
901 echo "Network validated"; break; \
905 @if ! test -f "$(nnuenet)"; then \
906 echo "Failed to download $(nnuenet)."; \
909 # clean binaries and objects
911 @rm -f stockfish stockfish.exe *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o
913 # clean auxiliary profiling files
916 @rm -f bench.txt *.gcda *.gcno ./syzygy/*.gcda ./nnue/*.gcda ./nnue/features/*.gcda *.s
917 @rm -f stockfish.profdata *.profraw
918 @rm -f stockfish.*args*
919 @rm -f stockfish.*lt*
921 @rm -f ./-lstdc++.res
926 ### ==========================================================================
927 ### Section 5. Private Targets
928 ### ==========================================================================
935 @echo "debug: '$(debug)'"
936 @echo "sanitize: '$(sanitize)'"
937 @echo "optimize: '$(optimize)'"
938 @echo "arch: '$(arch)'"
939 @echo "bits: '$(bits)'"
940 @echo "kernel: '$(KERNEL)'"
942 @echo "prefetch: '$(prefetch)'"
943 @echo "popcnt: '$(popcnt)'"
944 @echo "pext: '$(pext)'"
945 @echo "sse: '$(sse)'"
946 @echo "mmx: '$(mmx)'"
947 @echo "sse2: '$(sse2)'"
948 @echo "ssse3: '$(ssse3)'"
949 @echo "sse41: '$(sse41)'"
950 @echo "avx2: '$(avx2)'"
951 @echo "avxvnni: '$(avxvnni)'"
952 @echo "avx512: '$(avx512)'"
953 @echo "vnni256: '$(vnni256)'"
954 @echo "vnni512: '$(vnni512)'"
955 @echo "neon: '$(neon)'"
956 @echo "dotprod: '$(dotprod)'"
957 @echo "arm_version: '$(arm_version)'"
958 @echo "target_windows: '$(target_windows)'"
962 @echo "CXXFLAGS: $(CXXFLAGS)"
963 @echo "LDFLAGS: $(LDFLAGS)"
965 @echo "Testing config sanity. If this fails, try 'make help' ..."
967 @test "$(debug)" = "yes" || test "$(debug)" = "no"
968 @test "$(optimize)" = "yes" || test "$(optimize)" = "no"
969 @test "$(SUPPORTED_ARCH)" = "true"
970 @test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \
971 test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || test "$(arch)" = "e2k" || \
972 test "$(arch)" = "armv7" || test "$(arch)" = "armv8" || test "$(arch)" = "arm64" || test "$(arch)" = "riscv64"
973 @test "$(bits)" = "32" || test "$(bits)" = "64"
974 @test "$(prefetch)" = "yes" || test "$(prefetch)" = "no"
975 @test "$(popcnt)" = "yes" || test "$(popcnt)" = "no"
976 @test "$(pext)" = "yes" || test "$(pext)" = "no"
977 @test "$(sse)" = "yes" || test "$(sse)" = "no"
978 @test "$(mmx)" = "yes" || test "$(mmx)" = "no"
979 @test "$(sse2)" = "yes" || test "$(sse2)" = "no"
980 @test "$(ssse3)" = "yes" || test "$(ssse3)" = "no"
981 @test "$(sse41)" = "yes" || test "$(sse41)" = "no"
982 @test "$(avx2)" = "yes" || test "$(avx2)" = "no"
983 @test "$(avx512)" = "yes" || test "$(avx512)" = "no"
984 @test "$(vnni256)" = "yes" || test "$(vnni256)" = "no"
985 @test "$(vnni512)" = "yes" || test "$(vnni512)" = "no"
986 @test "$(neon)" = "yes" || test "$(neon)" = "no"
987 @test "$(comp)" = "gcc" || test "$(comp)" = "icx" || test "$(comp)" = "mingw" || test "$(comp)" = "clang" \
988 || test "$(comp)" = "armv7a-linux-androideabi16-clang" || test "$(comp)" = "aarch64-linux-android21-clang"
991 +$(CXX) -o $@ $(OBJS) $(LDFLAGS)
993 # Force recompilation to ensure version info is up-to-date
998 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
999 EXTRACXXFLAGS='-fprofile-instr-generate ' \
1000 EXTRALDFLAGS=' -fprofile-instr-generate' \
1004 $(XCRUN) llvm-profdata merge -output=stockfish.profdata *.profraw
1005 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1006 EXTRACXXFLAGS='-fprofile-instr-use=stockfish.profdata' \
1007 EXTRALDFLAGS='-fprofile-use ' \
1012 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1013 EXTRACXXFLAGS='-fprofile-generate=profdir' \
1014 EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
1015 EXTRALDFLAGS='-lgcov' \
1019 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1020 EXTRACXXFLAGS='-fprofile-use=profdir -fno-peel-loops -fno-tracer' \
1021 EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
1022 EXTRALDFLAGS='-lgcov' \
1026 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1027 EXTRACXXFLAGS='-fprofile-instr-generate ' \
1028 EXTRALDFLAGS=' -fprofile-instr-generate' \
1032 $(XCRUN) llvm-profdata merge -output=stockfish.profdata *.profraw
1033 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1034 EXTRACXXFLAGS='-fprofile-instr-use=stockfish.profdata' \
1035 EXTRALDFLAGS='-fprofile-use ' \
1039 -@$(CXX) $(DEPENDFLAGS) -MM $(SRCS) > $@ 2> /dev/null
1041 ifeq (, $(filter $(MAKECMDGOALS), help strip install clean net objclean profileclean config-sanity))