Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to FreeBSD (9.1) and I'm just setting up the system. One problem that I could not solve yet is to get ccache working. I installed it from ports and followed the guidelines in the documentation (modify /etc/make.conf). Compile new packages from ports works without errors but the cache is never filled, so it seems that ccache is simply not used.

Here is the content of my /etc/make.conf file:

# added by use.perl 2013-01-20 01:08:34

# the rest here is copied from /usr/local/share/doc/ccache/ccache-howto-freebsd.txt
.if (!empty(.CURDIR:M/usr/src*) || !empty(.CURDIR:M/usr/obj*))
.if !defined(NOCCACHE)

I also tried to follow the other guidelines in ccache-howto-freebsd.txt and added the following lines to /etc/csh.cshrc, which is the default shell used by root:

setenv PATH /usr/local/libexec/ccache:$PATH
setenv CCACHE_PATH /usr/bin:/usr/local/bin

Still no difference. ccache -s shows that the cache is still not filled during compilation. Do you have any ideas?

share|improve this question
got to a port directory you want to install and type make -V CC. The result should show ccache. If not, try to remove the first if statement, i am not sure what it is supposed to do. – arved Jan 22 '13 at 16:46
@arved Thanks, that solved my problem! I'll posted your comment as the accepted answer. Still I don't know the purpose of the if-statement (which I just copied). – Philipp Claßen Jan 22 '13 at 23:28
up vote 0 down vote accepted

(arved's comment was right. It solved my problem, but I still don't understand exactly why the if statement was recommended, anyway. Thus, I post the answer as community wiki. Feel free to improve it if you know why.)

First, find out which compiler is used:

 $ cd /usr/ports/devel/gdb && make -V CC

cc is the default C compiler but it should be ccache.

To solve the problem, edit /etc/make.conf and remove the if-statement ...

.if (!empty(.CURDIR:M/usr/src*) || !empty(.CURDIR:M/usr/obj*))`

... and, of course, its closing .endif statement. Then the problem is solved:

 $ cd /usr/ports/devel/gdb && make -V CC
share|improve this answer

I meet the same problem. A solution that works for me is the following /etc/make.conf

# added by use.perl 2013-09-06 18:26:40

.if !defined(NO_CCACHE)
    CC= /usr/local/libexec/ccache/world/cc
    CXX= /usr/local/libexec/ccache/world/c++

.if ${.CURDIR:M*/ports/devel/ccache}
    NO_CCACHE= yes
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.