Import devel/fpc-fpmkunit version 2.6.4
[dports.git] / Mk / bsd.ccache.mk
1 # $FreeBSD$
2
3 COMMANDS_Include_MAINTAINER=    portmgr@FreeBSD.org
4
5 .if !defined(_CCACHEMKINCLUDED)
6
7 _CCACHEMKINCLUDED=      yes
8
9 # Try to set a default CCACHE_DIR to workaround HOME=/dev/null and
10 # HOME=${WRKDIR}/* staging fixes
11 .if defined(WITH_CCACHE_BUILD) && !defined(CCACHE_DIR) && \
12     (!defined(HOME) || ${HOME} == /dev/null || ${HOME:S/^${WRKDIR}//} != ${HOME})
13 .  if defined(USER) && ${USER} == root
14 CCACHE_DIR=     /root/.ccache
15 .  else
16 NO_CCACHE=      yes
17 WARNING+=       WITH_CCACHE_BUILD support disabled, please set CCACHE_DIR.
18 .  endif
19 .endif
20
21 # Support NO_CCACHE for common setups, require WITH_CCACHE_BUILD, and
22 # don't use if ccache already set in CC
23 .if !defined(NO_CCACHE) && defined(WITH_CCACHE_BUILD) && !${CC:M*ccache*} && \
24   !defined(NO_BUILD) && !defined(NOCCACHE)
25 # Avoid depends loops between pkg and ccache
26 .       if !${.CURDIR:M*/devel/ccache} && !${.CURDIR:M*/ports-mgmt/pkg}
27 BUILD_DEPENDS+=         ${LOCALBASE}/bin/ccache:${PORTSDIR}/devel/ccache
28 .       endif
29
30 _CCACHE_PATH=   ${LOCALBASE}/libexec/ccache
31
32 # Prepend the ccache dir into the PATH and setup ccache env
33 PATH:=  ${_CCACHE_PATH}:${PATH}
34 #.MAKEFLAGS:            PATH=${PATH}
35 .if !${MAKE_ENV:MPATH=*} && !${CONFIGURE_ENV:MPATH=*}
36 MAKE_ENV+=                      PATH=${PATH}
37 CONFIGURE_ENV+=         PATH=${PATH}
38 .endif
39
40 # Ensure this is always in subchild environments
41 .       if defined(CCACHE_DIR)
42 #.MAKEFLAGS:            CCACHE_DIR=${CCACHE_DIR}
43 MAKE_ENV+=              CCACHE_DIR="${CCACHE_DIR}"
44 CONFIGURE_ENV+= CCACHE_DIR="${CCACHE_DIR}"
45 .       endif
46 .endif
47
48 .endif