1 # Copyright 1999-2024 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit toolchain-funcs
8 DESCRIPTION="Free UCI chess engine, claimed to be the strongest in the world"
9 HOMEPAGE="https://stockfishchess.org/"
11 NNUE_FILE="nn-3475407dc199.nnue"
13 SRC_URI="https://github.com/official-stockfish/Stockfish/archive/sf_${PV}.tar.gz -> ${P}.tar.gz
14 https://tests.stockfishchess.org/api/nn/${NNUE_FILE} -> ${P}-${NNUE_FILE}"
17 KEYWORDS="~amd64 ~riscv ~x86"
18 IUSE="cpu_flags_arm_v7 cpu_flags_x86_avx2 cpu_flags_x86_popcnt cpu_flags_x86_sse debug
19 general-32 general-64 +optimize"
21 DEPEND="|| ( app-arch/unzip app-arch/zip )"
23 S="${WORKDIR}/Stockfish-sf_${PV}/src"
28 cp "${DISTDIR}"/${P}-${NNUE_FILE} ${NNUE_FILE} || die "copying the nnue file failed"
30 # prevent pre-stripping
31 sed -e 's:-strip $(BINDIR)/$(EXE)::' -i Makefile \
32 || die 'failed to disable stripping in the Makefile'
38 # generic unoptimized first
39 use general-32 && my_arch=general-32
40 use general-64 && my_arch=general-64
43 use x86 && my_arch=x86-32-old
44 use cpu_flags_x86_sse && my_arch=x86-32
47 use amd64 && my_arch=x86-64
48 use cpu_flags_x86_popcnt && my_arch=x86-64-modern
50 # both bmi2 and avx2 are part of hni (haswell new instructions)
51 use cpu_flags_x86_avx2 && my_arch=x86-64-bmi2
54 use cpu_flags_arm_v7 && my_arch=armv7
55 use ppc && my_arch=ppc
56 use ppc64 && my_arch=ppc64
58 # Skip the "build" target and use "all" instead to avoid the config
59 # sanity check (which would throw a fit about our compiler). There's
60 # a nice hack in the Makefile that overrides the value of CXX with
61 # COMPILER to support Travis CI and we abuse it to make sure that we
62 # build with our compiler of choice.
63 emake all ARCH="${my_arch}" \
65 COMPILER="$(tc-getCXX)" \
66 debug=$(usex debug "yes" "no") \
67 optimize=$(usex optimize "yes" "no")
72 dodoc ../AUTHORS ../README.md