--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,6 +1,8 @@
 
 AUTOMAKE_OPTIONS = 1.0 foreign
 
+CFLAGS += -fprofile-arcs -ftest-coverage
+
 DEFS = 
 
 noinst_LTLIBRARIES = libshadow.la
--- a/libmisc/Makefile.am
+++ b/libmisc/Makefile.am
@@ -1,6 +1,8 @@
 
 EXTRA_DIST = .indent.pro xgetXXbyYY.c
 
+CFLAGS += -fprofile-arcs -ftest-coverage
+
 INCLUDES = -I$(top_srcdir)/lib
 
 noinst_LIBRARIES = libmisc.a
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,6 +6,8 @@
 usbindir = ${prefix}/sbin
 suidperms = 4755
 
+CFLAGS += -fprofile-arcs -ftest-coverage
+
 INCLUDES = \
 	-I${top_srcdir}/lib \
 	-I$(top_srcdir)/libmisc
--- a/debian/rules
+++ b/debian/rules
@@ -39,6 +39,12 @@
 endif
 export CFLAGS
 
+clean:: clean_gcov
+
+clean_gcov:
+	find . -name "*.gcda" -delete
+	find . -name "*.gcno" -delete
+
 # Add extras to the install process:
 binary-install/login::
 	dh_installpam -p login
