1#-*- tab-width: 4; -*- 2# ex:ts=4 3# 4# User settable: 5# - WITH_CCACHE_BUILD - enables depending on ccache and using it in the build. 6# - CCACHE_PKG_PREFIX - where ccache is already installed. Default: LOCALBASE 7# This should not be set unless it differs from the 8# default. 9# - CCACHE_DIR (optional) - where ccache stores its cache. See ccache(1). 10# This should not be set unless it differs from the 11# default. 12# 13# Port use (users should not modify these): 14# - CCACHE_ENABLED - tells the port if ccache is enabled. 15# - CCACHE_BIN - path to the ccache binary. Intended to be prefixed before CC. 16# - CCACHE_WRAPPER_PATH - path to directory containing compiler symlinks back 17# to ccache. For example, gcc5 -> ccache. Intended 18# to be added to $PATH 19# This is expected to end in /libexec/ccache. 20# 21# In general CCACHE_WRAPPER_PATH should be placed into the env PATH for a 22# port build rather than directly invoking CCACHE_BIN. Then when the port 23# runs 'cc' or 'gcc5' it will find the symlinks. If a port is directly 24# using a full path to a specific compiler then CCACHE_BIN can possibly be 25# prefixed in front of it, if the CC path cannot be fixed to be relative. 26# 27# Port use (special case): 28# - NO_CCACHE - disable using ccache entirely. This is for when a port build 29# fails with ccache being used. Typically this should be 30# temporary only. 31# - NO_CCACHE_DEPEND - avoid automatically depending on ccache but still 32# attempt to use it in PATH. This is typically only 33# needed in devel/ccache itself. 34# 35 36COMMANDS_Include_MAINTAINER= ports@MidnightBSD.org 37 38.if !defined(_CCACHEMKINCLUDED) 39 40_CCACHEMKINCLUDED= yes 41 42. if defined(NOCCACHE) 43NO_CCACHE= t 44. endif 45 46. if defined(WITH_CCACHE_BUILD) 47CCACHE_ENABLED= yes 48. else 49CCACHE_ENABLED= no 50. endif 51 52# HOME is always set to ${WRKDIR} now. Try to use /root/.ccache as default. 53. if defined(WITH_CCACHE_BUILD) && !defined(CCACHE_DIR) 54. if defined(USER) && ${USER} == root 55CCACHE_DIR= /root/.ccache 56. else 57CCACHE_ENABLED= no 58NO_CCACHE= yes 59WARNING+= WITH_CCACHE_BUILD support disabled, please set CCACHE_DIR. 60. endif 61. endif 62 63# Support NO_CCACHE for common setups, require WITH_CCACHE_BUILD, and 64# don't use if ccache already set in CC 65. if !defined(NO_CCACHE) && defined(WITH_CCACHE_BUILD) && !${CC:M*ccache*} && \ 66 !defined(NO_BUILD) 67 68# Poudriere will only define CCACHE_WRAPPER_PATH for using a host-static ccache 69# binary. 70. if defined(CCACHE_WRAPPER_PATH) 71CCACHE_PKG_PREFIX= ${CCACHE_WRAPPER_PATH:C,/libexec/ccache$,,} 72. endif 73CCACHE_PKG_PREFIX?= ${LOCALBASE} 74CCACHE_WRAPPER_PATH?= ${CCACHE_PKG_PREFIX}/libexec/ccache 75CCACHE_BIN?= ${CCACHE_PKG_PREFIX}/bin/ccache 76 77# Avoid depends loops between ccache and pkg 78. if !defined(NO_CCACHE_DEPEND) && \ 79 ${PKGORIGIN} != ${PKG_ORIGIN} 80BUILD_DEPENDS+= ${CCACHE_BIN}:devel/ccache 81. endif 82 83. if exists(${CCACHE_WRAPPER_PATH}) 84# Prepend the ccache dir into the PATH and setup ccache env 85PATH:= ${CCACHE_WRAPPER_PATH}:${PATH} 86#.MAKEFLAGS: PATH=${PATH} 87. if !${MAKE_ENV:MPATH=*} && !${CONFIGURE_ENV:MPATH=*} 88MAKE_ENV+= PATH=${PATH} 89CONFIGURE_ENV+= PATH=${PATH} 90. endif 91 92# Ensure this is always in subchild environments 93. if defined(CCACHE_DIR) 94#.MAKEFLAGS: CCACHE_DIR=${CCACHE_DIR} 95MAKE_ENV+= CCACHE_DIR="${CCACHE_DIR}" 96CONFIGURE_ENV+= CCACHE_DIR="${CCACHE_DIR}" 97. endif 98. endif 99 100# Some ports will truncate CCACHE_DIR from the env and due to HOME=${WRKDIR} 101# will incorrectly use ${WRKDIR}/.ccache. Symlink to the proper place. 102${WRKDIR}/.ccache: ${WRKDIR} 103 @${LN} -sf ${CCACHE_DIR} ${WRKDIR}/.ccache 104ccache-wrkdir-link: ${WRKDIR}/.ccache .PHONY 105post-extract: ccache-wrkdir-link 106. endif 107 108# enable ccache in case of USES=llvm and cmake 109. if ${CCACHE_ENABLED} == yes && \ 110 defined(_INCLUDE_USES_LLVM_MK) && \ 111 defined(_INCLUDE_USES_CMAKE_MK) 112CMAKE_ARGS+= -DCMAKE_C_COMPILER_LAUNCHER=ccache \ 113 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache 114. endif 115 116.endif 117