Module Name:    src
Committed By:   rillig
Date:           Sat Jul 25 21:00:48 UTC 2020

Modified Files:
        src/usr.bin/make: Makefile

Log Message:
make(1): make it easy to run gcov on the code

There seems to be no gcov support in share/mk yes, but it's still good
to have, especially for a complex program like make(1).


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/usr.bin/make/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/Makefile
diff -u src/usr.bin/make/Makefile:1.72 src/usr.bin/make/Makefile:1.73
--- src/usr.bin/make/Makefile:1.72	Sat Jul 25 20:50:00 2020
+++ src/usr.bin/make/Makefile	Sat Jul 25 21:00:48 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.72 2020/07/25 20:50:00 rillig Exp $
+#	$NetBSD: Makefile,v 1.73 2020/07/25 21:00:48 rillig Exp $
 #	@(#)Makefile	5.2 (Berkeley) 12/28/90
 
 PROG=	make
@@ -11,6 +11,13 @@ SRCS+=	lstFind.c lstFindFrom.c lstFirst.
 SRCS+=	lstInit.c lstInsert.c lstIsAtEnd.c lstIsEmpty.c lstLast.c lstMember.c
 SRCS+=	lstNext.c lstOpen.c lstPrev.c lstRemove.c lstReplace.c lstSucc.c
 
+USE_COVERAGE?=	no		# works only with gcc; clang9 fails to link
+.if ${USE_COVERAGE} == "yes"
+COPTS=		--coverage -O0 -ggdb
+LDADD=		--coverage
+CLEANFILES+=	${SRCS:.c=.gcda} ${SRCS:.c=.gcno} ${SRCS:=.gcov}
+.endif
+
 USE_META?=	yes
 .if ${USE_META:tl} != "no"
 
@@ -64,5 +71,12 @@ COPTS.meta.c+=	${GCC_NO_FORMAT_TRUNCATIO
 COPTS.parse.c+=	${GCC_NO_FORMAT_TRUNCATION}
 
 # A simple unit-test driver to help catch regressions
-accept test: .MAKE
-	cd ${.CURDIR}/unit-tests && MAKEFLAGS= ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
+test: .MAKE
+	cd ${.CURDIR}/unit-tests \
+	&& MAKEFLAGS= ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
+.if ${USE_COVERAGE} == yes
+	gcov ${SRCS}
+.endif
+
+accept: .MAKE
+	cd ${.CURDIR}/unit-tests && ${.MAKE} ${.TARGET}

Reply via email to