Switching to Binutils wrappers for ar, nm and ranlib are required for proper
functioning of Link-Time Optimization features. Currently full support of LTO
plugin is not ready in Binutils, so we need to use wrappers to prevent
"undefined reference" errors.
Change-Id: I7a944b6b26da1549aeb010c6d56120d7f172a020
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
%build
export CXXFLAGS="$RPM_OPT_FLAGS -fPIC -pie"
export CFLAGS="$CXXFLAGS"
+
+# Set up default CMake configuration for ranlib, ar and nm, so we can build
+# both CMake and target packages with LTO
+insertconfline() {
+ sed -e "/^' > .*InitialCacheFlags.cmake\"/i ${1}" -i bootstrap
+}
+
+insertconfline "set (CMAKE_RANLIB \"$(which %__ranlib)\" CACHE FILEPATH \"Path to ranlib tool.\" FORCE)"
+insertconfline "set (CMAKE_AR \"$(which %__ar)\" CACHE FILEPATH \"Path to ar tool.\" FORCE)"
+insertconfline "set (CMAKE_NM \"$(which %__nm)\" CACHE FILEPATH \"Path to nm tool.\" FORCE)"
+
./configure \
--prefix=%{_prefix} \
--datadir=/share/%{name} \
%__cmake %{_bindir}/cmake
%cmake \
+ AR="%__ar"; export AR ; \
+ NM="%__nm"; export NM ; \
+ RANLIB="%__ranlib"; export RANLIB ; \
CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; \