On 2026-09-04 12:11, Wolfram Schneider wrote:
I have problems with cross compiling on macos now:
Can you try if attached patch helps?
From cf55bdb4933625f6a140255a21593f47ebb37cf6 Mon Sep 17 00:00:00 2001
From: Xin LI <[email protected]>
Date: Fri, 4 Sep 2026 18:03:17 -0700
Subject: [PATCH] libmagic: Add swap.c and magic.h to SRCS.

file 5.48 added swap.c and swap.h for byte-swapping operations, which are
required on hosts that lack <byteswap.h> or <sys/bswap.h> (e.g. macOS 
cross-building
or older FreeBSD bootstrap environments).

Also add magic.h to SRCS so object files depend on the generated header
before compiling, avoiding falling back to the host's /usr/include/magic.h
during parallel builds.

Reported by:    wosch
MFC after:      1 week
Fixes:          7af41682a96b ("MFV: file 5.48")
---
 lib/libmagic/Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/libmagic/Makefile b/lib/libmagic/Makefile
index fe04f5ea68c8..bbb02eb7e7bf 100644
--- a/lib/libmagic/Makefile
+++ b/lib/libmagic/Makefile
@@ -19,7 +19,9 @@ SRCS= apprentice.c apptype.c ascmagic.c buffer.c cdf.c 
cdf_time.c \
        compress.c der.c encoding.c fsmagic.c funcs.c is_json.c \
        is_csv.c \
        is_simh.c \
-       is_tar.c magic.c print.c readcdf.c readelf.c seccomp.c softmagic.c
+       is_tar.c magic.c print.c readcdf.c readelf.c seccomp.c softmagic.c \
+       swap.c
+SRCS+= magic.h
 INCS=  magic.h
 
 MAGICPATH?=    /usr/share/misc
@@ -62,7 +64,7 @@ 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}
+mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c swap.c 
${INCS} ${BUILD_TOOLS_META}
        ${HOST_CC:N${CCACHE_BIN}} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o 
${.TARGET} \
            ${.ALLSRC:N*.h:O:u} ${LDADD}
 
-- 
2.50.1 (Apple Git-155)

Reply via email to