# Pre-defined build scripts.
build
+ configure = [ -x "%{CONFIGURE_SCRIPT}" ] && ./%{CONFIGURE_SCRIPT} %{configure_options}
+
# These variables are used if you have to add some targets
# directly to the make command.
make_build_targets =
end
def build
- if [ -e "%{CONFIGURE_SCRIPT}" ]; then
- ./%{CONFIGURE_SCRIPT} \
- %{configure_options}
+ # Run configure
+ %{configure}
- %{MACRO_FIX_LIBTOOL}
- fi
+ # Remove any RPATH stuff from locally installed libtool
+ %{MACRO_FIX_LIBTOOL}
# Run custom commands.
%{configure_cmds}
build
# Export CFLAGS
- export CFLAGS = # empty
+ export CFLAGS =
# Export CXXFLAGS
export CXXFLAGS = %{CFLAGS}
# Export LDFLAGS
- export LDFLAGS = -Wl,--as-needed -Wl,-z,relro -Wl,-z,now
+ export LDFLAGS =
# Enable optimisation and compile in debugging information
CFLAGS = -O2 -g
LTO_CFLAGS = -flto=auto -ffat-lto-objects
CFLAGS += %{LTO_CFLAGS}
+ # Optimise linked binaries https://lwn.net/Articles/192624/
+ LDFLAGS += -Wl,-O1
+
+ # Only link what we actually need
+ LDFLAGS += -Wl,--as-needed
+
+ # Create an ELF "PT_GNU_RELRO" segment header in the object
+ LDFLAGS += -Wl,-z,relro
+
+ # When generating an executable or shared library, mark it to tell the
+ # dynamic linker to resolve all symbols when the program is started,
+ # or when the shared library is linked to using dlopen, instead of
+ # deferring function call resolution to the point when the function is
+ # first called.
+ LDFLAGS += -Wl,-z,now
+
# Export default compilers
export CC = gcc
export CXX = g++
-DCMAKE_INSTALL_DATAROOTDIR:PATH=%{datadir} \
%{__cmake_lib_suffix} \
-DBUILD_SHARED_LIBS:BOOL=ON \
+ -DBUILD_STATIC_LIBS:BOOL=OFF \
\
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_C_FLAGS_RELWITHDEBINFO="%{CFLAGS}" \