File opencv.spec of Package opencv_24

# spec file for package opencv
# Copyright (c) 2015 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

%bcond_with ffmpeg

%define libname lib%{name}
%define soname 2_4

Name:           opencv
Version:        2.4.9
Release:        0
Summary:        Collection of algorithms for computer vision
License:        BSD-3-Clause
Group:          Development/Libraries/C and C++
# PATCH-FIX-UPSTREAM opencv-samples.patch -- Improve samples installation.
Patch1:         %{name}-samples.patch
# PATCH-FIX-UPSTREAM opencv-underlinking.patch -- Make link to libv4l2 since it's using symbols defined there.
Patch2:         %{name}-underlinking.patch
# PATCH-FIX-OPENSUSE improve-sphinx-search.diff -- properly find sphinx with alphabetic chars in version
Patch3:         improve-sphinx-search.diff
# PATCH-FIX-UPSTREAM opencv-pkgconfig.patch -- Make sure to provide link flags in  OpenCV pc file (bnc#853036). Issue is exposed when e.g. a project relies on
# getting opencv vars via pc (first), and then via CMake, as is the case with nomacs
# PATCH-FIX-UPSTREAM opencv-altivec-vector.patch -- use __vector for altivec.
Patch4:         opencv-pkgconfig.patch
Patch5:         opencv-altivec-vector.patch
# PATCH-FIX-UPSTREAM bomb_commit_gstreamer-1x-support.patch -- Add Gstreamer 1.x support
Patch6:         bomb_commit_gstreamer-1x-support.patch
BuildRequires:  cmake
BuildRequires:  fdupes
%if 0%{?suse_version} > 1310
BuildRequires:  gstreamer-plugins-base-devel
BuildRequires:  gstreamer-0_10-plugins-base-devel
BuildRequires:  libucil-devel
BuildRequires:  libunicap-devel
BuildRequires:  libdc1394-devel
%if 0%{?suse_version} != 1315
%if 0%{?suse_version} > 1230
BuildRequires:  libeigen3-devel
BuildRequires:  libeigen2-devel
%if %{with ffmpeg}
BuildRequires:  libffmpeg-devel
BuildRequires:  libjasper-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libqt4-devel
BuildRequires:  libtiff-devel
BuildRequires:  libv4l-devel
%if 0%{?suse_version} > 1220
BuildRequires:  ilmbase-devel
BuildRequires:  openexr-devel
BuildRequires:  OpenEXR-devel
BuildRequires:  libilmbase-devel
BuildRequires:  python-devel
BuildRequires:  python-numpy-devel
%if 0%{?suse_version} != 1315
BuildRequires:  python-sphinx
BuildRequires:  zlib-devel
BuildRequires:  pkgconfig(glu)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

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:        Development files for using the OpenCV library
Group:          Development/Libraries/C and C++

%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
Group:          Development/Libraries/C and C++
# Since 2.4.7
Provides:       %{name}-devel-static = %{version}
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)

%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 python-%{name}
Summary:        Python bindings for apps which use OpenCV
Group:          Development/Libraries/Python
Requires:       python-base = %{py_ver}

%description -n python-%{name}
This package contains Python bindings for the OpenCV library.

%package doc
Summary:        Documentation and examples for OpenCV
Group:          Development/Libraries/C and C++
Recommends:     python
# Since this package also contains examples that need -devel to be compiled
Recommends:     %{name}-devel

%description doc
This package contains the documentation and examples for the OpenCV library.

%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p0
%patch4 -p1
%patch5 -p1
%patch6 -p1

# Remove Windows specific files
rm -f doc/packaging.txt
# Fix "wrong-file-end-of-line-encoding" rpmlint warning
sed -i 's/\r$//' samples/c/facedetect.cmd

export CFLAGS="%{optflags} $(getconf LFS_CFLAGS)"
export CXXFLAGS="%{optflags} $(getconf LFS_CFLAGS)"
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_INSTALL_PREFIX='%{_prefix}' \
      -DLIB_SUFFIX=$(echo %{_lib} | cut -b4-) \
      -DWITH_QT=ON \
      -DWITH_XINE=ON \
%if 0%{?suse_version} <= 1310
      -DWITH_GSTREAMER_0_10=ON \
%ifnarch x86_64
      -DENABLE_SSE=0 \
      -DENABLE_SSE2=0 \
      -DENABLE_SSE3=0 \
make %{?_smp_mflags} VERBOSE=1

cd build
make DESTDIR=%{?buildroot:%{buildroot}} install/fast
mkdir -p %{buildroot}%{_docdir}
%if 0%{?suse_version} != 1315
mv %{buildroot}%{_datadir}/OpenCV/doc %{buildroot}%{_docdir}/%{name}-doc
mkdir -p %{buildroot}%{_docdir}/%{name}-doc
mv %{buildroot}%{_datadir}/OpenCV/samples %{buildroot}%{_docdir}/%{name}-doc/examples

# Fix rpmlint warning "doc-file-dependency"
chmod 644 %{buildroot}%{_docdir}/%{name}-doc/examples/python/*.py
chmod 644 %{buildroot}%{_docdir}/%{name}-doc/examples/python2/*.py

%fdupes -s %{buildroot}%{_docdir}/%{name}-doc/examples
%fdupes -s %{buildroot}%{_includedir}

%post -n %{libname}%{soname} -p /sbin/ldconfig

%postun -n %{libname}%{soname} -p /sbin/ldconfig

%exclude %{_datadir}/OpenCV/OpenCVConfig*.cmake

%files -n %{libname}%{soname}

%files devel

%files -n python-%{name}

%files doc

openSUSE Build Service is sponsored by