%define __strip %{_mingw32_strip}
%define __objdump %{_mingw32_objdump}
%define _use_internal_dependency_generator 0
%define __find_requires %{_mingw32_findrequires}
%define __find_provides %{_mingw32_findprovides}

Name:           mingw32-libusb-win32
Version:        0.1.12.1
Release:        1%{?dist}
Summary:        A library which allows userspace access to USB devices

License:        LGPLv2+
Group:          System Environment/Libraries
URL:            http://libusb-win32.sourceforge.net/
Source0:        http://download.sourceforge.net/libusb-win32/libusb-win32-src-%{version}.tar.gz
Patch0:         mingw32-libusb-win32.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildArch:      noarch

BuildRequires:  mingw32-filesystem >= 33
BuildRequires:  mingw32-gcc
BuildRequires:  mingw32-binutils
BuildRequires:  autoconf, automake, libtool


%description
This package provides a way for applications to access USB devices.


%prep
%setup -q -n libusb-win32-src-%{version}
%patch0 -p0

chmod -x COPYING_GPL.txt
chmod -x COPYING_LGPL.txt


%build
host_prefix=%{_mingw32_target} \
make


%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_mingw32_bindir}
mkdir -p $RPM_BUILD_ROOT/%{_mingw32_libdir}
mkdir -p $RPM_BUILD_ROOT/%{_mingw32_includedir}
mkdir -p $RPM_BUILD_ROOT/%{_mingw32_datadir}/libusb-win32
cp -p inf-wizard.exe install-filter.exe testlibusb.exe testlibusb-win.exe libusb0.dll libusb0.sys $RPM_BUILD_ROOT/%{_mingw32_bindir}
cp -p libusb.a libusbd.a $RPM_BUILD_ROOT/%{_mingw32_libdir}
cp -p src/usb.h $RPM_BUILD_ROOT/%{_mingw32_includedir}
cp -p COPYING_GPL.txt COPYING_LGPL.txt $RPM_BUILD_ROOT/%{_mingw32_datadir}/libusb-win32

%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root)
%{_mingw32_bindir}/libusb0.dll
%{_mingw32_bindir}/libusb0.sys
%{_mingw32_bindir}/inf-wizard.exe
%{_mingw32_bindir}/install-filter.exe
%{_mingw32_bindir}/testlibusb.exe
%{_mingw32_bindir}/testlibusb-win.exe
%{_mingw32_libdir}/libusb.a
%{_mingw32_libdir}/libusbd.a
%{_mingw32_includedir}/usb.h
%{_mingw32_datadir}/libusb-win32/COPYING_GPL.txt
%{_mingw32_datadir}/libusb-win32/COPYING_LGPL.txt


%changelog
* Tue Mar 24 2009 Michael Cronenworth <mike@cchtml.com> - 0.1.12.1-1
- Initial RPM release.
