diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk index 002f41e2d164..c6bf68b067f4 100644 --- a/share/mk/bsd.dep.mk +++ b/share/mk/bsd.dep.mk @@ -327,6 +327,10 @@ cleandepend: .endif .ORDER: cleandepend all .ORDER: cleandepend depend +.if ${MK_AUTO_OBJ} == "yes" +.ORDER: cleanobj depend +.ORDER: cleandir depend +.endif .if !target(checkdpadd) && (defined(DPADD) || defined(LDADD)) _LDADD_FROM_DPADD= ${DPADD:R:T:C;^lib(.*)$;-l\1;g} diff --git a/share/mk/bsd.init.mk b/share/mk/bsd.init.mk index 681a25b5ac97..f3851745a44d 100644 --- a/share/mk/bsd.init.mk +++ b/share/mk/bsd.init.mk @@ -64,7 +64,8 @@ _SKIP_BUILD= not building at level 0 ${.TARGETS:M*install*} == ${.TARGETS} || \ ${.TARGETS:Mclean*} == ${.TARGETS} || \ ${.TARGETS:Mdestroy*} == ${.TARGETS} || \ - make(obj) || make(analyze) || make(print-dir) + ${.TARGETS:Mobj} == ${.TARGETS} || \ + make(analyze) || make(print-dir) # Skip building, but don't show a warning. _SKIP_BUILD= .endif diff --git a/share/mk/bsd.obj.mk b/share/mk/bsd.obj.mk index d93e970af8a5..34ac227cd203 100644 --- a/share/mk/bsd.obj.mk +++ b/share/mk/bsd.obj.mk @@ -164,7 +164,8 @@ whereobj: .endif # Same check in bsd.progs.mk -.if ${CANONICALOBJDIR} != ${.CURDIR} && exists(${CANONICALOBJDIR}/) +.if ${CANONICALOBJDIR} != ${.CURDIR} && exists(${CANONICALOBJDIR}/) && \ + (${MK_AUTO_OBJ} == "no" || ${.TARGETS:Nclean*:N*clean:Ndestroy*} == "") cleanobj: -rm -rf ${CANONICALOBJDIR} .else @@ -188,6 +189,10 @@ clean: .endif .endif .ORDER: clean all +.if ${MK_AUTO_OBJ} == "yes" +.ORDER: cleanobj all +.ORDER: cleandir all +.endif .include