File telegram-qt.spec of Package telegram-qt

%define realname telegram-qt
%define srcext   tar.bz2

%define so_ver   0
%define lib_ver  0_2

# Common info
Name:          libtelegram-qt5-%{lib_ver}
Version:       0
Release:       wiz%{?extraver:0.}1%{?dist}
License:       LGPL-2.1+
Group:         Productivity/Networking/Instant Messenger
URL:           https://github.com/Kaffeine/telegram-qt
Summary:       Telegram binding for Qt

# Install-time parameters
Provides:      libTelegramQt5-%{lib_ver} = %{version}-%{release}
Provides:      libTelegramQt5Qml-%{lib_ver} = %{version}-%{release}

# Build-time parameters
BuildRequires: cmake >= 3.1
BuildRequires: gcc-c++
BuildRequires: pkgconfig(Qt5Core) >= 5.5.0 pkgconfig(Qt5Network) >= 5.5.0
BuildRequires: pkgconfig(Qt5Qml) >= 5.5.0
BuildRequires: openssl-devel
BuildRequires: zlib-devel
BuildRoot:     %{_tmppath}/%{name}-root
Source:        %{realname}-%{version}.%{srcext}

%description
Qt-based library for Telegram network

%package -n telegram-qt5-devel
Group:         Development/Languages/C and C++
Summary:       Telegram binding for Qt development files
Requires:      %{name} = %{version}-%{release}
Provides:      %{name}-devel %{realname}-devel
Provides:      libtelegram-qt5-devel

%description -n telegram-qt5-devel
Development stuff to build software using Telegram binding for Qt.

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

# Build step (compile/build binaries, documentation, etc)
%build
mkdir build
cd build
cmake .. \
 -DCMAKE_INSTALL_PREFIX=%{_prefix} \
 -DCMAKE_INSTALL_LIBDIR=%{_libdir} \
 -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_CXX_FLAGS_RELEASE="%{optflags} %{?gcc_lto}" \
 -DCMAKE_C_FLAGS_RELEASE="%{optflags} %{?gcc_lto}" \
 -DCMAKE_EXE_LINKER_FLAGS_RELEASE="-Wl,--as-needed -Wl,--strip-all %{?gcc_lto}" \
 -DCMAKE_MODULE_LINKER_FLAGS_RELEASE="-Wl,--as-needed -Wl,--strip-all %{?gcc_lto}" \
 -DCMAKE_SHARED_LINKER_FLAGS_RELEASE="-Wl,--as-needed -Wl,--strip-all %{?gcc_lto} -shared" \
 -DCMAKE_VERBOSE_MAKEFILE=YES
%{__make} %{?_smp_mflags}

# Install built stuff
%install
%{__make} -C build install DESTDIR=%{buildroot}

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

# Files list
%files
%defattr(-,root,root)
%doc LICENSE.LGPL README.md
%{_libdir}/libTelegramQt5.so.%{so_ver}*
%{_libdir}/libTelegramQt5Qml.so.%{so_ver}*
%dir %{_libdir}/qt5/qml/TelegramQt
%dir %{_libdir}/qt5/qml
%{_libdir}/qt5/qml/TelegramQt/*

%files -n telegram-qt5-devel
%defattr(-,root,root)
%doc LICENSE.LGPL README.md
%dir %{_includedir}/TelegramQt5/TelegramQt
%dir %{_includedir}/TelegramQt5
%{_includedir}/TelegramQt5/TelegramQt/*
%{_libdir}/pkgconfig/TelegramQt5.pc
%dir %{_libdir}/cmake/TelegramQt5
%dir %{_libdir}/cmake
%{_libdir}/cmake/TelegramQt5/TelegramQt5Config*.cmake
%{_libdir}/libTelegramQt5.so
%{_libdir}/libTelegramQt5Qml.so

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

%changelog