app-admin/awscli: Bump to 1.37.9
[gentoo/gentoo.git] / media-libs / openh264 / openh264-2.3.1-r3.ebuild
blob2e828c1b6819abf9c39a3b6d4b292b110e3e3b19
1 # Copyright 1999-2023 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=8
6 inherit toolchain-funcs multilib-minimal
8 MOZVER=114_2
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"
15 LICENSE="BSD"
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 )
20 SLOT="0/7"
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 )"
26 BDEPEND="
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 )
33 PATCHES=(
34         "${FILESDIR}"/openh264-2.3.0-pkgconfig-pathfix.patch
35         "${FILESDIR}"/${PN}-2.3.1-pr3630.patch
38 src_prepare() {
39         default
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
48         multilib_copy_sources
51 multilib_src_configure() {
52         ln -s "${WORKDIR}"/gmp-api-${MY_GMP_COMMIT} gmp-api || die
55 emakecmd() {
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) \
64                 ARCH="$(tc-arch)" \
65                 ENABLEPIC="Yes" \
66                 $@
69 multilib_src_compile() {
70         local myopts="ENABLE64BIT=No"
71         case "${ABI}" in
72                 s390x|alpha|*64) myopts="ENABLE64BIT=Yes";;
73         esac
75         if use arm; then
76                 myopts+=" USE_ASM=$(usex cpu_flags_arm_neon Yes No)"
77         fi
79         emakecmd ${myopts}
80         use plugin && emakecmd ${myopts} plugin
83 multilib_src_test() {
84         emakecmd test
87 multilib_src_install() {
88         emakecmd DESTDIR="${D}" install-shared
90         if use utils; then
91                 newbin h264enc openh264enc
92                 newbin h264dec openh264dec
93         fi
95         if use plugin; then
96                 local plugpath="${ROOT}/usr/$(get_libdir)/nsbrowser/plugins/gmp-gmp${PN}/system-installed"
97                 insinto "${plugpath}"
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");
105 PREFEOF
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
112         fi
115 pkg_postinst() {
116         if use plugin; then
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."
120                         elog ""
121                 fi
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."
126                 elog ""
127         fi
129         if use utils; then
130                 elog "Utilities h264enc and h264dec are installed as openh264enc and openh264dec"
131                 elog "to avoid file collisions with media-video/h264enc"
132                 elog ""
133         fi