File linphoneqt.spec of Package linphoneqt

#
# spec file for package linphoneqt
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define _name   linphone
Name:           linphoneqt
Version:        5.2.0
# Fedora release look standard from OpenSUSE build service:
# Release:      <CI_CNT>.<B_CNT>
# Release:      %%{?release_prefix}.<CI_CNT>.<B_CNT>
# where rpm macro %%{release_prefix} is defined in spec file
# Normally it looks like:
# Release:      63.fc38 for Fedora packages which is scripted as:
# Release:      0%%{?dist}
# OpenSUSE build service allows for this variant:
# Release:      63.1.fc38
# Release:       <CI_CNT>.<B_CNT>%%{?dist}
#
# Add this to Project Config to tag Fedora packages with fcXX:
# ------------------------------
# # reset release name
# onepercentage%%if 0onepercentage%%{?fedora_version}
# Release: <CI_CNT>.<B_CNT> spec:<CI_CNT>.<B_CNT>twopercentage%%{?dist}
# onepercentage%%endif
# ------------------------------
Release:        0
Summary:        Qt interface for Linphone
License:        GPL-3.0-or-later
Group:          Productivity/Telephony/SIP/Clients
URL:            https://linphone.org/technical-corner/linphone
Source:         https://gitlab.linphone.org/BC/public/linphone-desktop/-/archive/%{version}/%{_name}-desktop-%{version}.tar.bz2
Source1:        %{_name}.appdata.xml
# PATCH-FIX-OPENSUSE linphoneqt-fix-no-git.patch -- Fix building out-of-git.
Patch0:         linphoneqt-01-fix-no-git.patch
# PATCH-FIX-OPENSUSE https://aur.archlinux.org/cgit/aur.git/plain/0002-remove-bc_compute_full_version-usage.patch?h=linphone-desktop
Patch1:         linphoneqt-02-remove-bc_compute_full_version-usage.patch
#Patch2:         linphoneqt-03-icons.patch
%if 0%{?suse_version}
BuildRequires:  Mesa-libGLESv2-devel
%else
BuildRequires:  mesa-libGL-devel
%endif
BuildRequires:  chrpath
BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  hicolor-icon-theme
BuildRequires:  jsoncpp-devel
%if 0%{?suse_version}
BuildRequires:  libqt5-linguist-devel
%else
BuildRequires:  boost-devel
BuildRequires:  boost-json
BuildRequires:  qt5-linguist
BuildRequires:  qt5-qttools-devel
Requires:       qt5-qtquickcontrols
%endif
BuildRequires:  pkgconfig
%if 0%{?suse_version}
BuildRequires:  update-desktop-files
%endif
BuildRequires:  pkgconfig(Qt5Concurrent)
BuildRequires:  pkgconfig(Qt5Core) >= 5.12
BuildRequires:  pkgconfig(Qt5DBus)
BuildRequires:  pkgconfig(Qt5Gui)
BuildRequires:  pkgconfig(Qt5Network)
BuildRequires:  pkgconfig(Qt5Quick)
BuildRequires:  pkgconfig(Qt5QuickControls2)
BuildRequires:  pkgconfig(Qt5Svg)
BuildRequires:  pkgconfig(Qt5TextToSpeech)
BuildRequires:  pkgconfig(Qt5Widgets)
BuildRequires:  pkgconfig(Qt5Multimedia)
#OpenSUSE:
#BuildRequires:  libqt5-qtmultimedia-devel
#Fedora:
#BuildRequires:  qt5-qtmultimedia-devel
BuildRequires:  liblinphone-devel >= 5.3.1
BuildRequires:  pkgconfig(linphone) >= 5.3.0
BuildRequires:  mediastreamer2-devel >= 5.3.1
BuildRequires:  mediastreamer2-plugins >= 5.3.1
BuildRequires:  pkgconfig(mediastreamer) >= 5.3.0
BuildRequires:  pkgconfig(jsoncpp)
BuildRequires:  inkscape
BuildRequires:  ImageMagick

%description
Linphone is a Web phone with a Qt interface. It lets you make
two-party calls over IP networks such as the Internet. It uses the IETF
protocols SIP (Session Initiation Protocol) and RTP (Realtime TransporT
Protocol) to make calls, so it should be able to communicate with other
SIP-based Web phones. With several codecs available, it can be used
with high speed connections as well as 28k modems.

%package -n %{_name}
Summary:        Web Phone
Group:          Productivity/Telephony/SIP/Clients
Requires:       liblinphone-data
Requires:       qqc2-desktop-style
Recommends:     %{_name}-cli
Obsoletes:      %{_name}-lang < %{version}

%description -n %{_name}
Linphone is a Web phone with a Qt interface. It lets you make
two-party calls over IP networks such as the Internet. It uses the IETF
protocols SIP (Session Initiation Protocol) and RTP (Realtime TransporT
Protocol) to make calls, so it should be able to communicate with other
SIP-based Web phones. With several codecs available, it can be used
with high speed connections as well as 28k modems.

%package -n %{_name}-devel
Summary:        Web Phone
Group:          Productivity/Telephony/SIP/Clients
BuildArch:      noarch

%description -n %{_name}-devel
Devel package for %{_name}.

%package -n %{_name}-desktop
Summary:        Linphone graphical user interface.
Group:          Productivity/Telephony/SIP/Clients
Requires:       %{_name}
Recommends:     %{_name}-cli
Obsoletes:      %{_name}-lang < %{version}

%description -n %{_name}-desktop
Linphone-Desktop is the project name for Linphone on desktop, laptop
and notebook. Also known under names as linphone-qt and linphoneqt.
Linphone-Desktop is a web phone with a Qt interface. It lets you make
two-party calls over IP networks such as the Internet. It uses the IETF
protocols SIP (Session Initiation Protocol) and RTP (Realtime TransporT
Protocol) to make calls, so it should be able to communicate with other
SIP-based Web phones. With several codecs available, it can be used
with high speed connections as well as 28k modems. It is recommended
to manually enable the codecs GSM, G722, speex 32kHz, BV16 and iLBC
if those are not enabled automatically to gain better interoperability
with other SIP-phones in the world. It mimics how phones used to work in
year 1980, where it didn't matter which phone you had. It was still 
possible to call any other phone no matter who had manufactured the phone.

%prep
%autosetup -n %{_name}-desktop-%{version} -p1
cp %{SOURCE1} linphone.appdata.xml
touch linphone-sdk/CMakeLists.txt
%if 0%{?suse_version}
mkdir -p build/linphone-sdk/desktop/{bin,share}
%else
mkdir -p redhat-linux-build/linphone-sdk/desktop/{bin,share}
%endif

# Fix building out-of-git
echo '#define LINPHONE_QT_GIT_VERSION "${PROJECT_VERSION}"' >> linphone-app/src/config.h.cmake
# Hardcode linphoneqt version
echo "project(linphoneqt VERSION %{version})" > linphone-app/linphoneqt_version.cmake

%build
echo
which convert
which inkscape
find . -type f -name genicons_1.1.sh -exec {} \;
#find /usr/include
# Fix the include path to <json/json.h> to <jsoncpp/json/json.h> :
# MODIFY_FILE=/usr/include/linphone/FlexiAPIClient.hh; \
# sed -i 's/#include <json\/json\.h>/#include <jsoncpp\/json\/json.h>/g' $MODIFY_FILE
# MODIFY_FILE=/usr/src/packages/BUILD/src/FlexiAPIClient.cc; \
# sed -i 's/#include <json\/json\.h>/#include <jsoncpp\/json\/json.h>/g' $MODIFY_FILE
# MODIFY_FILE=/usr/src/packages/BUILD/tester/remote-provisioning-tester.cpp; \
# sed -i 's/#include <json\/json\.h>/#include <jsoncpp\/json\/json.h>/g' $MODIFY_FILE
# MODIFY_FILE=/usr/src/packages/BUILD/tester/flexiapiclient-tester.cpp; \
# sed -i 's/#include <json\/json\.h>/#include <jsoncpp\/json\/json.h>/g' $MODIFY_FILE
echo
if [[ %version = 5.2.[0-9]* ]]; then
    sed -i '/^add_custom_command/s@${CMAKE_INSTALL_PREFIX}/include/@%{buildroot}%{_includedir}/@;/^add_custom_command/s@${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/@%{buildroot}%{_libdir}/@' linphone-app/CMakeLists.txt
    sed -i '/\/ui/s@${qml_dir}@${CMAKE_CURRENT_SOURCE_DIR}/../&@' linphone-app/cmake_builder/linphone_package/CMakeLists.txt
%if 0%{?suse_version}
    mkdir -p build/linphone-sdk/desktop/share/{,sounds}/linphone
%else
    mkdir -p redhat-linux-build/linphone-sdk/desktop/share/{,sounds}/linphone
%endif
fi
#  -DCMAKE_EXE_LINKER_FLAGS="-L/usr/lib64/libjsoncpp.so -ljsoncpp" \
#  -DCMAKE_LDFLAGS="-L/usr/lib64/libjsoncpp.so -ljsoncpp $LDFLAGS" \
#  -DCMAKE_EXE_LINKER_FLAGS="-ljsoncpp" \
#

# Fix BCToolbox not found
mkdir -p /home/abuild/rpmbuild/BUILD/linphone-desktop-%{version}/build/share/BCToolbox
ln -s /usr/share/BCToolbox/cmake /home/abuild/rpmbuild/BUILD/linphone-desktop-%{version}/build/share/BCToolbox/cmake
ln -s /usr/lib64 /home/abuild/rpmbuild/BUILD/linphone-desktop-%{version}/build/lib64
# Not working to add cmake variables:
#  -Dbctoolbox_DIR=/usr/share/BCToolbox/cmake \
#  -DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH /usr/share/BCToolbox/cmake" \
#  -DCMAKE_MODULE_PATH="$CMAKE_MODULE_PATH /usr/share/BCToolbox/cmake" \
#  -DBCToolbox_CMAKE_DIR="/usr/share/BCToolbox/cmake" \

# Fix linphoneCxx
mkdir -p /home/abuild/rpmbuild/BUILD/linphone-desktop-%{version}/build/share/LinphoneCxx
ln -s /usr/share/LinphoneCxx/cmake /home/abuild/rpmbuild/BUILD/linphone-desktop-%{version}/build/share/LinphoneCxx/cmake

# Fix Mediastreamer2
mkdir -p /home/abuild/rpmbuild/BUILD/linphone-desktop-%{version}/build/share/Mediastreamer2
ln -s /usr/share/Mediastreamer2/cmake /home/abuild/rpmbuild/BUILD/linphone-desktop-%{version}/build/share/Mediastreamer2/cmake

# Fix BelCard
mkdir -p /home/abuild/rpmbuild/BUILD/linphone-desktop-%{version}/build/share/BelCard
ln -s /usr/share/BelCard/cmake /home/abuild/rpmbuild/BUILD/linphone-desktop-%{version}/build/share/BelCard/cmake


%cmake \
  -DCMAKE_CXX_FLAGS="%{optflags} -fpic -ffat-lto-objects -fpermissive -Wno-unused-but-set-variable -Wno-return-type" \
  -DCMAKE_LDFLAGS=" $LDFLAGS -ljsoncpp" \
  -DCMAKE_EXE_LINKER_FLAGS="-ljsoncpp" \
  -DCMAKE_BUILD_TYPE=Release \
  -DLINPHONE_OUTPUT_DIR="$PWD" \
  -DCMAKE_INSTALL_PREFIX=/usr \
  -DCMAKE_MODULE_PATH="${CMAKE_MODULE_PATH};/usr/src/packages/SOURCES;/usr/share/BCToolbox/cmake;/usr/share/BelCard/cmake;" \
  -DMediastreamer2_PLUGINS_DIR="/usr/lib64/mediastreamer/plugins" \
  -DBelcard_DIR="/usr/share/BelCard/cmake" \
  -DENABLE_UPDATE_CHECK=OFF \
  -DENABLE_QT_KEYCHAIN=OFF  \
  -DENABLE_STRICT=OFF       \
  -DENABLE_STATIC=OFF
%cmake_build

%install
%cmake_install
%if 0%{?fedora}
# for Fedora the internal call to cmake overwrites CMAKE_INSTALL_PREFIX, move...
mkdir -p %{buildroot}/usr
mv %{buildroot}/home/abuild/rpmbuild/BUILD/linphone-desktop*/redhat-linux-build/OUTPUT/* %{buildroot}/usr
rm -rf %{buildroot}/home
%endif
install -Dpm 0644 linphone.appdata.xml \
  %{buildroot}%{_datadir}/metainfo/org.linphone.appdata.xml

rm %{buildroot}%{_bindir}/qt.conf
chmod a-x %{buildroot}%{_datadir}/applications/linphone.desktop

chrpath -d %{buildroot}%{_bindir}/linphone %{buildroot}%{_libdir}/libapp-plugin.so

%files -n %{_name}
%license LICENSE.txt
%doc CHANGELOG.md README.md
%{_bindir}/linphone
%{_libdir}/libapp-plugin.so
%{_datadir}/linphone/
%{_datadir}/applications/linphone.desktop
%{_datadir}/icons/hicolor/*/apps/linphone.*
%dir %{_datadir}/icons/hicolor/scalable/web
%{_datadir}/icons/hicolor/*/web/linphonesystemtray.*
%dir %{_datadir}/metainfo/
%{_datadir}/metainfo/org.linphone.appdata.xml

%files -n %{_name}-devel
%{_includedir}/LinphoneApp/

%files -n %{_name}-desktop

%changelog
openSUSE Build Service is sponsored by