# local.init.mk | 36 ++++++++++++++++++++++++++++++++++++ # 1 file changed, 36 insertions(+) # svn status M share/mk/local.init.mk Index: share/mk/local.init.mk =================================================================== --- share/mk/local.init.mk (revision 289439) +++ share/mk/local.init.mk (working copy) @@ -38,3 +38,39 @@ CPP= ${HOST_CPP} HOST_CFLAGS+= -DHOSTPROG CFLAGS+= ${HOST_CFLAGS} .endif + +# Handle ccache after CC is determined. If CC is at some specific path then +# we must prepend the ccache wrapper. Otherwise we can just prepend PATH with +# the wrapper location, which is a more safe solution since it avoids spaces +# and compiler type guessing based on filename. +LOCALBASE?= /usr/local +CCACHE_WRAPPER_PATH?= ${LOCALBASE}/libexec/ccache +CCACHE_PATH?= ${LOCALBASE}/bin/ccache +.if defined(WITH_CCACHE_BUILD) && !defined(NOCCACHE) && \ + ${CC:M*ccache*} == "" && exists(${CCACHE_PATH}) +# Handle compiler changes properly. This avoids needing to use the 'world' +# wrappers. +CCACHE_COMPILERCHECK?= content +.export CCACHE_COMPILERCHECK +.if ${CC:M/*} == "" +# Can prepend to PATH, but don't add in if already there. +.if !${PATH:M${CCACHE_WRAPPER_PATH}\:*} +PATH:= ${CCACHE_WRAPPER_PATH}:${PATH} +.export PATH +.endif +.else +# Must prepend CC. +CC:= ${CCACHE_PATH} ${CC} +CXX:= ${CCACHE_PATH} ${CXX} +CPP:= ${CCACHE_PATH} ${CPP} +.if defined(HOST_CC) +HOST_CC:= ${CCACHE_PATH} ${HOST_CC} +.endif +.if defined(HOST_CXX) +HOST_CXX:= ${CCACHE_PATH} ${HOST_CXX} +.endif +.if defined(HOST_CPP) +HOST_CPP:= ${CCACHE_PATH} ${HOST_CPP} +.endif +.endif +.endif # WITH_CCACHE_BUILD