commit:     24ea9364ea9c83c441658f8d508dac51450fcc5a
Author:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 12 23:38:41 2025 +0000
Commit:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Wed Aug 13 00:22:30 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=24ea9364

media-video/ffmpeg: use pkgconf for npp

Hadn't noticed that cuda had .pc files (they are in /opt/cuda/pkgconfig
with PKG_CONFIG_PATH set in env.d), and this saves us from having to
figure out paths.

Also move to multilib_src_configure, while it only returns safe paths
"currently" would still rather not pass a 64bit -L for 32bit esp.
if it comes from pkgconf given it could unexpectedly change.

ffmpeg checks for several more libraries than just "nppc" but I see
little reason to maintain the full list in the ebuild, ffmpeg handles
the -l arguments itself and checks for two different sets which would
complicate things. Will revisit if a new cuda version ever starts
needing per-npp-library -L/-I for some reason.

Unsure if there is a reason why ffmpeg itself does not use .pc files,
would need to check what other distros and nvidia's own installer do
-- but given our cuda ebuild seem to have special handling for .pc
it's possible that they're missing for some/many or even all. Ideal
would be for ffmpeg to try these first and (if really needed) then
fallback to check_lib, but not going to look into upstreaming such fix
myself.

Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org>

 media-video/ffmpeg/ffmpeg-6.1.2-r3.ebuild | 14 +++++++-------
 media-video/ffmpeg/ffmpeg-7.1.1-r2.ebuild | 14 +++++++-------
 media-video/ffmpeg/ffmpeg-9999.ebuild     | 14 +++++++-------
 3 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/media-video/ffmpeg/ffmpeg-6.1.2-r3.ebuild 
b/media-video/ffmpeg/ffmpeg-6.1.2-r3.ebuild
index 820362189448..d0cf2139f99c 100644
--- a/media-video/ffmpeg/ffmpeg-6.1.2-r3.ebuild
+++ b/media-video/ffmpeg/ffmpeg-6.1.2-r3.ebuild
@@ -383,7 +383,7 @@ src_prepare() {
        # respect user preferences
        sed -i '/cflags -fdiagnostics-color/d' configure || die
 
-       # handle *FLAGS here to avoid repeating for each ABI below (bug #923491)
+       # handle here to avoid repeating for each ABI below (bug #923491)
        FFMPEG_ENABLE_LTO=
        if tc-is-lto; then
                : "$(get-flag -flto)" # get -flto=<val> (e.g. =thin)
@@ -392,15 +392,15 @@ src_prepare() {
        filter-lto
 
        use elibc_musl && append-cppflags -D__musl__ #940733
-
-       if use npp; then
-               local cuda=${ESYSROOT}/opt/cuda/targets/$(usex amd64 x86_64 
sbsa)-linux
-               append-cppflags -I"${cuda}"/include
-               append-ldflags -L"${cuda}"/lib
-       fi
 }
 
 multilib_src_configure() {
+       if use npp && multilib_is_native_abi; then
+               local -x CPPFLAGS=${CPPFLAGS} LDFLAGS=${LDFLAGS}
+               append-cppflags $($(tc-getPKG_CONFIG) --cflags nppc || die)
+               append-ldflags $($(tc-getPKG_CONFIG) --libs-only-L nppc || die)
+       fi
+
        local conf=( "${S}"/configure ) # not autotools-based
 
        local prefix=${EPREFIX}/usr

diff --git a/media-video/ffmpeg/ffmpeg-7.1.1-r2.ebuild 
b/media-video/ffmpeg/ffmpeg-7.1.1-r2.ebuild
index 5c2e786c9e3c..e228302fd459 100644
--- a/media-video/ffmpeg/ffmpeg-7.1.1-r2.ebuild
+++ b/media-video/ffmpeg/ffmpeg-7.1.1-r2.ebuild
@@ -395,22 +395,22 @@ src_prepare() {
        # respect user preferences
        sed -i '/cflags -fdiagnostics-color/d' configure || die
 
-       # handle *FLAGS here to avoid repeating for each ABI below (bug #923491)
+       # handle here to avoid repeating for each ABI below (bug #923491)
        FFMPEG_ENABLE_LTO=
        if tc-is-lto; then
                : "$(get-flag -flto)" # get -flto=<val> (e.g. =thin)
                FFMPEG_ENABLE_LTO=--enable-lto${_#-flto}
        fi
        filter-lto
-
-       if use npp; then
-               local cuda=${ESYSROOT}/opt/cuda/targets/$(usex amd64 x86_64 
sbsa)-linux
-               append-cppflags -I"${cuda}"/include
-               append-ldflags -L"${cuda}"/lib
-       fi
 }
 
 multilib_src_configure() {
+       if use npp && multilib_is_native_abi; then
+               local -x CPPFLAGS=${CPPFLAGS} LDFLAGS=${LDFLAGS}
+               append-cppflags $($(tc-getPKG_CONFIG) --cflags nppc || die)
+               append-ldflags $($(tc-getPKG_CONFIG) --libs-only-L nppc || die)
+       fi
+
        local conf=( "${S}"/configure ) # not autotools-based
 
        local prefix=${EPREFIX}/usr

diff --git a/media-video/ffmpeg/ffmpeg-9999.ebuild 
b/media-video/ffmpeg/ffmpeg-9999.ebuild
index c8b02fc14ee9..e394ca13c28e 100644
--- a/media-video/ffmpeg/ffmpeg-9999.ebuild
+++ b/media-video/ffmpeg/ffmpeg-9999.ebuild
@@ -386,22 +386,22 @@ src_prepare() {
        # respect user preferences
        sed -i '/cflags -fdiagnostics-color/d' configure || die
 
-       # handle *FLAGS here to avoid repeating for each ABI below (bug #923491)
+       # handle here to avoid repeating for each ABI below (bug #923491)
        FFMPEG_ENABLE_LTO=
        if tc-is-lto; then
                : "$(get-flag -flto)" # get -flto=<val> (e.g. =thin)
                FFMPEG_ENABLE_LTO=--enable-lto${_#-flto}
        fi
        filter-lto
-
-       if use npp; then
-               local cuda=${ESYSROOT}/opt/cuda/targets/$(usex amd64 x86_64 
sbsa)-linux
-               append-cppflags -I"${cuda}"/include
-               append-ldflags -L"${cuda}"/lib
-       fi
 }
 
 multilib_src_configure() {
+       if use npp && multilib_is_native_abi; then
+               local -x CPPFLAGS=${CPPFLAGS} LDFLAGS=${LDFLAGS}
+               append-cppflags $($(tc-getPKG_CONFIG) --cflags nppc || die)
+               append-ldflags $($(tc-getPKG_CONFIG) --libs-only-L nppc || die)
+       fi
+
        local conf=( "${S}"/configure ) # not autotools-based
 
        local prefix=${EPREFIX}/usr

Reply via email to