cleankernel: A target to delete the kernel compile file

With the meta-build, it's always a NO_CLEAN build. Provide a way to
remove so one can rebuild from scratch. 'cleankernel' will delete the
kernel and modules object directories. Document this in build(7).

Sponsored by:		Netflix
Reviewed by:		debdrup, markj
Differential Revision:	https://reviews.freebsd.org/D32978
This commit is contained in:
Warner Losh 2022-02-11 12:50:51 -07:00
parent d4b0fa45dc
commit 3e65b7d94d
3 changed files with 14 additions and 7 deletions

View File

@ -1,7 +1,7 @@
# #
# $FreeBSD$ # $FreeBSD$
# #
# The user-driven targets are: # The common user-driven targets are (for a complete list, see build(7)):
# #
# universe - *Really* build *everything* (buildworld and # universe - *Really* build *everything* (buildworld and
# all kernels on all architectures). Define # all kernels on all architectures). Define
@ -148,8 +148,8 @@ __DO_KERNELS?=yes
TGTS= all all-man buildenv buildenvvars buildkernel buildworld \ TGTS= all all-man buildenv buildenvvars buildkernel buildworld \
check check-old check-old-dirs check-old-files check-old-libs \ check check-old check-old-dirs check-old-files check-old-libs \
checkdpadd checkworld clean cleandepend cleandir cleanworld \ checkdpadd checkworld clean cleandepend cleandir cleankernel \
cleanuniverse \ cleanworld cleanuniverse \
delete-old delete-old-dirs delete-old-files delete-old-libs \ delete-old delete-old-dirs delete-old-files delete-old-libs \
depend distribute distributekernel distributekernel.debug \ depend distribute distributekernel distributekernel.debug \
distributeworld distrib-dirs distribution doxygen \ distributeworld distrib-dirs distribution doxygen \

View File

@ -3420,18 +3420,20 @@ builddtb: .PHONY
# #
.if make(cleanworld) .if make(cleanworld)
BW_CANONICALOBJDIR:=${OBJTOP}/ BW_CANONICALOBJDIR:=${OBJTOP}/
.elif make(cleankernel)
BW_CANONICALOBJDIR:=${KRNLOBJDIR}/${KERNCONF}/
.elif make(cleanuniverse) .elif make(cleanuniverse)
BW_CANONICALOBJDIR:=${OBJROOT} BW_CANONICALOBJDIR:=${OBJROOT}
.if ${MK_UNIFIED_OBJDIR} == "no" .if ${MK_UNIFIED_OBJDIR} == "no"
.error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled. .error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled.
.endif .endif
.endif .endif
cleanworld cleanuniverse: .PHONY cleanworld cleanuniverse cleankernel: .PHONY
.if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \ .if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \
${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA} ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA}
-rm -rf ${BW_CANONICALOBJDIR}* -(cd ${BW_CANONICALOBJDIR} && rm -rf *)
-chflags -R 0 ${BW_CANONICALOBJDIR} -chflags -R 0 ${BW_CANONICALOBJDIR}
rm -rf ${BW_CANONICALOBJDIR}* -(cd ${BW_CANONICALOBJDIR} && rm -rf *)
.endif .endif
.if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \ .if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \
(empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA}) (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA})

View File

@ -216,10 +216,15 @@ for native builds, and
for cross builds and native builds with variable for cross builds and native builds with variable
.Va CROSS_BUILD_TESTING .Va CROSS_BUILD_TESTING
set. set.
.It Cm cleankernel
Attempts to clean up targets built by a preceding
.Cm buildkernel ,
or similar step, built from the same source directory and
.Va KERNCONF .
.It Cm cleanworld .It Cm cleanworld
Attempt to clean up targets built by a preceding Attempt to clean up targets built by a preceding
.Cm buildworld , .Cm buildworld ,
or similar step built from this source directory. or similar step, built from this source directory.
.It Cm cleanuniverse .It Cm cleanuniverse
When When
.Va WITH_UNIFIED_OBJDIR .Va WITH_UNIFIED_OBJDIR