1################################################################################ 2# 3# ccache 4# 5################################################################################ 6 7CCACHE_VERSION = 3.7.12 8CCACHE_SITE = https://github.com/ccache/ccache/releases/download/v$(CCACHE_VERSION) 9CCACHE_SOURCE = ccache-$(CCACHE_VERSION).tar.xz 10CCACHE_LICENSE = GPL-3.0+, others 11CCACHE_LICENSE_FILES = LICENSE.adoc GPL-3.0.txt 12 13# Force ccache to use its internal zlib. The problem is that without 14# this, ccache would link against the zlib of the build system, but we 15# might build and install a different version of zlib in $(O)/host 16# afterwards, which ccache will pick up. This might break if there is 17# a version mismatch. A solution would be to add host-zlib has a 18# dependency of ccache, but it would require tuning the zlib .mk file 19# to use HOSTCC_NOCCACHE as the compiler. Instead, we take the easy 20# path: tell ccache to use its internal copy of zlib, so that ccache 21# has zero dependency besides the C library. 22HOST_CCACHE_CONF_OPTS += --with-bundled-zlib 23 24# We are ccache, so we can't use ccache 25HOST_CCACHE_CONF_ENV = \ 26 CC="$(HOSTCC_NOCCACHE)" \ 27 CXX="$(HOSTCXX_NOCCACHE)" 28 29# Patch host-ccache as follows: 30# - Use BR_CACHE_DIR instead of CCACHE_DIR, because CCACHE_DIR 31# is already used by autotargets for the ccache package. 32# BR_CACHE_DIR is exported by Makefile based on config option 33# BR2_CCACHE_DIR. 34# - Change hard-coded last-ditch default to match path in .config, to avoid 35# the need to specify BR_CACHE_DIR when invoking ccache directly. 36# CCache replaces "%s" with the home directory of the current user, 37# So rewrite BR_CACHE_DIR to take that into consideration for SDK purpose 38HOST_CCACHE_DEFAULT_CCACHE_DIR = $(patsubst $(HOME)/%,\%s/%,$(BR_CACHE_DIR)) 39 40define HOST_CCACHE_PATCH_CONFIGURATION 41 sed -i 's,getenv("CCACHE_DIR"),getenv("BR_CACHE_DIR"),' $(@D)/src/ccache.c 42 sed -i 's,"%s/.ccache","$(HOST_CCACHE_DEFAULT_CCACHE_DIR)",' $(@D)/src/conf.c 43endef 44 45HOST_CCACHE_POST_PATCH_HOOKS += HOST_CCACHE_PATCH_CONFIGURATION 46 47define HOST_CCACHE_MAKE_CACHE_DIR 48 mkdir -p $(BR_CACHE_DIR) 49endef 50 51HOST_CCACHE_POST_INSTALL_HOOKS += HOST_CCACHE_MAKE_CACHE_DIR 52 53# Provide capability to do initial ccache setup (e.g. increase default size) 54BR_CCACHE_INITIAL_SETUP = $(call qstrip,$(BR2_CCACHE_INITIAL_SETUP)) 55ifneq ($(BR_CCACHE_INITIAL_SETUP),) 56define HOST_CCACHE_DO_INITIAL_SETUP 57 @$(call MESSAGE,"Applying initial settings") 58 $(CCACHE) $(BR_CCACHE_INITIAL_SETUP) 59 $(CCACHE) -s 60endef 61 62HOST_CCACHE_POST_INSTALL_HOOKS += HOST_CCACHE_DO_INITIAL_SETUP 63endif 64 65$(eval $(host-autotools-package)) 66 67ifeq ($(BR2_CCACHE),y) 68ccache-stats: host-ccache 69 $(Q)$(CCACHE) -s 70 71ccache-options: host-ccache 72ifeq ($(CCACHE_OPTIONS),) 73 $(Q)echo "Usage: make ccache-options CCACHE_OPTIONS=\"opts\"" 74 $(Q)echo "where 'opts' corresponds to one or more valid ccache options" \ 75 "(see ccache help text below)" 76 $(Q)echo 77endif 78 $(Q)$(CCACHE) $(CCACHE_OPTIONS) 79endif 80