aboutsummaryrefslogtreecommitdiff
path: root/Mk/bsd.ccache.mk
diff options
context:
space:
mode:
Diffstat (limited to 'Mk/bsd.ccache.mk')
-rw-r--r--Mk/bsd.ccache.mk44
1 files changed, 26 insertions, 18 deletions
diff --git a/Mk/bsd.ccache.mk b/Mk/bsd.ccache.mk
index fa1b32ca8cfd..83f225748420 100644
--- a/Mk/bsd.ccache.mk
+++ b/Mk/bsd.ccache.mk
@@ -11,6 +11,7 @@
# default.
#
# Port use (users should not modify these):
+# - CCACHE_ENABLED - tells the port if ccache is enabled.
# - CCACHE_BIN - path to the ccache binary. Intended to be prefixed before CC.
# - CCACHE_WRAPPER_PATH - path to directory containing compiler symlinks back
# to ccache. For example, gcc5 -> ccache. Intended
@@ -38,56 +39,63 @@ COMMANDS_Include_MAINTAINER= portmgr@FreeBSD.org
_CCACHEMKINCLUDED= yes
-.if defined(NOCCACHE)
+. if defined(NOCCACHE)
NO_CCACHE= t
-.endif
+. endif
+
+. if defined(WITH_CCACHE_BUILD)
+CCACHE_ENABLED= yes
+. else
+CCACHE_ENABLED= no
+. endif
# HOME is always set to ${WRKDIR} now. Try to use /root/.ccache as default.
-.if defined(WITH_CCACHE_BUILD) && !defined(CCACHE_DIR)
-. if defined(USER) && ${USER} == root
+. if defined(WITH_CCACHE_BUILD) && !defined(CCACHE_DIR)
+. if defined(USER) && ${USER} == root
CCACHE_DIR= /root/.ccache
-. else
+. else
+CCACHE_ENABLED= no
NO_CCACHE= yes
WARNING+= WITH_CCACHE_BUILD support disabled, please set CCACHE_DIR.
+. endif
. endif
-.endif
# Support NO_CCACHE for common setups, require WITH_CCACHE_BUILD, and
# 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)
# Poudriere will only define CCACHE_WRAPPER_PATH for using a host-static ccache
# binary.
-.if defined(CCACHE_WRAPPER_PATH)
+. if defined(CCACHE_WRAPPER_PATH)
CCACHE_PKG_PREFIX= ${CCACHE_WRAPPER_PATH:C,/libexec/ccache$,,}
-.endif
+. endif
CCACHE_PKG_PREFIX?= ${LOCALBASE}
CCACHE_WRAPPER_PATH?= ${CCACHE_PKG_PREFIX}/libexec/ccache
CCACHE_BIN?= ${CCACHE_PKG_PREFIX}/bin/ccache
# Avoid depends loops between ccache and pkg
-. if !defined(NO_CCACHE_DEPEND) && \
+. if !defined(NO_CCACHE_DEPEND) && \
${PKGORIGIN} != ${PKG_ORIGIN}
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
PATH:= ${CCACHE_WRAPPER_PATH}:${PATH}
#.MAKEFLAGS: PATH=${PATH}
-.if !${MAKE_ENV:MPATH=*} && !${CONFIGURE_ENV:MPATH=*}
+. if !${MAKE_ENV:MPATH=*} && !${CONFIGURE_ENV:MPATH=*}
MAKE_ENV+= PATH=${PATH}
CONFIGURE_ENV+= PATH=${PATH}
-.endif
+. endif
# Ensure this is always in subchild environments
-. if defined(CCACHE_DIR)
+. if defined(CCACHE_DIR)
#.MAKEFLAGS: CCACHE_DIR=${CCACHE_DIR}
MAKE_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}
# will incorrectly use ${WRKDIR}/.ccache. Symlink to the proper place.
@@ -95,6 +103,6 @@ ${WRKDIR}/.ccache: ${WRKDIR}
@${LN} -sf ${CCACHE_DIR} ${WRKDIR}/.ccache
ccache-wrkdir-link: ${WRKDIR}/.ccache .PHONY
post-extract: ccache-wrkdir-link
-.endif
+. endif
.endif