1 2.if !target(_${_this}_) 3_${_this}_: .NOTMAIN 4 5.if ${MK_DIRDEPS_BUILD} == "yes" || ${MK_META_MODE} == "yes" 6 7# Not in the below list as it may make sense for non-meta mode 8# eventually. meta.sys.mk (DIRDEPS_BUILD) also already adds these in. 9.if ${MK_DIRDEPS_BUILD} == "no" && ${MK_META_MODE} == "yes" 10MAKE_PRINT_VAR_ON_ERROR += \ 11 .ERROR_TARGET \ 12 .ERROR_META_FILE \ 13 .MAKE.LEVEL \ 14 MAKEFILE \ 15 .MAKE.MODE 16.endif 17 18_ERROR_CMD_EXEC= ${sed -n '/^CMD/s,^CMD \(.*\),\1;,p' ${.ERROR_META_FILE}:L:sh} 19_ERROR_CMD= ${!empty(.ERROR_META_FILE):?${_ERROR_CMD_EXEC}:.PHONY} 20MAKE_PRINT_VAR_ON_ERROR+= \ 21 _ERROR_CMD \ 22 .CURDIR \ 23 .MAKE \ 24 .OBJDIR \ 25 .TARGETS \ 26 CPUTYPE \ 27 DESTDIR \ 28 LD_LIBRARY_PATH \ 29 MACHINE \ 30 MACHINE_ARCH \ 31 MACHINE_CPUARCH \ 32 MAKEOBJDIRPREFIX \ 33 MAKESYSPATH \ 34 MAKE_VERSION \ 35 PATH \ 36 SRCTOP \ 37 OBJTOP \ 38 ${MAKE_PRINT_VAR_ON_ERROR_XTRAS} 39 40# Meta mode may rebuild targets that then fail. The next build won't detect 41# the meta mode change. Not all targets have a 'rm ${.TARGET}' in them 42# so force it. 43.DELETE_ON_ERROR: 44 45.if ${.MAKE.LEVEL} > 0 46MAKE_PRINT_VAR_ON_ERROR += .MAKE.MAKEFILES .PATH 47.endif 48.endif 49 50.if !empty(.OBJDIR) 51OBJTOP?= ${.OBJDIR:S,${.CURDIR},,}${SRCTOP} 52.endif 53 54.if !empty(LIBDIR) 55_PREMK_LIBDIR:= ${LIBDIR} 56.endif 57 58.include "src.sys.mk" 59.-include <site.sys.mk> 60 61.if make(*-jobs) && empty(JOB_MAX) 62# provide a reasonable? default for JOB_MAX based on ncpu 63JOB_MAX_FACTOR?= 1.33 64NPROC?= ${(type nproc || true) 2> /dev/null:L:sh:M/*:[1]} 65NPROC:= ${NPROC} 66.if !empty(NPROC) 67ncpu!= ${NPROC} 68.elif ${.MAKE.OS:NDarwin:NFreeBSD} == "" 69ncpu!= sysctl -n hw.ncpu 70.endif 71.if ${ncpu:U0} > 1 72.if ${JOB_MAX_FACTOR} == 1 73JOB_MAX:= ${ncpu} 74.else 75jm!= echo ${ncpu} \* ${JOB_MAX_FACTOR} | bc 76JOB_MAX:= ${jm:R} 77.endif 78.endif 79.endif 80 81# this will be set via local.meta.sys.env.mk if appropriate 82MK_host_egacy?= no 83 84.if ${.MAKE.MODE:Mmeta*} != "" 85# we can afford to use cookies to prevent some targets 86# re-running needlessly but only when using filemon. 87# Targets that should support the meta mode cookie handling should just be 88# added to META_TARGETS. If bsd.sys.mk cannot be included then ${META_DEPS} 89# should be added as a target dependency as well. Otherwise the target 90# is added to in bsd.sys.mk since it comes last. 91.if ${.MAKE.MODE:Mnofilemon} == "" 92# Prepend .OBJDIR if not already there. 93_META_COOKIE_COND= "${.TARGET:M${.OBJDIR}/*}" == "" 94_META_COOKIE_DEFAULT= ${${_META_COOKIE_COND}:?${.OBJDIR}/${.TARGET}:${.TARGET}} 95# Use the default if COOKIE.${.TARGET} is not defined. 96META_COOKIE= ${COOKIE.${.TARGET}:U${_META_COOKIE_DEFAULT}} 97META_COOKIE_RM= @rm -f ${META_COOKIE} 98META_COOKIE_TOUCH= @touch ${META_COOKIE} 99CLEANFILES+= ${META_TARGETS} 100_meta_dep_before: .USEBEFORE .NOTMAIN 101 ${META_COOKIE_RM} 102_meta_dep_after: .USE .NOTMAIN 103 ${META_COOKIE_TOUCH} 104# Attach this to a target to allow it to benefit from meta mode's 105# not rerunning a command if it doesn't need to be considering its 106# metafile/filemon-tracked dependencies. 107META_DEPS= _meta_dep_before _meta_dep_after .META 108.endif 109.else 110# some targets need to be .PHONY - but not in meta mode 111META_NOPHONY= .PHONY 112.endif 113META_NOPHONY?= 114META_COOKIE_RM?= 115META_COOKIE_TOUCH?= 116META_DEPS+= ${META_NOPHONY} 117 118.endif 119