summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2010-07-01 15:12:18 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2010-07-15 15:37:48 +0100
commit84c402d247765dbd754a9255878d162e868d1201 (patch)
treef752a9ae2df94099a24e701d9d09006b99e6622e
parent57f31dac78ea87b5464133e88a4185cc3c2db44a (diff)
downloadtelepathy-haze-84c402d247765dbd754a9255878d162e868d1201.tar.gz
Add support for compiler and linker optimizations, and compiler coverage
-rw-r--r--.gitignore3
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac4
-rw-r--r--m4/Makefile.am2
-rw-r--r--m4/compiler.m467
-rw-r--r--m4/linker.m483
-rw-r--r--tools/lcov.am24
7 files changed, 185 insertions, 0 deletions
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 <scott@netsplit.com>.
+#
+# 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 <scott@netsplit.com>.
+#
+# 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 <<EOF
+TEST {
+ global:
+ *;
+};
+EOF
+
+ AC_TRY_LINK([], [], [
+ rm -f conftest.ver
+ LIBS="$aranha_old_libs"
+
+ AC_MSG_RESULT([$aranha_try_arg])
+ AC_SUBST(VERSION_SCRIPT_ARG, [$aranha_try_arg])
+ break
+ ])
+
+ rm -f conftest.ver
+ LIBS="$aranha_old_libs"
+done
+
+AM_CONDITIONAL(HAVE_VERSION_SCRIPT_ARG, [test -n "$VERSION_SCRIPT_ARG"])
+if test -z "$VERSION_SCRIPT_ARG"; then
+ AC_MSG_RESULT([unknown])
+fi
+])dnl
+])# LINKER_VERSION_SCRIPT
diff --git a/tools/lcov.am b/tools/lcov.am
new file mode 100644
index 0000000..7384f1b
--- /dev/null
+++ b/tools/lcov.am
@@ -0,0 +1,24 @@
+lcov-reset:
+ lcov --directory @top_srcdir@ --zerocounters
+
+lcov-report:
+ lcov --directory @top_srcdir@ --capture \
+ --output-file @top_builddir@/lcov.info.tmp
+ lcov --directory @top_srcdir@ --output-file @top_builddir@/lcov.info \
+ --remove @top_builddir@/lcov.info.tmp telepathy-glib-scan.c
+ rm @top_builddir@/lcov.info.tmp
+ $(mkdir_p) @top_builddir@/lcov.html
+ git_commit=`GIT_DIR=@top_srcdir@/.git git log -1 --pretty=format:%h 2>/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: