summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b1d24be112497808b4c88c52259958dd2bb3b82c (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
# Maintainer: Gustavo Alvarez <sl1pkn07@gmail.com>
# Contributor: Arthur Zamarin <arthurzam@gmail.com>
# Contributor: Hermann Mayer <hermann.mayer92@gmail.com>

pkgbase=psmoveapi-git
pkgname=(
  'psmoveapi-git'
  'python-psmoveapi-git'
)
pkgver=4.0.12.175.g26e1446
pkgrel=1
pkgdesc='Playstation Move Motion Controller API (GIT version)'
arch=('x86_64')
url='http://thp.io/2010/psmove'
license=('BSD')
makedepends=(
  'git'
  'cmake'
  'python-sphinx'
  'systemd-libs'
  'dbus'
  'bluez-libs'
  'v4l-utils'
  'opencv'
  'libusb'
  'libusb-compat'
)
source=(
  'git+https://github.com/thp/psmoveapi.git'
  'git+https://github.com/thp/hidapi.git'
  'git+https://github.com/inspirit/PS3EYEDriver.git'
  'git+https://github.com/libusb/libusb.git'
  'add-libv4l2-module.patch'
)
sha256sums=(
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  '271eaa3f1f5c50045873f1583ebc38eb6c9451440a7c98de5b75731058901480'
)
options=('debug')

pkgver() {
  cd psmoveapi
  echo "$(git describe --long --tags | tr - . | tr -d v)"
}

prepare() {
  cd psmoveapi
  git config submodule.external/hidapi.url "${srcdir}/hidapi"
  git config submodule.external/PS3EYEDriver.url "${srcdir}/PS3EYEDriver"
  git config submodule.external/libusb-1.0.url "${srcdir}/libusb"
  git -c protocol.file.allow=always submodule update --init \
    external/hidapi \
    external/PS3EYEDriver \
    external/libusb-1.0

  # Add the missing cmake libv4l2 linkage
  patch -p1 -i "${srcdir}/add-libv4l2-module.patch"

  mkdir -p docs/_static
}

build() {
  cmake -B build -S psmoveapi \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_SKIP_RPATH=ON \
    -DPSMOVEAPI_LIB_DEST=lib \
    -DPSMOVE_BUILD_EXAMPLES=ON \
    -DPSMOVE_BUILD_TRACKER=ON

  cmake --build build
}

package_psmoveapi-git() {
  provides=(
    'psmoveapi'
    'libpsmoveapi.so'
    'libpsmoveapi_tracker.so'
  )
  conflicts=('psmoveapi')
  depends=(
    'gcc-libs' # libgcc_s.so libstdc++.so
    'glibc' # libc.so libm.so
    'systemd-libs' 'libudev.so'
    'dbus' # libdbus-1.so
    'bluez-libs' 'libbluetooth.so'
    'libusb' 'libusb-1.0.so'
    'libusb-compat' # libusb-0.1.so
    'v4l-utils' # libv4l2.so
    'opencv' # libopencv_calib3d.so libopencv_core.so libopencv_highgui.so libopencv_imgcodecs.so libopencv_imgproc.so libopencv_videoio.so
  )

  DESTDIR="${pkgdir}" cmake --install build

  (cd psmoveapi/docs; make BUILDDIR="${pkgdir}/usr/share/doc/${pkgbase}" html)

  mkdir -p "${pkgdir}/usr/share/"{doc,licenses}"/${pkgbase}"
  mv "${pkgdir}/usr/share/psmoveapi/README.md" "${pkgdir}/usr/share/doc/${pkgbase}/README.md"
  mv "${pkgdir}/usr/share/psmoveapi/COPYING" "${pkgdir}/usr/share/licenses/${pkgbase}/COPYING"
  rm -fr "${pkgdir}/usr/share/psmoveapi"
}

package_python-psmoveapi-git() {
  pkgdesc='Python bindings for Playstation Move Motion Controller API (GIT version)'
  arch=('any')
  provides=('python-psmoveapi')
  conflicts=('python-psmoveapi')
  depends=(
    "psmoveapi-git=${pkgver}"
    'python'
  )

  _site_packages="$(python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')"
  install -Dm644 psmoveapi/bindings/python/psmoveapi.py "${pkgdir}${_site_packages}/psmoveapi.py"
  python -m compileall -q -f -d "${_site_packages}" "${pkgdir}${_site_packages}/psmoveapi.py"
  python -OO -m compileall -q -f -d "${_site_packages}" "${pkgdir}${_site_packages}/psmoveapi.py"

  mkdir -p "${pkgdir}/usr/share/licenses/${pkgname}"
  ln -s "/usr/share/licenses/${pkgbase}/COPYING" "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"
}