app-admin/awscli: Bump to 1.37.9
[gentoo/gentoo.git] / games-board / stockfish / stockfish-16.1.ebuild
blob4cc6280b6b5dc26b9c6381214136918c2908f75d
1 # Copyright 1999-2024 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=7
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_FILES="nn-b1a57edbea57.nnue nn-baff1ede1f90.nnue"
13 SRC_URI="https://github.com/official-stockfish/Stockfish/archive/sf_${PV}.tar.gz -> ${P}.tar.gz"
15 for i in $NNUE_FILES; do
16         SRC_URI+=" https://tests.stockfishchess.org/api/nn/${i} -> ${P}-${i}"
17 done
19 LICENSE="GPL-3"
20 SLOT="0"
21 KEYWORDS="~amd64 ~arm64 ~loong ~riscv ~x86"
22 IUSE="cpu_flags_arm_v7 cpu_flags_x86_avx2 cpu_flags_x86_popcnt cpu_flags_x86_sse cpu_flags_x86_avx512f
23         cpu_flags_x86_avx512dq debug general-32 general-64 +optimize"
25 DEPEND="|| ( app-arch/unzip app-arch/zip )"
27 S="${WORKDIR}/Stockfish-sf_${PV}/src"
29 pkg_setup() {
30         if ! tc-is-clang && ! tc-is-gcc; then
31                 die "Unsupported compiler: $(tc-getCC)"
32         fi
35 src_prepare() {
36         default
38         # remove config sanity check that doesn't like our COMPILER settings
39         sed -i -e 's/ config-sanity//g' Makefile || die
41         for i in $NNUE_FILES; do
42                 cp "${DISTDIR}"/${P}-${i} ${i} || die "copying the nnue file failed"
43         done
45         # prevent pre-stripping
46         sed -e 's:-strip $(BINDIR)/$(EXE)::' -i Makefile \
47                 || die 'failed to disable stripping in the Makefile'
49         # Makefile is a bit optimistic
50         sed -e 's:-flto=full:-flto:g' -i Makefile || die
53 src_compile() {
54         local my_arch
56         # generic unoptimized first
57         use general-32 && my_arch=general-32
58         use general-64 && my_arch=general-64
60         # x86
61         use x86 && my_arch=x86-32-old
62         use cpu_flags_x86_sse && my_arch=x86-32
64         # amd64
65         use amd64 && my_arch=x86-64
66         use cpu_flags_x86_popcnt && my_arch=x86-64-modern
68         # both bmi2 and avx2 are part of hni (haswell new instructions)
69         use cpu_flags_x86_avx2 && my_arch=x86-64-bmi2
71         # avx512
72         # we currently can't express  'avx512vnni' 'avx512dq' 'avx512f' 'avx512bw' 'avx512vl'
73         # so only enable basic support
74         use cpu_flags_x86_avx512f && use cpu_flags_x86_avx512dq && my_arch=x86-64-avx512
76         # other architectures
77         use cpu_flags_arm_v7 && my_arch=armv7
78         use ppc && my_arch=ppc
79         use ppc64 && my_arch=ppc64
81         # Bug 919781: COMP is a fixed string like clang/gcc to set tools for PGO
82         local comp
83         tc-is-gcc && comp="gcc"
84         tc-is-clang && comp="clang"
86         # There's a nice hack in the Makefile that overrides the value of CXX with
87         # COMPILER to support Travis CI and we abuse it to make sure that we
88         # build with our compiler of choice.
89         emake profile-build ARCH="${my_arch}" \
90                 COMP="${comp}" \
91                 COMPILER="$(tc-getCXX)" \
92                 debug=$(usex debug "yes" "no") \
93                 optimize=$(usex optimize "yes" "no")
96 src_install() {
97         dobin "${PN}"
98         dodoc ../AUTHORS ../README.md