Fix build with gcc 4.6 and add support for ccache.