mpv-9999.ebuild 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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 ~hppa ~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. )
  128. mpv_check_compiler() {
  129. if [[ ${MERGE_TYPE} != "binary" ]]; then
  130. if tc-is-gcc && ( [[ $(gcc-major-version) -lt 4 ]] || \
  131. ( [[ $(gcc-major-version) -eq 4 ]] && [[ $(gcc-minor-version) -lt 5 ]] ) ); then
  132. die "${PN} requires GCC>=4.5."
  133. fi
  134. if ( use opengl || use egl ) && ! tc-has-tls; then
  135. die "Your compiler lacks C++11 TLS support. Use GCC>=4.8 or Clang>=3.3."
  136. fi
  137. if use vaapi && use cpu_flags_x86_sse4_1 && ! tc-is-gcc; then
  138. die "${PN} requires GCC for SSE4.1 intrinsics."
  139. fi
  140. fi
  141. }
  142. pkg_pretend() {
  143. mpv_check_compiler
  144. }
  145. pkg_setup() {
  146. mpv_check_compiler
  147. [[ ${MERGE_TYPE} != "binary" ]] && python_setup
  148. }
  149. src_prepare() {
  150. cp "${DISTDIR}/waf-${WAF_PV}" "${S}"/waf || die
  151. chmod +x "${S}"/waf || die
  152. default_src_prepare
  153. }
  154. src_configure() {
  155. tc-export CC PKG_CONFIG AR
  156. if tc-is-cross-compiler && use raspberry-pi; then
  157. export EXTRA_PKG_CONFIG_LIBDIR="${SYSROOT%/}${EPREFIX}/opt/vc/lib/pkgconfig"
  158. # Drop next line when Gentoo bug 607344 is fixed or if you fixed it locally.
  159. die "${PN} can't be cross built with raspberry-pi USE enabled. See Gentoo bug 607344."
  160. fi
  161. local mywafargs=(
  162. --confdir="${EPREFIX}/etc/${PN}"
  163. --docdir="${EPREFIX}/usr/share/doc/${PF}"
  164. --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
  165. $(usex cli '' '--disable-cplayer')
  166. $(use_enable libmpv libmpv-shared)
  167. # See deep down below for build-date.
  168. --disable-libmpv-static
  169. --disable-static-build
  170. --disable-optimize # Don't add '-O2' to CFLAGS.
  171. --disable-debug-build # Don't add '-g' to CFLAGS.
  172. --enable-html-build
  173. $(use_enable doc pdf-build)
  174. $(use_enable cplugins)
  175. $(use_enable vf-dlopen vf-dlopen-filters)
  176. $(use_enable zsh-completion zsh-comp)
  177. $(use_enable test)
  178. $(use_enable iconv)
  179. $(use_enable samba libsmbclient)
  180. $(use_enable lua)
  181. $(usex luajit '--lua=luajit' '')
  182. $(use_enable libass)
  183. $(use_enable libass libass-osd)
  184. $(use_enable encode encoding)
  185. $(use_enable bluray libbluray)
  186. $(use_enable dvd dvdread)
  187. $(use_enable dvd dvdnav)
  188. $(use_enable cdda)
  189. $(use_enable uchardet)
  190. $(use_enable rubberband)
  191. $(use_enable lcms lcms2)
  192. --disable-vapoursynth # Only available in overlays.
  193. --disable-vapoursynth-lazy
  194. $(use_enable archive libarchive)
  195. --enable-libavdevice
  196. # Audio outputs:
  197. $(use_enable sdl sdl2) # Listed under audio, but also includes video.
  198. --disable-sdl1
  199. $(use_enable oss oss-audio)
  200. --disable-rsound # Only available in overlays.
  201. --disable-sndio # Only available in overlays.
  202. $(use_enable pulseaudio pulse)
  203. $(use_enable jack)
  204. $(use_enable openal)
  205. --disable-opensles
  206. $(use_enable alsa)
  207. $(use_enable coreaudio)
  208. # Video outputs:
  209. $(use_enable aqua cocoa)
  210. $(use_enable drm)
  211. $(use_enable gbm)
  212. $(use_enable wayland)
  213. $(use_enable X x11)
  214. $(use_enable xscreensaver xss)
  215. $(use_enable X xext)
  216. $(use_enable xv)
  217. $(use_enable xinerama)
  218. $(use_enable X xrandr)
  219. $(usex opengl "$(use_enable aqua gl-cocoa)" '--disable-gl-cocoa')
  220. $(usex opengl "$(use_enable X gl-x11)" '--disable-gl-x11')
  221. $(usex egl "$(use_enable X egl-x11)" '--disable-egl-x11')
  222. $(usex egl "$(use_enable gbm egl-drm)" '--disable-egl-drm')
  223. $(use_enable wayland gl-wayland)
  224. $(use_enable vdpau)
  225. $(usex vdpau "$(use_enable opengl vdpau-gl-x11)" '--disable-vdpau-gl-x11')
  226. $(use_enable vaapi) # See below for vaapi-glx, vaapi-x-egl.
  227. $(usex vaapi "$(use_enable X vaapi-x11)" '--disable-vaapi-x11')
  228. $(usex vaapi "$(use_enable wayland vaapi-wayland)" '--disable-vaapi-wayland')
  229. $(usex vaapi "$(use_enable gbm vaapi-drm)" '--disable-vaapi-drm')
  230. $(use_enable libcaca caca)
  231. $(use_enable jpeg)
  232. --disable-android
  233. $(use_enable raspberry-pi rpi)
  234. $(usex opengl "$(use_enable !aqua standard-gl)" '--disable-standard-gl')
  235. --disable-ios-gl
  236. $(usex libmpv "$(use_enable opengl plain-gl)" '--disable-plain-gl')
  237. --disable-mali-fbdev # Only available in overlays.
  238. # HWaccels:
  239. # Automagic Video Toolbox HW acceleration. See Gentoo bug 577332.
  240. $(use_enable vaapi vaapi-hwaccel)
  241. $(use_enable vdpau vdpau-hwaccel)
  242. $(use_enable cuda cuda-hwaccel)
  243. # TV features:
  244. $(use_enable v4l tv)
  245. $(use_enable v4l tv-v4l2)
  246. $(use_enable v4l libv4l2)
  247. $(use_enable v4l audio-input)
  248. $(use_enable dvb dvbin)
  249. # Miscellaneous features:
  250. --disable-apple-remote # Needs testing first. See Gentoo bug 577332.
  251. )
  252. if use vaapi && use X; then
  253. mywafargs+=(
  254. $(use_enable opengl vaapi-glx)
  255. $(use_enable egl vaapi-x-egl)
  256. )
  257. fi
  258. if ! use egl && ! use opengl && ! use raspberry-pi; then
  259. mywafargs+=(--disable-gl)
  260. fi
  261. # Create reproducible non-live builds.
  262. [[ ${PV} != *9999* ]] && mywafargs+=(--disable-build-date)
  263. waf-utils_src_configure "${mywafargs[@]}"
  264. }
  265. src_install() {
  266. waf-utils_src_install
  267. if use lua; then
  268. insinto /usr/share/${PN}
  269. doins -r TOOLS/lua
  270. fi
  271. if use cli && use luajit; then
  272. pax-mark -m "${ED}"usr/bin/${PN}
  273. fi
  274. if use tools; then
  275. dobin TOOLS/{mpv_identify.sh,umpv}
  276. newbin TOOLS/idet.sh mpv_idet.sh
  277. python_replicate_script "${ED}"usr/bin/umpv
  278. fi
  279. }
  280. pkg_preinst() {
  281. gnome2_icon_savelist
  282. }
  283. pkg_postinst() {
  284. local rv softvol_0_18_1=0 osc_0_21_0=0
  285. for rv in ${REPLACING_VERSIONS}; do
  286. version_compare ${rv} 0.18.1
  287. [[ $? -eq 1 ]] && softvol_0_18_1=1
  288. version_compare ${rv} 0.21.0
  289. [[ $? -eq 1 ]] && osc_0_21_0=1
  290. done
  291. if [[ ${softvol_0_18_1} -eq 1 ]]; then
  292. elog "Since version 0.18.1 the software volume control is always enabled."
  293. elog "This means that volume controls don't change the system volume,"
  294. elog "e.g. per-application volume with PulseAudio."
  295. elog "If you want to restore the previous behaviour, please refer to"
  296. elog
  297. elog "https://wiki.gentoo.org/wiki/Mpv#Volume_in_0.18.1"
  298. elog
  299. fi
  300. if [[ ${osc_0_21_0} -eq 1 ]]; then
  301. elog "In version 0.21.0 the default OSC layout was changed."
  302. elog "If you want to restore the previous layout, please refer to"
  303. elog
  304. elog "https://wiki.gentoo.org/wiki/Mpv#OSC_in_0.21.0"
  305. elog
  306. fi
  307. # bash-completion < 2.3-r1 already installs (mostly broken) mpv completion.
  308. if use cli && ! has_version '<app-shells/bash-completion-2.3-r1' && \
  309. ! has_version 'app-shells/mpv-bash-completion'; then
  310. elog "If you want to have command-line completion via bash-completion,"
  311. elog "please install app-shells/mpv-bash-completion."
  312. fi
  313. if use cli && [[ -n ${REPLACING_VERSIONS} ]] && \
  314. has_version 'app-shells/mpv-bash-completion'; then
  315. elog "If command-line completion doesn't work after mpv update,"
  316. elog "please rebuild app-shells/mpv-bash-completion."
  317. fi
  318. gnome2_icon_cache_update
  319. xdg_desktop_database_update
  320. }
  321. pkg_postrm() {
  322. gnome2_icon_cache_update
  323. xdg_desktop_database_update
  324. }
  325. src_test() {
  326. cd "${S}"/build/test || die
  327. local test
  328. for test in *; do
  329. if [[ -x ${test} ]]; then
  330. ./"${test}" || die "Test suite failed"
  331. fi
  332. done
  333. }