1 # Copyright 1999-2018 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} )
7 PYTHON_REQ_USE='threads(+)'
11 inherit eapi7-ver flag-o-matic gnome2-utils pax-utils python-r1 toolchain-funcs waf-utils xdg-utils
13 DESCRIPTION="Media player based on MPlayer and mplayer2"
14 HOMEPAGE="https://mpv.io/"
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 )
21 EGIT_REPO_URI="https://github.com/mpv-player/mpv.git"
25 SRC_URI+=" https://waf.io/waf-${WAF_PV}"
26 DOCS+=( README.md DOCS/{client-api,interface}-changes.rst )
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+ )"
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"
40 cuda? ( !libav opengl )
41 egl? ( || ( gbm X wayland ) )
42 gbm? ( drm egl opengl )
45 opengl? ( || ( aqua egl X raspberry-pi !cli ) )
46 raspberry-pi? ( opengl )
50 v4l? ( || ( alsa oss ) )
51 vaapi? ( || ( gbm X wayland ) )
53 vulkan? ( || ( X wayland ) )
55 X? ( egl? ( opengl ) )
57 zsh-completion? ( cli )
58 ${PYTHON_REQUIRED_USE}
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 )
70 >=media-libs/libdvdnav-4.2.0
71 >=media-libs/libdvdread-4.1.0
73 egl? ( media-libs/mesa[egl,gbm(-)?,wayland(-)?] )
76 uchardet? ( app-i18n/uchardet )
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 )
83 >=media-libs/libass-0.12.1:=[fontconfig,harfbuzz]
86 libcaca? ( >=media-libs/libcaca-0.99_beta18 )
88 !luajit? ( <dev-lang/lua-5.3:= )
89 luajit? ( dev-lang/luajit:2 )
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 )
102 media-libs/vulkan-loader[X?,wayland?]
105 >=dev-libs/wayland-1.6.0
106 >=x11-libs/libxkbcommon-0.3.0
107 dev-libs/wayland-protocols
111 x11-libs/libXScrnSaver
119 xv? ( x11-libs/libXv )
121 zlib? ( sys-libs/zlib )
123 DEPEND="${COMMON_DEPEND}
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 )
133 RDEPEND="${COMMON_DEPEND}
134 cuda? ( x11-drivers/nvidia-drivers[X] )
135 selinux? ( sec-policy/selinux-mplayer )
136 tools? ( ${PYTHON_DEPS} )
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"
146 cp "${DISTDIR}/waf-${WAF_PV}" "${S}"/waf || die
147 chmod +x "${S}"/waf || die
153 tc-export CC PKG_CONFIG AR
155 if use raspberry-pi; then
156 append-cflags -I"${SYSROOT%/}${EPREFIX}/opt/vc/include"
157 append-ldflags -L"${SYSROOT%/}${EPREFIX}/opt/vc/lib"
160 # Prevent access violations from zsh completion generation.
161 # See Gentoo bug 656086.
162 use zsh-completion && addpredict /dev/dri
165 --confdir="${EPREFIX}/etc/${PN}"
166 --docdir="${EPREFIX}/usr/share/doc/${PF}"
167 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
169 $(usex cli '' '--disable-cplayer')
170 $(use_enable libmpv libmpv-shared)
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.
179 $(use_enable doc pdf-build)
180 $(use_enable cplugins)
181 $(use_enable zsh-completion zsh-comp)
186 $(use_enable samba libsmbclient)
188 $(usex luajit '--lua=luajit' '')
189 $(use_enable javascript)
191 $(use_enable libass libass-osd)
193 $(use_enable encode encoding)
194 $(use_enable bluray libbluray)
195 $(use_enable dvd dvdread)
196 $(use_enable dvd dvdnav)
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)
208 $(use_enable sdl sdl2) # Listed under audio, but also includes video.
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)
218 $(use_enable coreaudio)
221 $(use_enable aqua cocoa)
224 $(use_enable wayland wayland-scanner)
225 $(use_enable wayland wayland-protocols)
226 $(use_enable wayland)
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')
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)
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')
250 # Automagic Video Toolbox HW acceleration. See Gentoo bug 577332.
251 $(use_enable cuda cuda-hwaccel)
255 $(use_enable v4l tv-v4l2)
256 $(use_enable v4l libv4l2)
257 $(use_enable v4l audio-input)
258 $(use_enable dvb dvbin)
260 # Miscellaneous features:
261 --disable-apple-remote # Needs testing first. See Gentoo bug 577332.
264 if use vaapi && use X; then
266 $(use_enable opengl vaapi-glx)
267 $(use_enable egl vaapi-x-egl)
271 # Create reproducible non-live builds.
272 [[ ${PV} != *9999* ]] && mywafargs+=(--disable-build-date)
274 waf-utils_src_configure "${mywafargs[@]}"
278 waf-utils_src_install
281 insinto /usr/share/${PN}
285 if use cli && use luajit; then
286 pax-mark -m "${ED}"usr/bin/${PN}
290 dobin TOOLS/{mpv_identify.sh,umpv}
291 newbin TOOLS/idet.sh mpv_idet.sh
292 python_replicate_script "${ED}"usr/bin/umpv
297 local rv softvol_0_18_1=0 osc_0_21_0=0 txtsubs_0_24_0=0 opengl_0_25_0=0
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
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"
312 elog "https://wiki.gentoo.org/wiki/Mpv#Volume_in_0.18.1"
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"
320 elog "https://wiki.gentoo.org/wiki/Mpv#OSC_in_0.21.0"
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"
328 elog "https://wiki.gentoo.org/wiki/Mpv#Subtitles_with_.txt_extension_in_0.24.0"
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."
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."
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."
349 gnome2_icon_cache_update
350 xdg_desktop_database_update
354 gnome2_icon_cache_update
355 xdg_desktop_database_update
359 cd "${S}"/build/test || die
362 if [[ -x ${test} ]]; then
363 ./"${test}" || die "Test suite failed"