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 --- -mavx512vnni --- Use Intel Vector Neural Network Instructions 256
96 # vnni512 = yes/no --- -mavx512vnni --- Use Intel Vector Neural Network Instructions 512
97 # neon = yes/no --- -DUSE_NEON --- Use ARM SIMD architecture
99 # Note that Makefile is space sensitive, so when adding new architectures
100 # or modifying existing flags, you have to make sure there are no extra spaces
101 # at the end of the line for flag values.
103 # Example of use for these flags:
104 # make build ARCH=x86-64-avx512 debug=yes sanitize="address undefined"
107 ### 2.1. General and architecture defaults
111 help_skip_sanity = yes
113 # explicitly check for the list of supported architectures (as listed with make help),
114 # the user can override with `make ARCH=x86-32-vnni256 SUPPORTED_ARCH=true`
115 ifeq ($(ARCH), $(filter $(ARCH), \
116 x86-64-vnni512 x86-64-vnni256 x86-64-avx512 x86-64-avxvnni x86-64-bmi2 \
117 x86-64-avx2 x86-64-sse41-popcnt x86-64-modern x86-64-ssse3 x86-64-sse3-popcnt \
118 x86-64 x86-32-sse41-popcnt x86-32-sse2 x86-32 ppc-64 ppc-32 e2k \
119 armv7 armv7-neon armv8 apple-silicon general-64 general-32 riscv64))
146 ### 2.2 Architecture specific
148 ifeq ($(findstring x86,$(ARCH)),x86)
152 ifeq ($(findstring x86-32,$(ARCH)),x86-32)
163 ifeq ($(findstring -sse,$(ARCH)),-sse)
167 ifeq ($(findstring -popcnt,$(ARCH)),-popcnt)
171 ifeq ($(findstring -mmx,$(ARCH)),-mmx)
175 ifeq ($(findstring -sse2,$(ARCH)),-sse2)
180 ifeq ($(findstring -ssse3,$(ARCH)),-ssse3)
186 ifeq ($(findstring -sse41,$(ARCH)),-sse41)
193 ifeq ($(findstring -modern,$(ARCH)),-modern)
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),apple-silicon)
319 ifeq ($(ARCH),ppc-32)
324 ifeq ($(ARCH),ppc-64)
330 ifeq ($(findstring e2k,$(ARCH)),e2k)
341 ifeq ($(ARCH),riscv64)
347 ### ==========================================================================
348 ### Section 3. Low-level Configuration
349 ### ==========================================================================
351 ### 3.1 Selecting compiler (default = gcc)
352 ifeq ($(MAKELEVEL),0)
353 export ENV_CXXFLAGS := $(CXXFLAGS)
354 export ENV_DEPENDFLAGS := $(DEPENDFLAGS)
355 export ENV_LDFLAGS := $(LDFLAGS)
358 CXXFLAGS = $(ENV_CXXFLAGS) -Wall -Wcast-qual -fno-exceptions -std=c++17 $(EXTRACXXFLAGS)
359 DEPENDFLAGS = $(ENV_DEPENDFLAGS) -std=c++17
360 LDFLAGS = $(ENV_LDFLAGS) $(EXTRALDFLAGS)
369 CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-declarations
371 ifeq ($(arch),$(filter $(arch),armv7 armv8 riscv64))
373 CXXFLAGS += -m$(bits)
376 ifeq ($(ARCH),riscv64)
380 CXXFLAGS += -m$(bits)
384 ifeq ($(arch),$(filter $(arch),armv7))
388 ifneq ($(KERNEL),Darwin)
389 LDFLAGS += -Wl,--no-as-needed
393 ifeq ($(target_windows),yes)
401 ifeq ($(shell which x86_64-w64-mingw32-c++-posix 2> /dev/null),)
402 CXX=x86_64-w64-mingw32-c++
404 CXX=x86_64-w64-mingw32-c++-posix
407 ifeq ($(shell which i686-w64-mingw32-c++-posix 2> /dev/null),)
408 CXX=i686-w64-mingw32-c++
410 CXX=i686-w64-mingw32-c++-posix
413 CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-declarations
419 CXXFLAGS += -diag-disable 1476,10120 -Wcheck -Wabi -Wdeprecated -strict-ansi
425 ifeq ($(target_windows),yes)
426 CXX=x86_64-w64-mingw32-clang++
429 CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-prototypes
431 ifeq ($(filter $(KERNEL),Darwin OpenBSD FreeBSD),)
432 ifeq ($(target_windows),)
433 ifneq ($(RTLIB),compiler-rt)
439 ifeq ($(arch),$(filter $(arch),armv7 armv8 riscv64))
441 CXXFLAGS += -m$(bits)
444 ifeq ($(ARCH),riscv64)
448 CXXFLAGS += -m$(bits)
453 ifeq ($(KERNEL),Darwin)
454 CXXFLAGS += -mmacosx-version-min=10.14
455 LDFLAGS += -mmacosx-version-min=10.14
457 CXXFLAGS += -arch $(arch)
458 LDFLAGS += -arch $(arch)
463 # To cross-compile for Android, NDK version r21 or later is recommended.
464 # In earlier NDK versions, you'll need to pass -fno-addrsig if using GNU binutils.
465 # Currently we don't know how to make PGO builds with the NDK yet.
467 CXXFLAGS += -stdlib=libc++ -fPIE
470 CXX=armv7a-linux-androideabi16-clang++
471 CXXFLAGS += -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon
472 ifneq ($(shell which arm-linux-androideabi-strip 2>/dev/null),)
473 STRIP=arm-linux-androideabi-strip
479 CXX=aarch64-linux-android21-clang++
480 ifneq ($(shell which aarch64-linux-android-strip 2>/dev/null),)
481 STRIP=aarch64-linux-android-strip
486 LDFLAGS += -static-libstdc++ -pie -lm -latomic
490 profile_make = icc-profile-make
491 profile_use = icc-profile-use
492 else ifeq ($(comp),clang)
493 profile_make = clang-profile-make
494 profile_use = clang-profile-use
496 profile_make = gcc-profile-make
497 profile_use = gcc-profile-use
498 ifeq ($(KERNEL),Darwin)
499 EXTRAPROFILEFLAGS = -fvisibility=hidden
503 ### Travis CI script uses COMPILER to overwrite CXX
508 ### Allow overwriting CXX from command line
513 ### Sometimes gcc is really clang
515 gccversion = $(shell $(CXX) --version 2>/dev/null)
516 gccisclang = $(findstring clang,$(gccversion))
517 ifneq ($(gccisclang),)
518 profile_make = clang-profile-make
519 profile_use = clang-profile-use
523 ### On mingw use Windows threads, otherwise POSIX
524 ifneq ($(comp),mingw)
525 CXXFLAGS += -DUSE_PTHREADS
526 # On Android Bionic's C library comes with its own pthread implementation bundled in
527 ifneq ($(OS),Android)
528 # Haiku has pthreads in its libroot, so only link it in on other platforms
529 ifneq ($(KERNEL),Haiku)
544 ### 3.2.2 Debugging with undefined behavior sanitizers
545 ifneq ($(sanitize),none)
546 CXXFLAGS += -g3 $(addprefix -fsanitize=,$(sanitize))
547 LDFLAGS += $(addprefix -fsanitize=,$(sanitize))
551 ifeq ($(optimize),yes)
556 ifeq ($(OS), Android)
557 CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp
561 ifeq ($(KERNEL),Darwin)
562 ifeq ($(comp),$(filter $(comp),clang icc))
563 CXXFLAGS += -mdynamic-no-pic
567 ifneq ($(arch),arm64)
568 CXXFLAGS += -mdynamic-no-pic
574 CXXFLAGS += -fexperimental-new-pass-manager
580 CXXFLAGS += -DIS_64BIT
583 ### 3.5 prefetch and popcount
584 ifeq ($(prefetch),yes)
589 CXXFLAGS += -DNO_PREFETCH
593 ifeq ($(arch),$(filter $(arch),ppc64 armv7 armv8 arm64))
594 CXXFLAGS += -DUSE_POPCNT
595 else ifeq ($(comp),icc)
596 CXXFLAGS += -msse3 -DUSE_POPCNT
598 CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT
602 ### 3.6 SIMD architectures
604 CXXFLAGS += -DUSE_AVX2
605 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
606 CXXFLAGS += -mavx2 -mbmi
610 ifeq ($(avxvnni),yes)
611 CXXFLAGS += -DUSE_VNNI -DUSE_AVXVNNI
612 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
613 CXXFLAGS += -mavxvnni
618 CXXFLAGS += -DUSE_AVX512
619 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
620 CXXFLAGS += -mavx512f -mavx512bw
624 ifeq ($(vnni256),yes)
625 CXXFLAGS += -DUSE_VNNI
626 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
627 CXXFLAGS += -mavx512f -mavx512bw -mavx512vnni -mavx512dq -mavx512vl -mprefer-vector-width=256
631 ifeq ($(vnni512),yes)
632 CXXFLAGS += -DUSE_VNNI
633 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
634 CXXFLAGS += -mavx512vnni -mavx512dq -mavx512vl
639 CXXFLAGS += -DUSE_SSE41
640 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
646 CXXFLAGS += -DUSE_SSSE3
647 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
653 CXXFLAGS += -DUSE_SSE2
654 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
660 CXXFLAGS += -DUSE_MMX
661 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
667 CXXFLAGS += -DUSE_NEON=$(arm_version)
668 ifeq ($(KERNEL),Linux)
670 ifneq ($(arch),armv8)
671 CXXFLAGS += -mfpu=neon
679 CXXFLAGS += -DUSE_PEXT
680 ifeq ($(comp),$(filter $(comp),gcc clang mingw))
685 ### 3.7.1 Try to include git commit sha for versioning
686 GIT_SHA = $(shell git rev-parse --short HEAD 2>/dev/null)
688 CXXFLAGS += -DGIT_SHA=\"$(GIT_SHA)\"
691 ### 3.7.2 Try to include git commit date for versioning
692 GIT_DATE = $(shell git show -s --date=format:'%Y%m%d' --format=%cd HEAD 2>/dev/null)
693 ifneq ($(GIT_DATE), )
694 CXXFLAGS += -DGIT_DATE=\"$(GIT_DATE)\"
697 ### 3.8 Link Time Optimization
698 ### This is a mix of compile and link time options because the lto link phase
699 ### needs access to the optimization flags.
700 ifeq ($(optimize),yes)
703 CXXFLAGS += -flto=full
704 ifeq ($(target_windows),yes)
705 CXXFLAGS += -fuse-ld=lld
707 LDFLAGS += $(CXXFLAGS)
709 # GCC and CLANG use different methods for parallelizing LTO and CLANG pretends to be
710 # GCC on some systems.
711 else ifeq ($(comp),gcc)
712 ifeq ($(gccisclang),)
713 CXXFLAGS += -flto -flto-partition=one
714 LDFLAGS += $(CXXFLAGS) -flto=jobserver
716 CXXFLAGS += -flto=full
717 LDFLAGS += $(CXXFLAGS)
720 # To use LTO and static linking on Windows,
721 # the tool chain requires gcc version 10.1 or later.
722 else ifeq ($(comp),mingw)
723 CXXFLAGS += -flto -flto-partition=one
724 LDFLAGS += $(CXXFLAGS) -save-temps
729 ### 3.9 Android 5 can only run position independent executables. Note that this
730 ### breaks Android 4.0 and earlier.
731 ifeq ($(OS), Android)
733 LDFLAGS += -fPIE -pie
736 ### ==========================================================================
737 ### Section 4. Public Targets
738 ### ==========================================================================
743 @echo "To compile stockfish, type: "
745 @echo "make target ARCH=arch [COMP=compiler] [COMPCXX=cxx]"
747 @echo "Supported targets:"
749 @echo "help > Display architecture details"
750 @echo "profile-build > standard build with profile-guided optimization"
751 @echo "build > skip profile-guided optimization"
752 @echo "net > Download the default nnue net"
753 @echo "strip > Strip executable"
754 @echo "install > Install executable"
755 @echo "clean > Clean up"
757 @echo "Supported archs:"
759 @echo "x86-64-vnni512 > x86 64-bit with vnni support 512bit wide"
760 @echo "x86-64-vnni256 > x86 64-bit with vnni support 256bit wide"
761 @echo "x86-64-avx512 > x86 64-bit with avx512 support"
762 @echo "x86-64-avxvnni > x86 64-bit with avxvnni support"
763 @echo "x86-64-bmi2 > x86 64-bit with bmi2 support"
764 @echo "x86-64-avx2 > x86 64-bit with avx2 support"
765 @echo "x86-64-sse41-popcnt > x86 64-bit with sse41 and popcnt support"
766 @echo "x86-64-modern > common modern CPU, currently x86-64-sse41-popcnt"
767 @echo "x86-64-ssse3 > x86 64-bit with ssse3 support"
768 @echo "x86-64-sse3-popcnt > x86 64-bit with sse3 and popcnt support"
769 @echo "x86-64 > x86 64-bit generic (with sse2 support)"
770 @echo "x86-32-sse41-popcnt > x86 32-bit with sse41 and popcnt support"
771 @echo "x86-32-sse2 > x86 32-bit with sse2 support"
772 @echo "x86-32 > x86 32-bit generic (with mmx and sse support)"
773 @echo "ppc-64 > PPC 64-bit"
774 @echo "ppc-32 > PPC 32-bit"
775 @echo "armv7 > ARMv7 32-bit"
776 @echo "armv7-neon > ARMv7 32-bit with popcnt and neon"
777 @echo "armv8 > ARMv8 64-bit with popcnt and neon"
778 @echo "e2k > Elbrus 2000"
779 @echo "apple-silicon > Apple silicon ARM64"
780 @echo "general-64 > unspecified 64-bit"
781 @echo "general-32 > unspecified 32-bit"
782 @echo "riscv64 > RISC-V 64-bit"
784 @echo "Supported compilers:"
786 @echo "gcc > Gnu compiler (default)"
787 @echo "mingw > Gnu compiler with MinGW under Windows"
788 @echo "clang > LLVM Clang compiler"
789 @echo "icc > Intel compiler"
790 @echo "ndk > Google NDK to cross-compile for Android"
792 @echo "Simple examples. If you don't know what to do, you likely want to run one of: "
794 @echo "make -j profile-build ARCH=x86-64-avx2 # typically a fast compile for common systems "
795 @echo "make -j profile-build ARCH=x86-64-modern # A more portable compile for 64-bit systems "
796 @echo "make -j profile-build ARCH=x86-64 # A portable compile for 64-bit systems "
798 @echo "Advanced examples, for experienced users: "
800 @echo "make -j profile-build ARCH=x86-64-bmi2"
801 @echo "make -j profile-build ARCH=x86-64-bmi2 COMP=gcc COMPCXX=g++-9.0"
802 @echo "make -j build ARCH=x86-64-ssse3 COMP=clang"
804 @echo "-------------------------------"
805 ifeq ($(SUPPORTED_ARCH)$(help_skip_sanity), true)
806 @echo "The selected architecture $(ARCH) will enable the following configuration: "
807 @$(MAKE) ARCH=$(ARCH) COMP=$(COMP) config-sanity
809 @echo "Specify a supported architecture with the ARCH option for more details"
814 .PHONY: help build profile-build strip install clean net objclean profileclean \
815 config-sanity icc-profile-use icc-profile-make gcc-profile-use gcc-profile-make \
816 clang-profile-use clang-profile-make FORCE
818 build: net config-sanity
819 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all
821 profile-build: net config-sanity objclean profileclean
823 @echo "Step 1/4. Building instrumented executable ..."
824 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make)
826 @echo "Step 2/4. Running benchmark for pgo-build ..."
827 $(PGOBENCH) 2>&1 | tail -n 4
829 @echo "Step 3/4. Building optimized executable ..."
830 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean
831 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use)
833 @echo "Step 4/4. Deleting profile data ..."
834 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean
840 -mkdir -p -m 755 $(BINDIR)
842 $(STRIP) $(BINDIR)/$(EXE)
845 clean: objclean profileclean
846 @rm -f .depend *~ core
848 # evaluation network (nnue)
850 $(eval nnuenet := $(shell grep EvalFileDefaultName evaluate.h | grep define | sed 's/.*\(nn-[a-z0-9]\{12\}.nnue\).*/\1/'))
851 @echo "Default net: $(nnuenet)"
852 $(eval nnuedownloadurl1 := https://tests.stockfishchess.org/api/nn/$(nnuenet))
853 $(eval nnuedownloadurl2 := https://github.com/official-stockfish/networks/raw/master/$(nnuenet))
854 $(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))
855 @if [ "x$(curl_or_wget)" = "x" ]; then \
856 echo "Neither curl nor wget is installed. Install one of these tools unless the net has been downloaded manually"; \
858 $(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))
859 @if [ "x$(shasum_command)" = "x" ]; then \
860 echo "shasum / sha256sum not found, skipping net validation"; \
862 @for nnuedownloadurl in "$(nnuedownloadurl1)" "$(nnuedownloadurl2)"; do \
863 if test -f "$(nnuenet)"; then \
864 echo "$(nnuenet) available."; \
866 if [ "x$(curl_or_wget)" != "x" ]; then \
867 echo "Downloading $${nnuedownloadurl}"; $(curl_or_wget) $${nnuedownloadurl} > $(nnuenet);\
869 echo "No net found and download not possible"; exit 1;\
872 if [ "x$(shasum_command)" != "x" ]; then \
873 if [ "$(nnuenet)" != "nn-"`$(shasum_command) $(nnuenet) | cut -c1-12`".nnue" ]; then \
874 echo "Removing failed download"; rm -f $(nnuenet); \
876 echo "Network validated"; break; \
880 @if ! test -f "$(nnuenet)"; then \
881 echo "Failed to download $(nnuenet)."; \
884 # clean binaries and objects
886 @rm -f stockfish stockfish.exe *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o
888 # clean auxiliary profiling files
891 @rm -f bench.txt *.gcda *.gcno ./syzygy/*.gcda ./nnue/*.gcda ./nnue/features/*.gcda *.s
892 @rm -f stockfish.profdata *.profraw
893 @rm -f stockfish.*args*
894 @rm -f stockfish.*lt*
896 @rm -f ./-lstdc++.res
901 ### ==========================================================================
902 ### Section 5. Private Targets
903 ### ==========================================================================
910 @echo "debug: '$(debug)'"
911 @echo "sanitize: '$(sanitize)'"
912 @echo "optimize: '$(optimize)'"
913 @echo "arch: '$(arch)'"
914 @echo "bits: '$(bits)'"
915 @echo "kernel: '$(KERNEL)'"
917 @echo "prefetch: '$(prefetch)'"
918 @echo "popcnt: '$(popcnt)'"
919 @echo "pext: '$(pext)'"
920 @echo "sse: '$(sse)'"
921 @echo "mmx: '$(mmx)'"
922 @echo "sse2: '$(sse2)'"
923 @echo "ssse3: '$(ssse3)'"
924 @echo "sse41: '$(sse41)'"
925 @echo "avx2: '$(avx2)'"
926 @echo "avxvnni: '$(avxvnni)'"
927 @echo "avx512: '$(avx512)'"
928 @echo "vnni256: '$(vnni256)'"
929 @echo "vnni512: '$(vnni512)'"
930 @echo "neon: '$(neon)'"
931 @echo "arm_version: '$(arm_version)'"
935 @echo "CXXFLAGS: $(CXXFLAGS)"
936 @echo "LDFLAGS: $(LDFLAGS)"
938 @echo "Testing config sanity. If this fails, try 'make help' ..."
940 @test "$(debug)" = "yes" || test "$(debug)" = "no"
941 @test "$(optimize)" = "yes" || test "$(optimize)" = "no"
942 @test "$(SUPPORTED_ARCH)" = "true"
943 @test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \
944 test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || test "$(arch)" = "e2k" || \
945 test "$(arch)" = "armv7" || test "$(arch)" = "armv8" || test "$(arch)" = "arm64" || test "$(arch)" = "riscv64"
946 @test "$(bits)" = "32" || test "$(bits)" = "64"
947 @test "$(prefetch)" = "yes" || test "$(prefetch)" = "no"
948 @test "$(popcnt)" = "yes" || test "$(popcnt)" = "no"
949 @test "$(pext)" = "yes" || test "$(pext)" = "no"
950 @test "$(sse)" = "yes" || test "$(sse)" = "no"
951 @test "$(mmx)" = "yes" || test "$(mmx)" = "no"
952 @test "$(sse2)" = "yes" || test "$(sse2)" = "no"
953 @test "$(ssse3)" = "yes" || test "$(ssse3)" = "no"
954 @test "$(sse41)" = "yes" || test "$(sse41)" = "no"
955 @test "$(avx2)" = "yes" || test "$(avx2)" = "no"
956 @test "$(avx512)" = "yes" || test "$(avx512)" = "no"
957 @test "$(vnni256)" = "yes" || test "$(vnni256)" = "no"
958 @test "$(vnni512)" = "yes" || test "$(vnni512)" = "no"
959 @test "$(neon)" = "yes" || test "$(neon)" = "no"
960 @test "$(comp)" = "gcc" || test "$(comp)" = "icc" || test "$(comp)" = "mingw" || test "$(comp)" = "clang" \
961 || test "$(comp)" = "armv7a-linux-androideabi16-clang" || test "$(comp)" = "aarch64-linux-android21-clang"
964 +$(CXX) -o $@ $(OBJS) $(LDFLAGS)
966 # Force recompilation to ensure version info is up-to-date
971 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
972 EXTRACXXFLAGS='-fprofile-instr-generate ' \
973 EXTRALDFLAGS=' -fprofile-instr-generate' \
977 $(XCRUN) llvm-profdata merge -output=stockfish.profdata *.profraw
978 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
979 EXTRACXXFLAGS='-fprofile-instr-use=stockfish.profdata' \
980 EXTRALDFLAGS='-fprofile-use ' \
985 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
986 EXTRACXXFLAGS='-fprofile-generate=profdir' \
987 EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
988 EXTRALDFLAGS='-lgcov' \
992 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
993 EXTRACXXFLAGS='-fprofile-use=profdir -fno-peel-loops -fno-tracer' \
994 EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
995 EXTRALDFLAGS='-lgcov' \
1000 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1001 EXTRACXXFLAGS='-prof-gen=srcpos -prof_dir ./profdir' \
1005 $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
1006 EXTRACXXFLAGS='-prof_use -prof_dir ./profdir' \
1010 -@$(CXX) $(DEPENDFLAGS) -MM $(SRCS) > $@ 2> /dev/null
1012 ifeq (, $(filter $(MAKECMDGOALS), help strip install clean net objclean profileclean config-sanity))