# Note that this is NOT a relocatable package
%define ver      @VERSION@
%define RELEASE  0
%define rel      %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
%define prefix   /usr/local

Summary: Application access to USB devices
Name: libopenusb
Version: %ver
Release: %rel
License: LGPL
Group: Libraries
Source: ftp://ftp.openusb.sourceforge.net/pub/openusb/libopenusb-%{ver}.tar.gz
BuildRoot: /var/tmp/libopenusb-%{PACKAGE_VERSION}-root
URL: http://openusb.sourceforge.net

%description
Provides a library for application access to USB devices. Development
libs and headers are in openusb-devel

%package devel
Summary: Application USB device access library
Group: System Environment/Libraries

%description devel
Static libraries and header files for the USB device access library


%changelog

%prep
%setup

%build
./configure --prefix=%{prefix} --libdir=%{prefix}/lib --libexecdir=%{prefix}/lib
make

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p %{buildroot}%{prefix}/%{_lib}
(cd src/.libs && tar cf - libopenusb.so*) | (cd %{buildroot}%{prefix}/%{_lib} && tar xBf -)
mkdir -p %{buildroot}%{prefix}/%{_lib}/openusb_backend
cp -p src/.libs/linux.la %{buildroot}%{prefix}/%{_lib}/openusb_backend/
cp -p src/.libs/linux.so %{buildroot}%{prefix}/%{_lib}/openusb_backend/
mkdir -p %{buildroot}%{_defaultdocdir}/packages/libopenusb/
cp -p AUTHORS COPYING LICENSE ChangeLog NEWS README %{buildroot}%{_defaultdocdir}/packages/libopenusb/
make DEST=%{buildroot} install

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-, root, root)
%{_defaultdocdir}/packages/libopenusb/
%{prefix}/%{_lib}/libopenusb.so*
%{prefix}/%{_lib}/openusb_backend/*.so
%{prefix}/%{_lib}/openusb_backend/*.la

%files devel
%defattr(-, root, root)
%{_defaultdocdir}/packages/libopenusb/
%{prefix}/%{_lib}/libopenusb.so*
%{prefix}/%{_lib}/openusb_backend/*.so
%{prefix}/%{_lib}/openusb_backend/*.la
%doc doc/html/*
