diff --git a/share/mk/auto.obj.mk b/share/mk/auto.obj.mk index aefaac46749d..b633937674be 100644 --- a/share/mk/auto.obj.mk +++ b/share/mk/auto.obj.mk @@ -42,6 +42,10 @@ MKOBJDIRS= auto # Use __objdir here so it is easier to tweak without impacting # the logic. .if !empty(MAKEOBJDIRPREFIX) +.if ${.CURDIR:M${MAKEOBJDIRPREFIX}/*} != "" +# we are already in obj tree! +__objdir?= ${.CURDIR} +.endif __objdir?= ${MAKEOBJDIRPREFIX}${.CURDIR} .endif __objdir?= ${MAKEOBJDIR:Uobj}