Last active
May 17, 2018 15:30
-
-
Save galeone/740d5b94a53e5a721261fd2ac477ac5c to your computer and use it in GitHub Desktop.
PKGBUILD for OpenCV 3.1.1 with CUDA 9 enabled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkgname="opencv-cuda-stable" | |
_pkgname="opencv-stable" | |
pkgver=3.4.1 | |
pkgrel=1 | |
pkgdesc="Open Source Computer Vision Library compiled with extra modules(opencv_contrib) and CUDA" | |
url="http://opencv.org/" | |
license=('BSD') | |
arch=('i686' 'x86_64' 'armv7h' 'armv6h') | |
depends=('gst-plugins-base' 'openexr' | |
'xine-lib' 'libdc1394' 'gtkglext' | |
'nvidia-utils' 'hdf5-cpp-fortran' | |
'python' 'eigen' 'ceres-solver' | |
'cuda' 'ocl-icd') | |
depends_x86_64=('intel-tbb') | |
depends_i686=('intel-tbb') | |
depends_armv7h=('intel-tbb') | |
makedepends=('git' 'cmake' 'python2-numpy' 'python-numpy' 'mesa' | |
'gcc6') | |
optdepends=( | |
'python-numpy: Python 3 interface' | |
'python2-numpy: Python 2 interface') | |
options=('staticlibs') | |
provides=("opencv" "${_pkgname%-stable}") | |
conflicts=(opencv "${_pkgname%-stable}") | |
source=("${_pkgname%-stable}-${pkgver}.tar.gz::https://github.com/opencv/opencv/archive/${pkgver}.tar.gz" | |
"${_pkgname%-stable}_contrib-${pkgver}.tar.gz::https://github.com/opencv/opencv_contrib/archive/${pkgver}.tar.gz" | |
"ippicv_linux_20151201.tgz::https://github.com/Itseez/opencv_3rdparty/raw/ippicv/master_20151201/ippicv/ippicv_linux_20151201.tgz" | |
'opencv_contrib_sfm_cmake.patch' | |
'opencv_gcc6_pch.patch' | |
'fsh.patch' | |
) | |
md5sums=('SKIP' | |
'SKIP' | |
'808b791a6eac9ed78d32a7666804320e' | |
'6497098ac0f9d52e3c988f5413af22c8' | |
'9c69b76b8f1b781e201c70d21e3d175e' | |
'752652494b42fd1532f52b789a85947f') | |
_cmakeopts=('-D CMAKE_BUILD_TYPE=RELEASE' | |
'-D CMAKE_INSTALL_PREFIX=/usr' | |
'-D CMAKE_INSTALL_LIBDIR=lib' | |
'-D CMAKE_CXX_FLAGS="-std=c++17"' | |
'-D WITH_CUDA=ON' | |
'-D WITH_CUBLAS=ON' | |
'-D WITH_TBB=OFF' | |
'-D WITH_PVAPI=ON', | |
'-D WITH_V4L=ON' | |
'-D WITH_QT=ON' | |
'-D WITH_OPENGL=ON' | |
'-D BUILD_PERF_TESTS=OFF' | |
'-D BUILD_TESTS=OFF' | |
'-D BUILD_opencv_java=OFF' | |
'-D CUDA_GENERATION=Auto' | |
'-D ENABLE_FAST_MATH=1' | |
'-D CUDA_FAST_MATH=1' | |
'-D WITH_NVCUVID=1' | |
'-D WITH_CUFFT=ON' | |
'-D WITH_EIGEN=ON' | |
'-D WITH_IPP=ON') | |
# SSE only available from Pentium 3 onwards (i686 is way older) | |
[[ "$CARCH" = 'i686' ]] && \ | |
_cmakeopts+=('-D ENABLE_SSE=OFF' | |
'-D ENABLE_SSE2=OFF') | |
# all x64 CPUs support SSE2 but not SSE3 | |
#[[ "$CARCH" = 'x86_64' ]] && _cmakeopts+=('-D ENABLE_SSE3=OFF') | |
# NEON support only for armv7h | |
[[ "$CARCH" = 'armv7h' ]] && _cmakeopts+=('-D ENABLE_NEON=ON') | |
# intel-tbb not available for armv6h | |
[[ "$CARCH" = 'armv6h' ]] && _cmakeopts+=('-D WITH_TBB=OFF') | |
#prepare() { | |
# cd "${srcdir}/${_pkgname%-stable}-${pkgver}" | |
# sed 's/OpenCV\/doc/doc\/opencv/' -i CMakeLists.txt | |
# sed 's/share\/OpenCV/share\/opencv/' -i CMakeLists.txt | |
# sed 's/share\/OpenCV/share\/opencv/' -i cmake/templates/opencv_run_all_tests_unix.sh.in | |
# cd "${srcdir}/${_pkgname%-stable}_contrib-${pkgver}" | |
#} | |
prepare() { | |
cd "${srcdir}/${_pkgname%-stable}-${pkgver}" | |
patch -p1 -i "${srcdir}/opencv_gcc6_pch.patch" | |
# hack-fix folder naming inconsistency that they won't fix | |
# see http://code.opencv.org/issues/2512 | |
# and https://bugs.archlinux.org/task/32342 | |
# patch -p1 -i "${srcdir}/fsh.patch" | |
sed 's/OpenCV\/doc/doc\/opencv/' -i CMakeLists.txt | |
sed 's/share\/OpenCV/share\/opencv/' -i CMakeLists.txt | |
sed 's/share\/OpenCV/share\/opencv/' -i cmake/templates/opencv_run_all_tests_unix.sh.in | |
mkdir -p "${srcdir}/${_pkgname%-stable}-${pkgver}/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/" | |
ln -sf "${srcdir}/ippicv_linux_20151201.tgz" "${srcdir}/${_pkgname%-stable}-${pkgver}/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/ippicv_linux_20151201.tgz" | |
cd "${srcdir}/${_pkgname%-stable}_contrib-${pkgver}" | |
# opencv_contrib sfm problem, use the complete FindGflags.cmake from ceres-solver | |
#patch -p1 -i "${srcdir}/opencv_contrib_sfm_cmake.patch" | |
} | |
build() { | |
cd "${srcdir}/${_pkgname%-stable}-${pkgver}" | |
mkdir -p build | |
cd build | |
#CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake ${_cmakeopts[@]} \ | |
#CC=/usr/bin/gcc-6 CXX=/usr/bin/g++-6 cmake ${_cmakeopts[@]} \ | |
# -D CUDA_NVCC_FLAGS="-D_FORCE_INLINES --expt-relaxed-constexpr" \ | |
# -D OPENCV_EXTRA_MODULES_PATH=$srcdir/${_pkgname%-stable}_contrib-${pkgver}/modules \ | |
# .. | |
CC=/usr/bin/gcc-6 CXX=/usr/bin/g++-6 cmake ${_cmakeopts[@]} \ | |
-D CUDA_NVCC_FLAGS='-Xcompiler -D__CORRECT_ISO_CPP11_MATH_H_PROTO --expt-relaxed-constexpr' \ | |
-D OPENCV_EXTRA_MODULES_PATH=$srcdir/${_pkgname%-stable}_contrib-${pkgver}/modules \ | |
.. | |
make -j $(($(nproc) + 1)) | |
} | |
package() { | |
options=('staticlibs') | |
cd "${srcdir}/${_pkgname%-stable}-${pkgver}" | |
cd build | |
make DESTDIR="${pkgdir}" install | |
# install LICENSE file | |
install -Dm644 "../LICENSE" "${pkgdir}/usr/share/licenses/${_pkgname%-stable}/LICENSE" | |
} | |
# vim:set ts=4 sw=4 et: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment