1# $FreeBSD$ 2# $Id: meta.sys.mk,v 1.19 2014/08/02 23:16:02 sjg Exp $ 3 4# 5# @(#) Copyright (c) 2010, Simon J. Gerraty 6# 7# This file is provided in the hope that it will 8# be of use. There is absolutely NO WARRANTY. 9# Permission to copy, redistribute or otherwise 10# use this file is hereby granted provided that 11# the above copyright notice and this notice are 12# left intact. 13# 14# Please send copies of changes and bug-fixes to: 15# sjg@crufty.net 16# 17 18# include this if you want to enable meta mode 19# for maximum benefit, requires filemon(4) driver. 20 21.if ${MAKE_VERSION:U0} > 20100901 22.if !target(.ERROR) 23 24.-include "local.meta.sys.mk" 25 26# absoulte path to what we are reading. 27_PARSEDIR = ${.PARSEDIR:tA} 28 29META_MODE += meta verbose 30.MAKE.MODE ?= ${META_MODE} 31 32.if ${.MAKE.LEVEL} == 0 33_make_mode := ${.MAKE.MODE} ${META_MODE} 34.if ${_make_mode:M*read*} != "" || ${_make_mode:M*nofilemon*} != "" 35# tell everyone we are not updating Makefile.depend* 36UPDATE_DEPENDFILE = NO 37.export UPDATE_DEPENDFILE 38.endif 39.if ${UPDATE_DEPENDFILE:Uyes:tl} == "no" && !exists(/dev/filemon) 40# we should not get upset 41META_MODE += nofilemon 42.export META_MODE 43.endif 44.endif 45 46.if !defined(NO_SILENT) 47.if ${MAKE_VERSION} > 20110818 48# only be silent when we have a .meta file 49META_MODE += silent=yes 50.else 51.SILENT: 52.endif 53.endif 54 55# make defaults .MAKE.DEPENDFILE to .depend 56# that won't work for us. 57.if ${.MAKE.DEPENDFILE} == ".depend" 58.undef .MAKE.DEPENDFILE 59.endif 60 61# if you don't cross build for multiple MACHINEs concurrently, then 62# .MAKE.DEPENDFILE = Makefile.depend 63# probably makes sense - you can set that in local.sys.mk 64.MAKE.DEPENDFILE ?= Makefile.depend.${MACHINE} 65 66# we use the pseudo machine "host" for the build host. 67# this should be taken care of before we get here 68.if ${OBJTOP:Ua} == ${HOST_OBJTOP:Ub} 69MACHINE = host 70.endif 71 72.if ${.MAKE.LEVEL} == 0 73# it can be handy to know which MACHINE kicked off the build 74# for example, if using Makefild.depend for multiple machines, 75# allowing only MACHINE0 to update can keep things simple. 76MACHINE0 := ${MACHINE} 77.export MACHINE0 78 79.if defined(PYTHON) && exists(${PYTHON}) 80# we prefer the python version of this - it is much faster 81META2DEPS ?= ${.PARSEDIR}/meta2deps.py 82.else 83META2DEPS ?= ${.PARSEDIR}/meta2deps.sh 84.endif 85META2DEPS := ${META2DEPS} 86.export META2DEPS 87.endif 88 89MAKE_PRINT_VAR_ON_ERROR += \ 90 .ERROR_TARGET \ 91 .ERROR_META_FILE \ 92 .MAKE.LEVEL \ 93 MAKEFILE \ 94 .MAKE.MODE 95 96.if !defined(SB) && defined(SRCTOP) 97SB = ${SRCTOP:H} 98.endif 99ERROR_LOGDIR ?= ${SB}/error 100meta_error_log = ${ERROR_LOGDIR}/meta-${.MAKE.PID}.log 101 102# we are not interested in make telling us a failure happened elsewhere 103.ERROR: _metaError 104_metaError: .NOMETA .NOTMAIN 105 -@[ "${.ERROR_META_FILE}" ] && { \ 106 grep -q 'failure has been detected in another branch' ${.ERROR_META_FILE} && exit 0; \ 107 mkdir -p ${meta_error_log:H}; \ 108 cp ${.ERROR_META_FILE} ${meta_error_log}; \ 109 echo "ERROR: log ${meta_error_log}" >&2; }; : 110 111.endif 112 113# Are we, after all, in meta mode? 114.if ${.MAKE.MODE:Mmeta*} != "" 115MKDEP_MK = meta.autodep.mk 116 117# if we think we are updating dependencies, 118# then filemon had better be present 119.if ${UPDATE_DEPENDFILE:Uyes:tl} != "no" && !exists(/dev/filemon) 120.error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded. 121.endif 122 123.if ${.MAKE.LEVEL} == 0 124# make sure dirdeps target exists and do it first 125all: dirdeps .WAIT 126dirdeps: 127.NOPATH: dirdeps 128 129.if defined(ALL_MACHINES) 130# the first .MAIN: is what counts 131# by default dirdeps is all we want at level0 132.MAIN: dirdeps 133# tell dirdeps.mk what we want 134BUILD_AT_LEVEL0 = no 135.endif 136.if ${.TARGETS:Nall} == "" 137# it works best if we do everything via sub-makes 138BUILD_AT_LEVEL0 ?= no 139.endif 140 141.endif 142.endif 143.endif 144