forked from mxe/mxe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccache.mk
94 lines (81 loc) · 3.4 KB
/
ccache.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# This file is part of MXE. See LICENSE.md for licensing information.
PKG := ccache
$(PKG)_WEBSITE := https://ccache.samba.org
$(PKG)_DESCR := ccache – a fast compiler cache
$(PKG)_IGNORE :=
$(PKG)_VERSION := 3.6
$(PKG)_CHECKSUM := a6b129576328fcefad00cb72035bc87bc98b6a76aec0f4b59bed76d67a399b1f
$(PKG)_SUBDIR := ccache-$($(PKG)_VERSION)
$(PKG)_FILE := ccache-$($(PKG)_VERSION).tar.xz
$(PKG)_URL := https://www.samba.org/ftp/ccache/ccache-$($(PKG)_VERSION).tar.xz
$(PKG)_DEPS := $(BUILD)~$(PKG)
$(PKG)_TARGETS := $(BUILD) $(MXE_TARGETS)
$(PKG)_DEPS_$(BUILD) :=
define $(PKG)_UPDATE
$(call GET_LATEST_VERSION, https://www.samba.org/ftp/ccache)
endef
BOOTSTRAP_PKGS += ccache
$(PKG)_SYS_CONF := $(MXE_CCACHE_DIR)/etc/$(PKG).conf
$(PKG)_USR_CONF := $(MXE_CCACHE_DIR)/$(PKG).conf
ifeq (mxe,$(MXE_USE_CCACHE))
define $(PKG)_BUILD_$(BUILD)
# remove any previous symlinks
rm -fv '$(PREFIX)/$(BUILD)/bin/$(BUILD_CC)' '$(PREFIX)/$(BUILD)/bin/$(BUILD_CXX)'
# minimal reqs build with bundled zlib
cd '$(BUILD_DIR)' && $(SOURCE_DIR)/configure \
$(MXE_CONFIGURE_OPTS) \
--with-bundled-zlib \
--disable-man \
--prefix='$(MXE_CCACHE_DIR)' \
--sysconfdir='$(dir $($(PKG)_SYS_CONF))'
$(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' $(MXE_DISABLE_DOCS)
$(MAKE) -C '$(BUILD_DIR)' -j 1 install $(MXE_DISABLE_DOCS)
# setup symlinks
ln -sf '$(MXE_CCACHE_DIR)/bin/ccache' '$(PREFIX)/$(BUILD)/bin/$(BUILD_CC)'
ln -sf '$(MXE_CCACHE_DIR)/bin/ccache' '$(PREFIX)/$(BUILD)/bin/$(BUILD_CXX)'
# https://ccache.samba.org/manual/latest.html#_configuration_settings
# always set/replace mxe `system` config
mkdir -p '$(dir $($(PKG)_SYS_CONF))'
(echo '# ccache system config'; \
echo '# this file is controlled by mxe, user config is in:'; \
echo '# $($(PKG)_USR_CONF)'; \
echo; \
echo 'base_dir = $(MXE_CCACHE_BASE_DIR)'; \
echo 'cache_dir = $(MXE_CCACHE_CACHE_DIR)'; \
echo 'compiler_check = %compiler% -v'; \
) > '$($(PKG)_SYS_CONF)'
# leave user config alone if set
[ -f '$($(PKG)_USR_CONF)' ] || \
(mkdir -p '$(dir $($(PKG)_USR_CONF))' && \
(echo '# ccache user config'; \
echo '# https://ccache.samba.org/manual/latest.html#_configuration_settings'; \
echo '# system config: $($(PKG)_SYS_CONF)'; \
echo; \
echo 'max_size = 20.0G'; \
) > '$($(PKG)_USR_CONF)')
endef
define $(PKG)_BUILD
# setup symlinks
ln -sf '$(MXE_CCACHE_DIR)/bin/ccache' '$(PREFIX)/$(BUILD)/bin/$(TARGET)-gcc'
ln -sf '$(MXE_CCACHE_DIR)/bin/ccache' '$(PREFIX)/$(BUILD)/bin/$(TARGET)-g++'
# setup cmake toolchain to allow runtime override
# CMAKE_CXX_COMPILER_LAUNCHER shows original cc and isn't clear in logs etc.
mkdir -p '$(CMAKE_TOOLCHAIN_DIR)'
(echo 'option(MXE_USE_CCACHE "Enable ccache by default" ON)'; \
echo 'if(MXE_USE_CCACHE)'; \
echo ' set(CMAKE_C_COMPILER $(PREFIX)/$(BUILD)/bin/$(TARGET)-gcc)'; \
echo ' set(CMAKE_CXX_COMPILER $(PREFIX)/$(BUILD)/bin/$(TARGET)-g++)'; \
echo 'endif()'; \
) > '$(CMAKE_TOOLCHAIN_DIR)/$(PKG).cmake'
endef
else
define $(PKG)_BUILD_$(BUILD)
# remove symlinks
rm -fv '$(PREFIX)/$(BUILD)/bin/$(BUILD_CC)' '$(PREFIX)/$(BUILD)/bin/$(BUILD_CXX)'
endef
define $(PKG)_BUILD
# remove symlinks and cmake toolchain
rm -fv '$(PREFIX)/$(BUILD)/bin/$(TARGET)-'*
rm -fv '$(CMAKE_TOOLCHAIN_DIR)/$(PKG).cmake'
endef
endif