From eb301edc44e18bfbed021e1ebef092982ec1df91 Mon Sep 17 00:00:00 2001 From: phantom Date: Sat, 29 Jun 2013 18:37:57 +0200 Subject: [PATCH] Enable LTO switch for configure script and automake 1.14 fix --- .hgignore | 3 ++- configure.ac | 31 +++++++++++++++++++++++++++++++ src/Makefile.am | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/.hgignore b/.hgignore index 8350e07d42..41862eba46 100644 --- a/.hgignore +++ b/.hgignore @@ -60,7 +60,8 @@ src/libtomcrypt/Release-* src/libtommath/build-* src/libtommath/Release-* src/*.old -src/.deps +*/.deps +*/.dirstamp src/*.a src/*.so GtkModule.so diff --git a/configure.ac b/configure.ac index 2f19c2f5b5..bd19709a49 100644 --- a/configure.ac +++ b/configure.ac @@ -48,6 +48,37 @@ case $compile in ;; esac +AC_ARG_ENABLE(lto, AS_HELP_STRING([--enable-lto], [Enable LTO]), enable_lto=$enableval, enable_lto=no) +if test x$enable_lto = xyes; then + if test "$CXX" != "g++"; then + AC_MSG_ERROR([g++ compiler is needed to use lto (if you have it installed, pass CXX=g++ to ./configure)]) + fi + gxx_version="`g++ -dumpversion`" + gxx_version_major=$(echo $gxx_version | cut -d'.' -f1) + gxx_version_minor=$(echo $gxx_version | cut -d'.' -f2) + if test [ "$gxx_version_major" -lt "4" ] || test [ "$gxx_version_minor" -lt "5" ]; then + AC_MSG_ERROR([Your g++ version is too old and doesn't support lto]) + fi + CFLAGS="$CFLAGS -O0 -flto" + CXXFLAGS="$CXXFLAGS -O0 -flto" + LDFLAGS="$LDFLAGS -flto" + case $compile in + release) + LDFLAGS="$LDFLAGS -O3" + ;; + debug) + LDFLAGS="$LDFLAGS -g" + ;; + fast) + LDFLAGS="$LDFLAGS -O2 -fno-inline" + ;; + esac + if test [ "$gxx_version_minor" -ge "8" ]; then + CFLAGS="$CFLAGS -fno-fat-lto-objects" + CXXFLAGS="$CXXFLAGS -fno-fat-lto-objects" + fi +fi + # Some (broken?) versions of gcc treat char as unsigned, check for that. AC_LANG_PUSH([C]) diff --git a/src/Makefile.am b/src/Makefile.am index 11f52385fa..7c86fa913f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,3 +1,5 @@ +AUTOMAKE_OPTIONS = subdir-objects + ## Do not install stepmania in the traditional way. noinst_PROGRAMS = stepmania TESTS =