###############################################################################
 comment "Legacy options removed in 2016.05"
 
+config BR2_PACKAGE_KODI_RSXS
+       bool "rsxs support in Kodi was moved to an addon"
+       select BR2_LEGACY
+       select BR2_PACKAGE_KODI_SCREENSAVER_RSXS
+       help
+         rsxs support in Kodi was moved to an addon
+
 config BR2_PACKAGE_KODI_GOOM
        bool "Goom support in Kodi was moved to an addon"
        select BR2_LEGACY
 
--- /dev/null
+Fix cross-compilation
+
+Use the cross-compiler and not the host version.
+
+Patch sent upstream:
+https://github.com/notspiff/screensavers.rsxs/pull/5
+
+Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
+
+diff -uNr screensavers.rsxs-195e0ec3fbbcb2ee2012cd560e42d05167f0f259.org/CMakeLists.txt screensavers.rsxs-195e0ec3fbbcb2ee2012cd560e42d05167f0f259/CMakeLists.txt
+--- screensavers.rsxs-195e0ec3fbbcb2ee2012cd560e42d05167f0f259.org/CMakeLists.txt      2015-03-19 12:20:23.000000000 +0100
++++ screensavers.rsxs-195e0ec3fbbcb2ee2012cd560e42d05167f0f259/CMakeLists.txt  2015-07-19 20:26:16.660481032 +0200
+@@ -33,6 +33,11 @@
+                     ${PROJECT_SOURCE_DIR}/${rsxs_dir}/src/skyrocket
+                     ${PROJECT_SOURCE_DIR}/${rsxs_dir}/src/solarwinds)
+                         
++
++get_filename_component( COMPILER_FILENAME "${CMAKE_C_COMPILER}" NAME )
++string( REGEX REPLACE "-[^-]+$" ""
++        TOOLCHAIN_NAME "${COMPILER_FILENAME}" )
++
+ include(ExternalProject)
+ set(update_command "")
+ if(BOOTSTRAP_IN_TREE OR NOT DEFINED BOOTSTRAP_IN_TREE)
+@@ -46,8 +51,11 @@
+   endif()
+ endif()
+ externalproject_add(rsxs SOURCE_DIR ${PROJECT_SOURCE_DIR}/${rsxs_dir}
+-                    CONFIGURE_COMMAND ${configure_start}
++                    CONFIGURE_COMMAND gl_cv_func_gettimeofday_clobber=no
++                                      ac_cv_func_malloc_0_nonnull=yes
++                                      ${configure_start}
+                                       --prefix=<INSTALL_DIR>
++                                      --host=${TOOLCHAIN_NAME}
+                                       --without-xscreensaver
+                                       --disable-cyclone
+                                       --disable-euphoria
 
--- /dev/null
+config BR2_PACKAGE_KODI_SCREENSAVER_RSXS
+       bool "kodi-screensaver-rsxs"
+       depends on BR2_PACKAGE_KODI_GL # libglu
+       help
+         RSXS screensaver add-ons for Kodi
+
+         https://github.com/notspiff/screensavers.rsxs
+
+comment "kodi-screensaver-rsxs needs an OpenGL backend"
+       depends on !BR2_PACKAGE_KODI_GL
 
--- /dev/null
+# Locally computed
+sha256 0797ffb720056ea2e04ac8b7ee4fc2dca1e42611ef138b347e928d8d7f3c696f kodi-screensaver-rsxs-195e0ec3fbbcb2ee2012cd560e42d05167f0f259.tar.gz
 
--- /dev/null
+################################################################################
+#
+# kodi-screensaver-rsxs
+#
+################################################################################
+
+KODI_SCREENSAVER_RSXS_VERSION = 195e0ec3fbbcb2ee2012cd560e42d05167f0f259
+KODI_SCREENSAVER_RSXS_SITE = $(call github,notspiff,screensavers.rsxs,$(KODI_SCREENSAVER_RSXS_VERSION))
+KODI_SCREENSAVER_RSXS_LICENSE = GPLv3
+KODI_SCREENSAVER_RSXS_LICENSE_FILES = lib/rsxs-1.0/COPYING
+
+KODI_SCREENSAVER_RSXS_DEPENDENCIES = kodi
+
+$(eval $(cmake-package))
 
        select BR2_PACKAGE_TIFF
        select BR2_PACKAGE_TINYXML
        select BR2_PACKAGE_LIBDRM if BR2_PACKAGE_KODI_GL
-       select BR2_PACKAGE_XLIB_LIBXMU if BR2_PACKAGE_KODI_GL # needed by rsxs screensaver
        select BR2_PACKAGE_XLIB_LIBXRANDR if BR2_PACKAGE_KODI_GL
-       select BR2_PACKAGE_XLIB_LIBXT if BR2_PACKAGE_KODI_GL # needed by rsxs screensaver
        select BR2_PACKAGE_YAJL
        select BR2_PACKAGE_ZLIB
        select BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_COPY if BR2_TOOLCHAIN_USES_GLIBC # runtime UTF conversion support
 comment "libbluray support needs a toolchain w/ dynamic library"
        depends on BR2_STATIC_LIBS
 
-config BR2_PACKAGE_KODI_RSXS
-       bool "rsxs screensaver"
-       depends on BR2_PACKAGE_KODI_GL
-       help
-         Enable goom screensaver
-
-comment "rsxs needs an OpenGL backend"
-       depends on !BR2_PACKAGE_KODI_GL
-
 config BR2_PACKAGE_KODI_LIBCEC
        bool "hdmi cec"
        depends on !BR2_STATIC_LIBS # libcec
        source "package/kodi-screensaver-greynetic/Config.in"
        source "package/kodi-screensaver-pingpong/Config.in"
        source "package/kodi-screensaver-pyro/Config.in"
+       source "package/kodi-screensaver-rsxs/Config.in"
        source "package/kodi-screensaver-stars/Config.in"
 endmenu
 
 
        --disable-openmax \
        --disable-projectm \
        --disable-pulse \
+       --disable-rsxs \
        --disable-vdpau \
        --disable-vtbdecoder \
        --enable-optimizations
 KODI_DEPENDENCIES += libglew libglu libgl xlib_libX11 xlib_libXext \
        xlib_libXmu xlib_libXrandr xlib_libXt libdrm
 KODI_CONF_OPTS += --enable-gl --enable-x11 --disable-gles
-ifeq ($(BR2_PACKAGE_KODI_RSXS),y)
-# fix rsxs compile
-# gcc5: http://trac.kodi.tv/ticket/16006#comment:6
-# make sure target libpng-config is used, options taken from rsxs-0.9/acinclude.m4
-KODI_CONF_ENV += \
-       ac_cv_type__Bool=yes \
-       jm_cv_func_gettimeofday_clobber=no \
-       mac_cv_pkg_png=$(STAGING_DIR)/usr/bin/libpng-config \
-       mac_cv_pkg_cppflags="`$(STAGING_DIR)/usr/bin/libpng-config --I_opts --cppflags`" \
-       mac_cv_pkg_cxxflags="`$(STAGING_DIR)/usr/bin/libpng-config --ccopts`" \
-       mac_cv_pkg_ldflags="`$(STAGING_DIR)/usr/bin/libpng-config --L_opts --R_opts`" \
-       mac_cv_pkg_libs="`$(STAGING_DIR)/usr/bin/libpng-config --libs`"
-KODI_CONF_OPTS += --enable-rsxs
 else
-KODI_CONF_OPTS += --disable-rsxs
-endif
-else
-KODI_CONF_OPTS += --disable-gl --disable-rsxs --disable-x11
+KODI_CONF_OPTS += --disable-gl --disable-x11
 ifeq ($(BR2_PACKAGE_KODI_EGL_GLES),y)
 KODI_DEPENDENCIES += libegl libgles
 KODI_CONF_ENV += CXXFLAGS="$(TARGET_CXXFLAGS) `$(PKG_CONFIG_HOST_BINARY) --cflags --libs egl`"
 KODI_PRE_CONFIGURE_HOOKS += KODI_BOOTSTRAP
 
 define KODI_CLEAN_UNUSED_ADDONS
-       rm -Rf $(TARGET_DIR)/usr/share/kodi/addons/screensaver.rsxs.plasma
        rm -Rf $(TARGET_DIR)/usr/share/kodi/addons/visualization.milkdrop
        rm -Rf $(TARGET_DIR)/usr/share/kodi/addons/visualization.projectm
        rm -Rf $(TARGET_DIR)/usr/share/kodi/addons/visualization.itunes