File libtorrent.spec of Package libtorrent-rasterbar
%define realname libtorrent
%define srcext tar.bz2
%bcond_with python3
%define so_ver 10
# turn off the generation of debuginfo rpm (RH9) ??
%global debug_package %{nil}
%if 0%{?suse_version} < 1500 && 0%{?rhel} < 8
%define cxx11abi -D_GLIBCXX_USE_CXX11_ABI=0
%endif
%if ! 0%{?py_ver:1}
%define py_ver %(python -c "import sys; v=sys.version_info[:2]; print('%%d.%%d'%%v)" 2>/dev/null || echo PYTHON-NOT-FOUND)
%endif
# Python 3.x support
%if 0%{?suse_version} || 0%{?rhel} == 7
%define python3_pkg python3
%define python3 %{_bindir}/python3
%endif
# EPEL
%if 0%{?rhel} == 6
%define python3_pkg python34
%define python3 %{_bindir}/python3.4
%endif
# platform-python
%if 0%{?rhel} == 8
%define python3_pkg python38
%define python3 %{_bindir}/python3.8
%endif
%if ! 0%{?py3_ver:1}
%define py3_ver %(%{python3} -c "import sys; v=sys.version_info[:2]; print ('%%d.%%d'%%v)" 2>/dev/null || echo PYTHON3-NOT-FOUND)
%endif
%if ! 0%{?python3_sitearch:1}
%define python3_sitearch %(%python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib(True))')
%endif
%if %{with python3}
%define python_pkg %{python3_pkg}
%define python_bin %{python3}
%define python_abi %{py3_ver}
%define python_dir %{python3_sitearch}
%else
%define python_pkg python
%define python_bin %{_bindir}/python
%define python_abi %{py_ver}
%define python_dir %{python_sitearch}
%endif
# Common info
Name: %{realname}-rasterbar%{?so_ver}
Version: 0
Release: wiz%{?extraver:0.}1%{?dist}
License: BSD-2-Clause
Group: Productivity/Networking/File-Sharing
URL: http://libtorrent.org/
Summary: C++ implementation of the BitTorrent protocol
# Install-time parameters
Provides: %{realname} = %{version}-%{release}
Provides: %{realname}-rasterbar = %{version}-%{release}
# Build-time parameters
BuildRequires: gcc-c++
BuildRequires: cmake >= 3.12.0
BuildRequires: ninja
BuildRequires: pkgconfig
BuildRequires: boost-devel >= 1.58
BuildRequires: libstdc++-devel
BuildRequires: openssl-devel
BuildRequires: %{python_pkg}-devel
BuildRequires: %{python_pkg}-setuptools
BuildRoot: %{_tmppath}/%{name}-root
Source: %{realname}-%{version}%{?extraver}.%{srcext}
%description
libtorrent is a feature complete C++ bittorrent implementation focusing on
efficiency and scalability. It runs on embedded devices as well as desktops. It
boasts a well documented library interface that is easy to use.
%package -n %{realname}-rasterbar-devel
Group: Development/Languages/C and C++
Summary: Development files for %{name}
Requires: %{name} = %{version}-%{release}
Provides: %{name}-devel = %{version}-%{release}
Provides: %{realname}-devel = %{version}-%{release}
%description -n %{realname}-rasterbar-devel
Development files for %{name}
%package -n %{python_pkg}-libtorrent
Group: Development/Languages/Python
Summary: Python bindings for %{name}
Requires: %{name} = %{version}-%{release}
Requires: python(abi) = %{python_abi}
Provides: %{python_pkg}-%{realname}-rasterbar = %{version}-%{release}
%description -n %{python_pkg}-libtorrent
Python %{python_abi} bindings for %{name}
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver}
%build
_CFLAGS='%{optflags} %{?gcc_lto}'
_CXXFLAGS='%{optflags} %{?gcc_lto} %{?cxx11abi}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,now -Wl,-z,relro %{?gcc_lto}'
mkdir tmp_build
cd tmp_build
cmake .. \
-G Ninja \
-DCMAKE_INSTALL_PREFIX=%{_prefix} \
-DCMAKE_INSTALL_LIBDIR=%{_lib} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS_RELEASE="$_CFLAGS" \
-DCMAKE_CXX_FLAGS_RELEASE="$_CXXFLAGS" \
-DCMAKE_EXE_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
-DCMAKE_MODULE_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
-DCMAKE_VERBOSE_MAKEFILE=YES \
\
-Dpython-bindings=ON \
\
-DPYTHON_EXECUTABLE=%{python_bin}
ninja %{?_smp_mflags}
%install
DESTDIR=%{buildroot} ninja -C tmp_build install
%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
%files
%defattr(-,root,root)
%doc AUTHORS CONTRIBUTING.rst COPYING ChangeLog LICENSE NEWS README.rst
%{_libdir}/%{realname}-rasterbar.so.%{version}
%{_libdir}/%{realname}-rasterbar.so.%{so_ver}
# Development stuff
%files -n %{realname}-rasterbar-devel
%defattr(-,root,root)
### %doc docs/*
%{_libdir}/pkgconfig/%{realname}-rasterbar.pc
%dir %{_includedir}/libtorrent/aux_
%dir %{_includedir}/libtorrent/extensions
%dir %{_includedir}/libtorrent/kademlia
%dir %{_includedir}/libtorrent/
%{_includedir}/libtorrent/aux_/*.h
%{_includedir}/libtorrent/aux_/*.hpp
%{_includedir}/libtorrent/extensions/*.hpp
%{_includedir}/libtorrent/kademlia/*.hpp
%{_includedir}/libtorrent/*.h
%{_includedir}/libtorrent/*.hpp
%{_libdir}/%{realname}-rasterbar.so
%dir %{_libdir}/cmake/LibtorrentRasterbar
%dir %{_libdir}/cmake
%{_libdir}/cmake/LibtorrentRasterbar/*.cmake
%dir %{_datadir}/cmake/Modules
%dir %{_datadir}/cmake
%{_datadir}/cmake/Modules/FindLibtorrentRasterbar.cmake
%files -n %{python_pkg}-libtorrent
%defattr(-,root,root)
%{python_sitearch}/libtorrent.so
%{python_sitearch}/%{realname}.egg-info
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%changelog