Name:           libgphoto2
Summary:        library for giving access to literally hundreds of digital cameras
Version:        2.5.18
Release:        3
License:        GPLv2+ and GPLv2
URL:            http://www.gphoto.org/
Source0:        http://downloads.sourceforge.net/gphoto/%{name}-%{version}.tar.bz2

Patch1:         gphoto2-pkgcfg.patch
Patch2:         gphoto2-device-return.patch

BuildRequires:  gcc gcc-c++ make systemd libtool-ltdl-devel libjpeg-devel gd-devel
BuildRequires:  pkgconfig(libxml-2.0) pkgconfig(libexif) lockdev-devel pkgconfig(libusb-1.0)

Requires:       lockdev

%description
%{name} is the core of gphoto2 software. It is a portable library
which gives access to literally hundreds of digital cameras.

%package devel
Summary:        Development files for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}
Provides:       gphoto2-devel = %{version}-%{release}
Obsoletes:      gphoto2-devel < 2.4.0-11

%description devel
%{name} Library Header Files and Link Libraries

%package_help

%prep
%autosetup -p1

for f in AUTHORS ChangeLog COPYING %{name}_port/AUTHORS %{name}_port/COPYING.LIB `find -name 'README.*'`; do
    iconv -f ISO-8859-1 -t UTF-8 $f > $f.conv
    mv -f $f.conv $f
done

%build
%configure \
    udevscriptdir='%(pkg-config --variable=udevdir udev)'   \
    --with-drivers=all           \
    --with-doc-dir=%{_pkgdocdir} \
    --disable-rpath              \
    --disable-static             \
    %{nil}

%disable_rpath %{name}_port/libtool

make %{?_smp_mflags}

%install
%make_install INSTALL="install -p" mandir=%{_mandir}

pushd packaging/linux-hotplug/
  export LIBDIR=${RPM_BUILD_ROOT}%{_libdir}
  export CAMLIBS=${RPM_BUILD_ROOT}%{_libdir}/%{name}/%{version}
  export LD_LIBRARY_PATH=${RPM_BUILD_ROOT}%{_libdir}
  install -d ${RPM_BUILD_ROOT}%{_udevrulesdir}
  ${RPM_BUILD_ROOT}%{_libdir}/%{name}/print-camera-list udev-rules version 136 > ${RPM_BUILD_ROOT}%{_udevrulesdir}/40-%{name}.rules
popd

find ${RPM_BUILD_ROOT} -type f -name "*.la" -print -delete

%find_lang %{name}-6
%find_lang %{name}_port-12
cat %{name}*.lang >> %{name}.lang

mkdir __doc
cp -a ${RPM_BUILD_ROOT}%{_pkgdocdir}/* __doc

%files -f %{name}.lang
%license COPYING
%dir %{_libdir}/%{name}/
%dir %{_libdir}/%{name}/%{version}/
%dir %{_libdir}/%{name}_port/
%dir %{_libdir}/%{name}_port/0.12.0/
%{_libdir}/%{name}.so.*
%{_libdir}/%{name}_port.so.*
%{_libdir}/%{name}/%{version}/*.so
%{_libdir}/%{name}_port/0.12.0/*.so
%{_udevrulesdir}/40-%{name}.rules
%(pkg-config --variable=udevdir udev)/check-ptp-camera
%{_datadir}/%{name}/
%exclude %{_includedir}/gphoto2/gphoto2
%exclude %{_libdir}/%{name}/print-camera-list
%exclude %{_pkgdocdir}
%exclude %{_datadir}/%{name}_port/*/vcamera/

%files devel
%{_bindir}/gphoto2-config
%{_bindir}/gphoto2-port-config
%{_libdir}/%{name}.so
%{_libdir}/%{name}_port.so
%{_libdir}/pkgconfig/%{name}.pc
%{_libdir}/pkgconfig/%{name}_port.pc
%{_includedir}/gphoto2/

%files help
%{_mandir}/man3/%{name}.3*
%{_mandir}/man3/%{name}_port.3*
%doc AUTHORS README.md NEWS
%doc __doc/*

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%changelog
* Wed Nov 20 2019 caomeng<caomeng5@huawei.com> - 2.5.18-3
- Package init
