commit:     d8467da93d612f11b7daaa2644a0c52bf581c979
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 16 01:56:01 2021 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Apr 16 02:26:58 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d8467da9

dev-libs/botan: rework src_configure (including CPU_FLAGS_*)

* Add support for CPU_FLAGS_* rather than automagic detection
* Consoldiate arch-specific workarounds
* Sort configure arguments
* Simplify disable logic
* Minor other style changes
* Drop USE=libressl

Closes: https://bugs.gentoo.org/724338
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-libs/botan/botan-2.18.0.ebuild | 105 ++++++++++++++++++++++++-------------
 1 file changed, 68 insertions(+), 37 deletions(-)

diff --git a/dev-libs/botan/botan-2.18.0.ebuild 
b/dev-libs/botan/botan-2.18.0.ebuild
index 0fd5992235c..ab5000d8a85 100644
--- a/dev-libs/botan/botan-2.18.0.ebuild
+++ b/dev-libs/botan/botan-2.18.0.ebuild
@@ -4,11 +4,9 @@
 EAPI=7
 
 PYTHON_COMPAT=( python3_{7,8,9} )
-
 inherit python-r1 toolchain-funcs
 
 MY_P="Botan-${PV}"
-
 DESCRIPTION="C++ crypto library"
 HOMEPAGE="https://botan.randombit.net/";
 SRC_URI="https://botan.randombit.net/releases/${MY_P}.tar.xz";
@@ -17,15 +15,17 @@ S="${WORKDIR}/${MY_P}"
 LICENSE="BSD-2"
 SLOT="2/$(ver_cut 1-2)" # soname version
 KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~ppc-macos"
-IUSE="bindist doc boost bzip2 libressl lzma python ssl static-libs sqlite zlib"
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
+IUSE="bindist doc boost bzip2 lzma python ssl static-libs sqlite zlib"
 
-BDEPEND="
-       ${PYTHON_DEPS}
-       $(python_gen_any_dep '
-               doc? ( dev-python/sphinx[${PYTHON_USEDEP}] )
-       ')
-"
+CPU_USE=(
+       cpu_flags_arm_{aes,neon}
+       cpu_flags_ppc_altivec
+       cpu_flags_x86_{aes,avx2,popcnt,rdrand,sse2,ssse3,sse4_1,sse4_2}
+)
+
+IUSE+=" ${CPU_USE[@]}"
+
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
 
 # NOTE: Boost is needed at runtime too for the CLI tool.
 DEPEND="
@@ -33,15 +33,17 @@ DEPEND="
        bzip2? ( >=app-arch/bzip2-1.0.5:= )
        lzma? ( app-arch/xz-utils:= )
        python? ( ${PYTHON_DEPS} )
-       ssl? (
-               !libressl? ( dev-libs/openssl:0=[bindist=] )
-               libressl? ( dev-libs/libressl:0= )
-       )
+       ssl? ( dev-libs/openssl:0=[bindist=] )
        sqlite? ( dev-db/sqlite:3= )
        zlib? ( >=sys-libs/zlib-1.2.3:= )
 "
-
 RDEPEND="${DEPEND}"
+BDEPEND="
+       ${PYTHON_DEPS}
+       $(python_gen_any_dep '
+               doc? ( dev-python/sphinx[${PYTHON_USEDEP}] )
+       ')
+"
 
 # NOTE: Considering patching Botan?
 # Please see upstream's guidance:
@@ -54,25 +56,35 @@ python_check_deps() {
 }
 
 src_configure() {
-       local disable_modules=()
-       use boost || disable_modules+=( "boost" )
-       use bindist && disable_modules+=( "ecdsa" )
-       elog "Disabling module(s): ${disable_modules[@]}"
+       local disable_modules=(
+               $(usex boost '' 'boost')
+               $(usex bindist 'ecdsa' '')
+       )
 
-       # Enable v9 instructions for sparc64
-       local chostarch="${CHOST%%-*}"
-       if [[ "${PROFILE_ARCH}" = "sparc64" ]] ; then
-               chostarch="sparc32-v9"
+       if [[ -z "${DISABLE_MODULES}" ]] ; then
+               elog "Disabling module(s): ${disable_modules[@]}"
        fi
 
+       local chostarch="${CHOST%%-*}"
+
+       # Arch specific wrangling
+
        local myos=
        case ${CHOST} in
-               *-darwin*) myos=darwin ;;
-               *) myos=linux  ;;
-       esac
+               *-darwin*)
+                       myos=darwin
+               ;;
+
+               *)
+                       myos=linux
+
+                       if [[ ${CHOST} == *hppa* ]] ; then
+                               chostarch=parisc
+                       elif [[ ${PROFILE_ARCH} == "sparc64" ]] ; then
+                               chostarch="sparc32-v9"
+                       fi
+               ;;
 
-       case ${CHOST} in
-               hppa*) chostarch=parisc ;;
        esac
 
        local pythonvers=()
@@ -84,31 +96,50 @@ src_configure() {
                python_foreach_impl _append
        fi
 
-       # Don't install Python bindings automatically
-       # (do it manually later in the right place)
-       # https://bugs.gentoo.org/723096
        local myargs=(
-               $(use_enable static-libs static-library)
+               # Intrinsics
+               # TODO: x86 RDSEED (new CPU_FLAGS_X86?)
+               # TODO: POWER Crypto (new CPU_FLAGS_PPC?)
+               $(usex cpu_flags_arm_aes '' '--disable-armv8crypto')
+               $(usex cpu_flags_arm_neon '' '--disable-neon')
+               $(usex cpu_flags_ppc_altivec '' '--disable-altivec')
+               $(usex cpu_flags_x86_aes '' '--disable-aes-ni')
+               $(usex cpu_flags_x86_avx2 '' '--disable-avx2')
+               $(usex cpu_flags_x86_popcnt '' '--disable-bmi2')
+               $(usex cpu_flags_x86_rdrand '' '--disable-rdrand')
+               $(usex cpu_flags_x86_sse2 '' '--disable-sse2')
+               $(usex cpu_flags_x86_ssse3 '' '--disable-ssse3')
+               $(usex cpu_flags_x86_sse4_1 '' '--disable-sse4.1')
+               $(usex cpu_flags_x86_sse4_2 '' '--disable-sse4.2')
+
+               $(usex hppa --without-stack-protector '')
+
                $(use_with boost)
                $(use_with bzip2)
                $(use_with doc documentation)
                $(use_with doc sphinx)
                $(use_with lzma)
-               $(use_with sqlite sqlite3)
+               $(use_enable static-libs static-library)
                $(use_with ssl openssl)
+               $(use_with sqlite sqlite3)
                $(use_with zlib)
-               $(usex hppa --without-stack-protector '')
+
                --cpu=${chostarch}
-               --disable-modules=$( IFS=","; echo "${disable_modules[*]}" )
                --docdir=share/doc
+               --disable-modules=$( IFS=","; echo "${disable_modules[*]}" )
+               --distribution-info="Gentoo ${PVR}"
                --libdir=$(get_libdir)
+
+               # Don't install Python bindings automatically
+               # (do it manually later in the right place)
+               # https://bugs.gentoo.org/723096
+               --no-install-python-module
+
                --os=${myos}
-               --distribution-info="Gentoo ${PVR}"
                --prefix="${EPREFIX}/usr"
                --with-endian="$(tc-endian)"
                --with-python-version=$( IFS=","; echo "${pythonvers[*]}" )
                --without-doxygen
-               --no-install-python-module
        )
 
        tc-export CC CXX AR

Reply via email to