summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorEmanuele Aina <em@nerd.ocracy.org>2007-06-26 13:21:54 +0000
committerEmanuele Aina <em@nerd.ocracy.org>2007-06-26 13:21:54 +0000
commit0e15968b5ee1c61bf9e1720e5240b598a1143660 (patch)
tree258fde9d484996323066b81ede07aa40ba081430 /m4
parentee29278e4d92f0057277199c3947a666ec3c4aa1 (diff)
downloadtelepathy-salut-0e15968b5ee1c61bf9e1720e5240b598a1143660.tar.gz
Fixed the valgrind and coverage compile options reorganizing the macro inclusion
20070626132154-f974e-1c612eaa640fd535b4ebb5b8bfc40695ff9819f5.gz
Diffstat (limited to 'm4')
-rw-r--r--m4/salut-args.m417
-rw-r--r--m4/salut-gcov.m457
-rw-r--r--m4/salut-lcov.m412
-rw-r--r--m4/salut-valgrind.m424
4 files changed, 63 insertions, 47 deletions
diff --git a/m4/salut-args.m4 b/m4/salut-args.m4
index eee986da..433113a2 100644
--- a/m4/salut-args.m4
+++ b/m4/salut-args.m4
@@ -39,15 +39,16 @@ AC_DEFUN([SALUT_ARG_VALGRIND],
[
dnl valgrind inclusion
AC_ARG_ENABLE(valgrind,
- AC_HELP_STRING([--disable-valgrind],[disable run-time valgrind detection]),
+ AC_HELP_STRING([--enable-valgrind],[enable valgrind checking and run-time detection]),
[
case "${enableval}" in
- yes) ENABLE_VALGRIND=yes ;;
- no) ENABLE_VALGRIND=no ;;
+ yes|no) enable="${enableval}" ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-valgrind) ;;
esac
],
- [ENABLE_VALGRIND=no])
+ [enable=no])
+
+ SALUT_VALGRIND($enable)
])
AC_DEFUN([SALUT_ARG_COVERAGE],
@@ -57,10 +58,12 @@ AC_DEFUN([SALUT_ARG_COVERAGE],
[compile with coverage profiling instrumentation (gcc only)]),
[
case "${enableval}" in
- yes) ENABLE_COVERAGE=yes ;;
- no) ENABLE_COVERAGE=no ;;
+ yes|no) enable="${enableval}" ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-coverage) ;;
esac
],
- [ENABLE_COVERAGE=no])
+ [enable=no])
+
+ SALUT_GCOV($enable)
+ SALUT_LCOV($enable)
])
diff --git a/m4/salut-gcov.m4 b/m4/salut-gcov.m4
index 00bd7314..25fcb50f 100644
--- a/m4/salut-gcov.m4
+++ b/m4/salut-gcov.m4
@@ -2,38 +2,39 @@ dnl Detect and set flags for gcov
AC_DEFUN([SALUT_GCOV],
[
- if test "x$GCC" != "xyes"
- then
- AC_MSG_ERROR([gcov only works if gcc is used])
- fi
+ enable=$1
+
+ GCOV=`echo $CC | sed s/gcc/gcov/g`
+ AC_CHECK_PROG(have_gcov, $GCOV, yes, no)
AS_COMPILER_FLAG(["-fprofile-arcs"],
- [GCOV_CFLAGS="$GCOV_CFLAGS -fprofile-arcs"],
- true)
+ [flag_profile_arcs=yes],
+ [flag_profile_arcs=no])
+
AS_COMPILER_FLAG(["-ftest-coverage"],
- [GCOV_CFLAGS="$GCOV_CFLAGS -ftest-coverage"],
- true)
- dnl remove any -O flags - FIXME: is this needed ?
- GCOV_CFLAGS=`echo "$GCOV_CFLAGS" | sed -e 's/-O[[0-9]]*//g'`
- dnl libtool 1.5.22 and lower strip -fprofile-arcs from the flags
- dnl passed to the linker, which is a bug; -fprofile-arcs implicitly
- dnl links in -lgcov, so we do it explicitly here for the same effect
- GCOV_LIBS=-lgcov
- AC_SUBST(GCOV_CFLAGS)
- AC_SUBST(GCOV_LIBS)
- GCOV=`echo $CC | sed s/gcc/gcov/g`
- AC_SUBST(GCOV)
+ [flag_test_coverage=yes],
+ [flag_test_coverage=no])
- AC_SUBST([MOSTLYCLEANFILES], "*.bb *.bbg *.da *.gcov *.gcda *.gcno")
+ if test "x$enable" = xyes &&
+ test "x$GCC" = "xyes" &&
+ test "$flag_profile_arcs" = yes &&
+ test "$flag_test_coverage" = yes ;
+ then
- HAVE_GCOV=yes
+ GCOV_CFLAGS="$GCOV_CFLAGS -fprofile-arcs -ftest-coverage"
+ dnl remove any -O flags - FIXME: is this needed ?
+ GCOV_CFLAGS=`echo "$GCOV_CFLAGS" | sed -e 's/-O[[0-9]]*//g'`
- AC_DEFINE_UNQUOTED(HAVE_GCOV, 1,
- [Defined if gcov is enabled to force a rebuild due to config.h changing])
+ dnl libtool 1.5.22 and lower strip -fprofile-arcs from the flags
+ dnl passed to the linker, which is a bug; -fprofile-arcs implicitly
+ dnl links in -lgcov, so we do it explicitly here for the same effect
+ GCOV_LIBS=-lgcov
+
+ AC_SUBST([MOSTLYCLEANFILES], "*.bb *.bbg *.da *.gcov *.gcda *.gcno")
+
+ AC_DEFINE_UNQUOTED(HAVE_GCOV, 1,
+ [Defined if gcov is enabled to force a rebuild due to config.h changing])
- dnl if gcov is used, we do not want default -O2 CFLAGS
- if test "x$HAVE_GCOV" = "xyes"
- then
CFLAGS="-O0"
AC_SUBST(CFLAGS)
CXXFLAGS="-O0"
@@ -45,5 +46,9 @@ AC_DEFUN([SALUT_GCOV],
AC_MSG_NOTICE([gcov enabled, setting CFLAGS and friends to $CFLAGS])
fi
- AM_CONDITIONAL(HAVE_GCOV, test x$HAVE_GCOV = xyes)
+ AC_SUBST(GCOV_CFLAGS)
+ AC_SUBST(GCOV_LIBS)
+ AC_SUBST(GCOV)
+
+ AM_CONDITIONAL(HAVE_GCOV, test x$have_gcov = xyes)
])
diff --git a/m4/salut-lcov.m4 b/m4/salut-lcov.m4
index 8d9a4da1..c0bbbf9c 100644
--- a/m4/salut-lcov.m4
+++ b/m4/salut-lcov.m4
@@ -2,9 +2,11 @@ dnl Check for lcov utility
AC_DEFUN([SALUT_LCOV],
[
- AC_PATH_PROG(LCOV_PATH, [lcov], [no])
+ enable=$1
- if test X$LCOV_PATH != Xno ; then
+ AC_PATH_PROG(LCOV_PATH, lcov)
+
+ if test -n "$LCOV_PATH" ; then
AC_MSG_CHECKING([whether lcov accepts --compat-libtool])
if $LCOV_PATH --compat-libtool --help > /dev/null 2>&1 ; then
AC_MSG_RESULT(ok)
@@ -12,12 +14,14 @@ AC_DEFUN([SALUT_LCOV],
AC_MSG_RESULT(no)
AC_MSG_WARN([lcov option --compat-libtool is not supported])
AC_MSG_WARN([update lcov to version > 1.5])
- LCOV_PATH=no
+ LCOV_PATH=""
fi
fi
- if test X$LCOV_PATH == Xno ; then
+ if test -z "$LCOV_PATH" ; then
AC_MSG_WARN([will use an internal lcov copy])
LCOV_PATH='$(top_srcdir)/scripts/lcov/lcov'
fi
+
+ AM_CONDITIONAL(HAVE_LCOV, test -n "$LCOV_PATH" && test "x$enable" = xyes)
])
diff --git a/m4/salut-valgrind.m4 b/m4/salut-valgrind.m4
index 53ff90f1..6c1ffd51 100644
--- a/m4/salut-valgrind.m4
+++ b/m4/salut-valgrind.m4
@@ -2,22 +2,26 @@ dnl Detect Valgrind location and flags
AC_DEFUN([SALUT_VALGRIND],
[
+ enable=$1
+
VALGRIND_REQ="2.1"
PKG_CHECK_MODULES(VALGRIND, valgrind > $VALGRIND_REQ,
- use_valgrind="yes",
- [
- use_valgrind="no"
- AC_MSG_RESULT([no])
- ])
+ have_valgrind_runtime="yes", have_valgrind_runtime="no")
+
+ AC_PATH_PROG(VALGRIND_PATH, valgrind)
- if test "x$use_valgrind" = xyes; then
+ # Compile the instrumentation for valgrind only if the valgrind
+ # libraries are installed and the valgrind executable is found
+ if test "x$enable" = xyes &&
+ test "$have_valgrind_runtime" = yes &&
+ test -n "$VALGRIND_PATH" ;
+ then
AC_DEFINE(HAVE_VALGRIND, 1, [Define if valgrind should be used])
- AC_MSG_NOTICE(Using extra code paths for valgrind)
+ AC_MSG_NOTICE(using compile-time instrumentation for valgrind)
fi
AC_SUBST(VALGRIND_CFLAGS)
AC_SUBST(VALGRIND_LIBS)
-
- AC_PATH_PROG(VALGRIND_PATH, valgrind, no)
- AM_CONDITIONAL(HAVE_VALGRIND, test ! "x$VALGRIND_PATH" = "xno")
+
+ AM_CONDITIONAL(HAVE_VALGRIND, test -n "$VALGRIND_PATH")
])