Subject: rebuilding stale .depend files
To: None <tech-toolchain@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-toolchain
Date: 11/02/2003 23:22:26
It gets rather anoying when a build fails because the old
.depend file references a now deleted file.
The patch forces the .depend file to be regenerated if any of the
referenced files has been deleted.
Note that it has to use exists(file) because .PATH has to be applied.
(the shell read handles the continuation lines...)
Thoughts?
David
Index: bsd.dep.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.dep.mk,v
retrieving revision 1.62
diff -u -p -r1.62 bsd.dep.mk
--- bsd.dep.mk 2003/10/28 01:25:33 1.62
+++ bsd.dep.mk 2003/11/02 23:08:49
@@ -29,6 +29,27 @@ __DPSRCS.notd= ${__DPSRCS.all:O:u:N*.d}
${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS}
.endif # }
+# Force .d files to be regenerated if they reference a missing file.
+# (stops some errors on update builds)
+missing=
+.if (make(dependall)||make(depend)) && !empty(__DPSRCS.d) && exists(.depend) # {
+deps != IFS=':'; while read t d; do \
+ echo $$d; \
+ done <.depend
+.for depfile in ${deps:O:u}
+.if !exists(${depfile})
+missing+= ${depfile}
+.endif
+.endfor
+
+.if !empty(missing)
+.PHONY: force
+force:
+ @echo '# Missing ${missing}, rebuilding .depend'
+${__DPSRCS.d}: force
+.endif
+.endif # }
+
.depend: ${__DPSRCS.d}
${_MKTARGET_CREATE}
rm -f .depend
--
David Laight: david@l8s.co.uk