File libupnp.spec of Package libupnp
%define realname pupnp
%define realver 1.14.19
%define srcext tar.gz
%define ixmlver 11.1.2
%define upnp_so_ver 17
%define ixml_so_ver 11
# Common info
Name: libupnp%{upnp_so_ver}
Version: %{realver}
Release: wiz%{?extraver:0.}1%{?dist}
License: BSD-3-Clause
Group: System/Libraries
URL: https://pupnp.github.io/pupnp/
Summary: Portable SDK for UPnP* Devices
# Install-time parameters
Provides: libupnp = %{version}-%{release}
# Build-time parameters
BuildRequires: cmake >= 3.11 ninja
BuildRequires: pkgconfig
BuildRequires: gcc-c++
BuildRequires: openssl-devel
BuildRoot: %{_tmppath}/%{name}-root
Source: https://github.com/pupnp/pupnp/archive/refs/tags/release-%{realver}%{?extraver}.%{srcext}#/%{realname}-%{realver}%{?extraver}.%{srcext}
%description
The portable SDK for UPnP Devices (libupnp) provides developers with an API and
open source code for building control points, devices, and bridges that are
compliant with Version 1.0 of the Universal Plug and Play Device Architecture
Specification and support several operating systems like Linux, *BSD, Solaris
and others.
%package -n libixml%{ixml_so_ver}
Group: System/Libraries
Summary: Intel XML Library
Provides: libixml%{ixml_so_ver} = %{version}-%{release}
Provides: libixml = %{version}-%{release}
%description -n libixml%{ixml_so_ver}
A tiny C XML parsing libary included by intel in their UPnP sdk.
%package -n %{realname}-devel
Group: Development/Languages/C and C++
Summary: Development files for %{name}
Requires: %{name} = %{version}-%{release}
Provides: %{name}-devel = %{version}-%{release}
%description -n %{realname}-devel
Development files for %{name}
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-release-%{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}'
_CMAKE_ARGS=(
-DCMAKE_INSTALL_PREFIX=%{_prefix}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_C_FLAGS_RELEASE="$_CFLAGS"
-DCMAKE_CXX_FLAGS_RELEASE="$_CFLAGS"
-DCMAKE_EXE_LINKER_FLAGS_RELEASE="$_LDFLAGS"
-DCMAKE_MODULE_LINKER_FLAGS_RELEASE="$_LDFLAGS"
-DCMAKE_SHARED_LINKER_FLAGS_RELEASE="$_LDFLAGS"
-DCMAKE_VERBOSE_MAKEFILE=YES
)
mkdir tmp_build
cd tmp_build
cmake .. \
-G Ninja \
-Wno-dev \
"${_CMAKE_ARGS[@]}" \
\
-DBUILD_TESTING=NO \
-DUPNP_BUILD_STATIC=NO \
-DUPNP_ENABLE_OPEN_SSL=YES
ninja -v %{?_smp_mflags}
%install
DESTDIR=%{buildroot} ninja -v -C tmp_build install
%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
%files
%defattr(-,root,root)
%license COPYING
%doc README.md THANKS
%{_bindir}/tv_*
%{_libdir}/libupnp.so.*
%{_datadir}/upnp/
%files -n libixml%{ixml_so_ver}
%license COPYING
%doc README.md THANKS
%{_libdir}/libixml.so.*
# Development stuff
%files -n %{realname}-devel
%defattr(-,root,root)
%license COPYING
%doc README.md THANKS
%{_libdir}/pkgconfig/libupnp.pc
%{_includedir}/upnp/
%dir %{_libdir}/cmake/IXML
%dir %{_libdir}/cmake/UPNP
%dir %{_libdir}/cmake
%{_libdir}/cmake/IXML/*.cmake
%{_libdir}/cmake/UPNP/*.cmake
%{_libdir}/*.so
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%changelog