Ports infrastructure now optionally supports ccache. This isn't
a general purpose thing but is mainly intended for ports developers
building huge ports. It's especially helpful if you make changes
to minor things like install directory locations and need to keep
rebuilding/packaging to check your work.
ccache examines source code and when you try to build the same
code, with the same compiler and same compiler options, it returns
an object from a cache where possible. It isn't able to do this
with all files but tries hard to silently invoke the compiler
when there's anything it can't handle.
It is careful to avoid anything which causes false cache hits; see
"HOW CCACHE WORKS" in ccache(1) for more details. Note in particular
that information about the compiler (by default: size and modification
time) is included in the hash in order that toolchain changes cause
things to be recompiled.
Typically you would enable it by adding something like this to mk.conf:
USE_CCACHE=Yes
Cached files are placed in ${WRKOBJDIR_${PKGPATH}}/.ccache by
default. Unless overridden this expands to /usr/ports/pobj/.ccache.
This can be changed by setting CCACHE_DIR. You might want to also
place CCACHE_DIR in your shell environment so that control and
information commands like "ccache -s" (stats) work. Commands to
work on the cache (adjust size, cleanup, etc) are generally
done with ccache(1).
Other configuration is done by environment; this can be passed
in with mk.conf settings e.g.:
CCACHE_ENV="CCACHE_LOGFILE=/tmp/ccache.log CCACHE_COMPRESS=yes"
See bsd.port.mk(5) and of course ccache's own documentation for more.