File libusb.spec of Package libusb
## define realname libusbx
%define realname libusb
%define gen_name libusb
%define realver 1.0.24
%define srcext tar.bz2
%define so_ver 0
%define abi_ver 1_0
# Common info
Name: %{gen_name}-%{abi_ver}-%{so_ver}
Version: %{realver}
Release: wiz%{?extraver:0.}1%{?dist}
License: LGPL-2.1+
Group: System/Libraries
URL: http://libusb.info/
Summary: A cross-platform library to access USB devices
# Build-time parameters
BuildRequires: pkg-config
%if 0%{?suse_version} || 0%{?rhel} >= 6
BuildRequires: libudev-devel
%endif
BuildRoot: %{_tmppath}/%{name}-root
Source: https://github.com/libusb/libusb/releases/download/v%{version}/libusb-%{version}.tar.bz2
%description
libusb is a C library that provides generic access to USB devices. It is
intended to be used by developers to facilitate the production of applications
that communicate with USB hardware.
%package -n %{gen_name}-%{abi_ver}-devel
Group: Development/Languages/C and C++
Summary: Development files for %{name}
Requires: %{name} = %{version}
Provides: %{gen_name}%{so_ver}-devel = %{version}
%description -n %{gen_name}-%{abi_ver}-devel
Development files for %{name}
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}
%build
_CFLAGS='%{optflags} %{?gcc_lto}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}'
%configure \
--disable-static \
%if 0%{?suse_version} || 0%{?rhel} >= 6
--enable-udev \
%else
--disable-udev \
%endif
CFLAGS="$_CFLAGS" \
LDFLAGS="$_LDFLAGS"
%{__make} %{?_smp_mflags} V=1
%install
%{__make} install DESTDIR=%{buildroot}
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%files
%defattr(-,root,root)
%doc AUTHORS COPYING NEWS README
%{_libdir}/libusb-1.0.so.%{so_ver}*
# Development stuff
%files -n %{gen_name}-%{abi_ver}-devel
%defattr(-,root,root)
%{_libdir}/pkgconfig/libusb-1.0.pc
%dir %{_includedir}/libusb-1.0/
%{_includedir}/libusb-1.0/libusb.h
%{_libdir}/libusb-1.0.so
%exclude %{_libdir}/*.la
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%changelog