1 # Copyright 1999-2023 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit toolchain-funcs multilib-minimal
9 MY_GMP_COMMIT="e7d30b921df736a1121a0c8e0cf3ab1ce5b8a4b7"
11 DESCRIPTION="Cisco OpenH264 library and Gecko Media Plugin for Mozilla packages"
12 HOMEPAGE="https://www.openh264.org/ https://github.com/cisco/openh264"
13 SRC_URI="https://github.com/cisco/openh264/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
14 https://github.com/mozilla/gmp-api/archive/${MY_GMP_COMMIT}.tar.gz -> gmp-api-Firefox${MOZVER}-${MY_GMP_COMMIT}.tar.gz"
17 # openh264 soname version.
18 # (2.2.0 needed a minor bump due to undocumented but breaking ABI changes, just to be sure.
19 # https://github.com/cisco/openh264/issues/3459 )
21 KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~mips ppc ppc64 ~riscv ~sparc x86"
22 IUSE="cpu_flags_arm_neon cpu_flags_x86_avx2 +plugin test utils"
24 RESTRICT="bindist !test? ( test )"
27 abi_x86_32? ( dev-lang/nasm )
28 abi_x86_64? ( dev-lang/nasm )
29 test? ( dev-cpp/gtest[${MULTILIB_USEDEP}] )"
31 DOCS=( LICENSE CONTRIBUTORS README.md )
34 "${FILESDIR}"/openh264-2.3.0-pkgconfig-pathfix.patch
35 "${FILESDIR}"/${PN}-2.3.1-pr3630.patch
41 ln -svf "/dev/null" "build/gtest-targets.mk" || die
42 sed -i -e 's/$(LIBPREFIX)gtest.$(LIBSUFFIX)//g' Makefile || die
44 sed -i -e 's/ | generate-version//g' Makefile || die
45 sed -e 's|$FULL_VERSION|""|g' codec/common/inc/version_gen.h.template > \
46 codec/common/inc/version_gen.h
51 multilib_src_configure() {
52 ln -s "${WORKDIR}"/gmp-api-${MY_GMP_COMMIT} gmp-api || die
56 CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" AR="$(tc-getAR)" \
57 emake V=Yes CFLAGS_M32="" CFLAGS_M64="" CFLAGS_OPT="" \
58 PREFIX="${EPREFIX}/usr" \
59 LIBDIR_NAME="$(get_libdir)" \
60 SHAREDLIB_DIR="${EPREFIX}/usr/$(get_libdir)" \
61 INCLUDES_DIR="${EPREFIX}/usr/include/${PN}" \
62 HAVE_AVX2=$(usex cpu_flags_x86_avx2 Yes No) \
63 HAVE_GTEST=$(usex test Yes No) \
69 multilib_src_compile() {
70 local myopts="ENABLE64BIT=No"
72 s390x|alpha|*64) myopts="ENABLE64BIT=Yes";;
76 myopts+=" USE_ASM=$(usex cpu_flags_arm_neon Yes No)"
80 use plugin && emakecmd ${myopts} plugin
87 multilib_src_install() {
88 emakecmd DESTDIR="${D}" install-shared
91 newbin h264enc openh264enc
92 newbin h264dec openh264dec
96 local plugpath="${ROOT}/usr/$(get_libdir)/nsbrowser/plugins/gmp-gmp${PN}/system-installed"
98 doins libgmpopenh264.so* gmpopenh264.info
99 echo "MOZ_GMP_PATH=\"${plugpath}\"" >"${T}"/98-moz-gmp-${PN}
100 doenvd "${T}"/98-moz-gmp-${PN}
102 cat <<PREFEOF >"${T}"/${P}.js
103 pref("media.gmp-gmp${PN}.autoupdate", false);
104 pref("media.gmp-gmp${PN}.version", "system-installed");
107 insinto /usr/$(get_libdir)/firefox/defaults/pref
108 newins "${T}"/${P}.js ${PN}-${PV/_p*/}.js
110 insinto /usr/$(get_libdir)/seamonkey/defaults/pref
111 newins "${T}"/${P}.js ${PN}-${PV/_p*/}.js
117 if [[ -z ${REPLACING_VERSIONS} ]]; then
118 elog "Please restart your login session, in order for the session's environment"
119 elog "to include the new MOZ_GMP_PATH variable."
122 elog "This package attempts to override the Mozilla GMPInstaller auto-update process,"
123 elog "however even if it is not successful in doing so the profile-installed plugin"
124 elog "will not be used unless this package is removed. This package will take precedence"
125 elog "over any gmp-gmpopenh264 that may be installed in a user's profile."
130 elog "Utilities h264enc and h264dec are installed as openh264enc and openh264dec"
131 elog "to avoid file collisions with media-video/h264enc"