Changeset View
Changeset View
Standalone View
Standalone View
Mk/bsd.ccache.mk
Show All 32 Lines | |||||
# | # | ||||
COMMANDS_Include_MAINTAINER= portmgr@FreeBSD.org | COMMANDS_Include_MAINTAINER= portmgr@FreeBSD.org | ||||
.if !defined(_CCACHEMKINCLUDED) | .if !defined(_CCACHEMKINCLUDED) | ||||
_CCACHEMKINCLUDED= yes | _CCACHEMKINCLUDED= yes | ||||
.if defined(NOCCACHE) | . if defined(NOCCACHE) | ||||
NO_CCACHE= t | NO_CCACHE= t | ||||
.endif | . endif | ||||
# HOME is always set to ${WRKDIR} now. Try to use /root/.ccache as default. | # HOME is always set to ${WRKDIR} now. Try to use /root/.ccache as default. | ||||
.if defined(WITH_CCACHE_BUILD) && !defined(CCACHE_DIR) | . if defined(WITH_CCACHE_BUILD) && !defined(CCACHE_DIR) | ||||
. if defined(USER) && ${USER} == root | . if defined(USER) && ${USER} == root | ||||
CCACHE_DIR= /root/.ccache | CCACHE_DIR= /root/.ccache | ||||
. else | . else | ||||
NO_CCACHE= yes | NO_CCACHE= yes | ||||
WARNING+= WITH_CCACHE_BUILD support disabled, please set CCACHE_DIR. | WARNING+= WITH_CCACHE_BUILD support disabled, please set CCACHE_DIR. | ||||
. endif | . endif | ||||
.endif | . endif | ||||
# Support NO_CCACHE for common setups, require WITH_CCACHE_BUILD, and | # Support NO_CCACHE for common setups, require WITH_CCACHE_BUILD, and | ||||
# don't use if ccache already set in CC | # don't use if ccache already set in CC | ||||
.if !defined(NO_CCACHE) && defined(WITH_CCACHE_BUILD) && !${CC:M*ccache*} && \ | . if !defined(NO_CCACHE) && defined(WITH_CCACHE_BUILD) && !${CC:M*ccache*} && \ | ||||
!defined(NO_BUILD) | !defined(NO_BUILD) | ||||
# Poudriere will only define CCACHE_WRAPPER_PATH for using a host-static ccache | # Poudriere will only define CCACHE_WRAPPER_PATH for using a host-static ccache | ||||
# binary. | # binary. | ||||
.if defined(CCACHE_WRAPPER_PATH) | . if defined(CCACHE_WRAPPER_PATH) | ||||
CCACHE_PKG_PREFIX= ${CCACHE_WRAPPER_PATH:C,/libexec/ccache$,,} | CCACHE_PKG_PREFIX= ${CCACHE_WRAPPER_PATH:C,/libexec/ccache$,,} | ||||
.endif | . endif | ||||
CCACHE_PKG_PREFIX?= ${LOCALBASE} | CCACHE_PKG_PREFIX?= ${LOCALBASE} | ||||
CCACHE_WRAPPER_PATH?= ${CCACHE_PKG_PREFIX}/libexec/ccache | CCACHE_WRAPPER_PATH?= ${CCACHE_PKG_PREFIX}/libexec/ccache | ||||
CCACHE_BIN?= ${CCACHE_PKG_PREFIX}/bin/ccache | CCACHE_BIN?= ${CCACHE_PKG_PREFIX}/bin/ccache | ||||
# Avoid depends loops between ccache and pkg | # Avoid depends loops between ccache and pkg | ||||
. if !defined(NO_CCACHE_DEPEND) && \ | . if !defined(NO_CCACHE_DEPEND) && \ | ||||
${PKGORIGIN} != ${PKG_ORIGIN} | ${PKGORIGIN} != ${PKG_ORIGIN} | ||||
BUILD_DEPENDS+= ${CCACHE_BIN}:devel/ccache | BUILD_DEPENDS+= ${CCACHE_BIN}:devel/ccache | ||||
. endif | . endif | ||||
.if exists(${CCACHE_WRAPPER_PATH}) | . if exists(${CCACHE_WRAPPER_PATH}) | ||||
# Prepend the ccache dir into the PATH and setup ccache env | # Prepend the ccache dir into the PATH and setup ccache env | ||||
PATH:= ${CCACHE_WRAPPER_PATH}:${PATH} | PATH:= ${CCACHE_WRAPPER_PATH}:${PATH} | ||||
#.MAKEFLAGS: PATH=${PATH} | #.MAKEFLAGS: PATH=${PATH} | ||||
.if !${MAKE_ENV:MPATH=*} && !${CONFIGURE_ENV:MPATH=*} | . if !${MAKE_ENV:MPATH=*} && !${CONFIGURE_ENV:MPATH=*} | ||||
MAKE_ENV+= PATH=${PATH} | MAKE_ENV+= PATH=${PATH} | ||||
CONFIGURE_ENV+= PATH=${PATH} | CONFIGURE_ENV+= PATH=${PATH} | ||||
.endif | . endif | ||||
# Ensure this is always in subchild environments | # Ensure this is always in subchild environments | ||||
. if defined(CCACHE_DIR) | . if defined(CCACHE_DIR) | ||||
#.MAKEFLAGS: CCACHE_DIR=${CCACHE_DIR} | #.MAKEFLAGS: CCACHE_DIR=${CCACHE_DIR} | ||||
MAKE_ENV+= CCACHE_DIR="${CCACHE_DIR}" | MAKE_ENV+= CCACHE_DIR="${CCACHE_DIR}" | ||||
CONFIGURE_ENV+= CCACHE_DIR="${CCACHE_DIR}" | CONFIGURE_ENV+= CCACHE_DIR="${CCACHE_DIR}" | ||||
. endif | . endif | ||||
.endif | . endif | ||||
# Some ports will truncate CCACHE_DIR from the env and due to HOME=${WRKDIR} | # Some ports will truncate CCACHE_DIR from the env and due to HOME=${WRKDIR} | ||||
# will incorrectly use ${WRKDIR}/.ccache. Symlink to the proper place. | # will incorrectly use ${WRKDIR}/.ccache. Symlink to the proper place. | ||||
${WRKDIR}/.ccache: ${WRKDIR} | ${WRKDIR}/.ccache: ${WRKDIR} | ||||
@${LN} -sf ${CCACHE_DIR} ${WRKDIR}/.ccache | @${LN} -sf ${CCACHE_DIR} ${WRKDIR}/.ccache | ||||
ccache-wrkdir-link: ${WRKDIR}/.ccache .PHONY | ccache-wrkdir-link: ${WRKDIR}/.ccache .PHONY | ||||
post-extract: ccache-wrkdir-link | post-extract: ccache-wrkdir-link | ||||
.endif | . endif | ||||
.endif | .endif |