summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d92c24a0dffc2f7d8f53c73a1e97287cfaa837ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Maintainer:  Philip Sequeira <qmega+aur@sksm.net>
# Contributor: Rudolf Polzer <divVerent@xonotic.org>
# Contributor: Bartłomiej Piotrowski <nospam@bpiotrowski.pl>
# Contributor: Eivind Uggedal <eivind@uggedal.com>

_opt_features=(

  # Disabled by default, need to be enabled every build:

  #dvd
  #cd
  #sdl2
  #openal

  # mpv supports lua52 and luajit, and will automatically enable Lua support if
  # either is installed. If both are installed, it will choose lua52. The choice
  # is made at compile time and only one of the two can be enabled. The two
  # options below, when uncommented, will force selection of their respective
  # implementations even if the other is installed, as well as adding the
  # appropriate dependency.

  #lua
  luajit

  # The rest of these are autodetected, and are just provided to set
  # dependencies the first time you build. If you have the dependencies
  # installed, subsequent builds will pick them up automatically.

  #javascript

  x11
  wayland

  #uchardet
  #rubberband
  #vapoursynth

  # Features disabled by default, but don't require any extra dependencies on an
  # Arch system:

  dvbin

)

# Note: The configure script will automatically enable most optional features it
# finds support for on your system. The dependencies of the built package will
# be updated based on dynamic libraries, but if you want to avoid linking
# against something you have installed, you'll have to disable it in the
# configure below.

pkgname=mpv-git
_gitname=mpv
pkgver=0.39.0_13_g2c5928e518
pkgrel=1
pkgdesc='Video player based on MPlayer/mplayer2 (git version)'
arch=('i686' 'x86_64' 'armv6h' 'armv7h' 'aarch64')
license=('GPL-2.0-or-later')
url='https://mpv.io'
_undetected_depends=('hicolor-icon-theme')
depends=('ffmpeg' 'libplacebo' 'libass' "${_undetected_depends[@]}")
optdepends=('yt-dlp: for video-sharing websites playback (preferred over youtube-dl)'
            'youtube-dl: for video-sharing websites playback')
makedepends=('git'
             'meson'
             'python-docutils' # for rst2man, to generate manpage
             'pacman-contrib' # for pactree, used in find-deps.py
             'vulkan-headers')
provides=('mpv' 'libmpv.so')
conflicts=('mpv')
options=('!emptydirs')
install=mpv.install
source=('git+https://github.com/mpv-player/mpv'
        'find-deps.py')
sha256sums=('SKIP'
            '1ba780ede4a28b68ae5b7ab839958ff91ed01d3c6c1d24cce8a5dd24492f8d2b')

_opt_extra_flags=()

for feature in "${_opt_features[@]}"; do
  case "$feature" in
    dvd)
      depends+=('libdvdnav')
      _opt_extra_flags+=('-Ddvdnav=enabled')
      ;;
    cd)
      depends+=('libcdio-paranoia')
      _opt_extra_flags+=('-Dcdda=enabled')
      ;;
    lua)
      depends+=('lua52')
      _opt_extra_flags+=('-Dlua=enabled' '-Dlua=lua52')
      ;;
    luajit)
      depends+=('luajit')
      _opt_extra_flags+=('-Dlua=enabled' '-Dlua=luajit')
      ;;
    javascript)
      depends+=('mujs')
      _opt_extra_flags+=('-Djavascript=enabled')
      ;;
    x11)
      depends+=('libxinerama' 'libxpresent' 'libxss')
      _opt_extra_flags+=('-Dx11=enabled')
      ;;
    wayland)
      depends+=('wayland' 'libxkbcommon')
      makedepends+=('wayland-protocols')
      _opt_extra_flags+=('-Dwayland=enabled')
      ;;
    sdl2|openal|uchardet|rubberband|vapoursynth)
      depends+=("$feature")
      _opt_extra_flags+=("-D${feature}=enabled")
      ;;
    dvbin)
      _opt_extra_flags+=("-D${feature}=enabled")
      ;;
    *)
      echo "ERROR: Unknown feature option: $feature" >&2
      exit 1
  esac
done

pkgver() {
  cd "$srcdir/$_gitname"
  git describe --always --tags --dirty | sed -e 's/^v//' -e 's/-/_/g'
}

build() {
  cd "$srcdir/$_gitname"

  # Removing build dir, if present, ensures features omitted from the configure
  # command get their default values, and cleans up after waf if it was
  # previously used (which can cause the build to fail otherwise).
  # Downside is wasted recompilation.
  rm -rf build

  meson setup build \
        --prefix=/usr \
        --sysconfdir=/etc \
        --buildtype=plain \
        --wrap-mode=nodownload \
        -Dlibmpv=true \
        "${_opt_extra_flags[@]}"

  meson compile -C build
}

package() {
  cd "$srcdir/$_gitname"
  meson install -C build --no-rebuild --destdir="$pkgdir"

  # Update dependencies automatically based on dynamic libraries
  _detected_depends=($(python3 "$srcdir"/find-deps.py "$pkgdir"/usr/{bin/mpv,lib/libmpv.so}))
  echo 'Auto-detected dependencies:'
  echo "${_detected_depends[@]}" | fold -s -w 79 | sed 's/^/ /'
  depends=("${_detected_depends[@]}" "${_undetected_depends[@]}")
}