git: 81ec547fbd3f - main - bsd.endian.mk: Allow for the cross building case

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 04 Jan 2022 23:18:34 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=81ec547fbd3f7b9840df2af86a01aeb0c4baf37e

commit 81ec547fbd3f7b9840df2af86a01aeb0c4baf37e
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-01-04 23:17:17 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-01-04 23:17:17 +0000

    bsd.endian.mk: Allow for the cross building case
    
    We need to include bsd.endian.mk from bsd.compiler.mk to enable
    compressed symbols only on FreeBSD little endian targets.
    
    However, since we include bsd.compiler.mk from Makefile.inc1 and from
    the build tools makefiles, it has to work on Linux and osx. Make the
    error condition only when we're building natively (so that we are
    forced to add a new architecture to the list).
    
    Otherwise, define bogus, poisoned values and leave TARGET_ENDIANNESS
    undefined.  Since we don't actually use TARGET_ENDIANNESS for anything
    in the cross building phase, these values are a failsafe agianst their
    use. The one place in the build phase that detects endian is
    appropriately protected.
    
    Sponsored by:           Netflix
    Reviewed by:            jrtc27
    Differential Revision:  https://reviews.freebsd.org/D33742
---
 share/mk/bsd.endian.mk | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/share/mk/bsd.endian.mk b/share/mk/bsd.endian.mk
index a6c66ef7f961..61a71add062d 100644
--- a/share/mk/bsd.endian.mk
+++ b/share/mk/bsd.endian.mk
@@ -15,6 +15,16 @@ LOCALEDEF_ENDIAN= -l
 TARGET_ENDIANNESS= 4321
 CAP_MKDB_ENDIAN= -b
 LOCALEDEF_ENDIAN= -b
-.else
+.elif ${.MAKE.OS} == "FreeBSD"
 .error "Don't know the endian of this architecture"
+.else
+#
+# During bootstrapping on !FreeBSD OSes, we need to define some value.  Short of
+# having an exhaustive list for all variants of Linux and MacOS we simply do not
+# set TARGET_ENDIANNESS and poison the other variables. They should be unused
+# during the bootstrap phases (apart from one place that's adequately protected
+# in bsd.compiler.mk) where we're building the bootstrap tools.
+#
+CAP_MKDB_ENDIAN= -B	# Poisoned value, invalid flags for both cap_mkdb
+LOCALEDEF_ENDIAN= -B	# and localedef.
 .endif