--- /dev/null
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 4417de6..70dbba3 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -4,10 +4,9 @@ project (kadu)
+ set (QT_MIN_VERSION "4.7.0")
+ set (CMAKE_MIN_VERSION "2.6.0")
+ set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+-option (BUILD_PLUGINS "Switch to Off if you do not want to build plugins" ON)
+
+ # configuration
+-option (INSTALL_CMAKE_MODULE "Install cmake modules" ON)
++option (BUILD_PLUGINS "Switch to Off if you do not want to build plugins" ON)
+ if (UNIX)
+ option (SIG_HANDLING_ENABLED "Define if you want system signals handling" ON)
+ if (UNIX AND NOT APPLE)
+@@ -106,14 +105,15 @@ else (APPLE)
+ endif (APPLE)
+ endmacro (kadu_source_subdirectories)
+
++set (KADU_INSTALLS_SDK TRUE)
+ include (cmake/FindKadu.cmake)
+ include_directories (${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/kadu-core ${QT_INCLUDES})
+
+-if (INSTALL_CMAKE_MODULE)
++if (INSTALL_SDK)
+ install (FILES cmake/FindKadu.cmake DESTINATION ${KADU_CMAKE_MODULES_DIR})
+ install (PROGRAMS translations/plugintsupdate.sh DESTINATION ${KADU_PLUGINS_DIR}/sdk)
+ install (FILES translations/configuration-ui.xsl DESTINATION ${KADU_PLUGINS_DIR}/sdk)
+-endif (INSTALL_CMAKE_MODULE)
++endif (INSTALL_SDK)
+
+ # build
+ configure_file (${CMAKE_SOURCE_DIR}/kadu-config.h.cmake ${CMAKE_BINARY_DIR}/kadu-config.h)
+diff --git a/Plugins.cmake b/Plugins.cmake
+index ad63f20..524c164 100644
+--- a/Plugins.cmake
++++ b/Plugins.cmake
+@@ -1,4 +1,4 @@
+-set (COMPILE_PLUGINS
++set (DEFAULT_PLUGINS
+
+ # protocols
+ # GaduGadu protocol suppot
+@@ -100,7 +100,7 @@ set (COMPILE_PLUGINS
+ # Platform-speficic plugins
+
+ if (UNIX)
+- list (APPEND COMPILE_PLUGINS
++ list (APPEND DEFAULT_PLUGINS
+
+ # mediaplayer
+ # MPD mediaplayer support
+@@ -111,7 +111,7 @@ if (UNIX)
+ endif (UNIX)
+
+ if (UNIX AND NOT APPLE)
+- list (APPEND COMPILE_PLUGINS
++ list (APPEND DEFAULT_PLUGINS
+
+ # notifiers
+ # Freedesktop notification support
+@@ -130,7 +130,7 @@ if (UNIX AND NOT APPLE)
+ endif (UNIX AND NOT APPLE)
+
+ if (APPLE)
+- list (APPEND COMPILE_PLUGINS
++ list (APPEND DEFAULT_PLUGINS
+
+ # notifiers
+ # Growl notification support
+@@ -143,7 +143,7 @@ if (APPLE)
+ endif (APPLE)
+
+ if (WIN32)
+- list (APPEND COMPILE_PLUGINS
++ list (APPEND DEFAULT_PLUGINS
+
+ # mediaplayer
+ # Winamp Media Player support
+@@ -152,4 +152,35 @@ if (WIN32)
+ endif (WIN32)
+
+ # Sort the list so plugins will be built in alphabetical order
+-list (SORT COMPILE_PLUGINS)
++list (SORT DEFAULT_PLUGINS)
++
++# We must remember that the defaults may change and we want all Git users who didn't set
++# COMPILE_PLUGINS by hand to always have current defaults.
++# So if it is the very first run (and the user didn't manually specify COMPILE_PLUGINS)
++# or last time default plugins were compiled and the user didn't change COMPILE_PLUGINS manually,
++# pick the default plugins.
++if ((NOT COMPILE_PLUGINS) OR (HAVE_DEFAULT_PLUGINS AND ("${OLD_COMPILE_PLUGINS}" STREQUAL "${COMPILE_PLUGINS}")))
++ set (COMPILE_PLUGINS ${DEFAULT_PLUGINS})
++ set (HAVE_DEFAULT_PLUGINS "TRUE" CACHE INTERNAL "" FORCE)
++else ((NOT COMPILE_PLUGINS) OR (HAVE_DEFAULT_PLUGINS AND ("${OLD_COMPILE_PLUGINS}" STREQUAL "${COMPILE_PLUGINS}")))
++ # Replace whitespace and commas with semicolons
++ string (REGEX REPLACE "[ \t\n\r,]" ";" COMPILE_PLUGINS "${COMPILE_PLUGINS}")
++ # Convert to list
++ set (COMPILE_PLUGINS ${COMPILE_PLUGINS})
++
++ # Remove empty entries
++ list (REMOVE_ITEM COMPILE_PLUGINS "")
++
++ # Sort the list locally so we can compare with the default
++ set (_compile_plugins ${COMPILE_PLUGINS})
++ list (SORT _compile_plugins)
++
++ if ("${_compile_plugins}" STREQUAL "${DEFAULT_PLUGINS}")
++ set (HAVE_DEFAULT_PLUGINS "TRUE" CACHE INTERNAL "" FORCE)
++ else ("${_compile_plugins}" STREQUAL "${DEFAULT_PLUGINS}")
++ set (HAVE_DEFAULT_PLUGINS "FALSE" CACHE INTERNAL "" FORCE)
++ endif ("${_compile_plugins}" STREQUAL "${DEFAULT_PLUGINS}")
++endif ((NOT COMPILE_PLUGINS) OR (HAVE_DEFAULT_PLUGINS AND ("${OLD_COMPILE_PLUGINS}" STREQUAL "${COMPILE_PLUGINS}")))
++
++set (COMPILE_PLUGINS "${COMPILE_PLUGINS}" CACHE STRING "Plugins to compile" FORCE)
++set (OLD_COMPILE_PLUGINS "${COMPILE_PLUGINS}" CACHE INTERNAL "" FORCE)
+diff --git a/cmake/FindKadu.cmake b/cmake/FindKadu.cmake
+index dfa54e2..94f9c7c 100644
+--- a/cmake/FindKadu.cmake
++++ b/cmake/FindKadu.cmake
+@@ -62,6 +62,9 @@ if (CMAKE_COMPILER_IS_GNUCXX)
+ endif (CMAKE_COMPILER_IS_GNUCXX)
+
+ option (ENABLE_DEVELOPER_BUILD "Turn on some features helpful during development process (has nothing to do with debugging symbols)" OFF)
++if (KADU_INSTALLS_SDK)
++ option (INSTALL_SDK "Install SDK (API headers, cmake modules)" ON)
++endif (KADU_INSTALLS_SDK)
+
+ if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR ENABLE_DEVELOPER_BUILD OR WIN32)
+ set (DEBUG_ENABLED 1)
+@@ -133,10 +136,16 @@ endif (WIN32)
+ set (KADU_PLUGINS_DIR ${KADU_DATA_DIR}/plugins)
+
+ macro (kadu_api_directories INCLUDE_DIR)
+- foreach (ARG ${ARGN})
+- file (GLOB API_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/${ARG}/*.h)
+- install (FILES ${API_HEADERS} DESTINATION ${KADU_INSTALL_INCLUDE_DIR}/kadu/${INCLUDE_DIR}/${ARG})
+- endforeach (ARG)
++ if (NOT KADU_INSTALLS_SDK)
++ message (FATAL_ERROR "kadu_api_directories called but KADU_INSTALLS_SDK is not set")
++ endif (NOT KADU_INSTALLS_SDK)
++
++ if (INSTALL_SDK)
++ foreach (ARG ${ARGN})
++ file (GLOB API_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/${ARG}/*.h)
++ install (FILES ${API_HEADERS} DESTINATION ${KADU_INSTALL_INCLUDE_DIR}/kadu/${INCLUDE_DIR}/${ARG})
++ endforeach (ARG)
++ endif (INSTALL_SDK)
+ endmacro (kadu_api_directories)
+
+ macro (kadu_configuration)
+diff --git a/plugins/docking/CMakeLists.txt b/plugins/docking/CMakeLists.txt
+index 9fadbc2..d2509bf 100644
+--- a/plugins/docking/CMakeLists.txt
++++ b/plugins/docking/CMakeLists.txt
+@@ -6,6 +6,7 @@ set (QT_MIN_VERSION "4.7.0")
+ set (CMAKE_MIN_VERSION "2.6.0")
+
+ set (KADU_FIND_REQUIRED true)
++set (KADU_INSTALLS_SDK TRUE)
+ include (FindKadu)
+
+ kadu_api_directories (plugins/docking
+diff --git a/plugins/encryption_ng/CMakeLists.txt b/plugins/encryption_ng/CMakeLists.txt
+index 2de13e9..ebf62fd 100644
+--- a/plugins/encryption_ng/CMakeLists.txt
++++ b/plugins/encryption_ng/CMakeLists.txt
+@@ -6,6 +6,7 @@ set (QT_MIN_VERSION "4.7.0")
+ set (CMAKE_MIN_VERSION "2.6.0")
+
+ set (KADU_FIND_REQUIRED true)
++set (KADU_INSTALLS_SDK TRUE)
+ include (FindKadu)
+
+ include (FindPkgConfig)
+diff --git a/plugins/gadu_protocol/CMakeLists.txt b/plugins/gadu_protocol/CMakeLists.txt
+index f9d2c03..c9fd708 100644
+--- a/plugins/gadu_protocol/CMakeLists.txt
++++ b/plugins/gadu_protocol/CMakeLists.txt
+@@ -13,6 +13,7 @@ set (QT_USE_QTSCRIPT 1)
+ set (QT_USE_QTSCRIPTTOOLS 1)
+
+ set (KADU_FIND_REQUIRED true)
++set (KADU_INSTALLS_SDK TRUE)
+ include (FindKadu)
+
+ include (FindPkgConfig)
+diff --git a/plugins/history/CMakeLists.txt b/plugins/history/CMakeLists.txt
+index 81f962f..9b97f3c 100644
+--- a/plugins/history/CMakeLists.txt
++++ b/plugins/history/CMakeLists.txt
+@@ -6,6 +6,7 @@ set (QT_MIN_VERSION "4.7.0")
+ set (CMAKE_MIN_VERSION "2.8.0")
+
+ set (KADU_FIND_REQUIRED true)
++set (KADU_INSTALLS_SDK TRUE)
+ include (FindKadu)
+
+ kadu_api_directories (plugins/history
+diff --git a/plugins/history_migration/CMakeLists.txt b/plugins/history_migration/CMakeLists.txt
+index 111f6ba..e99a868 100644
+--- a/plugins/history_migration/CMakeLists.txt
++++ b/plugins/history_migration/CMakeLists.txt
+@@ -6,6 +6,7 @@ set (QT_MIN_VERSION "4.7.0")
+ set (CMAKE_MIN_VERSION "2.8.0")
+
+ set (KADU_FIND_REQUIRED true)
++set (KADU_INSTALLS_SDK TRUE)
+ include (FindKadu)
+
+ kadu_api_directories (plugins/history_migration
+diff --git a/plugins/idle/CMakeLists.txt b/plugins/idle/CMakeLists.txt
+index 25b8fad..4d6cdaf 100644
+--- a/plugins/idle/CMakeLists.txt
++++ b/plugins/idle/CMakeLists.txt
+@@ -6,6 +6,7 @@ set (QT_MIN_VERSION "4.7.0")
+ set (CMAKE_MIN_VERSION "2.6.0")
+
+ set (KADU_FIND_REQUIRED true)
++set (KADU_INSTALLS_SDK TRUE)
+ include (FindKadu)
+
+ kadu_api_directories (plugins/idle
+diff --git a/plugins/jabber_protocol/CMakeLists.txt b/plugins/jabber_protocol/CMakeLists.txt
+index 3f581c9..a2b6104 100644
+--- a/plugins/jabber_protocol/CMakeLists.txt
++++ b/plugins/jabber_protocol/CMakeLists.txt
+@@ -6,6 +6,7 @@ set (QT_MIN_VERSION "4.7.0")
+ set (CMAKE_MIN_VERSION "2.8.0")
+
+ set (KADU_FIND_REQUIRED true)
++set (KADU_INSTALLS_SDK TRUE)
+ include (FindKadu)
+
+ include (FindPkgConfig)
+diff --git a/plugins/mediaplayer/CMakeLists.txt b/plugins/mediaplayer/CMakeLists.txt
+index e1f0290..6aedb06 100644
+--- a/plugins/mediaplayer/CMakeLists.txt
++++ b/plugins/mediaplayer/CMakeLists.txt
+@@ -6,6 +6,7 @@ set (QT_MIN_VERSION "4.7.0")
+ set (CMAKE_MIN_VERSION "2.6.0")
+
+ set (KADU_FIND_REQUIRED true)
++set (KADU_INSTALLS_SDK TRUE)
+ include (FindKadu)
+
+ kadu_api_directories (plugins/mediaplayer
+diff --git a/plugins/qt4_docking/CMakeLists.txt b/plugins/qt4_docking/CMakeLists.txt
+index ae786f3..8cff0cf 100644
+--- a/plugins/qt4_docking/CMakeLists.txt
++++ b/plugins/qt4_docking/CMakeLists.txt
+@@ -6,6 +6,7 @@ set (QT_MIN_VERSION "4.7.0")
+ set (CMAKE_MIN_VERSION "2.6.0")
+
+ set (KADU_FIND_REQUIRED true)
++set (KADU_INSTALLS_SDK TRUE)
+ include (FindKadu)
+
+ kadu_api_directories (plugins/qt4_docking
+diff --git a/plugins/sound/CMakeLists.txt b/plugins/sound/CMakeLists.txt
+index 2e37302..f60c38a 100644
+--- a/plugins/sound/CMakeLists.txt
++++ b/plugins/sound/CMakeLists.txt
+@@ -6,6 +6,7 @@ set (QT_MIN_VERSION "4.7.0")
+ set (CMAKE_MIN_VERSION "2.8.0")
+
+ set (KADU_FIND_REQUIRED true)
++set (KADU_INSTALLS_SDK TRUE)
+ include (FindKadu)
+
+ include (FindPkgConfig)
--- /dev/null
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-im/kadu/kadu-0.10.1.ebuild,v 1.1 2011/10/19 19:06:30 reavertm Exp $
+
+EAPI="4"
+
+inherit base cmake-utils flag-o-matic
+
+MY_P="${P/_/-}"
+
+DESCRIPTION="An open source Gadu-Gadu and Jabber/XMPP protocol Instant Messenger client."
+HOMEPAGE="http://www.kadu.net"
+SRC_URI="http://download.kadu.im/stable/${MY_P}.tar.bz2"
+
+LICENSE="GPL-2"
+KEYWORDS="~amd64 ~ppc ~x86"
+SLOT="0"
+IUSE="+gadu mpd phonon sdk speech spell xmpp"
+REQUIRED_USE="
+ || (
+ gadu
+ xmpp
+ )
+"
+COMMON_DEPEND="
+ >=app-crypt/qca-2.0.0-r2
+ >=media-libs/libsndfile-1.0
+ >=net-libs/libgadu-1.11.0[threads]
+ x11-libs/libXfixes
+ x11-libs/libXScrnSaver
+ >=x11-libs/qt-dbus-4.7.0:4
+ >=x11-libs/qt-gui-4.7.0:4
+ >=x11-libs/qt-script-4.7.0:4
+ >=x11-libs/qt-sql-4.7.0:4[sqlite]
+ >=x11-libs/qt-svg-4.7.0:4
+ >=x11-libs/qt-webkit-4.7.0:4
+ gadu? ( >=x11-libs/qt-xmlpatterns-4.7.0:4 )
+ mpd? ( media-libs/libmpdclient )
+ phonon? (
+ || (
+ media-libs/phonon
+ >=x11-libs/qt-phonon-4.7.0:4
+ )
+ )
+ spell? ( app-text/enchant )
+ xmpp? (
+ net-dns/libidn
+ sys-libs/zlib
+ )
+"
+DEPEND="${COMMON_DEPEND}
+ x11-proto/fixesproto
+ x11-proto/scrnsaverproto
+"
+RDEPEND="${COMMON_DEPEND}
+ app-crypt/qca-ossl:2
+ speech? ( app-accessibility/powiedz )
+"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-0.10.1-buildsystem-improvements.patch"
+)
+
+PLUGINS='amarok1_mediaplayer antistring auto_hide autoaway autoresponder autostatus cenzor chat_notify config_wizard desktop_docking docking encryption_ng encryption_ng_simlite exec_notify ext_sound falf_mediaplayer filedesc firewall freedesktop_notify hints history idle imagelink last_seen mediaplayer mprisplayer_mediaplayer pcspeaker qt4_docking qt4_docking_notify screenshot simpleview single_window sms sound sql_history tabs word_fix'
+
+src_configure() {
+ # Filter out dangerous flags
+ filter-flags -fno-rtti
+ strip-unsupported-flags
+
+ # Ensure -DQT_NO_DEBUG is added
+ append-cppflags -DQT_NO_DEBUG
+
+ # Plugin selection
+ if use gadu; then
+ PLUGINS+=' gadu_protocol history_migration profiles_import'
+ fi
+
+ use mpd && PLUGINS+=' mpd_mediaplayer'
+ use xmpp && PLUGINS+=' jabber_protocol'
+ use phonon && PLUGINS+=' phonon_sound'
+ use speech && PLUGINS+=' speech'
+ use spell && PLUGINS+=' spellchecker'
+
+ # Configure package
+ local mycmakeargs=(
+ -DBUILD_DESCRIPTION='Gentoo Linux'
+ -DCOMPILE_PLUGINS="${PLUGINS}"
+ $(cmake-utils_use sdk INSTALL_SDK)
+ $(cmake-utils_use_with spell ENCHANT)
+ )
+ unset PLUGINS
+
+ cmake-utils_src_configure
+}