1# $Id: cc-wrap.mk,v 1.8 2025/08/09 22:42:24 sjg Exp $ 2# 3# @(#) Copyright (c) 2022, Simon J. Gerraty 4# 5# SPDX-License-Identifier: BSD-2-Clause 6# 7# Please send copies of changes and bug-fixes to: 8# sjg@crufty.net 9# 10 11.if ${MAKE_VERSION} >= 20220126 12# which targets are we interested in? 13CC_WRAP_TARGETS ?= ${OBJS:U} ${POBJS:U} ${SOBJS:U} 14 15.if !empty(CC_WRAP_TARGETS) 16# cleanup 17# all the target assignments below are effectively := anyway 18# so we might as well do this once 19CC_WRAP_TARGETS := ${CC_WRAP_TARGETS:O:u} 20 21# what do we wrap? 22CC_WRAP_LIST += CC CXX 23CC_WRAP_LIST := ${CC_WRAP_LIST:O:u} 24 25# what might we wrap them with? 26CC_WRAPPERS += ccache distcc icecc 27CC_WRAPPERS := ${CC_WRAPPERS:O:u} 28# $W can be as simple or complicated as you like (default is just $w) 29# eg. 30# CCACHE ?= ${CCACHE_ENV_VARS:@v@$v='${$v}'@} ${CCACHE_CMD} ${CCACHE_FLAGS} 31# or if you want global vars to be used modifiable after this include: 32# CCACHE ?= $${CCACHE_ENV_VARS:@v@$$v='$${$$v}'@} $${CCACHE_CMD} $${CCACHE_FLAGS} 33.for w in ${CC_WRAPPERS} 34${w:tu} ?= $w 35.endfor 36 37# we do not want to make all these targets out-of-date 38# just because one of the above wrappers are enabled/disabled 39${CC_WRAP_TARGETS}: .MAKE.META.CMP_FILTER = ${CC_WRAPPERS:tu:@W@${$W}@:S,^,N,} 40 41# some object src types we should not wrap 42CC_WRAP_SKIP_EXTS += s 43 44# We add the sequence we care about - excluding CC_WRAP_SKIP_EXTS 45# but prior filters can apply to full value of .IMPSRC 46CC_WRAP_FILTER += E:tl:${CC_WRAP_SKIP_EXTS:${M_ListToSkip}} 47CC_WRAP_FILTER := ${CC_WRAP_FILTER:ts:} 48 49# last one enabled wins! 50.for W in ${CC_WRAPPERS:tu} 51.if ${MK_$W:U} == "yes" 52.for C in ${CC_WRAP_LIST} 53# we have to protect the check of .IMPSRC from Global expansion 54${CC_WRAP_TARGETS}: $C = $${"$${.IMPSRC:${CC_WRAP_FILTER}}":?${$W}:} ${$C} 55.endfor 56.endif 57.endfor 58 59.endif 60.endif 61 62