@@ -29,3 +29,7 @@ libtool
*-libtool
m4/
stamp-h1
+
+# profiling
+*.gcda
+*.gcno
@@ -122,6 +122,16 @@ AC_ARG_ENABLE([tests],
[with_tests=false])
AM_CONDITIONAL([WITH_TESTS], [test "x$with_tests" = xtrue])
+AC_ARG_ENABLE([profiling],
+ [AS_HELP_STRING([--enable-profiling],
+ [enable gcov profiling on the core library and tests [default=no]])],
+ [if test "x$enableval" = xyes; then with_profiling=true; fi],
+ [with_profiling=false])
+if test "x$with_profiling" = xtrue
+then
+ AC_SUBST(PROFILING_FLAGS, ["-fprofile-arcs -ftest-coverage"])
+fi
+
AC_DEFUN([FUNC_NOT_FOUND_TESTS],
[ERR_NOT_FOUND([$1()], [tests])])
@@ -17,6 +17,7 @@ libgpiod_la_SOURCES = chip.c \
libgpiod_la_CFLAGS = -Wall -Wextra -g -std=gnu89
libgpiod_la_CFLAGS += -fvisibility=hidden -I$(top_srcdir)/include/
libgpiod_la_CFLAGS += -include $(top_builddir)/config.h
+libgpiod_la_CFLAGS += $(PROFILING_FLAGS)
libgpiod_la_LDFLAGS = -version-info $(subst .,:,$(ABI_VERSION))
pkgconfigdir = $(libdir)/pkgconfig
@@ -7,6 +7,7 @@ AM_CFLAGS = -I$(top_srcdir)/include/ -I$(top_srcdir)/tests/gpiosim/
AM_CFLAGS += -include $(top_builddir)/config.h
AM_CFLAGS += -Wall -Wextra -g -std=gnu89 $(GLIB_CFLAGS)
AM_CFLAGS += -DG_LOG_DOMAIN=\"gpiod-test\"
+AM_CFLAGS += $(PROFILING_FLAGS)
AM_LDFLAGS = -pthread
LDADD = $(top_builddir)/lib/libgpiod.la
LDADD += $(top_builddir)/tests/gpiosim/libgpiosim.la
Add a configure switch that adds the relevant gcov options to the compiler flags for the core library and tests. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> --- .gitignore | 4 ++++ configure.ac | 10 ++++++++++ lib/Makefile.am | 1 + tests/Makefile.am | 1 + 4 files changed, 16 insertions(+)