media-video/mpv: drop alpha keyword for 0.28.2
[gentoo.git] / media-video / mpv / mpv-0.28.2.ebuild
1 # Copyright 1999-2018 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} )
7 PYTHON_REQ_USE='threads(+)'
8
9 WAF_PV=1.9.8
10
11 inherit eapi7-ver flag-o-matic gnome2-utils pax-utils python-r1 toolchain-funcs waf-utils xdg-utils
12
13 DESCRIPTION="Media player based on MPlayer and mplayer2"
14 HOMEPAGE="https://mpv.io/"
15
16 if [[ ${PV} != *9999* ]]; then
17         SRC_URI="https://github.com/mpv-player/mpv/archive/v${PV}.tar.gz -> ${P}.tar.gz"
18         KEYWORDS="~amd64 ~arm ~hppa ~ppc ~ppc64 ~x86 ~amd64-linux"
19         DOCS=( RELEASE_NOTES )
20 else
21         EGIT_REPO_URI="https://github.com/mpv-player/mpv.git"
22         inherit git-r3
23         DOCS=(); SRC_URI=""
24 fi
25 SRC_URI+=" https://waf.io/waf-${WAF_PV}"
26 DOCS+=( README.md DOCS/{client-api,interface}-changes.rst )
27
28 # See Copyright in sources and Gentoo bug 506946. Waf is BSD, libmpv is ISC.
29 LICENSE="LGPL-2.1+ GPL-2+ BSD ISC samba? ( GPL-3+ )"
30 SLOT="0"
31 IUSE="+alsa aqua archive bluray cdda +cli coreaudio cplugins cuda doc drm dvb
32         dvd +egl encode gbm +iconv jack javascript jpeg lcms +libass libav libcaca
33         libmpv +lua luajit openal +opengl oss pulseaudio raspberry-pi rubberband
34         samba sdl selinux test tools +uchardet v4l vaapi vdpau vulkan wayland +X
35         +xv zlib zsh-completion"
36
37 REQUIRED_USE="
38         || ( cli libmpv )
39         aqua? ( opengl )
40         cuda? ( !libav opengl )
41         egl? ( || ( gbm X wayland ) )
42         gbm? ( drm egl opengl )
43         lcms? ( opengl )
44         luajit? ( lua )
45         opengl? ( || ( aqua egl X raspberry-pi !cli ) )
46         raspberry-pi? ( opengl )
47         test? ( opengl )
48         tools? ( cli )
49         uchardet? ( iconv )
50         v4l? ( || ( alsa oss ) )
51         vaapi? ( || ( gbm X wayland ) )
52         vdpau? ( X )
53         vulkan? ( || ( X wayland ) )
54         wayland? ( egl )
55         X? ( egl? ( opengl ) )
56         xv? ( X )
57         zsh-completion? ( cli )
58         ${PYTHON_REQUIRED_USE}
59 "
60
61 COMMON_DEPEND="
62         !libav? ( >=media-video/ffmpeg-4.0:0=[encode?,threads,vaapi?,vdpau?] )
63         libav? ( ~media-video/libav-9999:0=[encode?,threads,vaapi?,vdpau?] )
64         alsa? ( >=media-libs/alsa-lib-1.0.18 )
65         archive? ( >=app-arch/libarchive-3.0.0:= )
66         bluray? ( >=media-libs/libbluray-0.3.0:= )
67         cdda? ( dev-libs/libcdio-paranoia )
68         drm? ( x11-libs/libdrm )
69         dvd? (
70                 >=media-libs/libdvdnav-4.2.0
71                 >=media-libs/libdvdread-4.1.0
72         )
73         egl? ( media-libs/mesa[egl,gbm(-)?,wayland(-)?] )
74         iconv? (
75                 virtual/libiconv
76                 uchardet? ( app-i18n/uchardet )
77         )
78         jack? ( virtual/jack )
79         javascript? ( >=dev-lang/mujs-1.0.0 )
80         jpeg? ( virtual/jpeg:0 )
81         lcms? ( >=media-libs/lcms-2.6:2 )
82         libass? (
83                 >=media-libs/libass-0.12.1:=[fontconfig,harfbuzz]
84                 virtual/ttf-fonts
85         )
86         libcaca? ( >=media-libs/libcaca-0.99_beta18 )
87         lua? (
88                 !luajit? ( <dev-lang/lua-5.3:= )
89                 luajit? ( dev-lang/luajit:2 )
90         )
91         openal? ( >=media-libs/openal-1.13 )
92         pulseaudio? ( media-sound/pulseaudio )
93         raspberry-pi? ( >=media-libs/raspberrypi-userland-0_pre20160305-r1 )
94         rubberband? ( >=media-libs/rubberband-1.8.0 )
95         samba? ( net-fs/samba )
96         sdl? ( media-libs/libsdl2[sound,threads,video] )
97         v4l? ( media-libs/libv4l )
98         vaapi? ( x11-libs/libva:=[drm?,X?,wayland?] )
99         vdpau? ( x11-libs/libvdpau )
100         vulkan? (
101                 media-libs/shaderc
102                 media-libs/vulkan-loader[X?,wayland?]
103         )
104         wayland? (
105                 >=dev-libs/wayland-1.6.0
106                 >=x11-libs/libxkbcommon-0.3.0
107                 dev-libs/wayland-protocols
108         )
109         X? (
110                 x11-libs/libX11
111                 x11-libs/libXScrnSaver
112                 x11-libs/libXext
113                 x11-libs/libXinerama
114                 x11-libs/libXrandr
115                 opengl? (
116                         x11-libs/libXdamage
117                         virtual/opengl
118                 )
119                 xv? ( x11-libs/libXv )
120         )
121         zlib? ( sys-libs/zlib )
122 "
123 DEPEND="${COMMON_DEPEND}
124         ${PYTHON_DEPS}
125         dev-python/docutils
126         virtual/pkgconfig
127         doc? ( dev-python/rst2pdf )
128         dvb? ( virtual/linuxtv-dvb-headers )
129         test? ( >=dev-util/cmocka-1.0.0 )
130         v4l? ( virtual/os-headers )
131         zsh-completion? ( dev-lang/perl )
132 "
133 RDEPEND="${COMMON_DEPEND}
134         cuda? ( x11-drivers/nvidia-drivers[X] )
135         selinux? ( sec-policy/selinux-mplayer )
136         tools? ( ${PYTHON_DEPS} )
137 "
138
139 PATCHES=(
140         "${FILESDIR}/${PN}-0.19.0-make-ffmpeg-version-check-non-fatal.patch"
141         "${FILESDIR}/${PN}-0.25.0-fix-float-comparisons-in-tests.patch"
142         "${FILESDIR}/${PN}-0.27.0-add-missing-link-flags-for-rpi.patch"
143 )
144
145 src_prepare() {
146         cp "${DISTDIR}/waf-${WAF_PV}" "${S}"/waf || die
147         chmod +x "${S}"/waf || die
148         default_src_prepare
149 }
150
151 src_configure() {
152         python_setup
153         tc-export CC PKG_CONFIG AR
154
155         if use raspberry-pi; then
156                 append-cflags -I"${SYSROOT%/}${EPREFIX}/opt/vc/include"
157                 append-ldflags -L"${SYSROOT%/}${EPREFIX}/opt/vc/lib"
158         fi
159
160         # Prevent access violations from zsh completion generation.
161         # See Gentoo bug 656086.
162         use zsh-completion && addpredict /dev/dri
163
164         local mywafargs=(
165                 --confdir="${EPREFIX}/etc/${PN}"
166                 --docdir="${EPREFIX}/usr/share/doc/${PF}"
167                 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
168
169                 $(usex cli '' '--disable-cplayer')
170                 $(use_enable libmpv libmpv-shared)
171
172                 --disable-libmpv-static
173                 --disable-static-build
174                 # See deep down below for build-date.
175                 --disable-optimize # Don't add '-O2' to CFLAGS.
176                 --disable-debug-build # Don't add '-g' to CFLAGS.
177                 --enable-html-build
178
179                 $(use_enable doc pdf-build)
180                 $(use_enable cplugins)
181                 $(use_enable zsh-completion zsh-comp)
182                 $(use_enable test)
183
184                 --disable-android
185                 $(use_enable iconv)
186                 $(use_enable samba libsmbclient)
187                 $(use_enable lua)
188                 $(usex luajit '--lua=luajit' '')
189                 $(use_enable javascript)
190                 $(use_enable libass)
191                 $(use_enable libass libass-osd)
192                 $(use_enable zlib)
193                 $(use_enable encode encoding)
194                 $(use_enable bluray libbluray)
195                 $(use_enable dvd dvdread)
196                 $(use_enable dvd dvdnav)
197                 $(use_enable cdda)
198                 $(use_enable uchardet)
199                 $(use_enable rubberband)
200                 $(use_enable lcms lcms2)
201                 --disable-vapoursynth # Only available in overlays.
202                 --disable-vapoursynth-lazy
203                 $(use_enable archive libarchive)
204
205                 --enable-libavdevice
206
207                 # Audio outputs:
208                 $(use_enable sdl sdl2) # Listed under audio, but also includes video.
209                 --disable-sdl1
210                 $(use_enable oss oss-audio)
211                 --disable-rsound # Only available in overlays.
212                 --disable-sndio # Only available in overlays.
213                 $(use_enable pulseaudio pulse)
214                 $(use_enable jack)
215                 $(use_enable openal)
216                 --disable-opensles
217                 $(use_enable alsa)
218                 $(use_enable coreaudio)
219
220                 # Video outputs:
221                 $(use_enable aqua cocoa)
222                 $(use_enable drm)
223                 $(use_enable gbm)
224                 $(use_enable wayland wayland-scanner)
225                 $(use_enable wayland wayland-protocols)
226                 $(use_enable wayland)
227                 $(use_enable X x11)
228                 $(use_enable xv)
229                 $(usex opengl "$(use_enable aqua gl-cocoa)" '--disable-gl-cocoa')
230                 $(usex opengl "$(use_enable X gl-x11)" '--disable-gl-x11')
231                 $(usex egl "$(use_enable X egl-x11)" '--disable-egl-x11')
232                 $(usex egl "$(use_enable gbm egl-drm)" '--disable-egl-drm')
233                 $(usex opengl "$(use_enable wayland gl-wayland)" '--disable-gl-wayland')
234                 $(use_enable vdpau)
235                 $(usex vdpau "$(use_enable opengl vdpau-gl-x11)" '--disable-vdpau-gl-x11')
236                 $(use_enable vaapi) # See below for vaapi-glx, vaapi-x-egl.
237                 $(usex vaapi "$(use_enable X vaapi-x11)" '--disable-vaapi-x11')
238                 $(usex vaapi "$(use_enable wayland vaapi-wayland)" '--disable-vaapi-wayland')
239                 $(usex vaapi "$(use_enable gbm vaapi-drm)" '--disable-vaapi-drm')
240                 $(use_enable libcaca caca)
241                 $(use_enable jpeg)
242                 $(use_enable vulkan shaderc)
243                 $(use_enable raspberry-pi rpi)
244                 $(usex libmpv "$(use_enable opengl plain-gl)" '--disable-plain-gl')
245                 --disable-mali-fbdev # Only available in overlays.
246                 $(usex opengl '' '--disable-gl')
247                 $(use_enable vulkan)
248
249                 # HWaccels:
250                 # Automagic Video Toolbox HW acceleration. See Gentoo bug 577332.
251                 $(use_enable cuda cuda-hwaccel)
252
253                 # TV features:
254                 $(use_enable v4l tv)
255                 $(use_enable v4l tv-v4l2)
256                 $(use_enable v4l libv4l2)
257                 $(use_enable v4l audio-input)
258                 $(use_enable dvb dvbin)
259
260                 # Miscellaneous features:
261                 --disable-apple-remote # Needs testing first. See Gentoo bug 577332.
262         )
263
264         if use vaapi && use X; then
265                 mywafargs+=(
266                         $(use_enable opengl vaapi-glx)
267                         $(use_enable egl vaapi-x-egl)
268                 )
269         fi
270
271         # Create reproducible non-live builds.
272         [[ ${PV} != *9999* ]] && mywafargs+=(--disable-build-date)
273
274         waf-utils_src_configure "${mywafargs[@]}"
275 }
276
277 src_install() {
278         waf-utils_src_install
279
280         if use lua; then
281                 insinto /usr/share/${PN}
282                 doins -r TOOLS/lua
283         fi
284
285         if use cli && use luajit; then
286                 pax-mark -m "${ED}"usr/bin/${PN}
287         fi
288
289         if use tools; then
290                 dobin TOOLS/{mpv_identify.sh,umpv}
291                 newbin TOOLS/idet.sh mpv_idet.sh
292                 python_replicate_script "${ED}"usr/bin/umpv
293         fi
294 }
295
296 pkg_postinst() {
297         local rv softvol_0_18_1=0 osc_0_21_0=0 txtsubs_0_24_0=0 opengl_0_25_0=0
298
299         for rv in ${REPLACING_VERSIONS}; do
300                 ver_test ${rv} -lt 0.18.1 && softvol_0_18_1=1
301                 ver_test ${rv} -lt 0.21.0 && osc_0_21_0=1
302                 ver_test ${rv} -lt 0.24.0 && txtsubs_0_24_0=1
303                 ver_test ${rv} -lt 0.25.0 && ! use opengl && opengl_0_25_0=1
304         done
305
306         if [[ ${softvol_0_18_1} -eq 1 ]]; then
307                 elog "Since version 0.18.1 the software volume control is always enabled."
308                 elog "This means that volume controls don't change the system volume,"
309                 elog "e.g. per-application volume with PulseAudio."
310                 elog "If you want to restore the previous behaviour, please refer to"
311                 elog
312                 elog "https://wiki.gentoo.org/wiki/Mpv#Volume_in_0.18.1"
313                 elog
314         fi
315
316         if [[ ${osc_0_21_0} -eq 1 ]]; then
317                 elog "In version 0.21.0 the default OSC layout was changed."
318                 elog "If you want to restore the previous layout, please refer to"
319                 elog
320                 elog "https://wiki.gentoo.org/wiki/Mpv#OSC_in_0.21.0"
321                 elog
322         fi
323
324         if [[ ${txtsubs_0_24_0} -eq 1 ]]; then
325                 elog "Since version 0.24.0 subtitles with .txt extension aren't autoloaded."
326                 elog "If you want to restore the previous behaviour, please refer to"
327                 elog
328                 elog "https://wiki.gentoo.org/wiki/Mpv#Subtitles_with_.txt_extension_in_0.24.0"
329                 elog
330         fi
331
332         if [[ ${opengl_0_25_0} -eq 1 ]]; then
333                 elog "Since version 0.25.0 the 'opengl' USE flag is mapped to"
334                 elog "the 'opengl' video output and no longer explicitly requires"
335                 elog "X11 or Mac OS Aqua. Consider enabling the 'opengl' USE flag."
336         fi
337
338         if use cli && ! has_version 'app-shells/mpv-bash-completion'; then
339                 elog "If you want to have command-line completion via bash-completion,"
340                 elog "please install app-shells/mpv-bash-completion."
341         fi
342
343         if use cli && [[ -n ${REPLACING_VERSIONS} ]] &&
344                         has_version 'app-shells/mpv-bash-completion'; then
345                 elog "If command-line completion doesn't work after mpv update,"
346                 elog "please rebuild app-shells/mpv-bash-completion."
347         fi
348
349         gnome2_icon_cache_update
350         xdg_desktop_database_update
351 }
352
353 pkg_postrm() {
354         gnome2_icon_cache_update
355         xdg_desktop_database_update
356 }
357
358 src_test() {
359         cd "${S}"/build/test || die
360         local test
361         for test in *; do
362                 if [[ -x ${test} ]]; then
363                         ./"${test}" || die "Test suite failed"
364                 fi
365         done
366 }