From 84c402d247765dbd754a9255878d162e868d1201 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 1 Jul 2010 15:12:18 +0100 Subject: Add support for compiler and linker optimizations, and compiler coverage --- .gitignore | 3 +++ Makefile.am | 2 ++ configure.ac | 4 +++ m4/Makefile.am | 2 ++ m4/compiler.m4 | 67 +++++++++++++++++++++++++++++++++++++++++++++++ m4/linker.m4 | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/lcov.am | 24 +++++++++++++++++ 7 files changed, 185 insertions(+) create mode 100644 m4/compiler.m4 create mode 100644 m4/linker.m4 create mode 100644 tools/lcov.am diff --git a/.gitignore b/.gitignore index e218c68..1ee1784 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,8 @@ data/org.freedesktop.Telepathy.ConnectionManager.haze.service depcomp /extensions/extensions.html install-sh +/lcov.html/ +/lcov.info libtool ltmain.sh m4/ @@ -34,4 +36,5 @@ tags *.swp *~ *.pyc +*.gc?? autom4te.cache diff --git a/Makefile.am b/Makefile.am index 5c77175..baab706 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,3 +3,5 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = tools extensions src data m4 tests EXTRA_DIST = autogen.sh + +include tools/lcov.am diff --git a/configure.ac b/configure.ac index df0cc43..7693a79 100644 --- a/configure.ac +++ b/configure.ac @@ -43,6 +43,10 @@ AC_PROG_CC_STDC AC_PROG_INSTALL AC_PROG_LIBTOOL +COMPILER_OPTIMISATIONS +COMPILER_COVERAGE +LINKER_OPTIMISATIONS + ifelse(haze_nano_version, 0, [release=yes], [release=no]) TP_COMPILER_WARNINGS([ERROR_CFLAGS], [test x$release = xno], [all \ diff --git a/m4/Makefile.am b/m4/Makefile.am index 3b39ac3..dfb2d32 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -1,4 +1,6 @@ EXTRA_DIST = \ as-ac-expand.m4 \ as-compiler-flag.m4 \ +compiler.m4 \ +linker.m4 \ tp-compiler-warnings.m4 diff --git a/m4/compiler.m4 b/m4/compiler.m4 new file mode 100644 index 0000000..5aff5d8 --- /dev/null +++ b/m4/compiler.m4 @@ -0,0 +1,67 @@ +# compiler.m4 - autoconf macros for compiler settings +# +# Copyright © 2005 Scott James Remnant . +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +# COMPILER_WARNINGS +# ---------------------- +# Add configure option to enable additional compiler warnings and treat +# them as errors. +AC_DEFUN([COMPILER_WARNINGS], +[AC_ARG_ENABLE(compiler-warnings, + AS_HELP_STRING([--enable-compiler-warnings], + [Enable additional compiler warnings]), +[if test "x$enable_compiler_warnings" = "xyes"; then + if test "x$GCC" = "xyes"; then + CFLAGS="-Wall -Werror $CFLAGS" + fi + if test "x$GXX" = "xyes"; then + CXXFLAGS="-Wall -Werror $CXXFLAGS" + fi +fi])dnl +])# COMPILER_WARNINGS + +# COMPILER_OPTIMISATIONS +# --------------------------- +# Add configure option to disable optimisations. +AC_DEFUN([COMPILER_OPTIMISATIONS], +[AC_ARG_ENABLE(compiler-optimisations, + AS_HELP_STRING([--disable-compiler-optimisations], + [Disable compiler optimisations]), +[if test "x$enable_compiler_optimisations" = "xno"; then + [CFLAGS=`echo "$CFLAGS" | sed -e "s/ -O[1-9]*\b/ -O0/g"`] +fi])dnl +])# COMPILER_OPTIMISATIONS + +# COMPILER_COVERAGE +# ---------------------- +# Add configure option to enable coverage data. +AC_DEFUN([COMPILER_COVERAGE], +[AC_ARG_ENABLE(compiler-coverage, + AS_HELP_STRING([--enable-compiler-coverage], + [Enable generation of coverage data]), +[if test "x$enable_compiler_coverage" = "xyes"; then + if test "x$GCC" = "xyes"; then + CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage" + fi +fi])dnl +])# COMPILER_COVERAGE diff --git a/m4/linker.m4 b/m4/linker.m4 new file mode 100644 index 0000000..d62257b --- /dev/null +++ b/m4/linker.m4 @@ -0,0 +1,83 @@ +# linker.m4 - autoconf macros for linker settings +# +# Copyright © 2005 Scott James Remnant . +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +# LINKER_OPTIMISATIONS +# -------------------- +# Add configure option to disable linker optimisations. +AC_DEFUN([LINKER_OPTIMISATIONS], +[ +AC_MSG_CHECKING([whether linker supports -Wl,-O1]) +save_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS -Wl,-O1" +AC_TRY_LINK([], [], [can_use_linker_opt=yes], + [can_use_linker_opt=no]) +AC_MSG_RESULT([$can_use_linker_opt]) + +if test "x$can_use_linker_opt" = "xno"; then + LDFLAGS="$save_LDFLAGS" +fi + +AC_ARG_ENABLE(linker-optimisations, + AS_HELP_STRING([--disable-linker-optimisations], + [Disable linker optimisations]), +[if test "x$enable_linker_optimisations" = "xno"; then + [LDFLAGS=`echo "$LDFLAGS" | sed -e "s/ -Wl,-O[0-9]*\b//g"`] +fi], [])dnl +])# LINKER_OPTIMISATIONS + +# LINKER_VERSION_SCRIPT +# -------------------------- +# Detect whether the linker supports version scripts +AC_DEFUN([LINKER_VERSION_SCRIPT], +[AC_MSG_CHECKING([for linker version script argument]) +for aranha_try_arg in "-Wl,--version-script"; do + aranha_old_libs="$LIBS" + LIBS="$LIBS $aranha_try_arg=conftest.ver" + + cat >conftest.ver </dev/null`;\ + genhtml --title "@PACKAGE_STRING@ $$git_commit" \ + --output-directory @top_builddir@/lcov.html lcov.info + @echo + @echo 'lcov report can be found in:' + @echo 'file://@abs_top_builddir@/lcov.html/index.html' + @echo + +lcov-check: + $(MAKE) lcov-reset + $(MAKE) check $(LCOV_CHECK_ARGS) + $(MAKE) lcov-report + +## vim:set ft=automake: -- cgit v1.2.1