2015-06-13 19:20:56 +00:00
|
|
|
# $FreeBSD$
|
2020-11-24 21:45:38 +00:00
|
|
|
# $Id: meta.sys.mk,v 1.38 2020/08/19 17:51:53 sjg Exp $
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
#
|
2020-11-24 21:45:38 +00:00
|
|
|
# @(#) Copyright (c) 2010-2020, Simon J. Gerraty
|
2012-08-22 19:25:57 +00:00
|
|
|
#
|
|
|
|
# This file is provided in the hope that it will
|
|
|
|
# be of use. There is absolutely NO WARRANTY.
|
|
|
|
# Permission to copy, redistribute or otherwise
|
2020-11-24 21:45:38 +00:00
|
|
|
# use this file is hereby granted provided that
|
2012-08-22 19:25:57 +00:00
|
|
|
# the above copyright notice and this notice are
|
2020-11-24 21:45:38 +00:00
|
|
|
# left intact.
|
|
|
|
#
|
2012-08-22 19:25:57 +00:00
|
|
|
# Please send copies of changes and bug-fixes to:
|
|
|
|
# sjg@crufty.net
|
|
|
|
#
|
|
|
|
|
|
|
|
# include this if you want to enable meta mode
|
|
|
|
# for maximum benefit, requires filemon(4) driver.
|
|
|
|
|
|
|
|
.if ${MAKE_VERSION:U0} > 20100901
|
|
|
|
.if !target(.ERROR)
|
|
|
|
|
2018-08-02 21:33:45 +00:00
|
|
|
.-include <local.meta.sys.mk>
|
2015-05-26 21:47:43 +00:00
|
|
|
|
2018-07-27 10:44:38 +00:00
|
|
|
# absolute path to what we are reading.
|
2015-05-26 21:47:43 +00:00
|
|
|
_PARSEDIR = ${.PARSEDIR:tA}
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2016-09-09 01:21:35 +00:00
|
|
|
.if !defined(SYS_MK_DIR)
|
|
|
|
SYS_MK_DIR := ${_PARSEDIR}
|
|
|
|
.endif
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
META_MODE += meta verbose
|
|
|
|
.MAKE.MODE ?= ${META_MODE}
|
|
|
|
|
|
|
|
.if ${.MAKE.LEVEL} == 0
|
|
|
|
_make_mode := ${.MAKE.MODE} ${META_MODE}
|
|
|
|
.if ${_make_mode:M*read*} != "" || ${_make_mode:M*nofilemon*} != ""
|
|
|
|
# tell everyone we are not updating Makefile.depend*
|
|
|
|
UPDATE_DEPENDFILE = NO
|
|
|
|
.export UPDATE_DEPENDFILE
|
|
|
|
.endif
|
|
|
|
.if ${UPDATE_DEPENDFILE:Uyes:tl} == "no" && !exists(/dev/filemon)
|
|
|
|
# we should not get upset
|
|
|
|
META_MODE += nofilemon
|
|
|
|
.export META_MODE
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !defined(NO_SILENT)
|
|
|
|
.if ${MAKE_VERSION} > 20110818
|
|
|
|
# only be silent when we have a .meta file
|
|
|
|
META_MODE += silent=yes
|
|
|
|
.else
|
|
|
|
.SILENT:
|
|
|
|
.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
|
|
|
|
|
2019-12-11 17:38:15 +00:00
|
|
|
.if !defined(MACHINE0)
|
2012-08-22 19:25:57 +00:00
|
|
|
# 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}
|
2015-05-26 21:47:43 +00:00
|
|
|
.export MACHINE0
|
2019-12-11 17:38:15 +00:00
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2019-12-11 17:38:15 +00:00
|
|
|
.if !defined(META2DEPS)
|
2012-08-22 19:25:57 +00:00
|
|
|
.if defined(PYTHON) && exists(${PYTHON})
|
|
|
|
# we prefer the python version of this - it is much faster
|
|
|
|
META2DEPS ?= ${.PARSEDIR}/meta2deps.py
|
|
|
|
.else
|
|
|
|
META2DEPS ?= ${.PARSEDIR}/meta2deps.sh
|
|
|
|
.endif
|
|
|
|
META2DEPS := ${META2DEPS}
|
|
|
|
.export META2DEPS
|
|
|
|
.endif
|
|
|
|
|
|
|
|
MAKE_PRINT_VAR_ON_ERROR += \
|
|
|
|
.ERROR_TARGET \
|
|
|
|
.ERROR_META_FILE \
|
|
|
|
.MAKE.LEVEL \
|
|
|
|
MAKEFILE \
|
|
|
|
.MAKE.MODE
|
|
|
|
|
|
|
|
.if !defined(SB) && defined(SRCTOP)
|
|
|
|
SB = ${SRCTOP:H}
|
|
|
|
.endif
|
|
|
|
ERROR_LOGDIR ?= ${SB}/error
|
|
|
|
meta_error_log = ${ERROR_LOGDIR}/meta-${.MAKE.PID}.log
|
|
|
|
|
|
|
|
# we are not interested in make telling us a failure happened elsewhere
|
|
|
|
.ERROR: _metaError
|
|
|
|
_metaError: .NOMETA .NOTMAIN
|
|
|
|
-@[ "${.ERROR_META_FILE}" ] && { \
|
|
|
|
grep -q 'failure has been detected in another branch' ${.ERROR_META_FILE} && exit 0; \
|
|
|
|
mkdir -p ${meta_error_log:H}; \
|
|
|
|
cp ${.ERROR_META_FILE} ${meta_error_log}; \
|
|
|
|
echo "ERROR: log ${meta_error_log}" >&2; }; :
|
|
|
|
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# Are we, after all, in meta mode?
|
2016-03-11 00:37:02 +00:00
|
|
|
.if ${.MAKE.MODE:Uno:Mmeta*} != ""
|
2014-08-19 06:50:54 +00:00
|
|
|
MKDEP_MK = meta.autodep.mk
|
|
|
|
|
2018-08-02 21:33:45 +00:00
|
|
|
.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
|
|
|
|
|
2016-09-09 01:21:35 +00:00
|
|
|
# we can afford to use cookies to prevent some targets
|
|
|
|
# re-running needlessly
|
2016-09-13 22:17:25 +00:00
|
|
|
META_COOKIE_TOUCH?= touch ${COOKIE.${.TARGET}:U${.OBJDIR}/${.TARGET:T}}
|
2016-09-09 01:21:35 +00:00
|
|
|
META_NOPHONY=
|
2018-08-02 21:33:45 +00:00
|
|
|
META_NOECHO= :
|
2016-09-09 01:21:35 +00:00
|
|
|
|
|
|
|
# some targets involve old pre-built targets
|
|
|
|
# ignore mtime of shell
|
|
|
|
# and mtime of makefiles does not matter in meta mode
|
|
|
|
.MAKE.META.IGNORE_PATHS += \
|
2020-11-24 21:45:38 +00:00
|
|
|
${MAKEFILE} \
|
|
|
|
${MAKE_SHELL} \
|
|
|
|
${SHELL} \
|
|
|
|
${SYS_MK_DIR} \
|
|
|
|
|
2016-09-09 01:21:35 +00:00
|
|
|
|
2018-08-02 21:33:45 +00:00
|
|
|
.if ${UPDATE_DEPENDFILE:Uyes:tl} != "no"
|
|
|
|
.if ${.MAKEFLAGS:Uno:M-k} != ""
|
|
|
|
# make this more obvious
|
|
|
|
.warning Setting UPDATE_DEPENDFILE=NO due to -k
|
|
|
|
UPDATE_DEPENDFILE= NO
|
|
|
|
.export UPDATE_DEPENDFILE
|
|
|
|
.elif !exists(/dev/filemon)
|
2014-08-19 06:50:54 +00:00
|
|
|
.error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded.
|
|
|
|
.endif
|
2018-08-02 21:33:45 +00:00
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
.if ${.MAKE.LEVEL} == 0
|
|
|
|
# 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
|
2016-09-13 22:17:25 +00:00
|
|
|
.else
|
|
|
|
META_COOKIE_TOUCH=
|
|
|
|
# some targets need to be .PHONY in non-meta mode
|
|
|
|
META_NOPHONY= .PHONY
|
2018-08-02 21:33:45 +00:00
|
|
|
META_NOECHO= echo
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
.endif
|