dev-python/mpmath: Bump to 1.4.0_alpha4
[gentoo/gentoo.git] / media-video / handbrake / handbrake-9999.ebuild
blob87d75de6700c6badc5bac97f1b443e4e37587c0d
1 # Copyright 1999-2024 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=8
6 PYTHON_COMPAT=( python3_{10..13} )
8 inherit edo flag-o-matic multiprocessing python-any-r1 toolchain-funcs xdg
10 DESCRIPTION="Open-source, GPL-licensed, multiplatform, multithreaded video transcoder"
11 HOMEPAGE="https://handbrake.fr/ https://github.com/HandBrake/HandBrake"
13 if [[ ${PV} == *9999* ]]; then
14         EGIT_REPO_URI="https://github.com/HandBrake/HandBrake.git"
15         inherit git-r3
16 else
17         MY_P="HandBrake-${PV}"
18         SRC_URI="https://github.com/HandBrake/HandBrake/releases/download/${PV}/${MY_P}-source.tar.bz2 -> ${P}.tar.bz2"
19         S="${WORKDIR}/${MY_P}"
20         KEYWORDS="~amd64 ~arm64 ~x86"
23 # contrib/<project>/module.defs
24 declare -A BUNDLED=(
25         # Heavily patched in an incompatible way.
26         # Issues related to using system ffmpeg historically.
27         # See bug #829595 and #922828
28         [ffmpeg]="https://github.com/HandBrake/HandBrake-contribs/releases/download/contribs2/ffmpeg-7.1.tar.bz2;"
29         # Patched in an incompatible way
30         [x265]="https://github.com/HandBrake/HandBrake-contribs/releases/download/contribs2/x265_4.1.tar.gz;x265"
31         [x265_8bit]="https://github.com/HandBrake/HandBrake-contribs/releases/download/contribs2/x265_4.1.tar.gz;x265"
32         [x265_10bit]="https://github.com/HandBrake/HandBrake-contribs/releases/download/contribs2/x265_4.1.tar.gz;x265"
33         [x265_12bit]="https://github.com/HandBrake/HandBrake-contribs/releases/download/contribs2/x265_4.1.tar.gz;x265"
36 bundle_src_uri() {
37         for name in "${!BUNDLED[@]}"; do
38                 IFS=$';' read -r uri use <<< ${BUNDLED[${name}]}
39                 local tarball=${uri##*/}
40                 if [[ -n ${use} ]]; then
41                         SRC_URI+=" ${use}? ( ${uri} -> handbrake-${tarball} )"
42                 else
43                         SRC_URI+=" ${uri} -> handbrake-${tarball}"
44                 fi
45         done
48 bundle_src_uri
50 LICENSE="GPL-2"
51 SLOT="0"
52 IUSE="amf +fdk gui libdovi numa nvenc qsv x265"
54 REQUIRED_USE="numa? ( x265 )"
56 COMMON_DEPEND="
57         app-arch/bzip2
58         >=app-arch/xz-utils-5.2.6
59         dev-libs/jansson:=
60         >=media-libs/dav1d-1.0.0:=
61         >=media-libs/libjpeg-turbo-2.1.4:=
62         >=media-libs/libass-0.16.0:=
63         >=media-libs/libbluray-1.3.4:=
64         media-libs/libdvdnav
65         >=media-libs/libdvdread-6.1.3:=
66         media-libs/libtheora
67         media-libs/libvorbis
68         >=media-libs/libvpx-1.12.0:=
69         media-libs/opus
70         >=media-libs/speex-1.2.1
71         >=media-libs/svt-av1-1.4.1:=
72         >=media-libs/x264-0.0.20220222:=
73         >=media-libs/zimg-3.0.4
74         media-sound/lame
75         sys-libs/zlib
76         fdk? ( media-libs/fdk-aac:= )
77         libdovi? ( media-libs/libdovi:= )
78         gui? (
79                 >=gui-libs/gtk-4.4:4[gstreamer]
80                 dev-libs/glib:2
81                 >=dev-libs/libxml2-2.10.3
82                 x11-libs/gdk-pixbuf:2
83                 x11-libs/pango
84         )
85         numa? ( sys-process/numactl )
86         nvenc? ( media-libs/nv-codec-headers )
87         qsv? (
88                 media-libs/libva:=
89                 media-libs/libvpl:=
90         )
92 RDEPEND="
93         ${COMMON_DEPEND}
94         amf? ( media-video/amdgpu-pro-amf )
96 DEPEND="
97         ${COMMON_DEPEND}
98         amf? ( media-libs/amf-headers )
100 # cmake needed for custom script: bug #852701
101 BDEPEND="
102         ${PYTHON_DEPS}
103         dev-build/cmake
104         dev-lang/nasm
105         gui? (
106                 dev-build/meson
107                 sys-devel/gettext
108         )
111 PATCHES=(
112         "${FILESDIR}"/handbrake-1.9.0-link-libdovi-properly.patch
113         "${FILESDIR}"/handbrake-1.9.0-include-vpl-properly.patch
116 src_unpack() {
117         if [[ ${PV} == 9999 ]]; then
118                 git-r3_src_unpack
119         else
120                 unpack ${P}.tar.bz2
121         fi
124 src_prepare() {
125         mkdir download || die
126         for name in "${!BUNDLED[@]}"; do
127                 IFS=$';' read -r uri use <<< ${BUNDLED[${name}]}
128                 local tarball="${uri##*/}"
129                 if [[ -n ${use} ]]; then
130                         use ${use} || continue
131                 fi
132                 cp "${DISTDIR}/handbrake-${tarball}" download/${tarball} || die
133         done
135         # Get rid of leftover bundled library build definitions
136         sed -i -E \
137                 -e "/MODULES \+= contrib\// { /($(IFS=$'|'; echo "${!BUNDLED[*]}"))$/! d }" \
138                 "${S}"/make/include/main.defs || die
140         # noop fetching
141         sed -i -e '/DF..*.exe/ { s/= .*/= true/ }' make/include/tool.defs || die
143         # noop strip
144         sed -i \
145                         -e "s/\(strip\s*= ToolProbe( 'STRIP.exe',\s*'strip',\s*\)'strip'/\1'true'/" \
146                         make/configure.py || die
148         # Use whichever python is set by portage
149         sed -i -e "s/for p in .*/for p in ${EPYTHON}/" configure || die
151         for tool in ar ranlib libtool; do
152                 # Detect system tools - bug 738110
153                 sed -i \
154                         -e "s/\(${tool}\s*= ToolProbe( '${tool^^}.exe',\s*'${tool}',\s*\)'${tool}'/\1os.environ.get('${tool^^}', '${tool}')/" \
155                         make/configure.py || die
156         done
158         default
161 src_configure() {
162         tc-export AR RANLIB
164         # ODR violations, lto-type-mismatches
165         # bug #878899
166         filter-lto
168         local myconfargs=(
169                 --force
170                 --verbose
171                 --disable-df-fetch
172                 --disable-df-verify
173                 --launch-jobs=$(get_makeopts_jobs)
174                 --prefix="${EPREFIX}/usr"
175                 --disable-flatpak
176                 --no-harden #bug #890279
177                 $(use_enable amf vce)
178                 $(use_enable fdk fdk-aac)
179                 $(use_enable gui gtk)
180                 $(use_enable libdovi)
181                 $(use_enable numa)
182                 $(use_enable nvenc)
183                 $(use_enable x265)
184                 $(use_enable qsv)
185         )
187         edo ./configure ${myconfargs[@]}
190 src_compile() {
191         emake -C build
194 src_install() {
195         emake -C build DESTDIR="${D}" install
196         dodoc README.markdown AUTHORS.markdown NEWS.markdown THANKS.markdown
199 pkg_postinst() {
200         einfo "Gentoo builds of HandBrake are NOT SUPPORTED by upstream as they"
201         einfo "do not use the bundled (and often patched) upstream libraries."
202         einfo ""
203         einfo "Please do not raise bugs with upstream because of these ebuilds,"
204         einfo "report bugs to Gentoo's bugzilla or Multimedia forum instead."
206         einfo "For the CLI version of HandBrake, you can use \`HandBrakeCLI\`."
207         if use gui ; then
208                 einfo "For the GUI version of HandBrake, you can run \`ghb\`."
209         fi
211         xdg_pkg_postinst