File opencv.spec of Package opencv
#
# spec file for package opencv
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
%define libname lib%{name}
%define soname 4_4
# disabled by default as many fail
%bcond_with tests
%bcond_without qt5
%bcond_without ffmpeg
%bcond_without python2
%bcond_without python3
%bcond_without openblas
Name: opencv
Version: 4.4.0
Release: lp162.147.1
Packager: Alessandro de Oliveira Faria (A.K.A CABELO) <cabelo@opensuse.org>
Summary: Collection of algorithms for computer vision
License: BSD-3-Clause AND GPL-2.0-only AND Apache-2.0
Group: Development/Libraries/C and C++
Url: http://opencv.org/
Source0: https://github.com/opencv/opencv/archive/%{version}.tar.gz
#Patch1: opencv-gles.patch
#Patch8: opencv-build-compare.patch
#Patch11: 0001-Do-not-include-glx.h-when-using-GLES.patch
#Patch12: fix_processor_detection_for_32bit_on_64bit.patch
#Patch13: opencv-lib_suffix.patch
BuildRequires: git
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: fdupes
BuildRequires: libtiff
BuildRequires: libtiff-devel
BuildRequires: zlib
BuildRequires: zlib-devel
BuildRequires: tbb-devel
%if 0%{?centos_version} == 700
BuildRequires: python
BuildRequires: python-devel
BuildRequires: gstreamer-plugins-base-devel
%endif
%if 0%{?centos_version} == 800
BuildRequires: python38
BuildRequires: python38-devel
BuildRequires: gstreamer1-plugins-base-devel
%endif
%if 0%{?centos_version} == 700 || 0%{?centos_version} == 800
BuildRequires: gtk2-devel
BuildRequires: libpng-devel
BuildRequires: jasper-devel
BuildRequires: openexr-devel
BuildRequires: libjpeg-turbo-devel
BuildRequires: freeglut-devel
BuildRequires: mesa-libGL
BuildRequires: mesa-libGL-devel
BuildRequires: boost
BuildRequires: boost-thread
BuildRequires: boost-devel
BuildRequires: libv4l-devel
%endif
%if 0%{?fedora_version}==28 || 0%{?fedora_version}==29
BuildRequires: cmake3
%else
BuildRequires: cmake >= 3.5.1
%endif
%if 0%{?scientificlinux_version} == 700
BuildRequires: libjasper-devel
BuildRequires: python-devel
BuildRequires: python
BuildRequires: libjpeg-devel
BuildRequires: pkgconfig
BuildRequires: unzip
BuildRequires: ilmbase
BuildRequires: OpenEXR-libs
BuildRequires: OpenEXR-devel
BuildRequires: mesa-libGLU-devel
BuildRequires: mesa-libGL-devel
BuildRequires: gstreamer1-plugins-base
BuildRequires: mesa-libGL
BuildRequires: mesa-libGLU
BuildRequires: gstreamer1-devel
BuildRequires: gstreamer1
BuildRequires: gstreamer1-plugins-base-devel
BuildRequires: numpy
BuildRequires: libgphoto2
BuildRequires: libgphoto2-devel
BuildRequires: libpng
BuildRequires: libpng-devel
%endif
%if 0%{?mageia} == 6
BuildRequires: python-devel
BuildRequires: python
BuildRequires: libjasper-devel
BuildRequires: libjpeg-devel
BuildRequires: pkgconfig
BuildRequires: python3-devel
BuildRequires: unzip
BuildRequires: libpng
BuildRequires: libpng-devel
BuildRequires: python-numpy-devel
%endif
%if 0%{?fedora_version}==28 || 0%{?fedora_version}==29
BuildRequires: python-devel
BuildRequires: python
BuildRequires: rpmfusion-free-release
BuildRequires: rpmfusion-nonfree-release
BuildRequires: qt5-qtbase-devel
BuildRequires: python3
BuildRequires: python3-devel
BuildRequires: python3-pip
BuildRequires: python-pip
BuildRequires: numpy
BuildRequires: python3-numpy
BuildRequires: ffmpeg
BuildRequires: ffmpeg-devel
BuildRequires: libpng-devel
BuildRequires: libpng
BuildRequires: openexr
BuildRequires: openexr-devel
BuildRequires: libwebp-devel
BuildRequires: libjpeg-turbo-devel
BuildRequires: freeglut
BuildRequires: freeglut-devel
BuildRequires: mesa-libGL
BuildRequires: mesa-libGL-devel
BuildRequires: libdc1394-devel
BuildRequires: eigen3-devel
BuildRequires: boost
BuildRequires: boost-thread
BuildRequires: boost-devel
%endif
%if 0%{?rhel_version}==700
BuildRequires: python
BuildRequires: python-devel
%endif
%if 0%{?rhel_version}==800
BuildRequires: python38
BuildRequires: python38-devel
%endif
%if 0%{?rhel_version}==700 || 0%{?rhel_version}==800
BuildRequires: numpy
BuildRequires: ffmpeg
BuildRequires: ffmpeg-devel
BuildRequires: libpng-devel
BuildRequires: libjpeg-turbo-devel
BuildRequires: freeglut-devel
BuildRequires: mesa-libGL
BuildRequires: mesa-libEGL
BuildRequires: mesa-libEGL-devel
BuildRequires: mesa-libGL-devel
BuildRequires: boost
BuildRequires: boost-thread
BuildRequires: boost-devel
%endif
%if (0%{?sle_version} >= 120200 && 0%{?is_opensuse}) || ( 0%{?sle_version} >= 120400 && !0%{?is_opensuse} )
BuildRequires: libjasper-devel
BuildRequires: libjpeg-devel
BuildRequires: pkgconfig
BuildRequires: python3-devel
BuildRequires: unzip
BuildRequires: openexr
BuildRequires: openexr-devel
BuildRequires: ilmbase-devel
BuildRequires: gstreamer-plugins-base-devel
BuildRequires: gstreamer-plugins-base
BuildRequires: glu-devel
BuildRequires: libGLU1
BuildRequires: Mesa-libEGL-devel
BuildRequires: Mesa-libGL-devel
BuildRequires: Mesa-libEGL1
BuildRequires: Mesa-libGL1
BuildRequires: Mesa
BuildRequires: libdc1394
BuildRequires: libdc1394-devel
BuildRequires: libraw1394
BuildRequires: libraw1394-devel
BuildRequires: libgphoto2-6
BuildRequires: libgphoto2-devel
BuildRequires: libpng16-16
BuildRequires: libpng16-devel
BuildRequires: libv4l2-0
BuildRequires: libv4lconvert0
Provides: opencv-qt5
Obsoletes: opencv-qt5
%if (0%{?sle_version} >= 120200 && 0%{?is_opensuse})
BuildRequires: libeigen3-devel
%if %{with openblas}
BuildRequires: openblas-devel
%endif
%endif
%if %{with python2}
BuildRequires: python-base
BuildRequires: python-devel
%if 0%{?suse_version} > 1325
BuildRequires: python2-numpy-devel
%else
BuildRequires: python-numpy-devel
%endif
%endif
%if %{with python3}
%if (0%{?sle_version} >= 120200 && 0%{?is_opensuse})
BuildRequires: python3-numpy-devel
%endif
BuildRequires: python3-base
BuildRequires: python3-devel
%endif
%if %{with qt5}
BuildRequires: libQt5Concurrent-devel
BuildRequires: libQt5Gui5
BuildRequires: libQt5OpenGL-devel
BuildRequires: libQt5Test-devel
BuildRequires: libQt5Widgets5
BuildRequires: libQt5Core-devel
%else
BuildRequires: libQtCore-devel
BuildRequires: libQtGui
BuildRequires: libQtOpenGL-devel
BuildRequires: libQtTest-devel
%endif
%if %{with ffmpeg}
BuildRequires: libavcodec-devel
BuildRequires: libavformat-devel
BuildRequires: libavutil-devel
BuildRequires: libswscale-devel
%endif
%endif
%description
OpenCV means IntelĀ® Open Source Computer Vision Library. It is a collection of C
functions and a few C++ classes that implement some popular Image Processing and
Computer Vision algorithms.
%package -n %{libname}%{soname}
Summary: Libraries to use OpenCV computer vision
License: BSD-3-Clause
Group: System/Libraries
%description -n %{libname}%{soname}
The Open Computer Vision Library is a collection of algorithms and sample code
for various computer vision problems. The library is compatible with IPL and
utilizes Intel Integrated Performance Primitives for better performance.
%package devel
Summary: Development files for using the OpenCV library
License: BSD-3-Clause
Group: Development/Libraries/C and C++
Requires: %{libname}%{soname} = %{version}
Requires: %{name} = %{version}
Requires: pkgconfig(gl)
Requires: pkgconfig(glu)
Requires: pkgconfig(ice)
Requires: pkgconfig(sm)
Requires: pkgconfig(x11)
Requires: pkgconfig(xext)
Provides: %{name}-qt5-devel
Obsoletes: %{name}-qt5-devel
%description devel
This package contains the OpenCV C/C++ library and header files, as well as
documentation. It should be installed if you want to develop programs that will
use the OpenCV library.
%package -n python2-%{name}
Summary: Python 2 bindings for apps which use OpenCV
License: BSD-3-Clause
Group: Development/Libraries/Python
Provides: python-%{name} = %{version}-%{release}
Obsoletes: python-%{name} < %{version}-%{release}
Provides: python-%{name}-qt5
Obsoletes: python-%{name}-qt5
%description -n python2-%{name}
This package contains Python 2 bindings for the OpenCV library.
%package -n python3-%{name}
Summary: Python 3 bindings for apps which use OpenCV
License: BSD-3-Clause
Group: Development/Libraries/Python
Provides: python3-%{name}-qt5
Obsoletes: python3-%{name}-qt5
%description -n python3-%{name}
This package contains Python 3 bindings for the OpenCV library.
%package doc
Summary: Documentation and examples for OpenCV
License: BSD-3-Clause
Group: Documentation/Other
%if 0%{?sle_version} >= 120200 && 0%{?is_opensuse}
Recommends: python
# Since this package also contains examples that need -devel to be compiled
Suggests: %{name}-devel
Provides: %{name}-qt5-doc
Obsoletes: %{name}-qt5-doc
%endif
%description doc
This package contains the documentation and examples for the OpenCV library.
%prep
#%setup -q -a 1
%setup -q -a 0
%autopatch -p1
# Remove Windows specific files
rm -f doc/packaging.txt
%build
# Dynamic dispatch: https://github.com/opencv/opencv/wiki/CPU-optimizations-build-options
# x86: disable SSE on 32bit, do not dispatch AVX and later - SSE3
# is the highest extension available on any non-64bit x86 CPU
# ARM: ARMv6, e.g. RPi1, only has VFPv2
%if 0%{?fedora_version}==28 || 0%{?fedora_version}==29 || 0%{?rhel_version}==700 0%{?fedora_version}==31 || 0%{?fedora_version}==30 ||
mkdir build
cd build
echo "Debug line 286"
%endif
%if 0%{?rhel_version}==700
cmake \
%else
%cmake \
%endif
%if %{with tests}
-DBUILD_TESTS=ON \
%endif
-DINSTALL_C_EXAMPLES=ON \
%if 0%{?centos_version} == 700
-DINSTALL_PYTHON_EXAMPLES=OFF \
%else
-DINSTALL_PYTHON_EXAMPLES=ON \
%endif
-DENABLE_OMIT_FRAME_POINTER=OFF \
-DWITH_OPENNI=OFF \
%if ( 0%{?rhel_version}==700) || (0%{?mageia} == 6) || 0%{?scientificlinux_version} == 700 || 0%{?centos_version} == 700
-DWITH_QT=OFF \
%else
-DWITH_QT=ON \
%endif
-DWITH_CUDA=OFF\
-DCUDA_FAST_MATH=OFF \
-DWITH_CUBLAS=OFF \
-DWITH_OPENGL=ON \
-DWITH_UNICAP=ON \
-DWITH_XINE=ON \
-DWITH_IPP=ON \
-DWITH_TBB=ON \
-DENABLE_SSE42=OFF \
-DOPENCV_GENERATE_PKGCONFIG=ON \
%ifarch %{ix86}
-DCPU_BASELINE_DISABLE=SSE \
-DCPU_DISPATCH=SSE,SSE2,SSE3 \
%endif
%ifarch x86_64
-DCPU_BASELINE=SSE2 \
-DCPU_DISPATCH=SSE3,SSE4_1,SSE4_2,AVX,FP16,AVX2 \
%endif
%ifarch %{arm}
%ifarch armv7l armv7hl
-DCPU_BASELINE=VFPV3 \
-DCPU_DISPATCH=NEON \
%else
-DCPU_BASELINE_DISABLE=NEON,VFPV3 \
%endif
%endif
%ifarch aarch64
-DCPU_BASELINE=NEON \
-DCPU_DISPATCH=FP16 \
%endif
%if 0%{?suse_version} >= 1500
-DPYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3 \
%endif
%if 0%{?fedora_version}==28 || 0%{?fedora_version}==29 || 0%{?fedora_version}==30 || 0%{?fedora_version}==31 || 0%{?rhel_version}==700 || ( 0%{?sle_version} >= 120400 && !0%{?is_opensuse} )
..
%endif
make %{?_smp_mflags} VERBOSE=1
%check
%if %{with tests}
export LD_LIBRARY_PATH=$(pwd)/build/lib:$LD_LIBRARY_PATH
%ctest
%endif
%install
%if ( 0%{?sle_version} >= 120200 && 0%{?is_opensuse}) || ( 0%{?sle_version} >= 120400 && !0%{?is_opensuse} )
%cmake_install
%else
%{__make} -C build install DESTDIR=%{buildroot}
#find /home/abuild/rpmbuild/BUILDROOT/opencv-4.0.1-57.1.x86_64/ -name 'cv2.so'
%endif
mkdir -p %{buildroot}%{_docdir}/%{name}-doc
%post -n %{libname}%{soname} -p /sbin/ldconfig
%postun -n %{libname}%{soname} -p /sbin/ldconfig
%files
%defattr(-,root,root,-)
%license LICENSE
%if 0%{?rhel_version}==700
%dir %{_prefix}/local/share/opencv4
%dir %{_prefix}/local/share/opencv4/haarcascades
%dir %{_prefix}/local/share/opencv4/lbpcascades
%dir %{_prefix}/local/share/licenses/opencv4
%dir %{_prefix}/local/bin
%{_prefix}/local/bin/opencv_*
%{_prefix}/local/share/opencv4/haarcascades/*
%{_prefix}/local/share/opencv4/lbpcascades/*
%{_prefix}/local/share/licenses/opencv4/*
%{_prefix}/local/bin/setup_vars_opencv4.sh
%else
%dir %{_prefix}/share/opencv4
%dir %{_prefix}/share/opencv4/haarcascades
%dir %{_prefix}/share/opencv4/lbpcascades
%dir %{_prefix}/share/licenses/opencv4
%{_bindir}/opencv_*
%{_prefix}/share/opencv4/haarcascades/*
%{_prefix}/share/opencv4/lbpcascades/*
%{_prefix}/share/licenses/opencv4/*
%{_bindir}/setup_vars_opencv4.sh
%endif
%files -n %{libname}%{soname}
%defattr(-,root,root,-)
%license LICENSE
%if 0%{?rhel_version}==700
# || ( 0%{?sle_version} >= 120400 && !0%{?is_opensuse} )
%{_prefix}/local/lib64/libopencv_*.so.*
%{_prefix}/local/lib64/libopencv_*.so
%else
%{_libdir}/libopencv_*.so.*
%{_libdir}/libopencv_*.so
%endif
%files devel
%defattr(-,root,root,-)
%license LICENSE
%if 0%{?rhel_version}==700
%dir %{_prefix}/local/lib64/cmake/opencv4
%dir %{_prefix}/local/include/opencv4
%dir %{_prefix}/local/include/opencv4/opencv2
%dir %{_prefix}/local/share/opencv4
%dir %{_prefix}/local/share/opencv4/samples
%{_prefix}/local/share/opencv4/samples
%{_prefix}/local/share/opencv4/valgrind.supp
%{_prefix}/local/share/opencv4/valgrind_3rdparty.supp
%{_prefix}/local/lib64/lib*.so
%{_prefix}/local/lib64/cmake/opencv4/*
%{_prefix}/local/lib64/pkgconfig/opencv4.pc
%{_prefix}/local/include/opencv4/opencv2/*
%else
%dir %{_libdir}/cmake/opencv4
%dir %{_includedir}/opencv4
%dir %{_includedir}/opencv4/opencv2
%dir %{_prefix}/share/opencv4
%dir %{_prefix}/share/opencv4/samples
%{_prefix}/share/opencv4/samples
%{_prefix}/share/opencv4/valgrind.supp
%{_prefix}/share/opencv4/valgrind_3rdparty.supp
%{_libdir}/lib*.so
%{_libdir}/cmake/opencv4/*
%{_libdir}/pkgconfig/opencv4.pc
%{_includedir}/opencv4/opencv2/*
%endif
%if !(0%{?centos_version} == 700 )
%if %{with python2}
%files -n python2-%{name}
%defattr(-,root,root,-)
%if 0%{?fedora_version}==28 || 0%{?fedora_version}==29 || (0%{?mageia} == 6) || (0%{?scientificlinux_version} == 700)
%exclude %{python_sitearch}/cv2/*.pyc
%exclude %{python_sitearch}/cv2/*.pyo
%endif
%if (0%{?rhel_version}==700)
%exclude %{_prefix}/local/lib/python%{python_version}/site-packages/cv2/*.pyc
%exclude %{_prefix}/local/lib/python%{python_version}/site-packages/cv2/*.pyo
%endif
%if 0%{?rhel_version}==700
%dir %{_prefix}/local/lib/python%{python_version}/site-packages/cv2
%dir %{_prefix}/local/lib/python%{python_version}/site-packages/cv2/python-%{python_version}
%{_prefix}/local/lib/python%{python_version}/site-packages/cv2/python-%{python_version}/cv2.so
%{_prefix}/local/lib/python%{python_version}/site-packages/cv2/*.py
%else
%dir %{python_sitearch}/cv2
%dir %{python_sitearch}/cv2/python-%{python_version}
%{python_sitearch}/cv2/python-%{python_version}/cv2.so
%{python_sitearch}/cv2/*.py
%endif
%endif
%endif
%if !(0%{?centos_version} == 700 )
%if (!0%{?rhel_version}) && !(0%{?sle_version} >= 120400 && !0%{?is_opensuse}) && !(0%{?mageia} == 6) && !(0%{?scientificlinux_version} == 700)
%if %{with python3}
%files -n python3-%{name}
%defattr(-,root,root,-)
%if 0%{?fedora_version}==28 || 0%{?fedora_version}==29
%{python3_sitearch}/cv2/__pycache__/*.pyc
%endif
%dir %{python3_sitearch}/cv2
%dir %{python3_sitearch}/cv2/python-%{python3_version}
%{python3_sitearch}/cv2/python-%{python3_version}/cv2.*.so
%{python3_sitearch}/cv2/*.py
%endif
%endif
%endif
%files doc
%defattr(-,root,root,-)
%{_docdir}/%{name}-doc/
%changelog
* Fri Mar 1 2019 cabelo@opensuse.org
- Initial package
* add opencv-lib_suffix.patch, remove LIB_SUFFIX
from OPENCV_LIB_INSTALL_PATH, as CMAKE_INSTALL
_LIBDIR is arch dependent.