5 # WITH_CCACHE_BUILD=yes enables depending on ccache and using it in the build.
6 # NO_CCACHE_DEPEND will additionally not add the dependency on ccache.
7 # NO_CCACHE will disable this entirely.
9 COMMANDS_Include_MAINTAINER= portmgr@FreeBSD.org
11 .if !defined(_CCACHEMKINCLUDED)
13 _CCACHEMKINCLUDED= yes
15 # HOME is always set to ${WRKDIR} now. Try to use /root/.ccache as default.
16 .if defined(WITH_CCACHE_BUILD) && !defined(CCACHE_DIR)
17 . if defined(USER) && ${USER} == root
18 CCACHE_DIR= /root/.ccache
21 WARNING+= WITH_CCACHE_BUILD support disabled, please set CCACHE_DIR.
25 # Support NO_CCACHE for common setups, require WITH_CCACHE_BUILD, and
26 # don't use if ccache already set in CC
27 .if !defined(NO_CCACHE) && defined(WITH_CCACHE_BUILD) && !${CC:M*ccache*} && \
28 !defined(NO_BUILD) && !defined(NOCCACHE)
30 # Avoid depends loops between ccache and pkg
31 . if !defined(NO_CCACHE_DEPEND) && \
32 ${PKGORIGIN} != ${PKG_ORIGIN}
33 BUILD_DEPENDS+= ${LOCALBASE}/bin/ccache:devel/ccache
36 CCACHE_WRAPPER_PATH?= ${LOCALBASE}/libexec/ccache
38 .if exists(${CCACHE_WRAPPER_PATH})
39 # Prepend the ccache dir into the PATH and setup ccache env
40 PATH:= ${CCACHE_WRAPPER_PATH}:${PATH}
41 #.MAKEFLAGS: PATH=${PATH}
42 .if !${MAKE_ENV:MPATH=*} && !${CONFIGURE_ENV:MPATH=*}
43 MAKE_ENV+= PATH=${PATH}
44 CONFIGURE_ENV+= PATH=${PATH}
47 # Ensure this is always in subchild environments
48 . if defined(CCACHE_DIR)
49 #.MAKEFLAGS: CCACHE_DIR=${CCACHE_DIR}
50 MAKE_ENV+= CCACHE_DIR="${CCACHE_DIR}"
51 CONFIGURE_ENV+= CCACHE_DIR="${CCACHE_DIR}"
55 # Some ports will truncate CCACHE_DIR from the env and due to HOME=${WRKDIR}
56 # will incorrectly use ${WRKDIR}/.ccache. Symlink to the proper place.
57 ${WRKDIR}/.ccache: ${WRKDIR}
58 @${LN} -sf ${CCACHE_DIR} ${WRKDIR}/.ccache
59 ccache-wrkdir-link: ${WRKDIR}/.ccache .PHONY
60 post-extract: ccache-wrkdir-link