From: Sebastian Harl Date: Sat, 21 Dec 2013 20:08:43 +0000 (+0100) Subject: build system: Added --enable-gcov configure option. X-Git-Tag: sysdb-0.1.0~293 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0ad163769f0e9ebd07fa9978bf2978bd6012781f;p=sysdb.git build system: Added --enable-gcov configure option. --- diff --git a/configure.ac b/configure.ac index b7a07e6..8620ff8 100644 --- a/configure.ac +++ b/configure.ac @@ -185,6 +185,46 @@ if test "x$enable_strict_checks" = "xyes"; then fi AC_SUBST([STRICT_CFLAGS]) +AC_ARG_ENABLE([gcov], + AS_HELP_STRING([--enable-gcov], + [Gcov coverage statistics @<:@default=no@:>@]), + [enable_gcov="$enableval"], + [enable_gcov="no"]) + +COVERAGE_CFLAGS="" +COVERAGE_LDFLAGS="" +if test "x$enable_gcov" = "xyes"; then + COVERAGE_CFLAGS="-O0" + cov_flag_have_problem="no" + + AC_MSG_CHECKING([whether $CC accepts --coverage]) + if test_cc_flags --coverage; then + COVERAGE_CFLAGS="$COVERAGE_CFLAGS --coverage" + COVERAGE_LDFLAGS="$COVERAGE_LDFLAGS --coverage" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + cov_flag_have_problem="yes" + fi + + for flag in -fno-inline; do + AC_MSG_CHECKING([whether $CC accepts $flag]) + if test_cc_flags $flag; then + COVERAGE_CFLAGS="$COVERAGE_CFLAGS $flag" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + cov_flag_have_problem="yes" + fi + done + + if test "x$cov_flag_have_problem" != "xno"; then + AC_MSG_WARN([Some coverage flags are not supported by your compiler!]) + fi +fi +AC_SUBST([COVERAGE_CFLAGS]) +AC_SUBST([COVERAGE_LDFLAGS]) + m4_divert_once([HELP_ENABLE], [ Build dependencies:]) @@ -373,6 +413,7 @@ AC_MSG_RESULT([ Features:]) AC_MSG_RESULT([ documentation: . . . . . . $build_documentation]) AC_MSG_RESULT([ unit testing: . . . . . . . $build_testing]) AC_MSG_RESULT([ stdio mocking: . . . . . $have_fopencookie]) +AC_MSG_RESULT([ coverage testing: . . . . . $enable_gcov]) AC_MSG_RESULT() AC_MSG_RESULT([ Libraries:]) AC_MSG_RESULT([ libdbi: . . . . . . . . . . $with_libdbi]) diff --git a/src/Makefile.am b/src/Makefile.am index fea709e..32da635 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,8 @@ SUBDIRS = liboconfig -AM_CFLAGS = @STRICT_CFLAGS@ +# coverage related flags are only set when gcov is enabled +AM_CFLAGS = @STRICT_CFLAGS@ @COVERAGE_CFLAGS@ +AM_LDFLAGS = @COVERAGE_LDFLAGS@ AM_CPPFLAGS = -Iinclude AM_CPPFLAGS += -DSYSCONFDIR='"${sysconfdir}"' AM_CPPFLAGS += -DLOCALSTATEDIR='"${localstatedir}"' @@ -46,7 +48,7 @@ libsysdbclient_la_SOURCES = \ utils/strbuf.c include/utils/strbuf.h libsysdbclient_la_CFLAGS = $(AM_CFLAGS) libsysdbclient_la_CPPFLAGS = $(AM_CPPFLAGS) $(LTDLINCL) -libsysdbclient_la_LDFLAGS = -version-info 0:0:0 -pthread +libsysdbclient_la_LDFLAGS = $(AM_LDFLAGS) -version-info 0:0:0 -pthread libsysdbclient_la_LIBADD = $(LIBLTDL) libsysdb_la_SOURCES = \ @@ -69,7 +71,7 @@ libsysdb_la_SOURCES = \ utils/unixsock.c include/utils/unixsock.h libsysdb_la_CFLAGS = $(AM_CFLAGS) libsysdb_la_CPPFLAGS = $(AM_CPPFLAGS) $(LTDLINCL) -libsysdb_la_LDFLAGS = -version-info 0:0:0 -pthread +libsysdb_la_LDFLAGS = $(AM_LDFLAGS) -version-info 0:0:0 -pthread libsysdb_la_LIBADD = $(LIBLTDL) -lrt liboconfig/liboconfig.la libsysdb_la_DEPENDENCIES = liboconfig/liboconfig.la @@ -117,7 +119,7 @@ pkgcnamelib_LTLIBRARIES = if BUILD_PLUGIN_COLLECTD pkgbackendcollectdlib_LTLIBRARIES += backend/collectd/unixsock.la backend_collectd_unixsock_la_SOURCES = backend/collectd/unixsock.c -backend_collectd_unixsock_la_LDFLAGS = -module -avoid-version +backend_collectd_unixsock_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version libsysdb_la_LIBADD += -dlopen backend/collectd/unixsock.la libsysdb_la_DEPENDENCIES += backend/collectd/unixsock.la endif @@ -125,7 +127,7 @@ endif if BUILD_PLUGIN_MKLIVESTATUS pkgbackendlib_LTLIBRARIES += backend/mk-livestatus.la backend_mk_livestatus_la_SOURCES = backend/mk-livestatus.c -backend_mk_livestatus_la_LDFLAGS = -module -avoid-version +backend_mk_livestatus_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version libsysdb_la_LIBADD += -dlopen backend/mk-livestatus.la libsysdb_la_DEPENDENCIES += backend/mk-livestatus.la endif @@ -133,7 +135,7 @@ endif if BUILD_PLUGIN_PUPPETSTORECONFIGS pkgbackendpuppetlib_LTLIBRARIES += backend/puppet/store-configs.la backend_puppet_store_configs_la_SOURCES = backend/puppet/store-configs.c -backend_puppet_store_configs_la_LDFLAGS = -module -avoid-version +backend_puppet_store_configs_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version libsysdb_la_LIBADD += -dlopen backend/puppet/store-configs.la libsysdb_la_DEPENDENCIES += backend/puppet/store-configs.la endif @@ -141,7 +143,7 @@ endif if BUILD_PLUGIN_SYSLOG pkglib_LTLIBRARIES += plugins/syslog.la plugins_syslog_la_SOURCE = plugins/syslog.c -plugins_syslog_la_LDFLAGS = -module -avoid-version +plugins_syslog_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version libsysdb_la_LIBADD += -dlopen plugins/syslog.la libsysdb_la_DEPENDENCIES += plugins/syslog.la endif @@ -149,7 +151,7 @@ endif if BUILD_PLUGIN_CNAMEDNS pkgcnamelib_LTLIBRARIES += plugins/cname/dns.la plugins_cname_dns_la_SOURCE = plugins/cname/dns.c -plugins_cname_dns_la_LDFLAGS = -module -avoid-version +plugins_cname_dns_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version libsysdb_la_LIBADD += -dlopen plugins/cname/dns.la libsysdb_la_DEPENDENCIES += plugins/cname/dns.la endif