mpv-0.24.0.ebuild 10 KB

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