chiark / gitweb /
Add test coverage and generate report with lcov
[elogind.git] / configure.ac
index 0881e47365efccfc1886b2b18aecd07bae8c3dba..afbe8e9048a5aa66306a483e57d610447862069b 100644 (file)
@@ -20,7 +20,7 @@
 AC_PREREQ([2.64])
 
 AC_INIT([systemd],
-        [204],
+        [205],
         [http://bugs.freedesktop.org/enter_bug.cgi?product=systemd],
         [systemd],
         [http://www.freedesktop.org/wiki/Software/systemd])
@@ -74,6 +74,8 @@ AC_PATH_PROG([SETCAP], [setcap], [/usr/sbin/setcap])
 
 AC_PATH_PROG([KILL], [kill], [/usr/bin/kill])
 
+AC_PATH_PROG([KMOD], [kmod], [/usr/bin/kmod])
+
 # gtkdocize greps for '^GTK_DOC_CHECK', so it needs to be on its own line
 m4_ifdef([GTK_DOC_CHECK], [
 GTK_DOC_CHECK([1.18],[--flavour no-tmpl])],
@@ -212,14 +214,41 @@ m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-conf
 
 PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.3.2])
 
+# ------------------------------------------------------------------------------
+have_coverage=no
+AC_ARG_ENABLE(coverage, AS_HELP_STRING([--enable-coverage], [enable test coverage]))
+if test "x$enable_coverage" = "xyes" ; then
+        AC_CHECK_PROG(lcov_found, [lcov], [yes], [no])
+        if test "x$lcov_found" = xno ; then
+                AC_MSG_ERROR([*** lcov support requested but the program was not found])
+        else
+                lcov_version_major="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 1`"
+                lcov_version_minor="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 2`"
+                if test "$lcov_version_major" -eq 1 -a "$lcov_version_minor" -lt 10; then
+                        AC_MSG_ERROR([*** lcov version is too old. 1.10 required])
+                else
+                        have_coverage=yes
+                        CC_CHECK_FLAGS_APPEND([with_coverage_cflags], [CFLAGS], [\
+                        -fprofile-arcs \
+                        -ftest-coverage])
+                        AC_SUBST([OUR_CFLAGS], "$with_cflags $with_coverage_cflags")
+                fi
+        fi
+fi
+AM_CONDITIONAL(ENABLE_COVERAGE, [test "$have_coverage" = "yes"])
+
 # ------------------------------------------------------------------------------
 have_kmod=no
 AC_ARG_ENABLE(kmod, AS_HELP_STRING([--disable-kmod], [disable loadable modules support]))
 if test "x$enable_kmod" != "xno"; then
-        PKG_CHECK_MODULES(KMOD, [ libkmod >= 5 ],
-                [AC_DEFINE(HAVE_KMOD, 1, [Define if kmod is available]) have_kmod=yes], have_kmod=no)
+        PKG_CHECK_EXISTS([ libkmod ], have_kmod=yes, have_kmod=no)
+        if test "x$have_kmod" = "xyes"; then
+                PKG_CHECK_MODULES(KMOD, [ libkmod >= 14 ],
+                        [AC_DEFINE(HAVE_KMOD, 1, [Define if kmod is available])],
+                        AC_MSG_ERROR([*** kmod version >= 14 not found]))
+        fi
         if test "x$have_kmod" = xno -a "x$enable_kmod" = xyes; then
-                AC_MSG_ERROR([*** kmod support requested but libraries not found])
+                AC_MSG_ERROR([*** kmod support requested, but libraries not found])
         fi
 fi
 AM_CONDITIONAL(HAVE_KMOD, [test "$have_kmod" = "yes"])
@@ -994,6 +1023,7 @@ AC_MSG_RESULT([
         Python Headers:          ${have_python_devel}
         man pages:               ${have_manpages}
         gtk-doc:                 ${enable_gtk_doc}
+        test coverage:           ${have_coverage}
         Split /usr:              ${enable_split_usr}
         SysV compatibility:      ${SYSTEM_SYSV_COMPAT}