summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 15bf3d77a76820b7a066f237b34f30c041eef581 (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
# Maintainer: 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.7
pkgrel=1
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 ffmpeg)
makedepends=(cmake python-numpy python-setuptools mesa eigen hdf5 lapacke gtk3 vtk glew double-conversion)
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=('4f7668a83828e0b290b8da999305b7ee30156898de00fe4db524ccf71edaf148'
            '5e3ba5fbe0ff3ab7462d42c08501f8c15d3e46b0684aee281f735345e1353cb4')

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" \
    -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" \
    -DEIGEN_INCLUDE_PATH=`pkg-config --cflags-only-I eigen3 | sed "s/-I//"`
  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
}