21bb95bbbdbb27c4ed1e55dde704f2215350ab7d
[gentoo.git] / media-video / handbrake / handbrake-1.3.0-r2.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python3_{1,2,3,4,5,6,7} python2_7 )
7
8 inherit autotools eutils gnome2-utils python-any-r1 xdg-utils
9
10 if [[ ${PV} = *9999* ]]; then
11         EGIT_REPO_URI="https://github.com/HandBrake/HandBrake.git"
12         inherit git-r3
13         KEYWORDS=""
14 else
15         MY_P="HandBrake-${PV}"
16         SRC_URI="https://download2.handbrake.fr/${PV}/${MY_P}-source.tar.bz2 -> ${P}.tar.bz2"
17         S="${WORKDIR}/${MY_P}"
18         KEYWORDS="~amd64 ~x86"
19 fi
20
21 DESCRIPTION="Open-source, GPL-licensed, multiplatform, multithreaded video transcoder"
22 HOMEPAGE="http://handbrake.fr/"
23 LICENSE="GPL-2"
24
25 SLOT="0"
26 IUSE="+fdk gstreamer gtk libav libav-aac numa nvenc x265"
27
28 REQUIRED_USE="^^ ( fdk libav-aac )"
29
30 RDEPEND="
31         app-arch/xz-utils
32         media-libs/speex
33         dev-libs/jansson
34         dev-libs/libxml2
35         media-libs/a52dec
36         media-libs/libass:=
37         >=media-libs/libbluray-1.0
38         >=media-libs/dav1d-0.5.1
39         media-libs/libdvdnav
40         media-libs/libdvdread:=
41         media-libs/libsamplerate
42         media-libs/libtheora
43         media-libs/libvorbis
44         >=media-libs/libvpx-1.8
45         nvenc? ( media-libs/nv-codec-headers )
46         media-libs/opus
47         media-libs/x264:=
48         media-sound/lame
49         sys-libs/zlib
50         libav? ( >=media-video/libav-12.2:0=[fdk?] )
51         !libav? ( >=media-video/ffmpeg-4.2.1:0=[fdk?] )
52         gstreamer? (
53                 media-libs/gstreamer:1.0
54                 media-libs/gst-plugins-base:1.0
55                 media-libs/gst-plugins-good:1.0
56                 media-libs/gst-plugins-bad:1.0
57                 media-libs/gst-plugins-ugly:1.0
58                 media-plugins/gst-plugins-a52dec:1.0
59                 media-plugins/gst-plugins-libav:1.0
60                 media-plugins/gst-plugins-x264:1.0
61                 media-plugins/gst-plugins-gdkpixbuf:1.0
62         )
63         gtk? (
64                 >=x11-libs/gtk+-3.10
65                 dev-libs/dbus-glib
66                 dev-libs/glib:2
67                 dev-libs/libgudev:=
68                 x11-libs/cairo
69                 x11-libs/gdk-pixbuf:2
70                 x11-libs/libnotify
71                 x11-libs/pango
72         )
73         fdk? ( media-libs/fdk-aac )
74         x265? ( >=media-libs/x265-3.2:0=[10bit,12bit,numa?] )
75         "
76
77 DEPEND="${RDEPEND}
78         ${PYTHON_DEPS}
79         dev-lang/yasm
80         dev-util/intltool
81         sys-devel/automake"
82
83 PATCHES=(
84         # Remove libdvdnav duplication and call it on the original instead.
85         # It may work this way; if not, we should try to mimic the duplication.
86         "${FILESDIR}/${PN}-9999-remove-dvdnav-dup.patch"
87
88         # Remove faac dependency; TODO: figure out if we need to do this at all.
89         "${FILESDIR}/${PN}-9999-remove-faac-dependency.patch"
90
91         # Fix missing flags
92         "${FILESDIR}/${P}-missing-linker-flags.patch"
93
94         # Use whichever python is set by portage
95         "${FILESDIR}/${P}-dont-search-for-python.patch"
96 )
97
98 src_prepare() {
99         # Get rid of leftover bundled library build definitions,
100         sed -i 's:.*\(/contrib\|contrib/\).*::g' \
101                 "${S}"/make/include/main.defs \
102                 || die "Contrib removal failed."
103
104         default
105
106         cd "${S}/gtk"
107         # Don't run autogen.sh.
108         sed -i '/autogen.sh/d' module.rules || die "Removing autogen.sh call failed"
109         eautoreconf
110 }
111
112 src_configure() {
113         # Libav was replaced in 1.2 with ffmpeg by default
114         # but I've elected to not make people change their use flags for AAC
115         # as its the same code anyway
116         ./configure \
117                 --force \
118                 --verbose \
119                 --prefix="${EPREFIX}/usr" \
120                 --disable-gtk-update-checks \
121                 --disable-flatpak \
122                 --disable-gtk4 \
123                 $(use_enable libav-aac ffmpeg-aac) \
124                 $(use_enable fdk fdk-aac) \
125                 $(usex !gtk --disable-gtk) \
126                 $(usex !gstreamer --disable-gst) \
127                 $(use_enable numa) \
128                 $(use_enable nvenc) \
129                 $(use_enable x265) || die "Configure failed."
130 }
131
132 src_compile() {
133         emake -C build
134
135         # TODO: Documentation building is currently broken, try to fix it.
136         #
137         # if use doc ; then
138         #       emake -C build doc
139         # fi
140 }
141
142 src_install() {
143         emake -C build DESTDIR="${D}" install
144
145         dodoc README.markdown AUTHORS.markdown NEWS.markdown THANKS.markdown
146 }
147
148 pkg_postinst() {
149         einfo "Gentoo builds of HandBrake are NOT SUPPORTED by upstream as they"
150         einfo "do not use the bundled (and often patched) upstream libraries."
151         einfo ""
152         einfo "Please do not raise bugs with upstream because of these ebuilds,"
153         einfo "report bugs to Gentoo's bugzilla or Multimedia forum instead."
154
155         einfo "For the CLI version of HandBrake, you can use \`HandBrakeCLI\`."
156         if use gtk ; then
157                 einfo "For the GTK+ version of HandBrake, you can run \`ghb\`."
158         fi
159
160         gnome2_icon_cache_update
161         xdg_desktop_database_update
162 }
163
164 pkg_preinst() {
165         gnome2_icon_savelist
166 }
167
168 pkg_postrm() {
169         gnome2_icon_cache_update
170         xdg_desktop_database_update
171 }