1*6eef5f0cSAntonio Huete Jimenez# $Id: meta.sys.mk,v 1.42 2021/12/13 05:50:55 sjg Exp $ 25f1e34d9SAlexandre Perrin 35f1e34d9SAlexandre Perrin# 4*6eef5f0cSAntonio Huete Jimenez# @(#) Copyright (c) 2010-2021, Simon J. Gerraty 55f1e34d9SAlexandre Perrin# 65f1e34d9SAlexandre Perrin# This file is provided in the hope that it will 75f1e34d9SAlexandre Perrin# be of use. There is absolutely NO WARRANTY. 85f1e34d9SAlexandre Perrin# Permission to copy, redistribute or otherwise 95f1e34d9SAlexandre Perrin# use this file is hereby granted provided that 105f1e34d9SAlexandre Perrin# the above copyright notice and this notice are 115f1e34d9SAlexandre Perrin# left intact. 125f1e34d9SAlexandre Perrin# 135f1e34d9SAlexandre Perrin# Please send copies of changes and bug-fixes to: 145f1e34d9SAlexandre Perrin# sjg@crufty.net 155f1e34d9SAlexandre Perrin# 165f1e34d9SAlexandre Perrin 175f1e34d9SAlexandre Perrin# include this if you want to enable meta mode 185f1e34d9SAlexandre Perrin# for maximum benefit, requires filemon(4) driver. 195f1e34d9SAlexandre Perrin 205f1e34d9SAlexandre Perrin.if ${MAKE_VERSION:U0} > 20100901 215f1e34d9SAlexandre Perrin.if !target(.ERROR) 225f1e34d9SAlexandre Perrin 23f445c897SJohn Marino.-include <local.meta.sys.mk> 24f445c897SJohn Marino 25ca58f742SDaniel Fojt# absolute path to what we are reading. 26f445c897SJohn Marino_PARSEDIR = ${.PARSEDIR:tA} 27f445c897SJohn Marino 28f445c897SJohn Marino.if !defined(SYS_MK_DIR) 29f445c897SJohn MarinoSYS_MK_DIR := ${_PARSEDIR} 30f445c897SJohn Marino.endif 315f1e34d9SAlexandre Perrin 325f1e34d9SAlexandre PerrinMETA_MODE += meta verbose 33*6eef5f0cSAntonio Huete Jimenez.if ${MAKE_VERSION:U0} > 20130323 && empty(.MAKE.PATH_FILEMON) 34*6eef5f0cSAntonio Huete Jimenez# we do not support filemon 35*6eef5f0cSAntonio Huete JimenezMETA_MODE += nofilemon 36*6eef5f0cSAntonio Huete JimenezMKDEP_MK ?= auto.dep.mk 37*6eef5f0cSAntonio Huete Jimenez.endif 38*6eef5f0cSAntonio Huete Jimenez 395f1e34d9SAlexandre Perrin.MAKE.MODE ?= ${META_MODE} 405f1e34d9SAlexandre Perrin 41*6eef5f0cSAntonio Huete Jimenez_filemon := ${.MAKE.PATH_FILEMON:U/dev/filemon} 42*6eef5f0cSAntonio Huete Jimenez 43*6eef5f0cSAntonio Huete Jimenez.if empty(UPDATE_DEPENDFILE) 445f1e34d9SAlexandre Perrin_make_mode := ${.MAKE.MODE} ${META_MODE} 455f1e34d9SAlexandre Perrin.if ${_make_mode:M*read*} != "" || ${_make_mode:M*nofilemon*} != "" 465f1e34d9SAlexandre Perrin# tell everyone we are not updating Makefile.depend* 475f1e34d9SAlexandre PerrinUPDATE_DEPENDFILE = NO 485f1e34d9SAlexandre Perrin.export UPDATE_DEPENDFILE 495f1e34d9SAlexandre Perrin.endif 50*6eef5f0cSAntonio Huete Jimenez.if ${_filemon:T:Mfilemon} == "filemon" 51*6eef5f0cSAntonio Huete Jimenez.if ${UPDATE_DEPENDFILE:Uyes:tl} == "no" && !exists(${_filemon}) 525f1e34d9SAlexandre Perrin# we should not get upset 535f1e34d9SAlexandre PerrinMETA_MODE += nofilemon 545f1e34d9SAlexandre Perrin.export META_MODE 555f1e34d9SAlexandre Perrin.endif 565f1e34d9SAlexandre Perrin.endif 57*6eef5f0cSAntonio Huete Jimenez.endif 585f1e34d9SAlexandre Perrin 595f1e34d9SAlexandre Perrin.if !defined(NO_SILENT) 605f1e34d9SAlexandre Perrin.if ${MAKE_VERSION} > 20110818 615f1e34d9SAlexandre Perrin# only be silent when we have a .meta file 625f1e34d9SAlexandre PerrinMETA_MODE += silent=yes 635f1e34d9SAlexandre Perrin.else 645f1e34d9SAlexandre Perrin.SILENT: 655f1e34d9SAlexandre Perrin.endif 665f1e34d9SAlexandre Perrin.endif 675f1e34d9SAlexandre Perrin 685f1e34d9SAlexandre Perrin# we use the pseudo machine "host" for the build host. 695f1e34d9SAlexandre Perrin# this should be taken care of before we get here 705f1e34d9SAlexandre Perrin.if ${OBJTOP:Ua} == ${HOST_OBJTOP:Ub} 715f1e34d9SAlexandre PerrinMACHINE = host 725f1e34d9SAlexandre Perrin.endif 735f1e34d9SAlexandre Perrin 74ca58f742SDaniel Fojt.if !defined(MACHINE0) 755f1e34d9SAlexandre Perrin# it can be handy to know which MACHINE kicked off the build 765f1e34d9SAlexandre Perrin# for example, if using Makefild.depend for multiple machines, 775f1e34d9SAlexandre Perrin# allowing only MACHINE0 to update can keep things simple. 785f1e34d9SAlexandre PerrinMACHINE0 := ${MACHINE} 79f445c897SJohn Marino.export MACHINE0 80ca58f742SDaniel Fojt.endif 815f1e34d9SAlexandre Perrin 82ca58f742SDaniel Fojt.if !defined(META2DEPS) 835f1e34d9SAlexandre Perrin.if defined(PYTHON) && exists(${PYTHON}) 845f1e34d9SAlexandre Perrin# we prefer the python version of this - it is much faster 855f1e34d9SAlexandre PerrinMETA2DEPS ?= ${.PARSEDIR}/meta2deps.py 865f1e34d9SAlexandre Perrin.else 875f1e34d9SAlexandre PerrinMETA2DEPS ?= ${.PARSEDIR}/meta2deps.sh 885f1e34d9SAlexandre Perrin.endif 895f1e34d9SAlexandre PerrinMETA2DEPS := ${META2DEPS} 905f1e34d9SAlexandre Perrin.export META2DEPS 915f1e34d9SAlexandre Perrin.endif 925f1e34d9SAlexandre Perrin 935f1e34d9SAlexandre PerrinMAKE_PRINT_VAR_ON_ERROR += \ 945f1e34d9SAlexandre Perrin .ERROR_TARGET \ 955f1e34d9SAlexandre Perrin .ERROR_META_FILE \ 965f1e34d9SAlexandre Perrin .MAKE.LEVEL \ 975f1e34d9SAlexandre Perrin MAKEFILE \ 985f1e34d9SAlexandre Perrin .MAKE.MODE 995f1e34d9SAlexandre Perrin 1005f1e34d9SAlexandre Perrin.if !defined(SB) && defined(SRCTOP) 1015f1e34d9SAlexandre PerrinSB = ${SRCTOP:H} 1025f1e34d9SAlexandre Perrin.endif 1035f1e34d9SAlexandre PerrinERROR_LOGDIR ?= ${SB}/error 1045f1e34d9SAlexandre Perrinmeta_error_log = ${ERROR_LOGDIR}/meta-${.MAKE.PID}.log 1055f1e34d9SAlexandre Perrin 1065f1e34d9SAlexandre Perrin# we are not interested in make telling us a failure happened elsewhere 1075f1e34d9SAlexandre Perrin.ERROR: _metaError 1085f1e34d9SAlexandre Perrin_metaError: .NOMETA .NOTMAIN 1095f1e34d9SAlexandre Perrin -@[ "${.ERROR_META_FILE}" ] && { \ 1105f1e34d9SAlexandre Perrin grep -q 'failure has been detected in another branch' ${.ERROR_META_FILE} && exit 0; \ 1115f1e34d9SAlexandre Perrin mkdir -p ${meta_error_log:H}; \ 1125f1e34d9SAlexandre Perrin cp ${.ERROR_META_FILE} ${meta_error_log}; \ 1135f1e34d9SAlexandre Perrin echo "ERROR: log ${meta_error_log}" >&2; }; : 1145f1e34d9SAlexandre Perrin 1155f1e34d9SAlexandre Perrin.endif 1165f1e34d9SAlexandre Perrin 1175f1e34d9SAlexandre Perrin# Are we, after all, in meta mode? 118f445c897SJohn Marino.if ${.MAKE.MODE:Uno:Mmeta*} != "" 119*6eef5f0cSAntonio Huete JimenezMKDEP_MK ?= meta.autodep.mk 1206a91b982SJohn Marino 121f445c897SJohn Marino.if ${.MAKE.MAKEFILES:M*sys.dependfile.mk} == "" 122f445c897SJohn Marino# this does all the smarts of setting .MAKE.DEPENDFILE 123f445c897SJohn Marino.-include <sys.dependfile.mk> 124f445c897SJohn Marino# check if we got anything sane 125f445c897SJohn Marino.if ${.MAKE.DEPENDFILE} == ".depend" 126f445c897SJohn Marino.undef .MAKE.DEPENDFILE 127f445c897SJohn Marino.endif 128f445c897SJohn Marino.MAKE.DEPENDFILE ?= Makefile.depend 129f445c897SJohn Marino.endif 130f445c897SJohn Marino 131f445c897SJohn Marino# we can afford to use cookies to prevent some targets 132f445c897SJohn Marino# re-running needlessly 133ca58f742SDaniel FojtMETA_COOKIE_TOUCH?= touch ${COOKIE.${.TARGET}:U${.OBJDIR}/${.TARGET:T}} 134f445c897SJohn MarinoMETA_NOPHONY= 135ca58f742SDaniel FojtMETA_NOECHO= : 136f445c897SJohn Marino 137f445c897SJohn Marino# some targets involve old pre-built targets 138f445c897SJohn Marino# ignore mtime of shell 139f445c897SJohn Marino# and mtime of makefiles does not matter in meta mode 140f445c897SJohn Marino.MAKE.META.IGNORE_PATHS += \ 141f445c897SJohn Marino ${MAKEFILE} \ 142ca58f742SDaniel Fojt ${MAKE_SHELL} \ 143f445c897SJohn Marino ${SHELL} \ 144ca58f742SDaniel Fojt ${SYS_MK_DIR} \ 145ca58f742SDaniel Fojt 146f445c897SJohn Marino 147f445c897SJohn Marino.if ${UPDATE_DEPENDFILE:Uyes:tl} != "no" 148f445c897SJohn Marino.if ${.MAKEFLAGS:Uno:M-k} != "" 149f445c897SJohn Marino# make this more obvious 150f445c897SJohn Marino.warning Setting UPDATE_DEPENDFILE=NO due to -k 151f445c897SJohn MarinoUPDATE_DEPENDFILE= NO 152f445c897SJohn Marino.export UPDATE_DEPENDFILE 153*6eef5f0cSAntonio Huete Jimenez.elif ${_filemon:T} == "filemon" && !exists(${_filemon}) 154*6eef5f0cSAntonio Huete Jimenez.error ${.newline}ERROR: The filemon module (${_filemon}) is not loaded. 1556a91b982SJohn Marino.endif 156f445c897SJohn Marino.endif 1575f1e34d9SAlexandre Perrin 1585f1e34d9SAlexandre Perrin.if ${.MAKE.LEVEL} == 0 159*6eef5f0cSAntonio Huete Jimenez.if ${MK_DIRDEPS_BUILD:Uyes} == "yes" 1605f1e34d9SAlexandre Perrin# make sure dirdeps target exists and do it first 1615f1e34d9SAlexandre Perrinall: dirdeps .WAIT 1625f1e34d9SAlexandre Perrindirdeps: 1635f1e34d9SAlexandre Perrin.NOPATH: dirdeps 1645f1e34d9SAlexandre Perrin 1655f1e34d9SAlexandre Perrin.if defined(ALL_MACHINES) 1665f1e34d9SAlexandre Perrin# the first .MAIN: is what counts 1675f1e34d9SAlexandre Perrin# by default dirdeps is all we want at level0 1685f1e34d9SAlexandre Perrin.MAIN: dirdeps 1695f1e34d9SAlexandre Perrin.endif 170*6eef5f0cSAntonio Huete Jimenez.endif 1715f1e34d9SAlexandre Perrin 1725f1e34d9SAlexandre Perrin.endif 173ca58f742SDaniel Fojt.else 174ca58f742SDaniel FojtMETA_COOKIE_TOUCH= 175ca58f742SDaniel Fojt# some targets need to be .PHONY in non-meta mode 176ca58f742SDaniel FojtMETA_NOPHONY= .PHONY 177ca58f742SDaniel FojtMETA_NOECHO= echo 1785f1e34d9SAlexandre Perrin.endif 1795f1e34d9SAlexandre Perrin.endif 180