summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1c5efe37ce1f1d673313e2b7555ccda5af73e860 (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
# Contributor: michaelchou <michaeljchou at the hotmail domain which is .com>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>

pkgbase=opencv3-opt
pkgname=("$pkgbase" "$pkgbase"-samples)
pkgver=3.4.20
pkgrel=2
pkgdesc="Open Source Computer Vision Library (Legacy Version & /opt directory version)"
arch=(x86_64)
license=(BSD)
url="http://opencv.org/"
depends=(intel-tbb openexr gst-plugins-base libdc1394 cblas lapack libgphoto2 jasper ffmpeg4.4)
makedepends=(
  cmake
  double-conversion
  eigen
  glew
  gtk3
  hdf5
  lapacke
  mesa
  openmpi
  python-numpy
  python-setuptools
  vtk
)
optdepends=('opencv-samples: samples'
            'gtk3: for the HighGUI module'
            'vtk: for the viz module'
            'hdf5: support for HDF5 format'
            'opencl-icd-loader: For coding with OpenCL'
            'python-numpy: Python interface')
source=(
"opencv-$pkgver.tar.gz::https://github.com/opencv/opencv/archive/$pkgver.zip"
"opencv_contrib-$pkgver.tar.gz::https://github.com/opencv/opencv_contrib/archive/$pkgver.tar.gz"
)
sha256sums=('82098bd221d18aa75a01b0ee91eca146c5868107306709721257330da54f0074'
            'b0bb3fa7ae4ac00926b83d4d95c6500c2f7af542f8ec78d0f01b2961a690d5dc')

prepare() {
  mkdir -p build
}

build() {
  cd build
  # cmake's FindLAPACK doesn't add cblas to LAPACK_LIBRARIES, so we need to specify them manually
  cmake ../opencv-$pkgver \
    -DWITH_OPENCL=ON \
    -DWITH_OPENGL=ON \
    -DWITH_TBB=ON \
    -DOpenGL_GL_PREFERENCE=GLVND \
    -DBUILD_WITH_DEBUG_INFO=OFF \
    -DBUILD_TESTS=OFF \
    -DBUILD_PERF_TESTS=OFF \
    -DBUILD_EXAMPLES=OFF \
    -DINSTALL_C_EXAMPLES=ON \
    -DINSTALL_PYTHON_EXAMPLES=ON \
    -DCMAKE_INSTALL_PREFIX=/opt/opencv3 \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DCPU_BASELINE_DISABLE=SSE3 \
    -DCPU_BASELINE_REQUIRE=SSE2 \
    -DOPENCV_EXTRA_MODULES_PATH="$srcdir/opencv_contrib-$pkgver/modules" \
    -DFFMPEG_INCLUDE_DIRS="/usr/include/ffmpeg4.4" \
    -DFFMPEG_LIBRARIES="/usr/lib/ffmpeg4.4/libavcodec.so;/usr/lib/ffmpeg4.4/libavformat.so;/usr/lib/ffmpeg4.4/libavutil.so;/usr/lib/ffmpeg4.4/libswscale.so" \
    -DFFMPEG_LIBRARY_DIRS="/usr/lib/ffmpeg4.4" \
    -DLAPACK_LIBRARIES="/usr/lib/liblapack.so;/usr/lib/libblas.so;/usr/lib/libcblas.so" \
    -DLAPACK_CBLAS_H="/usr/include/cblas.h" \
    -DLAPACK_LAPACKE_H="/usr/include/lapacke.h"
  make
}

package_opencv3-opt() {
  options=(staticlibs)
  provides=(opencv3)

  cd build
  make DESTDIR="$pkgdir" install

  # install license file
  install -Dm644 "$srcdir"/opencv-$pkgver/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname

  mkdir -p "$pkgdir"/usr/lib/pkgconfig
  cd "$pkgdir"/usr/lib/pkgconfig
  ln -s /opt/opencv3/lib/pkgconfig/opencv.pc opencv3.pc
  ln -s /opt/opencv3/lib/pkgconfig/opencv.pc opencv3-opt.pc

  mkdir -p "$pkgdir"/etc/ld.so.conf.d
  echo /opt/opencv3/lib > "$pkgdir"/etc/ld.so.conf.d/opencv3-opt.conf

  # install python bindings
  # cd python_loader
  # python setup.py install --root="$pkgdir"
  # rm -r "$pkgdir"/usr/python

  cd "$pkgdir"/opt/opencv3/share

  # separate samples package
  rm -rf "$srcdir"/samples
  mv OpenCV/samples "$srcdir"
  mv OpenCV opencv3 # otherwise folder naming is inconsistent
  ln -sf /opt/opencv3/share/opencv3 OpenCV # fix some compatibility problems
}

package_opencv3-opt-samples() {
  pkgdesc+=" (samples)"
  depends=("$pkgbase=$pkgver")
  unset optdepends
  provides=(opencv3-samples)

  mkdir -p "$pkgdir"/opt/opencv3/share/opencv3
  cp -r "$srcdir/"samples "$pkgdir"/opt/opencv3/share/opencv3/samples

  # install license file
  install -Dm644 "$srcdir"/opencv-$pkgver/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
}