git: cf20b1f81c10 - main - Extract some of local.meta.sys.mk to local.meta.sys.env.mk

From: Simon J. Gerraty <sjg_at_FreeBSD.org>
Date: Sat, 22 Apr 2023 22:08:28 UTC
The branch main has been updated by sjg:

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

commit cf20b1f81c1043faca2a5e4fe16bc48679494fe0
Author:     Simon J. Gerraty <sjg@FreeBSD.org>
AuthorDate: 2023-04-22 22:07:53 +0000
Commit:     Simon J. Gerraty <sjg@FreeBSD.org>
CommitDate: 2023-04-22 22:07:53 +0000

    Extract some of local.meta.sys.mk to local.meta.sys.env.mk
    
    Latest meta.sys.mk follows sys.mk in including local.meta.sys.env.mk
    and local.meta.sys.mk late, but we have things we need done early
    so move them to local.meta.sys.env.mk
---
 share/mk/local.meta.sys.env.mk | 90 ++++++++++++++++++++++++++++++++++++++++++
 share/mk/local.meta.sys.mk     | 85 +--------------------------------------
 share/mk/local.sys.env.mk      |  5 ---
 3 files changed, 91 insertions(+), 89 deletions(-)

diff --git a/share/mk/local.meta.sys.env.mk b/share/mk/local.meta.sys.env.mk
new file mode 100644
index 000000000000..937b9c10bc3b
--- /dev/null
+++ b/share/mk/local.meta.sys.env.mk
@@ -0,0 +1,90 @@
+# $FreeBSD$
+
+# local configuration specific to meta mode
+# before we process TARGET_SPEC
+# we assume that MK_DIRDEPS_BUILD=yes
+
+.if !defined(HOST_TARGET) || !defined(HOST_MACHINE)
+# we need HOST_TARGET etc below.
+.include <host-target.mk>
+.export HOST_TARGET
+.endif
+
+# from src/Makefile (for universe)
+TARGET_ARCHES_arm?=     arm armv6 armv7
+TARGET_ARCHES_arm64?=   aarch64
+TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpc64le powerpcspe
+TARGET_ARCHES_riscv?=   riscv64
+
+# some corner cases
+BOOT_MACHINE_DIR.amd64 = boot/i386
+MACHINE_ARCH.host = ${_HOST_ARCH}
+
+# the list of machines we support
+ALL_MACHINE_LIST?= amd64 arm arm64 i386 powerpc riscv
+
+.-include <site.meta.sys.env.mk>
+
+.for m in ${ALL_MACHINE_LIST:O:u}
+MACHINE_ARCH_LIST.$m?= ${TARGET_ARCHES_${m}:U$m}
+MACHINE_ARCH.$m?= ${MACHINE_ARCH_LIST.$m:[1]}
+BOOT_MACHINE_DIR.$m ?= boot/$m
+.endfor
+
+.if empty(MACHINE_ARCH)
+.if !empty(TARGET_ARCH)
+MACHINE_ARCH= ${TARGET_ARCH}
+.else
+MACHINE_ARCH= ${MACHINE_ARCH.${MACHINE}}
+.endif
+.endif
+MACHINE_ARCH?= ${MACHINE_ARCH.${MACHINE}}
+MACHINE_ARCH:= ${MACHINE_ARCH}
+
+# For universe we want to potentially
+# build for multiple MACHINE_ARCH per MACHINE
+# so we need more than MACHINE in TARGET_SPEC
+TARGET_SPEC_VARS?= MACHINE MACHINE_ARCH
+
+HOST_OBJTOP ?= ${OBJROOT}${HOST_TARGET}
+
+.if ${REQUESTED_MACHINE:U${MACHINE}} == "host"
+MACHINE= host
+.if ${TARGET_MACHINE:Uno} == ${HOST_TARGET}
+# not what we want
+TARGET_MACHINE= host
+.endif
+.endif
+.if ${MACHINE} == "host"
+OBJTOP := ${HOST_OBJTOP}
+MACHINE_ARCH= ${MACHINE_ARCH.${MACHINE}}
+.endif
+
+.if ${.MAKE.LEVEL} == 0 || empty(PYTHON)
+PYTHON ?= /usr/local/bin/python
+.export PYTHON
+# _SKIP_BUILD is not 100% as it requires wrapping all 'all:' targets to avoid
+# building in MAKELEVEL0.  Just prohibit 'all' entirely in this case to avoid
+# problems.
+.if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.LEVEL} == 0
+.MAIN: dirdeps
+.if make(all)
+.error DIRDEPS_BUILD: Please run '${MAKE}' instead of '${MAKE} all'.
+.endif
+.endif
+.endif
+
+# this is sufficient for most of the tree.
+.MAKE.DEPENDFILE_DEFAULT = ${.MAKE.DEPENDFILE_PREFIX}
+
+# but if we have a machine qualified file it should be used in preference
+.MAKE.DEPENDFILE_PREFERENCE = \
+	${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \
+	${.MAKE.DEPENDFILE_PREFIX}
+
+.undef .MAKE.DEPENDFILE
+
+META_MODE+=	missing-meta=yes
+.if empty(META_MODE:Mnofilemon)
+META_MODE+=	missing-filemon=yes
+.endif
diff --git a/share/mk/local.meta.sys.mk b/share/mk/local.meta.sys.mk
index 6e03a99d7dfe..7747329694ff 100644
--- a/share/mk/local.meta.sys.mk
+++ b/share/mk/local.meta.sys.mk
@@ -6,43 +6,8 @@
 # we need this until there is an alternative
 MK_INSTALL_AS_USER= yes
 
-.if !defined(HOST_TARGET) || !defined(HOST_MACHINE)
-# we need HOST_TARGET etc below.
-.include <host-target.mk>
-.export HOST_TARGET
-.endif
-
-# from src/Makefile (for universe)
-TARGET_ARCHES_arm?=     arm armv6 armv7
-TARGET_ARCHES_arm64?=   aarch64
-TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpc64le powerpcspe
-TARGET_ARCHES_riscv?=   riscv64
-
-# some corner cases
-BOOT_MACHINE_DIR.amd64 = boot/i386
-MACHINE_ARCH.host = ${_HOST_ARCH}
-
-# the list of machines we support
-ALL_MACHINE_LIST?= amd64 arm arm64 i386 powerpc riscv
-
 .-include <site.meta.sys.mk>
 
-.for m in ${ALL_MACHINE_LIST:O:u}
-MACHINE_ARCH_LIST.$m?= ${TARGET_ARCHES_${m}:U$m}
-MACHINE_ARCH.$m?= ${MACHINE_ARCH_LIST.$m:[1]}
-BOOT_MACHINE_DIR.$m ?= boot/$m
-.endfor
-
-.if empty(MACHINE_ARCH)
-.if !empty(TARGET_ARCH)
-MACHINE_ARCH= ${TARGET_ARCH}
-.else
-MACHINE_ARCH= ${MACHINE_ARCH.${MACHINE}}
-.endif
-.endif
-MACHINE_ARCH?= ${MACHINE_ARCH.${MACHINE}}
-MACHINE_ARCH:= ${MACHINE_ARCH}
-
 # to be consistent with src/Makefile just concatenate with '.'s
 TARGET_OBJ_SPEC:= ${TARGET_SPEC:S;,;.;g}
 OBJTOP:= ${OBJROOT}${TARGET_OBJ_SPEC}
@@ -53,33 +18,6 @@ OBJTOP:= ${OBJROOT}${TARGET_OBJ_SPEC}
 .endif
 .endif
 
-HOST_OBJTOP ?= ${OBJROOT}${HOST_TARGET}
-
-.if ${OBJTOP} == ${HOST_OBJTOP} || ${REQUESTED_MACHINE:U${MACHINE}} == "host"
-MACHINE= host
-.if ${TARGET_MACHINE:Uno} == ${HOST_TARGET}
-# not what we want
-TARGET_MACHINE= host
-.endif
-.endif
-.if ${MACHINE} == "host"
-OBJTOP := ${HOST_OBJTOP}
-MACHINE_ARCH= ${MACHINE_ARCH.${MACHINE}}
-.endif
-
-.if ${.MAKE.LEVEL} == 0 || empty(PYTHON)
-PYTHON ?= /usr/local/bin/python
-.export PYTHON
-# _SKIP_BUILD is not 100% as it requires wrapping all 'all:' targets to avoid
-# building in MAKELEVEL0.  Just prohibit 'all' entirely in this case to avoid
-# problems.
-.if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.LEVEL} == 0
-.MAIN: dirdeps
-.if make(all)
-.error DIRDEPS_BUILD: Please run '${MAKE}' instead of '${MAKE} all'.
-.endif
-.endif
-.endif
 
 # we want to end up with a singe stage tree for all machines
 .if ${MK_STAGING} == "yes"
@@ -130,25 +68,9 @@ LDFLAGS_LAST+= -L${STAGE_LIBDIR}
 
 .-include "local.toolchain.mk"
 
-# this is sufficient for most of the tree.
-.MAKE.DEPENDFILE_DEFAULT = ${.MAKE.DEPENDFILE_PREFIX}
-
-# but if we have a machine qualified file it should be used in preference
-.MAKE.DEPENDFILE_PREFERENCE = \
-	${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \
-	${.MAKE.DEPENDFILE_PREFIX}
-
-.undef .MAKE.DEPENDFILE
-
-.include "sys.dependfile.mk"
-
 .if ${.MAKE.LEVEL} > 0 && ${MACHINE} == "host" && ${.MAKE.DEPENDFILE:E} != "host"
 # we can use this but should not update it.
-UPDATE_DEPENDFILE= NO
-.endif
-# Don't require filemon for makeman.
-.if make(showconfig)
-UPDATE_DEPENDFILE= NO
+UPDATE_DEPENDFILE?= NO
 .endif
 
 # define the list of places that contain files we are responsible for
@@ -232,11 +154,6 @@ CFLAGS+= ${CROSS_TARGET_FLAGS}
 ACFLAGS+= ${CROSS_TARGET_FLAGS}
 .endif
 
-META_MODE+=	missing-meta=yes
-.if empty(META_MODE:Mnofilemon)
-META_MODE+=	missing-filemon=yes
-.endif
-
 .if ${MK_DIRDEPS_BUILD} == "yes"
 # we set these here, rather than local.gendirdeps.mk
 # so we can ensure any DEP_* values that might be used in
diff --git a/share/mk/local.sys.env.mk b/share/mk/local.sys.env.mk
index 626aafe61270..e3348537db41 100644
--- a/share/mk/local.sys.env.mk
+++ b/share/mk/local.sys.env.mk
@@ -50,8 +50,3 @@ ECHO_TRACE?=	true
 
 .include "src.sys.env.mk"
 .-include <site.sys.env.mk>
-
-# For universe we want to potentially
-# build for multiple MACHINE_ARCH per MACHINE
-# so we need more than MACHINE in TARGET_SPEC
-TARGET_SPEC_VARS?= MACHINE MACHINE_ARCH