1 #############################################################
3 # build ccache to make recompiles faster on the build system
5 #############################################################
7 CCACHE_SITE
:=http
://samba.org
/ftp
/ccache
8 CCACHE_SOURCE
:=ccache-
$(CCACHE_VER
).
tar.gz
9 CCACHE_DIR1
:=$(TOOL_BUILD_DIR
)/ccache-
$(CCACHE_VER
)
10 CCACHE_DIR2
:=$(BUILD_DIR
)/ccache-
$(CCACHE_VER
)
13 CCACHE_TARGET_BINARY
:=usr
/bin
/ccache
15 $(DL_DIR
)/$(CCACHE_SOURCE
):
16 $(WGET
) -P
$(DL_DIR
) $(CCACHE_SITE
)/$(CCACHE_SOURCE
)
18 $(CCACHE_DIR1
)/.unpacked
: $(DL_DIR
)/$(CCACHE_SOURCE
)
19 $(CCACHE_CAT
) $(DL_DIR
)/$(CCACHE_SOURCE
) |
tar -C
$(TOOL_BUILD_DIR
) $(TAR_OPTIONS
) -
22 $(CCACHE_DIR1
)/.patched
: $(CCACHE_DIR1
)/.unpacked
23 # WARNING - this will break if the toolchain is moved.
24 # Should probably patch things to use a relative path.
25 $(SED
) "s,getenv(\"CCACHE_PATH\"),\"$(STAGING_DIR)/usr/bin-ccache\",g" \
26 $(CCACHE_DIR1
)/execute.c
27 # WARNING - this will break if the toolchain build dir is deleted.
28 $(SED
) "s,getenv(\"CCACHE_DIR\"),\"$(CCACHE_DIR1)/cache\",g" \
29 $(CCACHE_DIR1
)/ccache.c
30 mkdir
-p
$(CCACHE_DIR1
)/cache
31 $(CONFIG_UPDATE
) $(@D
)
34 $(CCACHE_DIR1
)/.configured
: $(CCACHE_DIR1
)/.patched
35 mkdir
-p
$(CCACHE_DIR1
)
36 (cd
$(CCACHE_DIR1
); rm -rf config.cache
; \
38 $(CCACHE_DIR1
)/configure \
39 --target
=$(GNU_HOST_NAME
) \
40 --host
=$(GNU_HOST_NAME
) \
41 --build
=$(GNU_HOST_NAME
) \
46 $(CCACHE_DIR1
)/$(CCACHE_BINARY
): $(CCACHE_DIR1
)/.configured
47 $(MAKE
) CC
="$(HOSTCC)" -C
$(CCACHE_DIR1
)
49 $(STAGING_DIR
)/$(CCACHE_TARGET_BINARY
): $(CCACHE_DIR1
)/$(CCACHE_BINARY
)
50 mkdir
-p
$(STAGING_DIR
)/usr
/bin
51 cp
$(CCACHE_DIR1
)/ccache
$(STAGING_DIR
)/usr
/bin
52 # Keep the actual toolchain binaries in a directory at the same level.
53 # Otherwise, relative paths for include dirs break.
54 mkdir
-p
$(STAGING_DIR
)/usr
/bin-ccache
55 (cd
$(STAGING_DIR
)/usr
/bin-ccache
; \
56 ln
-fs
$(REAL_GNU_TARGET_NAME
)-gcc
$(GNU_TARGET_NAME
)-gcc
; \
57 ln
-fs
$(REAL_GNU_TARGET_NAME
)-gcc
$(GNU_TARGET_NAME
)-cc; \
58 ln
-fs
$(REAL_GNU_TARGET_NAME
)-gcc
$(REAL_GNU_TARGET_NAME
)-cc; \
60 [ -f
$(STAGING_DIR
)/usr
/bin
/$(REAL_GNU_TARGET_NAME
)-gcc
] && \
61 mv
$(STAGING_DIR
)/usr
/bin
/$(REAL_GNU_TARGET_NAME
)-gcc \
62 $(STAGING_DIR
)/usr
/bin-ccache
/
63 (cd
$(STAGING_DIR
)/usr
/bin
; \
64 ln
-fs ccache
$(GNU_TARGET_NAME
)-cc; \
65 ln
-fs ccache
$(GNU_TARGET_NAME
)-gcc
; \
66 ln
-fs ccache
$(REAL_GNU_TARGET_NAME
)-cc; \
67 ln
-fs ccache
$(REAL_GNU_TARGET_NAME
)-gcc
; \
69 ifeq ($(BR2_INSTALL_LIBSTDCPP
),y
)
70 [ -f
$(STAGING_DIR
)/usr
/bin
/$(REAL_GNU_TARGET_NAME
)-c
++ ] && \
71 mv
$(STAGING_DIR
)/usr
/bin
/$(REAL_GNU_TARGET_NAME
)-c
++ \
72 $(STAGING_DIR
)/usr
/bin-ccache
/
73 [ -f
$(STAGING_DIR
)/usr
/bin
/$(REAL_GNU_TARGET_NAME
)-g
++ ] && \
74 mv
$(STAGING_DIR
)/usr
/bin
/$(REAL_GNU_TARGET_NAME
)-g
++ \
75 $(STAGING_DIR
)/usr
/bin-ccache
/
76 (cd
$(STAGING_DIR
)/usr
/bin
; \
77 ln
-fs ccache
$(GNU_TARGET_NAME
)-c
++; \
78 ln
-fs ccache
$(GNU_TARGET_NAME
)-g
++;\
79 ln
-fs ccache
$(REAL_GNU_TARGET_NAME
)-c
++; \
80 ln
-fs ccache
$(REAL_GNU_TARGET_NAME
)-g
++; \
82 (cd
$(STAGING_DIR
)/usr
/bin-ccache
; \
83 ln
-fs
$(REAL_GNU_TARGET_NAME
)-c
++ $(GNU_TARGET_NAME
)-c
++; \
84 ln
-fs
$(REAL_GNU_TARGET_NAME
)-g
++ $(GNU_TARGET_NAME
)-g
++; \
88 ccache
: gcc
$(STAGING_DIR
)/$(CCACHE_TARGET_BINARY
)
91 rm -rf
$(STAGING_DIR
)/usr
/bin
/$(GNU_TARGET_NAME
)-cc
92 rm -rf
$(STAGING_DIR
)/usr
/bin
/$(GNU_TARGET_NAME
)-gcc
93 rm -rf
$(STAGING_DIR
)/usr
/bin
/$(REAL_GNU_TARGET_NAME
)-cc
94 rm -rf
$(STAGING_DIR
)/usr
/bin
/$(REAL_GNU_TARGET_NAME
)-gcc
95 if
[ -f
$(STAGING_DIR
)/usr
/bin-ccache
/$(REAL_GNU_TARGET_NAME
)-gcc
]; then \
96 mv
$(STAGING_DIR
)/usr
/bin-ccache
/$(REAL_GNU_TARGET_NAME
)-gcc \
97 $(STAGING_DIR
)/usr
/bin
/; \
98 (cd
$(STAGING_DIR
)/usr
/bin
; \
99 ln
-fs
$(REAL_GNU_TARGET_NAME
)-gcc \
100 $(REAL_GNU_TARGET_NAME
)-cc; \
101 ln
-fs
$(REAL_GNU_TARGET_NAME
)-gcc \
102 $(GNU_TARGET_NAME
)-cc; \
103 ln
-fs
$(REAL_GNU_TARGET_NAME
)-gcc \
104 $(GNU_TARGET_NAME
)-gcc
; \
107 if
[ -f
$(STAGING_DIR
)/usr
/bin-ccache
/$(REAL_GNU_TARGET_NAME
)-c
++ ]; then \
108 rm -f
$(STAGING_DIR
)/usr
/bin
/$(REAL_GNU_TARGET_NAME
)-c
++; \
109 mv
$(STAGING_DIR
)/usr
/bin-ccache
/$(REAL_GNU_TARGET_NAME
)-c
++ \
110 $(STAGING_DIR
)/usr
/bin
/; \
112 if
[ -f
$(STAGING_DIR
)/usr
/bin-ccache
/$(REAL_GNU_TARGET_NAME
)-g
++ ]; then \
113 rm -f
$(STAGING_DIR
)/usr
/bin
/$(REAL_GNU_TARGET_NAME
)-g
++; \
114 mv
$(STAGING_DIR
)/usr
/bin-ccache
/$(REAL_GNU_TARGET_NAME
)-g
++ \
115 $(STAGING_DIR
)/usr
/bin
/; \
117 rm -rf
$(STAGING_DIR
)/usr
/bin-ccache
/*
118 (cd
$(STAGING_DIR
)/usr
/bin
; \
119 ln
-fs
$(REAL_GNU_TARGET_NAME
)-g
++ $(GNU_TARGET_NAME
)-c
++; \
120 ln
-fs
$(REAL_GNU_TARGET_NAME
)-g
++ $(GNU_TARGET_NAME
)-g
++; \
121 ln
-fs
$(REAL_GNU_TARGET_NAME
)-g
++ $(REAL_GNU_TARGET_NAME
)-c
++; \
123 -$(MAKE
) -C
$(CCACHE_DIR1
) clean
126 rm -rf
$(CCACHE_DIR1
)
131 #############################################################
133 # build ccache for use on the target system
135 #############################################################
137 $(CCACHE_DIR2
)/.unpacked
: $(DL_DIR
)/$(CCACHE_SOURCE
)
138 $(CCACHE_CAT
) $(DL_DIR
)/$(CCACHE_SOURCE
) |
tar -C
$(BUILD_DIR
) $(TAR_OPTIONS
) -
141 $(CCACHE_DIR2
)/.patched
: $(CCACHE_DIR2
)/.unpacked
144 $(CCACHE_DIR2
)/.configured
: $(CCACHE_DIR2
)/.patched
145 mkdir
-p
$(CCACHE_DIR2
)
146 (cd
$(CCACHE_DIR2
); rm -rf config.cache
; \
147 $(TARGET_CONFIGURE_OPTS
) \
148 $(CCACHE_DIR2
)/configure \
149 --target
=$(GNU_TARGET_NAME
) \
150 --host
=$(GNU_TARGET_NAME
) \
151 --build
=$(GNU_HOST_NAME
) \
155 --sbindir
=/usr
/sbin \
156 --libexecdir
=/usr
/lib \
158 --datadir=/usr
/share \
159 --localstatedir
=/var \
161 --infodir=/usr
/info \
166 $(CCACHE_DIR2
)/$(CCACHE_BINARY
): $(CCACHE_DIR2
)/.configured
167 $(MAKE
) -C
$(CCACHE_DIR2
) CFLAGS
="$(TARGET_CFLAGS)"
169 $(TARGET_DIR
)/$(CCACHE_TARGET_BINARY
): $(CCACHE_DIR2
)/$(CCACHE_BINARY
)
170 $(MAKE
) DESTDIR
=$(TARGET_DIR
) -C
$(CCACHE_DIR2
) install
171 rm -rf
$(TARGET_DIR
)/share
/locale
$(TARGET_DIR
)/usr
/info \
172 $(TARGET_DIR
)/usr
/man
$(TARGET_DIR
)/usr
/share
/doc
173 # put a bunch of symlinks into /bin, since that is earlier
174 # in the default PATH than /usr/bin where gcc lives
175 (cd
$(TARGET_DIR
)/bin
; \
176 ln
-fs
/usr
/bin
/ccache
cc; \
177 ln
-fs
/usr
/bin
/ccache gcc
; \
178 ln
-fs
/usr
/bin
/ccache c
++; \
179 ln
-fs
/usr
/bin
/ccache g
++; \
182 ccache_target
: uclibc
$(TARGET_DIR
)/$(CCACHE_TARGET_BINARY
)
184 ccache_target-sources
: $(DL_DIR
)/$(CCACHE_SOURCE
)
187 rm -f
$(TARGET_DIR
)/$(CCACHE_TARGET_BINARY
)
188 -$(MAKE
) -C
$(CCACHE_DIR2
) clean
190 ccache_target-dirclean
:
191 rm -rf
$(CCACHE_DIR2
)
192 #############################################################
194 # Toplevel Makefile options
196 #############################################################
197 ifeq ($(BR2_CCACHE
),y
)
200 ifeq ($(BR2_PACKAGE_CCACHE_TARGET
),y
)
201 TARGETS
+=ccache_target