makefileautotoolsccache

Detect if a compiler is using ccache


ccache does not support some compiler options (e.g. --coverage). If there is an unsupported compiler options it compiles but the cache is not used.

There are more than one ways how to enable ccache (modifying PATH, using CC/CXX environment variables).

I would like to detect if the compiler uses ccache and if yes disable the unsupported compiler options.

The best i have come up with is something like this:

CC = $(shell which $(CC))
ifeq (,$(findstring ccache,$(CC)))

Any ideas how to improve this?


Solution

  • This might be a more elegant solution:

    ifeq ($(shell readlink -f `which $(CC)`),$(shell which ccache))
        echo "Using ccache"
    else
        echo "Not using ccache"
    endif