commit: 69d5c34dca046b4fa55c390d75c456a942da360f
Author: Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 12 08:49:53 2025 +0000
Commit: Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Wed Mar 12 10:11:41 2025 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=69d5c34d
ffmpeg-compat.eclass: add ffmpeg_compat_add_flags helper
Most packages are fine, but then there's cmake.
Also some others doing -L/usr/lib64 *before* pkg-config flags.
Not great, but adding to CPPFLAGS/LDFLAGS directly tend to
workaround most issues and helper will spare repeating this.
Also emphasize on importance to verify libraries, e.g. it can
build against ffmpeg-compat:6 but the -L/usr/lib64 will make
it use ffmpeg-7 and this sometimes succeed even if package was
broken with ffmpeg-7 assuming no missing symbols. -rpath could
also have been lost and libraries be not found.
Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org>
eclass/ffmpeg-compat.eclass | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/eclass/ffmpeg-compat.eclass b/eclass/ffmpeg-compat.eclass
index f91fe6eead31..1835a8c7e95a 100644
--- a/eclass/ffmpeg-compat.eclass
+++ b/eclass/ffmpeg-compat.eclass
@@ -12,7 +12,8 @@
# To use this, run ``ffmpeg_compat_setup <slot>`` before packages use
# pkg-config, depend on media-video/ffmpeg-compat:<slot>=, and ensure
# usage of both pkg-config --cflags and --libs (which adds -Wl,-rpath
-# to find libraries at runtime).
+# to find libraries at runtime). Always verify that it is linked with
+# the right libraries after.
#
# This eclass is intended as a quick-to-setup alternative to setting
# an upper bound on ffmpeg for packages broken with the latest version,
@@ -41,6 +42,27 @@ esac
if [[ -z ${_FFMPEG_COMPAT_ECLASS} ]]; then
_FFMPEG_COMPAT_ECLASS=1
+inherit flag-o-matic toolchain-funcs
+
+# @FUNCTION: ffmpeg_compat_add_flags
+# @DESCRIPTION:
+# Append ``pkg-config --cflags libavcodec`` to CPPFLAGS and
+# --libs-only-{L,other} to LDFLAGS for the current ABI.
+#
+# Must run ``ffmpeg_compat_setup <slot>`` first.
+#
+# Ideally this function should not be used, but can be useful when
+# packages do not use pkg-config properly or drop some flags (common
+# with cmake).
+#
+# For multilib, ebuild should preserve previous flags by doing e.g.
+# ``local -x CPPFLAGS=${CPPFLAGS} LDFLAGS=${LDFLAGS}`` first.
+ffmpeg_compat_add_flags() {
+ # should be no real need to check anything but libavcodec's flags
+ append-cppflags $($(tc-getPKG_CONFIG) --cflags libavcodec || die)
+ append-ldflags $($(tc-getPKG_CONFIG) --libs-only-{L,other} libavcodec
|| die)
+}
+
# @FUNCTION: ffmpeg_compat_get_prefix
# @USAGE: <slot>
# @DESCRIPTION: