summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.inc12
-rw-r--r--share/mk/local.dirdeps.mk14
2 files changed, 16 insertions, 0 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1
index 3c5e0188a813..4e8a8fd6493b 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -815,6 +815,7 @@ _worldtmp: .PHONY
@echo "--------------------------------------------------------------"
.if !defined(NO_CLEAN)
rm -rf ${WORLDTMP}
+ @mkdir -p ${WORLDTMP}
.else
.if exists(${WORLDTMP})
@echo ">>> Deleting stale files in build tree..."
@@ -831,6 +832,7 @@ _worldtmp: .PHONY
.endfor
.endif # ${USING_SYSTEM_COMPILER} == "yes"
.endif # !defined(NO_CLEAN)
+ @touch ${WORLDTMP}/${.TARGET}
.for _dir in \
lib lib/casper usr legacy/bin legacy/usr
diff --git a/share/mk/local.dirdeps.mk b/share/mk/local.dirdeps.mk
index 45581da7c0a7..85f7bbf052c0 100644
--- a/share/mk/local.dirdeps.mk
+++ b/share/mk/local.dirdeps.mk
@@ -49,6 +49,20 @@ DIRDEPS_FILTER.host = \
DIRDEPS_FILTER+= \
Nbin/cat.host \
${DIRDEPS_FILTER.xtras:U}
+
+# Cleanup a buildworld's WORLDTMP so that any files generated from it
+# or using it will rebuild with the DIRDEPS SYSROOT. Otherwise existing
+# object .meta files may still reference those directories and not be
+# rebuilt and lead to incorrect Makefile.depend files due to lack of
+# .dirdep files.
+.if !defined(NO_CLEANUP_WORLDTMP) && exists(${OBJTOP}/tmp/_worldtmp)
+cleanup_worldtmp: .PHONY .NOMETA
+ @echo "Cleaning leftover WORLDTMP from buildworld."
+ -rm -rf ${OBJTOP}/tmp/*
+ -chflags -R 0 ${OBJTOP}/tmp/*
+ rm -rf ${OBJTOP}/tmp
+beforedirdeps: cleanup_worldtmp
+.endif
.endif
# reset this each time