diff --git a/Makefile.am b/Makefile.am
index c853f527c7368d0791110080821974518a127238..f23bb0183118a329a99a06adc0a41feeff09027d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -999,7 +999,8 @@ lcov.out: lcov-raw.out
 
 lcov: lcov.out
 	rm -Rf lcov lcov.tmp
-	genhtml lcov.out -o lcov.tmp
+	prefix="$$(cd "$(top_srcdir)" && pwd)" ; \
+	genhtml -p "$$prefix" -o lcov.tmp lcov.out >/dev/null
 	mv lcov.tmp lcov
 
 .PHONY: lcov-raw.out