%?mingw_package_header

%global commit d17db57b9d4354752e0af42f5f33007a42ef2906
%global shortcommit %(c=%{commit}; echo ${c:0:7})

%global name1 hidapi
Name:           mingw-%{name1}
Version:        0.8.0
Release:        0.2.%{shortcommit}%{?dist}
Summary:        MinGW library for communicating with USB and Bluetooth HID devices

Group:          System Environment/Libraries
License:        GPLv3 or BSD
URL:            http://www.signal11.us/oss/hidapi/
Source0:        https://github.com/signal11/%{name1}/archive/%{commit}/%{name1}-%{version}-%{shortcommit}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch:      noarch

BuildRequires:  mingw32-filesystem
BuildRequires:  mingw64-filesystem
BuildRequires:  mingw32-gcc
BuildRequires:  mingw64-gcc
BuildRequires:  mingw32-gcc-c++
BuildRequires:  mingw64-gcc-c++
BuildRequires:  mingw32-binutils
BuildRequires:  mingw64-binutils
BuildRequires:  mingw32-libusbx
BuildRequires:  mingw64-libusbx
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  libtool
BuildRequires:  m4

%description
HIDAPI is a multi-platform library which allows an application to interface
with USB and Bluetooth HID-class devices on Windows, Linux, FreeBSD and Mac OS
X.

%package -n mingw32-%{name1}
Summary:        MinGW library for communicating with USB and Bluetooth HID devices

%description -n mingw32-%{name1}
HIDAPI is a multi-platform library which allows an application to interface
with USB and Bluetooth HID-class devices on Windows, Linux, FreeBSD and Mac OS
X.

%package -n mingw64-%{name1}
Summary:        MinGW library for communicating with USB and Bluetooth HID devices

%description -n mingw64-%{name1}
HIDAPI is a multi-platform library which allows an application to interface
with USB and Bluetooth HID-class devices on Windows, Linux, FreeBSD and Mac OS
X.

%{?mingw_debug_package}

%prep
%setup -q -n %{name1}-%{commit}


%build
autoreconf -vif
%mingw_configure --disable-testgui --disable-static

%mingw_make %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT
%mingw_make install DESTDIR=$RPM_BUILD_ROOT INSTALL="install -p"
find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
rm -rf %{buildroot}%{mingw32_datadir}/doc/%{name1}
rm -rf %{buildroot}%{mingw64_datadir}/doc/%{name1}

%clean
rm -rf $RPM_BUILD_ROOT

%files -n mingw32-%{name1}
%defattr(-,root,root,-)
%license LICENSE*.txt
%doc AUTHORS.txt README.txt
%{mingw32_bindir}/libhidapi-0.dll
%{mingw32_includedir}/hidapi/hidapi.h
%{mingw32_libdir}/libhidapi.dll.a
%{mingw32_libdir}/pkgconfig/hidapi.pc

%files -n mingw64-%{name1}
%defattr(-,root,root,-)
%license LICENSE*.txt
%doc AUTHORS.txt README.txt
%{mingw64_bindir}/libhidapi-0.dll
%{mingw64_includedir}/hidapi/hidapi.h
%{mingw64_libdir}/libhidapi.dll.a
%{mingw64_libdir}/pkgconfig/hidapi.pc

%changelog
* Thu Feb 02 2017 Thomas Sailer <thomas.sailer@axsem.com> - 0.2.d17db57-1
- Initial Specfile