File libuv.spec of Package libuv

%define realname libuv
%define realver  1.33.1
%define srcext   tar.gz

%define so_ver   1

# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}

# Common info
Name:          %{realname}%{?so_ver}
%if 0%{?rhel}
Epoch:         1
%endif
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       MIT
Group:         System/Libraries
URL:           http://libuv.org/
Summary:       Cross-platform asynchronous I/O

# Install-time parameters
Provides:      %{realname} = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes:     %{realname} < %{?epoch:%{epoch}:}%{version}-%{release}

# Build-time parameters
BuildRequires: cmake >= 3.4
BuildRequires: pkgconfig
BuildRoot:     %{_tmppath}/%{name}-root
Source:        http://dist.libuv.org/dist/v%{realver}/%{realname}-v%{realver}%{?extraver}.%{srcext}

%description
libuv is a multi-platform support library with a focus on asynchronous I/O.
It was primarily developed for use by Node.js, but it's also used by Luvit,
Julia, pyuv, and others.

Feature highlights:

  * Full-featured event loop backed by epoll, kqueue, IOCP, event ports.
  * Asynchronous TCP and UDP sockets
  * Asynchronous DNS resolution
  * Asynchronous file and file system operations
  * File system events
  * ANSI escape code controlled TTY
  * IPC with socket sharing, using Unix domain sockets or named pipes (Windows)
  * Child processes
  * Thread pool
  * Signal handling
  * High resolution clock
  * Threading and synchronization primitives

%package -n %{realname}-devel
Group:         Development/Languages/C and C++
Summary:       Development files for %{name}
Requires:      %{name} = %{?epoch:%{epoch}:}%{version}-%{release}
Provides:      %{name}-devel = %{?epoch:%{epoch}:}%{version}-%{release}

%description -n %{realname}-devel
Development files for %{name}

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-v%{version}%{?extraver}

%build
_CFLAGS='%{optflags} %{?gcc_lto}'
_CXXFLAGS='%{optflags} %{?gcc_lto} %{?cxx11abi}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all %{?gcc_lto}'
mkdir build
cd build
cmake .. \
 -DCMAKE_INSTALL_PREFIX=%{_prefix} \
 -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_C_FLAGS_RELEASE="$_CFLAGS" \
 -DCMAKE_CXX_FLAGS_RELEASE="$_CXXFLAGS" \
 -DCMAKE_EXE_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
 -DCMAKE_SHARED_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
 -DCMAKE_VERBOSE_MAKEFILE=ON \
 \
 -DBUILD_TESTING=OFF \
 -DLIBUV_BUILD_TESTS=OFF
%{__make} %{?_smp_mflags}
cd -

%install
%{__make} install DESTDIR=%{buildroot} -C build
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}%{_datadir}/doc/libuv/LICENSE

%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%doc AUTHORS LICENSE MAINTAINERS.md README.md SUPPORTED_PLATFORMS.md
%{_libdir}/%{realname}.so.%{?so_ver}*

# Development stuff
%files -n %{realname}-devel
%defattr(-,root,root)
%doc AUTHORS CONTRIBUTING.md LICENSE README.md
%{_libdir}/pkgconfig/%{realname}.pc
%{_includedir}/uv.h
%{_includedir}/uv/*.h
%{_libdir}/%{realname}.so
%exclude %{_libdir}/*.a

%post   -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%changelog