Name: @PACKAGE_NAME@
Version: @PACKAGE_VERSION@
Release: 1
Group:   Development/Libraries/C and C++

Vendor: L-Card
URL: http://www.lcard.ru
License: LGPL-3.0+

Source: @PACKAGE_SRC_TAR_NAME@

BuildRoot: %{_tmppath}/%{name}-%{version}-root

BuildRequires: cmake >= 2.6, udev
%if 0%{?mageia}
BuildRequires: libavahi-common-devel, libavahi-client-devel
%else
BuildRequires: avahi-devel
%endif

# включаем зависимость от libusb-1.0
%if 0%{?fedora}
BuildRequires: libusb1-devel
%endif

%if 0%{?suse_version}
BuildRequires: libusb-1_0-devel
%endif

%if 0%{?mageia}
BuildRequires: libusb1.0-devel
%endif

%if 0%{?rhel_version} || 0%{?rhel} || 0%{?centos_version}
BuildRequires: libusbx-devel
%endif


Obsoletes: l502api

Summary: Source package for libraries for L502 and E502 devices

%description 
This package contain libraries for control L-Card data acqusition 
L502 and E502 devices.

#запрет отладочной информации, т.к. на некоторых платформах (Fedora >= 27) есть проблемы сборки пакетов с ней
%global debug_package %{nil}

%prep
#извлечение исходников из архива
%setup

%build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix}\
    -DX502_INSTALL_INCLUDE=%{_includedir} -DX502_INSTALL_LIB=%{_libdir}
make

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

%clean
rm -rf $RPM_BUILD_ROOT




#---------- x502api  ---------------

%package -n libx502api1
Summary: Library for control L-Card L502 and E502 devices
Group:   System/Libraries



%post -n libx502api1
ldconfig

%postun -n libx502api1
ldconfig

%files -n libx502api1
%defattr(0644,root,root)
%{_libdir}/libx502api.so.*

%description -n libx502api1
This package contain the shared object files with general functions for E502 and L502 devices.


#---------- e502api  ---------------

%package -n libe502api1
Summary: Library for control L-Card E502 device
Group:   System/Libraries
Requires: udev

%post -n libe502api1
ldconfig

if [ $1 -eq 1 ] ; then

  if [ -x /sbin/udevadm ]; then
      /sbin/udevadm control --reload-rules
      /sbin/udevadm trigger --subsystem-match=usb --attr-match=idVendor=2a52 --attr-match=idProduct=e502
      /sbin/udevadm trigger --subsystem-match=usb --attr-match=idVendor=2a52 --attr-match=idProduct=0e16
  fi
fi


%postun -n libe502api1
ldconfig

%files -n libe502api1
%defattr(-,root,root)
/usr/lib/udev/rules.d/e502.rules
/usr/lib/udev/rules.d/e16.rules
%defattr(0644,root,root)
%{_libdir}/libe502api.so.*

%description -n libe502api1
This package contain the shared object files for control L-Card E502 data acquisition module with USB and Ethernet interface.



#---------- l502api  ---------------

%package -n libl502api1
Summary: Library for control L-Card L502 device
Group:   System/Libraries

%post -n libl502api1
ldconfig

%postun -n libl502api1
ldconfig

%files -n libl502api1
%defattr(0644,root,root)
%{_libdir}/libl502api.so.*

%description -n libl502api1
This package contain the shared object files for control L-Card L502 data acquisition module with USB and Ethernet interface.





#---------- package with developers files  ---------------
%package -n libx502api1-devel
Summary: Developer files for  L-Card L502 and E502 devices
Group:   Development/Libraries/C and C++
Requires: libx502api1 = @PACKAGE_VERSION@
Requires: libe502api1 = @PACKAGE_VERSION@          
Requires: libl502api1 = @PACKAGE_VERSION@
Obsoletes: libl502api1-devel

%description -n libx502api1-devel
This package contain developer files such as headers and linker files for libraries
for control L-Card L502 and E502 devices.

You need these files if you writing your own software. Non-developers likely 
have little use for this package.

%files -n libx502api1-devel
%defattr(0644,root,root)
%{_includedir}/*
%{_libdir}/lib*.so


