Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 May 2023 23:16:25 GMT
From:      "Simon J. Gerraty" <sjg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: bee3d4bf8ed5 - main - Move DIRDEPS_BUILD settings to sys.dirdeps.mk
Message-ID:  <202305112316.34BNGPYr032398@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by sjg:

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

commit bee3d4bf8ed55260d8cfc6d168ffa1afb49ef6a8
Author:     Simon J. Gerraty <sjg@FreeBSD.org>
AuthorDate: 2023-05-11 23:15:04 +0000
Commit:     Simon J. Gerraty <sjg@FreeBSD.org>
CommitDate: 2023-05-11 23:15:04 +0000

    Move DIRDEPS_BUILD settings to sys.dirdeps.mk
    
    When originally implemented, there was no distinction between
    DIRDEPS_BUILD and META_MODE, they were one and the same.
    
    META_MODE however is useful by itself, but since meta.sys.mk
    had lots of settings related to DIRDEPS_BUILD its use was limited
    to DIRDEPS_BUILD.
    
    Move (most) DIRDEPS_BUILD related items to sys.dirdeps.mk
    so that meta.sys.mk can be used for just META_MODE.
    There is of course some bluring of the lines, so settings remain
    in meta.sys.mk
    
    Add MK_META_ERROR_TARGET to enable the META_MODE .ERROR target
    independent of DIRDEPS_BUILD, it copies failed .meta files to ${SB}/error
    to make it easier to identify the cause of build failures.
    
    Since sys.dirdeps.mk should be included first, most of
    local.meta.sys.mk becomes local.sys.dirdeps.mk
    and some other bits need to move to local.sys.dirdeps.env.mk
    
    Also fix dirdeps.mk to not add CURDIR to DIRDEPS when it is SRCTOP.
    
    Reviewed by:    bdrewery
    Differential Revision:  https://reviews.freebsd.org/D40053
---
 share/mk/dirdeps.mk                                |   8 +-
 share/mk/local.meta.sys.env.mk                     |  29 +---
 share/mk/local.sys.dirdeps.env.mk                  |  14 ++
 .../mk/{local.meta.sys.mk => local.sys.dirdeps.mk} |  33 +---
 share/mk/local.sys.env.mk                          |   6 +
 share/mk/meta.sys.mk                               | 114 +++----------
 share/mk/src.sys.obj.mk                            |   5 -
 share/mk/sys.dependfile.mk                         |  18 +-
 share/mk/sys.dirdeps.mk                            | 183 +++++++++++++++++++++
 share/mk/sys.mk                                    |  21 +--
 10 files changed, 253 insertions(+), 178 deletions(-)

diff --git a/share/mk/dirdeps.mk b/share/mk/dirdeps.mk
index 83b620044aa5..aafa5ab47557 100644
--- a/share/mk/dirdeps.mk
+++ b/share/mk/dirdeps.mk
@@ -1,4 +1,4 @@
-# $Id: dirdeps.mk,v 1.158 2023/05/04 18:26:17 sjg Exp $
+# $Id: dirdeps.mk,v 1.160 2023/05/10 20:44:58 sjg Exp $
 
 # SPDX-License-Identifier: BSD-2-Clause
 #
@@ -273,6 +273,10 @@ _machine_dependfiles := ${.MAKE.DEPENDFILE_PREFERENCE:T:M*${MACHINE}*}
 .endif
 .endif
 
+# turn a list into a set of :N modifiers
+# NskipFoo = ${Foo:${M_ListToSkip}}
+M_ListToSkip ?= O:u:S,^,N,:ts:
+
 # this is how we identify non-machine specific dependfiles
 N_notmachine := ${.MAKE.DEPENDFILE_PREFERENCE:E:N*${MACHINE}*:${M_ListToSkip}}
 
@@ -661,7 +665,7 @@ _machines := ${_machines:${M_dep_qual_fixes:ts:}:O:u}
 # reset each time through
 _build_dirs =
 
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+.if ${DEP_RELDIR} == ${_DEP_RELDIR} && ${_CURDIR} != ${SRCTOP}
 # pickup other machines for this dir if necessary
 _build_dirs += ${_machines:@m@${_CURDIR}.$m@}
 .endif
diff --git a/share/mk/local.meta.sys.env.mk b/share/mk/local.meta.sys.env.mk
index 6d0d493f1047..f109da4f39dd 100644
--- a/share/mk/local.meta.sys.env.mk
+++ b/share/mk/local.meta.sys.env.mk
@@ -4,12 +4,6 @@
 # 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
@@ -41,11 +35,6 @@ MACHINE_ARCH= ${MACHINE_ARCH.${MACHINE}}
 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"
@@ -74,17 +63,13 @@ PYTHON ?= /usr/local/bin/python
 .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 !defined(NO_META_MISSING)
+META_MODE+=    missing-meta=yes
+.endif
+# silent will hide command output if a .meta file is created.
+.if !defined(NO_SILENT)
+META_MODE+=    silent=yes
+.endif
 .if empty(META_MODE:Mnofilemon)
 META_MODE+=	missing-filemon=yes
 .endif
diff --git a/share/mk/local.sys.dirdeps.env.mk b/share/mk/local.sys.dirdeps.env.mk
new file mode 100644
index 000000000000..ab22f4c9e7d9
--- /dev/null
+++ b/share/mk/local.sys.dirdeps.env.mk
@@ -0,0 +1,14 @@
+
+# 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
+ 
+# 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}
+
diff --git a/share/mk/local.meta.sys.mk b/share/mk/local.sys.dirdeps.mk
similarity index 85%
rename from share/mk/local.meta.sys.mk
rename to share/mk/local.sys.dirdeps.mk
index 9d66e7295a0a..00030cb247bb 100644
--- a/share/mk/local.meta.sys.mk
+++ b/share/mk/local.sys.dirdeps.mk
@@ -6,39 +6,13 @@
 # we need this until there is an alternative
 MK_INSTALL_AS_USER= yes
 
+.-include <site.sys.dirdeps.mk>
+# previously only included for DIRDEPS_BUILD anyway
 .-include <site.meta.sys.mk>
 
-# to be consistent with src/Makefile just concatenate with '.'s
-TARGET_OBJ_SPEC:= ${TARGET_SPEC:S;,;.;g}
-.if ${MACHINE} != "host"
-OBJTOP:= ${OBJROOT}${TARGET_OBJ_SPEC}
-.endif
-
-.if defined(MAKEOBJDIR)
-.if ${MAKEOBJDIR:M/*} == ""
-.error Cannot use MAKEOBJDIR=${MAKEOBJDIR}${.newline}Unset MAKEOBJDIR to get default:  MAKEOBJDIR='${_default_makeobjdir}'
-.endif
-.endif
-
-
-# we want to end up with a singe stage tree for all machines
 .if ${MK_STAGING} == "yes"
-.if empty(STAGE_ROOT)
-STAGE_ROOT?= ${OBJROOT}stage
-.export STAGE_ROOT
-.endif
-.endif
 
-.if ${MK_STAGING} == "yes"
-.if ${MACHINE} == "host"
-STAGE_MACHINE= ${HOST_TARGET}
-.else
-STAGE_MACHINE:= ${TARGET_OBJ_SPEC}
-.endif
-STAGE_OBJTOP:= ${STAGE_ROOT}/${STAGE_MACHINE}
-STAGE_COMMON_OBJTOP:= ${STAGE_ROOT}/common
 STAGE_TARGET_OBJTOP:= ${STAGE_ROOT}/${TARGET_OBJ_SPEC}
-STAGE_HOST_OBJTOP:= ${STAGE_ROOT}/${HOST_TARGET}
 # These are exported for hooking in out-of-tree builds.  They will always
 # be overridden in sub-makes above when building in-tree.
 .if ${.MAKE.LEVEL} > 0
@@ -156,7 +130,6 @@ CFLAGS+= ${CROSS_TARGET_FLAGS}
 ACFLAGS+= ${CROSS_TARGET_FLAGS}
 .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
 # conditionals do not cause syntax errors when Makefile.depend
@@ -185,5 +158,3 @@ $V?= ${${V:S,DEP_,,}}
 # some makefiles expect this
 BOOTSTRAPPING= 0
 .endif
-
-.endif
diff --git a/share/mk/local.sys.env.mk b/share/mk/local.sys.env.mk
index e3348537db41..e10bf58e14e8 100644
--- a/share/mk/local.sys.env.mk
+++ b/share/mk/local.sys.env.mk
@@ -50,3 +50,9 @@ ECHO_TRACE?=	true
 
 .include "src.sys.env.mk"
 .-include <site.sys.env.mk>
+
+.if !defined(HOST_TARGET) || !defined(HOST_MACHINE)
+# we need HOST_TARGET etc below.
+.include <host-target.mk>
+.export HOST_TARGET
+.endif
diff --git a/share/mk/meta.sys.mk b/share/mk/meta.sys.mk
index f580f4962be8..ba213dd49da4 100644
--- a/share/mk/meta.sys.mk
+++ b/share/mk/meta.sys.mk
@@ -1,7 +1,7 @@
-# $Id: meta.sys.mk,v 1.48 2023/05/04 16:41:10 sjg Exp $
+# $Id: meta.sys.mk,v 1.51 2023/05/11 20:05:32 sjg Exp $
 
 #
-#	@(#) Copyright (c) 2010-2021, Simon J. Gerraty
+#	@(#) Copyright (c) 2010-2023, Simon J. Gerraty
 #
 #	This file is provided in the hope that it will
 #	be of use.  There is absolutely NO WARRANTY.
@@ -17,56 +17,21 @@
 # include this if you want to enable meta mode
 # for maximum benefit, requires filemon(4) driver.
 
-.if ${MAKE_VERSION:U0} > 20100901
-.if !target(.ERROR)
+# absolute path to what we are reading.
+_PARSEDIR ?= ${.PARSEDIR:tA}
 
 .-include <local.meta.sys.env.mk>
 
-# If TARGET_SPEC_VARS is other than just MACHINE
-# it should be set by now.
-# TARGET_SPEC must not contain any '.'s.
-TARGET_SPEC_VARS ?= MACHINE
-
-.if !target(_meta_tspec_env_done_)
-_meta_tspec_env_done_: .NOTMAIN
-# Allow for local.meta.sys.env.mk to have done this
-
-.if ${TARGET_SPEC:Uno:M*,*} != ""
-# deal with TARGET_SPEC from env
-_tspec := ${TARGET_SPEC:S/,/ /g}
-.for i in ${TARGET_SPEC_VARS:${M_RANGE:Urange}}
-${TARGET_SPEC_VARS:[$i]} := ${_tspec:[$i]}
-.endfor
-# We need to stop that TARGET_SPEC affecting any submakes
-TARGET_SPEC=
-# so export but do not track
-.export-env TARGET_SPEC
-.export ${TARGET_SPEC_VARS}
-.for v in ${TARGET_SPEC_VARS:O:u}
-.if empty($v)
-.undef $v
-.endif
-.endfor
-.endif
-.endif
-
-# Now make sure we know what TARGET_SPEC is
-# as we may need it to find Makefile.depend*
-.if ${MACHINE:Mhost*} != ""
-# host is special
-TARGET_SPEC = ${MACHINE}
-.else
-TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
-.endif
-
-# absolute path to what we are reading.
-_PARSEDIR = ${.PARSEDIR:tA}
-
 .if !defined(SYS_MK_DIR)
 SYS_MK_DIR := ${_PARSEDIR}
 .endif
 
-META_MODE += meta verbose
+.if !target(.ERROR)
+
+META_MODE += meta
+.if empty(.MAKEFLAGS:M-s)
+META_MODE += verbose
+.endif
 .if ${MAKE_VERSION:U0} > 20130323 && empty(.MAKE.PATH_FILEMON)
 # we do not support filemon
 META_MODE += nofilemon
@@ -102,19 +67,7 @@ META_MODE += silent=yes
 .endif
 .endif
 
-# we use the pseudo machine "host" for the build host.
-# this should be taken care of before we get here
-.if ${OBJTOP:Ua} == ${HOST_OBJTOP:Ub}
-MACHINE = host
-.endif
-
-.if !defined(MACHINE0)
-# it can be handy to know which MACHINE kicked off the build
-# for example, if using Makefild.depend for multiple machines,
-# allowing only MACHINE0 to update can keep things simple.
-MACHINE0 := ${MACHINE}
-.export MACHINE0
-.endif
+.if ${MK_DIRDEPS_BUILD:Uno} == "yes"
 
 .if !defined(META2DEPS)
 .if defined(PYTHON) && exists(${PYTHON})
@@ -134,6 +87,11 @@ MAKE_PRINT_VAR_ON_ERROR += \
 	MAKEFILE \
 	.MAKE.MODE
 
+MK_META_ERROR_TARGET = yes
+.endif
+
+.if ${MK_META_ERROR_TARGET:Uno} == "yes"
+
 .if !defined(SB) && defined(SRCTOP)
 SB = ${SRCTOP:H}
 .endif
@@ -150,21 +108,12 @@ _metaError: .NOMETA .NOTMAIN
 	echo "ERROR: log ${meta_error_log}" >&2; }; :
 
 .endif
+.endif
 
 # Are we, after all, in meta mode?
 .if ${.MAKE.MODE:Uno:Mmeta*} != ""
 MKDEP_MK ?= meta.autodep.mk
 
-.if ${.MAKE.MAKEFILES:M*sys.dependfile.mk} == ""
-# this does all the smarts of setting .MAKE.DEPENDFILE
-.-include <sys.dependfile.mk>
-# check if we got anything sane
-.if ${.MAKE.DEPENDFILE} == ".depend"
-.undef .MAKE.DEPENDFILE
-.endif
-.MAKE.DEPENDFILE ?= Makefile.depend
-.endif
-
 # we can afford to use cookies to prevent some targets
 # re-running needlessly
 META_COOKIE_TOUCH?= touch ${COOKIE.${.TARGET}:U${.OBJDIR}/${.TARGET:T}}
@@ -192,36 +141,13 @@ UPDATE_DEPENDFILE= NO
 .endif
 .endif
 
-.if ${.MAKE.LEVEL} == 0
-.if ${MK_DIRDEPS_BUILD:Uyes} == "yes"
-# make sure dirdeps target exists and do it first
-all: dirdeps .WAIT
-dirdeps:
-.NOPATH: dirdeps
-
-.if defined(ALL_MACHINES)
-# the first .MAIN: is what counts
-# by default dirdeps is all we want at level0
-.MAIN: dirdeps
-.endif
-.endif
+.else				# in meta mode?
 
-.else	# level > 0
-
-# Makefile.depend* get read at level 1+
-# and often refer to DEP_MACHINE etc,
-# so ensure DEP_* (for TARGET_SPEC_VARS anyway) are set
-.for V in ${TARGET_SPEC_VARS}
-DEP_$V = ${$V}
-.endfor
-
-.endif
-.else
 META_COOKIE_TOUCH=
 # some targets need to be .PHONY in non-meta mode
 META_NOPHONY= .PHONY
 META_NOECHO= echo
-.endif
-.endif
+
+.endif				# in meta mode?
 
 .-include <local.meta.sys.mk>
diff --git a/share/mk/src.sys.obj.mk b/share/mk/src.sys.obj.mk
index 3b48fc3c5514..3d2cf7043c96 100644
--- a/share/mk/src.sys.obj.mk
+++ b/share/mk/src.sys.obj.mk
@@ -220,11 +220,6 @@ OBJROOT=	${SRCTOP}/
 .endif
 .endif	# defined(NO_OBJ)
 
-.if !defined(HOST_TARGET)
-# we need HOST_TARGET etc below.
-.include <host-target.mk>
-.export HOST_TARGET
-.endif
 HOST_OBJTOP?=	${OBJROOT}${HOST_TARGET}
 
 .endif	# ${MK_DIRDEPS_BUILD} == "no"
diff --git a/share/mk/sys.dependfile.mk b/share/mk/sys.dependfile.mk
index 745873f6bfeb..49232646d569 100644
--- a/share/mk/sys.dependfile.mk
+++ b/share/mk/sys.dependfile.mk
@@ -1,20 +1,22 @@
-# $FreeBSD$
-# $Id: sys.dependfile.mk,v 1.7 2016/02/20 01:57:39 sjg Exp $
+# $Id: sys.dependfile.mk,v 1.10 2023/05/10 19:23:26 sjg Exp $
 #
-#	@(#) Copyright (c) 2012, Simon J. Gerraty
+#	@(#) Copyright (c) 2012-2023, Simon J. Gerraty
 #
 #	This file is provided in the hope that it will
 #	be of use.  There is absolutely NO WARRANTY.
 #	Permission to copy, redistribute or otherwise
-#	use this file is hereby granted provided that 
+#	use this file is hereby granted provided that
 #	the above copyright notice and this notice are
-#	left intact. 
-#      
+#	left intact.
+#
 #	Please send copies of changes and bug-fixes to:
 #	sjg@crufty.net
 #
 
-# This only makes sense in meta mode.
+.if !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__: .NOTMAIN
+
+# This only makes sense for DIRDEPS_BUILD.
 # This allows a mixture of auto generated as well as manually edited
 # dependency files, which can be differentiated by their names.
 # As per dirdeps.mk we only require:
@@ -58,3 +60,5 @@ MACHINE := ${_m}
 .endif
 .endif
 .MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_DEFAULT}
+
+.endif
diff --git a/share/mk/sys.dirdeps.mk b/share/mk/sys.dirdeps.mk
new file mode 100644
index 000000000000..845eda181b90
--- /dev/null
+++ b/share/mk/sys.dirdeps.mk
@@ -0,0 +1,183 @@
+# $Id: sys.dirdeps.mk,v 1.9 2023/05/11 20:05:42 sjg Exp $
+#
+#	@(#) Copyright (c) 2012-2023, Simon J. Gerraty
+#
+#	This file is provided in the hope that it will
+#	be of use.  There is absolutely NO WARRANTY.
+#	Permission to copy, redistribute or otherwise
+#	use this file is hereby granted provided that
+#	the above copyright notice and this notice are
+#	left intact.
+#
+#	Please send copies of changes and bug-fixes to:
+#	sjg@crufty.net
+#
+
+# Originally DIRDEPS_BUILD and META_MODE were the same thing.
+# So, much of this was done in *meta.sys.mk and local*mk
+# but properly belongs here.
+
+# Include from [local.]sys.mk - if doing DIRDEPS_BUILD
+# we should not be here otherwise
+MK_DIRDEPS_BUILD ?= yes
+# these are all implied
+MK_AUTO_OBJ ?= yes
+MK_META_MODE ?= yes
+MK_STAGING ?= yes
+
+_PARSEDIR ?= ${.PARSEDIR:tA}
+
+.-include <local.sys.dirdeps.env.mk>
+
+.if ${.MAKE.LEVEL} == 0
+# make sure dirdeps target exists and do it first
+dirdeps:
+# first .MAIN is what counts
+.MAIN: dirdeps
+.NOPATH: dirdeps
+all: dirdeps .WAIT
+.endif
+
+.if empty(SRCTOP)
+# fallback assumes share/mk!
+SRCTOP := ${SB_SRC:U${.PARSEDIR:tA:H:H}}
+.export SRCTOP
+.endif
+
+# fake SB if not using mk wrapper
+.if !defined(SB)
+SB := ${SRCTOP:H}
+.export SB
+.endif
+
+.if empty(OBJROOT)
+OBJROOT := ${SB_OBJROOT:U${MAKEOBJDIRPREFIX:U${SB}/obj}/}
+.export OBJROOT
+.endif
+
+.if empty(STAGE_ROOT)
+STAGE_ROOT ?= ${OBJROOT}stage
+.export STAGE_ROOT
+.endif
+
+# We should be included before meta.sys.mk
+# If TARGET_SPEC_VARS is other than just MACHINE
+# it should be set by now.
+# TARGET_SPEC must not contain any '.'s.
+TARGET_SPEC_VARS ?= MACHINE
+
+.if !target(_tspec_env_done_)
+_tspec_env_done_: .NOTMAIN
+
+.if ${TARGET_SPEC:Uno:M*,*} != ""
+# deal with TARGET_SPEC from env
+_tspec := ${TARGET_SPEC:S/,/ /g}
+.for i in ${TARGET_SPEC_VARS:${M_RANGE:Urange}}
+${TARGET_SPEC_VARS:[$i]} := ${_tspec:[$i]}
+.endfor
+# We need to stop that TARGET_SPEC affecting any submakes
+TARGET_SPEC=
+# so export but do not track
+.export-env TARGET_SPEC
+.export ${TARGET_SPEC_VARS}
+.for v in ${TARGET_SPEC_VARS:O:u}
+.if empty($v)
+.undef $v
+.endif
+.endfor
+.endif
+.endif
+
+# Now make sure we know what TARGET_SPEC is
+# as we may need it to find Makefile.depend*
+.if ${MACHINE:Mhost*} != ""
+# host is special
+TARGET_SPEC = ${MACHINE}
+.else
+TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
+.endif
+
+.if ${TARGET_SPEC_VARS:[#]} > 1
+TARGET_OBJ_SPEC ?= ${TARGET_SPEC_VARS:@v@${$v:U}@:ts.}
+.else
+TARGET_OBJ_SPEC ?= ${MACHINE}
+.endif
+
+MAKE_PRINT_VAR_ON_ERROR += ${TARGET_SPEC_VARS}
+
+.if !defined(MACHINE0)
+# it can be handy to know which MACHINE kicked off the build
+# for example, if using Makefild.depend for multiple machines,
+# allowing only MACHINE0 to update can keep things simple.
+MACHINE0 := ${MACHINE}
+.export MACHINE0
+.endif
+
+.if ${MACHINE} == "host"
+OBJTOP = ${HOST_OBJTOP}
+.elif ${MACHINE} == "host32"
+OBJTOP = ${HOST_OBJTOP32}
+.endif
+
+MACHINE_OBJ.host = ${HOST_TARGET}
+MACHINE_OBJ.host32 = ${HOST_TARGET32}
+MACHINE_OBJ.${MACHINE} ?= ${TARGET_OBJ_SPEC}
+MACHINE_OBJDIR = ${MACHINE_OBJ.${MACHINE}}
+OBJTOP = ${OBJROOT}/${MACHINE_OBJDIR}
+
+# we do not use MAKEOBJDIRPREFIX
+.undef MAKEOBJDIRPREFIX
+# we use this
+MAKEOBJDIR ?= ${.CURDIR:S,${SRCTOP},${OBJTOP},}
+
+STAGE_MACHINE ?= ${MACHINE_OBJDIR}
+STAGE_OBJTOP ?= ${STAGE_ROOT}/${STAGE_MACHINE}
+STAGE_COMMON_OBJTOP ?= ${STAGE_ROOT}/common
+STAGE_HOST_OBJTOP ?= ${STAGE_ROOT}/${HOST_TARGET}
+STAGE_HOST_OBJTOP32 ?= ${STAGE_ROOT}/${HOST_TARGET32}
+
+STAGE_INCLUDEDIR ?= ${STAGE_OBJTOP}${INCLUDEDIR:U/usr/include}
+STAGE_LIBDIR ?= ${STAGE_OBJTOP}${LIBDIR:U/lib}
+
+TIME_STAMP_FMT ?= @ %s [%Y-%m-%d %T] ${:U}
+DATE_TIME_STAMP ?= `date '+${TIME_STAMP_FMT}'`
+TIME_STAMP ?= ${TIME_STAMP_FMT:localtime}
+
+.if ${MK_TIME_STAMPS:Uyes} == "yes"
+TRACER = ${TIME_STAMP}
+ECHO_DIR = echo ${TIME_STAMP}
+ECHO_TRACE = echo ${TIME_STAMP}
+.endif
+
+.if ${.CURDIR} == ${SRCTOP}
+RELDIR= .
+RELTOP= .
+.elif ${.CURDIR:M${SRCTOP}/*}
+RELDIR:= ${.CURDIR:S,${SRCTOP}/,,}
+.else
+RELDIR:= ${.OBJDIR:S,${OBJTOP}/,,}
+.endif
+RELTOP?= ${RELDIR:C,[^/]+,..,g}
+RELOBJTOP?= ${RELTOP}
+RELSRCTOP?= ${RELTOP}
+
+# this does all the smarts of setting .MAKE.DEPENDFILE
+.-include <sys.dependfile.mk>
+
+.-include <local.sys.dirdeps.mk>
+
+# check if we got anything sane
+.if ${.MAKE.DEPENDFILE} == ".depend"
+.undef .MAKE.DEPENDFILE
+.endif
+# just in case
+.MAKE.DEPENDFILE ?= Makefile.depend
+
+.if ${.MAKE.LEVEL} > 0
+# Makefile.depend* also get read at level 1+
+# and often refer to DEP_MACHINE etc,
+# so ensure DEP_* (for TARGET_SPEC_VARS anyway) are set
+.for V in ${TARGET_SPEC_VARS}
+DEP_$V = ${$V}
+.endfor
+.endif
diff --git a/share/mk/sys.mk b/share/mk/sys.mk
index 1ab0022ddc21..d585444a485f 100644
--- a/share/mk/sys.mk
+++ b/share/mk/sys.mk
@@ -33,6 +33,7 @@ __DEFAULT_NO_OPTIONS= \
 
 __DEFAULT_DEPENDENT_OPTIONS= \
 	AUTO_OBJ/DIRDEPS_BUILD \
+	META_ERROR_TARGET/DIRDEPS_BUILD \
 	META_MODE/DIRDEPS_BUILD \
 	STAGING/DIRDEPS_BUILD \
 	SYSROOT/DIRDEPS_BUILD
@@ -57,27 +58,13 @@ MK_META_MODE=	no
 .endif
 
 .if ${MK_DIRDEPS_BUILD} == "yes"
-.sinclude <meta.sys.mk>
-.elif ${MK_META_MODE} == "yes"
-META_MODE+=	meta
-.if empty(.MAKEFLAGS:M-s)
-# verbose will show .MAKE.META.PREFIX for each target.
-META_MODE+=	verbose
-.endif
-.if !defined(NO_META_MISSING)
-META_MODE+=	missing-meta=yes
-.endif
-# silent will hide command output if a .meta file is created.
-.if !defined(NO_SILENT)
-META_MODE+=	silent=yes
+.-include <sys.dirdeps.mk>
 .endif
+.if ${MK_META_MODE} == "yes"
 .if !exists(/dev/filemon) || defined(NO_FILEMON)
 META_MODE+= nofilemon
 .endif
-# Require filemon data with bmake
-.if empty(META_MODE:Mnofilemon)
-META_MODE+= missing-filemon=yes
-.endif
+.-include <meta.sys.mk>
 .endif
 META_MODE?= normal
 .export META_MODE



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202305112316.34BNGPYr032398>