git: 2b7c1402f96b - main - src.sys.obj.mk: Export OBJTOP

From: Simon J. Gerraty <sjg_at_FreeBSD.org>
Date: Tue, 28 May 2024 18:52:50 UTC
The branch main has been updated by sjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=2b7c1402f96be2d2986738e32706dab7b5691ef0

commit 2b7c1402f96be2d2986738e32706dab7b5691ef0
Author:     Simon J. Gerraty <sjg@FreeBSD.org>
AuthorDate: 2024-05-28 18:51:31 +0000
Commit:     Simon J. Gerraty <sjg@FreeBSD.org>
CommitDate: 2024-05-28 18:51:31 +0000

    src.sys.obj.mk: Export OBJTOP
    
    If we had to set OBJTOP we want to .export it (if .MAKE.LEVEL > 0)
    for the benefit of things like x!= ${.MAKE} -r ... and similar.
    
    Without OBJTOP, the default MAKEOBJDIR setting will result in
    attempting to use an objdir like /lib or /bin etc in some cases.
    
    This patch is based on D30990
    with the addition of the check for level > 0.
    
    Reviewed by: jrtc27
    Differential Revision:        <https://reviews.freebsd.org/D30990>
---
 share/mk/src.sys.obj.mk | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/share/mk/src.sys.obj.mk b/share/mk/src.sys.obj.mk
index 708559edcdb8..e4c31f746f3d 100644
--- a/share/mk/src.sys.obj.mk
+++ b/share/mk/src.sys.obj.mk
@@ -94,6 +94,9 @@ OBJTOP:=	${OBJROOT}${MACHINE}.${MACHINE_ARCH}
 # TARGET.TARGET_ARCH handled in OBJROOT already.
 OBJTOP:=	${OBJROOT:H}
 .endif	# ${MK_UNIFIED_OBJDIR} == "yes"
+.if ${.MAKE.LEVEL} > 0
+.export OBJTOP
+.endif
 .endif	# empty(OBJTOP)
 
 # Fixup OBJROOT/OBJTOP if using MAKEOBJDIRPREFIX.