1102768Sscottl# $Id: meta.sys.mk,v 1.28 2016/04/05 15:58:37 sjg Exp $ 2102768Sscottl 3102768Sscottl# 4102768Sscottl# @(#) Copyright (c) 2010, Simon J. Gerraty 5102768Sscottl# 6102768Sscottl# This file is provided in the hope that it will 7102768Sscottl# be of use. There is absolutely NO WARRANTY. 8102768Sscottl# Permission to copy, redistribute or otherwise 9102768Sscottl# use this file is hereby granted provided that 10102768Sscottl# the above copyright notice and this notice are 11102768Sscottl# left intact. 12102768Sscottl# 13102768Sscottl# Please send copies of changes and bug-fixes to: 14102768Sscottl# sjg@crufty.net 15102768Sscottl# 16102768Sscottl 17102768Sscottl# include this if you want to enable meta mode 18102768Sscottl# for maximum benefit, requires filemon(4) driver. 19102768Sscottl 20102768Sscottl.if ${MAKE_VERSION:U0} > 20100901 21102768Sscottl.if !target(.ERROR) 22102768Sscottl 23102768Sscottl.-include <local.meta.sys.mk> 24102768Sscottl 25102768Sscottl# absoulte path to what we are reading. 26102768Sscottl_PARSEDIR = ${.PARSEDIR:tA} 27102768Sscottl 28102768SscottlMETA_MODE += meta verbose 29102768Sscottl.MAKE.MODE ?= ${META_MODE} 30102768Sscottl 31131570Ssimon.if ${.MAKE.LEVEL} == 0 32102768Sscottl_make_mode := ${.MAKE.MODE} ${META_MODE} 33102768Sscottl.if ${_make_mode:M*read*} != "" || ${_make_mode:M*nofilemon*} != "" 34102768Sscottl# tell everyone we are not updating Makefile.depend* 35102768SscottlUPDATE_DEPENDFILE = NO 36102768Sscottl.export UPDATE_DEPENDFILE 37102768Sscottl.endif 38158762Sbrueffer.if ${UPDATE_DEPENDFILE:Uyes:tl} == "no" && !exists(/dev/filemon) 39158762Sbrueffer# we should not get upset 40158762SbruefferMETA_MODE += nofilemon 41158762Sbrueffer.export META_MODE 42158762Sbrueffer.endif 43158762Sbrueffer.endif 44158762Sbrueffer 45102768Sscottl.if !defined(NO_SILENT) 46107728Sru.if ${MAKE_VERSION} > 20110818 47102768Sscottl# only be silent when we have a .meta file 48102810SscottlMETA_MODE += silent=yes 49102768Sscottl.else 50102768Sscottl.SILENT: 51102768Sscottl.endif 52102810Sscottl.endif 53107728Sru 54102768Sscottl# we use the pseudo machine "host" for the build host. 55158762Sbrueffer# this should be taken care of before we get here 56158762Sbrueffer.if ${OBJTOP:Ua} == ${HOST_OBJTOP:Ub} 57158762SbruefferMACHINE = host 58158762Sbrueffer.endif 59158762Sbrueffer 60107728Sru.if ${.MAKE.LEVEL} == 0 61102768Sscottl# it can be handy to know which MACHINE kicked off the build 62102768Sscottl# for example, if using Makefild.depend for multiple machines, 63102768Sscottl# allowing only MACHINE0 to update can keep things simple. 64102768SscottlMACHINE0 := ${MACHINE} 65131570Ssimon.export MACHINE0 66102768Sscottl 67102768Sscottl.if defined(PYTHON) && exists(${PYTHON}) 68102768Sscottl# we prefer the python version of this - it is much faster 69102768SscottlMETA2DEPS ?= ${.PARSEDIR}/meta2deps.py 70102768Sscottl.else 71102768SscottlMETA2DEPS ?= ${.PARSEDIR}/meta2deps.sh 72102768Sscottl.endif 73107728SruMETA2DEPS := ${META2DEPS} 74102768Sscottl.export META2DEPS 75102768Sscottl.endif 76107728Sru 77107728SruMAKE_PRINT_VAR_ON_ERROR += \ 78107728Sru .ERROR_TARGET \ 79107728Sru .ERROR_META_FILE \ 80107728Sru .MAKE.LEVEL \ 81108317Sschweikh MAKEFILE \ 82107728Sru .MAKE.MODE 83107728Sru 84107728Sru.if !defined(SB) && defined(SRCTOP) 85107728SruSB = ${SRCTOP:H} 86107728Sru.endif 87107728SruERROR_LOGDIR ?= ${SB}/error 88107728Srumeta_error_log = ${ERROR_LOGDIR}/meta-${.MAKE.PID}.log 89107728Sru 90107728Sru# we are not interested in make telling us a failure happened elsewhere 91107728Sru.ERROR: _metaError 92107728Sru_metaError: .NOMETA .NOTMAIN 93107728Sru -@[ "${.ERROR_META_FILE}" ] && { \ 94107728Sru grep -q 'failure has been detected in another branch' ${.ERROR_META_FILE} && exit 0; \ 95102768Sscottl mkdir -p ${meta_error_log:H}; \ 96102768Sscottl cp ${.ERROR_META_FILE} ${meta_error_log}; \ 97102768Sscottl echo "ERROR: log ${meta_error_log}" >&2; }; : 98107728Sru 99102768Sscottl.endif 100107728Sru 101107728SruMETA_COOKIE_TOUCH= 102102768Sscottl# some targets need to be .PHONY in non-meta mode 103102768SscottlMETA_NOPHONY= .PHONY 104102768Sscottl# Are we, after all, in meta mode? 105102768Sscottl.if ${.MAKE.MODE:Uno:Mmeta*} != "" 106107728SruMKDEP_MK = meta.autodep.mk 107107728Sru 108107728Sru.if ${.MAKE.MAKEFILES:M*sys.dependfile.mk} == "" 109102768Sscottl# this does all the smarts of setting .MAKE.DEPENDFILE 110107728Sru.-include <sys.dependfile.mk> 111108317Sschweikh# check if we got anything sane 112102768Sscottl.if ${.MAKE.DEPENDFILE} == ".depend" 113102768Sscottl.undef .MAKE.DEPENDFILE 114102768Sscottl.endif 115102768Sscottl.MAKE.DEPENDFILE ?= Makefile.depend 116102768Sscottl.endif 117102768Sscottl 118102768Sscottl# we can afford to use cookies to prevent some targets 119102768Sscottl# re-running needlessly 120102768SscottlMETA_COOKIE_TOUCH= touch ${COOKIE.${.TARGET}:U${.OBJDIR}/${.TARGET}} 121107728SruMETA_NOPHONY= 122107728Sru.if ${UPDATE_DEPENDFILE:Uyes:tl} != "no" 123107728Sru.if ${.MAKEFLAGS:Uno:M-k} != "" 124131570Ssimon# make this more obvious 125131570Ssimon.warning Setting UPDATE_DEPENDFILE=NO due to -k 126131570SsimonUPDATE_DEPENDFILE= NO 127131570Ssimon.export UPDATE_DEPENDFILE 128131570Ssimon.elif !exists(/dev/filemon) 129131570Ssimon.error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded. 130131570Ssimon.endif 131131570Ssimon.endif 132131570Ssimon 133131570Ssimon.if ${.MAKE.LEVEL} == 0 134131570Ssimon# make sure dirdeps target exists and do it first 135131570Ssimonall: dirdeps .WAIT 136131570Ssimondirdeps: 137131570Ssimon.NOPATH: dirdeps 138131570Ssimon 139131570Ssimon.if defined(ALL_MACHINES) 140131570Ssimon# the first .MAIN: is what counts 141131570Ssimon# by default dirdeps is all we want at level0 142131570Ssimon.MAIN: dirdeps 143131570Ssimon# tell dirdeps.mk what we want 144131570SsimonBUILD_AT_LEVEL0 = no 145131570Ssimon.endif 146131570Ssimon.if ${.TARGETS:Nall} == "" 147131570Ssimon# it works best if we do everything via sub-makes 148131570SsimonBUILD_AT_LEVEL0 ?= no 149131570Ssimon.endif 150131570Ssimon 151131570Ssimon.endif 152131570Ssimon.endif 153131570Ssimon.endif 154131570Ssimon