File kodi.binary-addons.spec of Package kodi.binary-addons

# spec file for package kodi
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
# 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

# Please edit kodi.spec and kodi.changes only. *-noX.* files are generated from
# kodi.* files with the script
%define kodi_version Leia
%define _kodi_addons_dir %{_datadir}/kodi/addons
%define dev_build 1
# kodi can be built without X support when openGL ES is used (mainly used on ARM boards used as media center)
%define noX_build 0
%if %{noX_build}
# no X build needs openGL ES
%bcond_with enable_opengl
%bcond_without enable_opengles
%ifarch %arm armv6l armv6hl
%bcond_with enable_opengl
%bcond_without enable_opengles
%bcond_without enable_opengl
%bcond_with enable_opengles

%define kodi_platform none
%define kodi_player none

Name:           kodi.binary-addons
Version:        18.8
Release:        0
Summary:        Binary Addons for Kodi
License:        GPL-2.0+ and GPL-3.0+
Group:          Productivity/Multimedia/Video/Players
Source3:        kodi.binary-addons.tar
Source4:        repo-binary-addons.%{kodi_version}.tar.bz2
Source5:        kodi-platform-e8574b8.tar.gz
Source21:       rapidxml.cmake
Patch1:         cmake-binary-addons.patch
Patch2:         addon-helpers_lib64.patch
# PATCH-PACKMAN kodi.binary-addons-audiodecoder.ncsf-gcc5.3.patch - fixes compiling of audiodecoder.ncsf with gcc > 4.8, suse_version >= 1320
#Patch3:         kodi.binary-addons-audiodecoder.ncsf-gcc5.3.patch
# PATCH-PACKMAN kodi.binary-addons-screensavers.rsxs-upstream-stdbool_h.patch - fixes compiling of screensavers.rsxs with gcc > 4.8, suse_version >= 1320
#Patch4:         kodi.binary-addons-screensavers.rsxs-upstream-stdbool_h.patch
#Patch5:         lib555-missing-xlocale.patch
#Patch6:         pvr.stalker-gcc7.patch
# PATCH-PACKMAN kodi.binary.addons-noreturnfromnonvoid.patch - - Suddenly an rpmlint no return from nonvoid has appeared after taglib was updated.
Patch7:         kodi.binary.addons-noreturnfromnonvoid.patch
#Patch8:         kodi.binary-addons-screensavers.rsxs-host-toolchain.patch

BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  ccache
BuildRequires:  cmake
BuildRequires:  fdupes
%if 0%{?suse_version} > 1320 && 0%{?sle_version} == 0
BuildRequires:	gcc9
BuildRequires:  gcc9-c++
BuildRequires:  gcc8
BuildRequires:  gcc8-c++
%if %{noX_build}
BuildRequires:  kodi-noX-devel = %{version}
BuildRequires:  kodi-devel = %{version}
BuildRequires:  giflib-devel
BuildRequires:  gli-devel
BuildRequires:  cmake(glm) >= 0.9.9
BuildRequires:  jsoncpp-devel
BuildRequires:	nlohmann_json-devel
BuildRequires:  tinyxml-devel
BuildRequires:  libhdhomerun-devel
BuildRequires:  liblz4-devel
BuildRequires:  libmp3lame-devel
BuildRequires:  libnfs-devel
BuildRequires:  libraw-devel
BuildRequires:  libsmbclient-devel
BuildRequires:  libSOIL-devel
BuildRequires:  libstdc++-devel
BuildRequires:  libtiff-devel
BuildRequires:  libtool
BuildRequires:  libxml2-devel
BuildRequires:  lzo-devel
BuildRequires:  nlohmann_json-devel
BuildRequires:  pkg-config
BuildRequires:  pkgconfig(flac)
BuildRequires:  pkgconfig(fluidsynth)
BuildRequires:  pkgconfig(libarchive) >= 3.3.2
BuildRequires:	pkgconfig(libjpeg)
BuildRequires:  pkgconfig(libmodplug)
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(libprojectM)
BuildRequires:  pkgconfig(librtmp)
BuildRequires:  pkgconfig(libssh)
BuildRequires:  pkgconfig(libssl)
BuildRequires:  pkgconfig(p8-platform)
BuildRequires:  pkgconfig(tinyxml2)
BuildRequires:  pkgconfig(vorbis)
BuildRequires:  rapidjson-devel

# kodi needs the same libtag version which was used to build against
%requires_eq    libtag1
%if !%{noX_build}
BuildRequires:  xorg-x11-devel
%if %{with enable_opengl}
BuildRequires:  pkgconfig(gl)
BuildRequires:  pkgconfig(glew)
BuildRequires:  pkgconfig(glu)
BuildRequires:  pkgconfig(vdpau)

%if %{with enable_opengles}
%if %{kodi_platform} == "none"
BuildRequires:  Mesa-libEGL-devel
BuildRequires:  Mesa-libGLESv2-devel
%if %{kodi_platform} == "raspberry-pi" || %{kodi_platform} == "raspberry-pi2"
BuildRequires:  raspberrypi-userland-devel

# glxinfo is needed to check hw accel
%if 0%{?suse_version} >= 1220
%if !%{noX_build}
Requires:       Mesa-demo-x
Requires:       xdpyinfo

BuildRoot:      %{_tmprath}/%{name}-%{version}-build
ExcludeArch:    ppc64
Requires:       kodi = %{version}
#Requires:       libjsoncpp1

Binary Addons for Kodi Media Center

%include %{SOURCE1}

%setup -q -n xbmc-%{version}-%{kodi_version}

pushd cmake/addons
tar xvf %{SOURCE3}
mkdir -pv build/bootstrap/binary-addons/src
cp -v %{SOURCE4} build/bootstrap/binary-addons/src

# Remove deps that are already installed using BuildRequires
rm -rf depends/common/{p8-platform,tinyxml}
rm -f  depends/common/kodi-platform/deps.txt
cp -v %{SOURCE5} depends/common/kodi-platform
echo "kodi-platform file://../../../../../cmake/addons/depends/common/kodi-platform/kodi-platform-e8574b8.tar.gz" > depends/common/kodi-platform/kodi-platform.txt
mkdir -pv depends/common/rapidxml
cp -v %{SOURCE20} depends/common/rapidxml
cp -v %{SOURCE21} depends/common/rapidxml/CMakeLists.txt
echo "rapidxml file://../../../../../cmake/addons/depends/common/rapidxml/" > depends/common/rapidxml/rapidxml.txt
echo "c3f0b886374981bb20fabcf323d755db4be6dba42064599481da64a85f5b3571" > depends/common/rapidxml/rapidxml.sha256

sed -i~ 's/@@@_libdir@@@/%{_lib}/' cmake/scripts/common/AddonHelpers.cmake
diff -u cmake/scripts/common/AddonHelpers.cmake~ cmake/scripts/common/AddonHelpers.cmake && exit 0

# Tumbleweed and Factory have GCC 5.x ATM (20160309), source needs patching for this
#%if 0%{?suse_version} > 1320
  # patch audiodecoders.ncsf
  #patch -p0 < %%{PATCH3}
  # patch screensavers.rsxs
  #patch screensavers.rsxs/lib/rsxs-1.0/lib/ %{PATCH4}
  #patch -up0 --verbose < %{PATCH5}
  #patch -up4 --verbose < %{PATCH6}

# fake buildtime in audiodecoder.qsf
FAKE_BUILDDATE=$(LC_ALL=C date -u -r %{_sourcedir}/%{name}.changes '+%%b %%e %%Y')
FAKE_BUILDTIME=$(LC_ALL=C date -u -r %{_sourcedir}/%{name}.changes '+%%H:%%M:%%S')
#for file in audiodecoder.qsf/lib/Highly_Quixotic/Core/qsound.c \
#            audiodecoder.ssf/lib/Highly_Theoretical/Core/Starscream/star.c \
#            audiodecoder.ssf/lib/Highly_Theoretical/Core/sega.c \
#            audiodecoder.timidity/lib/timidity/timidity/speex_a.c; do
#  sed -i -e "s/__DATE__/\"$FAKE_BUILDDATE\"/" -e "s/__TIME__/\"$FAKE_BUILDTIME\"/" $file
#patch -p 0 < %{PATCH7}
#make VERBOSE=1 %{?_smp_mflags}

%if 0%{?suse_version} > 1320 && 0%{?sle_version} == 0
 export CC=gcc-9
 export CXX=g++-9
 export CC=gcc-8
 export CXX=g++-8

pushd tools/depends/target/binary-addons
mkdir -p native
%cmake \
    ../../../../../cmake/addons \
%if %{dev_build}
%ifarch %{ix86}
    -DCMAKE_C_FLAGS=-mavx \
    -DBUILD_DIR=build \
    -DAPP_LIB_DIR=%{buildroot}%{_libdir}/kodi \
    -DCMAKE_INSTALL_LIBDIR=%{buildroot}%{_libdir}/kodi \
    -DCMAKE_INSTALL_PREFIX=%{buildroot}%{_prefix} \


# Patching addons after being unpacked
pushd cmake/addons
patch -up2 --verbose -i %{PATCH7}
#patch -up0 --verbose -i %{PATCH8}
patch -up2 --verbose -i %{PATCH9}

pushd tools/depends/target/binary-addons/build

# Workaround for cmake 3.18 issue with copy_if_different issue adding "" at the end of line
sed -i -e 's#""##' depends/CMakeFiles/rapidxml.dir/build.make

make -O %{?_smp_mflags} VERBOSE=1 CC=$CC CXX=$CXX

%fdupes %{buildroot}

%dir %{_libdir}/kodi
%dir %{_datadir}/kodi

%include %{SOURCE2}