git: 39f6f6f1c6f8 - main - libmagic: Use HOST_CC when compiling hostprog used by build

From: Stephen J. Kiernan <stevek_at_FreeBSD.org>
Date: Wed, 27 Mar 2024 23:18:59 UTC
The branch main has been updated by stevek:

URL: https://cgit.FreeBSD.org/src/commit/?id=39f6f6f1c6f81fa93f3d0711d5ea222a8936ffd1

commit 39f6f6f1c6f81fa93f3d0711d5ea222a8936ffd1
Author:     Stephen J. Kiernan <stevek@FreeBSD.org>
AuthorDate: 2024-03-27 22:02:32 +0000
Commit:     Stephen J. Kiernan <stevek@FreeBSD.org>
CommitDate: 2024-03-27 23:18:43 +0000

    libmagic: Use HOST_CC when compiling hostprog used by build
    
    The "mkmagic" program should be built with the host compiler.
    
    Only use BTOOLSPATH if not building for host
    
    Obtained from:  Juniper Networks, Inc.
    Reviewed by:    sjg
    Differential Revision:  https://reviews.freebsd.org/D44539
---
 lib/libmagic/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/libmagic/Makefile b/lib/libmagic/Makefile
index 5aff4c1a478d..150ddc686241 100644
--- a/lib/libmagic/Makefile
+++ b/lib/libmagic/Makefile
@@ -59,12 +59,13 @@ magic.mgc: magic
 CLEANFILES+=	mkmagic
 DEPENDOBJS+=	mkmagic
 build-tools: mkmagic
+# For the non-dirdeps build, HOST_CC is CC by default
 mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${INCS} ${BUILD_TOOLS_META}
-	${CC:N${CCACHE_BIN}} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} \
+	${HOST_CC:N${CCACHE_BIN}} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} \
 	    ${.ALLSRC:N*.h:O:u} ${LDADD}
 
 .endif
-.if ${MK_DIRDEPS_BUILD} == "yes"
+.if ${MK_DIRDEPS_BUILD} == "yes" && ${MACHINE} != "host"
 BTOOLSPATH= ${HOST_OBJTOP}/${RELDIR}
 .else
 magic.mgc: mkmagic