Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): make it easy to run gcov on the code



details:   https://anonhg.NetBSD.org/src/rev/c14827a36692
branches:  trunk
changeset: 974132:c14827a36692
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jul 25 21:00:48 2020 +0000

description:
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).

diffstat:

 usr.bin/make/Makefile |  20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diffs (38 lines):

diff -r dbbc05b1e2a9 -r c14827a36692 usr.bin/make/Makefile
--- a/usr.bin/make/Makefile     Sat Jul 25 20:50:00 2020 +0000
+++ b/usr.bin/make/Makefile     Sat Jul 25 21:00:48 2020 +0000
@@ -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+= 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.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}



Home | Main Index | Thread Index | Old Index