From a9ea00474518545efea1b428eaeb5a1ed67eeba2 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Wed, 15 Jul 2020 12:07:47 +0000 Subject: [PATCH] Avoid rebuilding libpmc in every incremental rebuild Generate libpmc_events.c in a temporary file first and only overwrite it if the files are actually different. This avoids compiling and relinking the different variants of libpmc on every incremental build. Reviewed By: jhb Differential Revision: https://reviews.freebsd.org/D24784 --- lib/libpmc/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libpmc/Makefile b/lib/libpmc/Makefile index 19457880358..0097d5454bc 100644 --- a/lib/libpmc/Makefile +++ b/lib/libpmc/Makefile @@ -32,9 +32,13 @@ SUBDIR+= pmu-events .endif .endif -libpmc_events.c: ${JEVENTS} - ${JEVENTS} ${EVENT_ARCH} ${.CURDIR}/pmu-events/arch libpmc_events.c -SRCS+= libpmc_events.c +libpmc_events.c: ${JEVENTS} .META + ${JEVENTS} ${EVENT_ARCH} ${.CURDIR}/pmu-events/arch ${.TARGET}.tmp + if [ ! -e ${.TARGET} ] || ! cmp -s ${.TARGET} ${.TARGET}.tmp; then \ + mv -f ${.TARGET}.tmp ${.TARGET}; \ + fi +CLEANFILES+= libpmc_events.c libpmc_events.c.tmp +SRCS+= libpmc_events.c .endif WARNS?= 3