toolchain-external: Update Sourcery CodeBench MIPS toolchain
[buildroot-gz.git] / toolchain / toolchain-external / ext-tool.mk
blobdb2a99e01b3607ef7229b11831f8cae4c2aaf394
3 # This file implements the support for external toolchains, i.e
4 # toolchains that have not been produced by Buildroot itself and that
5 # Buildroot can download from the Web or that are already available on
6 # the system on which Buildroot runs. So far, we have tested this
7 # with:
9 # * Toolchains generated by Crosstool-NG
10 # * Toolchains generated by Buildroot
11 # * ARM, MIPS and PowerPC toolchains made available by
12 # Codesourcery. For the MIPS toolchain, the -muclibc variant isn't
13 # supported yet, only the default glibc-based variant is.
15 # The basic principle is the following
17 # 1. If the toolchain is not pre-installed, download and extract it
18 # in $(TOOLCHAIN_EXTERNAL_DIR).
20 # 2. For all external toolchains, perform some checks on the
21 # conformity between the toolchain configuration described in the
22 # Buildroot menuconfig system, and the real configuration of the
23 # external toolchain. This is for example important to make sure that
24 # the Buildroot configuration system knows whether the toolchain
25 # supports RPC, IPv6, locales, large files, etc. Unfortunately, these
26 # things cannot be detected automatically, since the value of these
27 # options (such as BR2_TOOLCHAIN_HAS_NATIVE_RPC) are needed at
28 # configuration time because these options are used as dependencies
29 # for other options. And at configuration time, we are not able to
30 # retrieve the external toolchain configuration.
32 # 3. Copy the libraries needed at runtime to the target directory,
33 # $(TARGET_DIR). Obviously, things such as the C library, the dynamic
34 # loader and a few other utility libraries are needed if dynamic
35 # applications are to be executed on the target system.
37 # 4. Copy the libraries and headers to the staging directory. This
38 # will allow all further calls to gcc to be made using --sysroot
39 # $(STAGING_DIR), which greatly simplifies the compilation of the
40 # packages when using external toolchains. So in the end, only the
41 # cross-compiler binaries remains external, all libraries and headers
42 # are imported into the Buildroot tree.
44 # 5. Build a toolchain wrapper which executes the external toolchain
45 # with a number of arguments (sysroot/march/mtune/..) hardcoded,
46 # so we're sure the correct configuration is always used and the
47 # toolchain behaves similar to an internal toolchain.
48 # This toolchain wrapper and symlinks are installed into
49 # $(HOST_DIR)/usr/bin like for the internal toolchains, and the rest
50 # of Buildroot is handled identical for the 2 toolchain types.
52 LIB_EXTERNAL_LIBS=ld*.so libc.so libcrypt.so libdl.so libgcc_s.so libm.so libnsl.so libresolv.so librt.so libutil.so
53 LIB_EXTERNAL_LIBS+=$(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
54 ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC),y)
55 LIB_EXTERNAL_LIBS+=libnss_files.so libnss_dns.so
56 endif
58 ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
59 USR_LIB_EXTERNAL_LIBS+=libstdc++.so
60 endif
62 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
63 LIB_EXTERNAL_LIBS+=libpthread.so
64 ifneq ($(BR2_PACKAGE_GDB_SERVER)$(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY),)
65 LIB_EXTERNAL_LIBS+=libthread_db.so
66 endif # gdbserver
67 endif # ! no threads
69 # Details about sysroot directory selection.
71 # To find the sysroot directory:
73 # * We first try the -print-sysroot option, available in gcc 4.4.x
74 # and in some Codesourcery toolchains.
76 # * If this option is not available, we fallback to the value of
77 # --with-sysroot as visible in CROSS-gcc -v.
79 # When doing those tests, we don't pass any option to gcc that could
80 # select a multilib variant (such as -march) as we want the "main"
81 # sysroot, which contains all variants of the C library in the case of
82 # multilib toolchains. We use the TARGET_CC_NO_SYSROOT variable, which
83 # is the path of the cross-compiler, without the
84 # --sysroot=$(STAGING_DIR), since what we want to find is the location
85 # of the original toolchain sysroot. This "main" sysroot directory is
86 # stored in SYSROOT_DIR.
88 # Then, multilib toolchains are a little bit more complicated, since
89 # they in fact have multiple sysroots, one for each variant supported
90 # by the toolchain. So we need to find the particular sysroot we're
91 # interested in.
93 # To do so, we ask the compiler where its sysroot is by passing all
94 # flags (including -march and al.), except the --sysroot flag since we
95 # want to the compiler to tell us where its original sysroot
96 # is. ARCH_SUBDIR will contain the subdirectory, in the main
97 # SYSROOT_DIR, that corresponds to the selected architecture
98 # variant. ARCH_SYSROOT_DIR will contain the full path to this
99 # location.
101 # One might wonder why we don't just bother with ARCH_SYSROOT_DIR. The
102 # fact is that in multilib toolchains, the header files are often only
103 # present in the main sysroot, and only the libraries are available in
104 # each variant-specific sysroot directory.
107 TOOLCHAIN_EXTERNAL_PREFIX=$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PREFIX))
108 ifeq ($(BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD),y)
109 TOOLCHAIN_EXTERNAL_DIR=$(HOST_DIR)/opt/ext-toolchain
110 else
111 TOOLCHAIN_EXTERNAL_DIR=$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PATH))
112 endif
114 ifeq ($(TOOLCHAIN_EXTERNAL_DIR),)
115 # if no path set, figure it out from path
116 TOOLCHAIN_EXTERNAL_BIN := $(shell dirname $(shell which $(TOOLCHAIN_EXTERNAL_PREFIX)-gcc))
117 else
118 ifeq ($(BR2_bfin),y)
119 TOOLCHAIN_EXTERNAL_BIN := $(TOOLCHAIN_EXTERNAL_DIR)/$(TOOLCHAIN_EXTERNAL_PREFIX)/bin
120 else
121 TOOLCHAIN_EXTERNAL_BIN := $(TOOLCHAIN_EXTERNAL_DIR)/bin
122 endif
123 endif
125 TOOLCHAIN_EXTERNAL_CROSS=$(TOOLCHAIN_EXTERNAL_BIN)/$(TOOLCHAIN_EXTERNAL_PREFIX)-
126 TOOLCHAIN_EXTERNAL_CC=$(TOOLCHAIN_EXTERNAL_CROSS)gcc
127 TOOLCHAIN_EXTERNAL_CXX=$(TOOLCHAIN_EXTERNAL_CROSS)g++
128 TOOLCHAIN_EXTERNAL_READELF=$(TOOLCHAIN_EXTERNAL_CROSS)readelf
129 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS = -DBR_SYSROOT='"$(STAGING_SUBDIR)"'
131 ifeq ($(filter $(HOST_DIR)/%,$(TOOLCHAIN_EXTERNAL_BIN)),)
132 # TOOLCHAIN_EXTERNAL_BIN points outside HOST_DIR => absolute path
133 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += \
134 -DBR_CROSS_PATH_ABS='"$(TOOLCHAIN_EXTERNAL_BIN)"'
135 else
136 # TOOLCHAIN_EXTERNAL_BIN points inside HOST_DIR => relative path
137 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += \
138 -DBR_CROSS_PATH_REL='"$(TOOLCHAIN_EXTERNAL_BIN:$(HOST_DIR)/%=%)"'
139 endif
141 CC_TARGET_TUNE_:=$(call qstrip,$(BR2_GCC_TARGET_TUNE))
142 ifeq ($(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)),)
143 CC_TARGET_CPU_:=$(call qstrip,$(BR2_GCC_TARGET_CPU))
144 else
145 CC_TARGET_CPU_:=$(call qstrip,$(BR2_GCC_TARGET_CPU)-$(BR2_GCC_TARGET_CPU_REVISION))
146 endif
147 CC_TARGET_ARCH_:=$(call qstrip,$(BR2_GCC_TARGET_ARCH))
148 CC_TARGET_ABI_:=$(call qstrip,$(BR2_GCC_TARGET_ABI))
149 CC_TARGET_FPU_:=$(call qstrip,$(BR2_GCC_TARGET_FPU))
150 CC_TARGET_FLOAT_ABI_:=$(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
151 CC_TARGET_MODE_:=$(call qstrip,$(BR2_GCC_TARGET_MODE))
153 # march/mtune/floating point mode needs to be passed to the external toolchain
154 # to select the right multilib variant
155 ifeq ($(BR2_x86_64),y)
156 TOOLCHAIN_EXTERNAL_CFLAGS += -m64
157 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_64
158 endif
159 ifneq ($(CC_TARGET_TUNE_),)
160 TOOLCHAIN_EXTERNAL_CFLAGS += -mtune=$(CC_TARGET_TUNE_)
161 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_TUNE='"$(CC_TARGET_TUNE_)"'
162 endif
163 ifneq ($(CC_TARGET_ARCH_),)
164 TOOLCHAIN_EXTERNAL_CFLAGS += -march=$(CC_TARGET_ARCH_)
165 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_ARCH='"$(CC_TARGET_ARCH_)"'
166 endif
167 ifneq ($(CC_TARGET_CPU_),)
168 TOOLCHAIN_EXTERNAL_CFLAGS += -mcpu=$(CC_TARGET_CPU_)
169 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_CPU='"$(CC_TARGET_CPU_)"'
170 endif
171 ifneq ($(CC_TARGET_ABI_),)
172 TOOLCHAIN_EXTERNAL_CFLAGS += -mabi=$(CC_TARGET_ABI_)
173 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_ABI='"$(CC_TARGET_ABI_)"'
174 endif
175 ifneq ($(CC_TARGET_FPU_),)
176 TOOLCHAIN_EXTERNAL_CFLAGS += -mfpu=$(CC_TARGET_FPU_)
177 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_FPU='"$(CC_TARGET_FPU_)"'
178 endif
179 ifneq ($(CC_TARGET_FLOAT_ABI_),)
180 TOOLCHAIN_EXTERNAL_CFLAGS += -mfloat-abi=$(CC_TARGET_FLOAT_ABI_)
181 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_FLOAT_ABI='"$(CC_TARGET_FLOAT_ABI_)"'
182 endif
183 ifneq ($(CC_TARGET_MODE_),)
184 TOOLCHAIN_EXTERNAL_CFLAGS += -m$(CC_TARGET_MODE_)
185 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_MODE='"$(CC_TARGET_MODE_)"'
186 endif
187 ifeq ($(BR2_BINFMT_FLAT),y)
188 TOOLCHAIN_EXTERNAL_CFLAGS += -Wl,-elf2flt
189 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_BINFMT_FLAT
190 endif
192 ifneq ($(BR2_TARGET_OPTIMIZATION),)
193 TOOLCHAIN_EXTERNAL_CFLAGS += $(call qstrip,$(BR2_TARGET_OPTIMIZATION))
194 # We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each
195 # flag is a separate argument when used in execv() by the external
196 # toolchain wrapper.
197 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_ADDITIONAL_CFLAGS='$(foreach f,$(call qstrip,$(BR2_TARGET_OPTIMIZATION)),"$(f)",)'
198 endif
200 ifeq ($(BR2_SOFT_FLOAT),y)
201 TOOLCHAIN_EXTERNAL_CFLAGS += -msoft-float
202 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_SOFTFLOAT=1
203 endif
205 ifeq ($(BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD),y)
206 TOOLCHAIN_EXTERNAL_DEPENDENCIES = $(TOOLCHAIN_EXTERNAL_DIR)/.extracted
207 endif
209 ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201109),y)
210 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/
211 TOOLCHAIN_EXTERNAL_SOURCE = arm-2011.09-70-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
212 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201203),y)
213 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/
214 TOOLCHAIN_EXTERNAL_SOURCE = arm-2012.03-57-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
215 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201305),y)
216 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/
217 TOOLCHAIN_EXTERNAL_SOURCE = arm-2013.05-24-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
218 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_ARAGO_ARMV7A_201109),y)
219 TOOLCHAIN_EXTERNAL_SITE = http://software-dl.ti.com/sdoemb/sdoemb_public_sw/arago_toolchain/2011_09/exports/
220 TOOLCHAIN_EXTERNAL_SOURCE = arago-2011.09-armv7a-linux-gnueabi-sdk.tar.bz2
221 define TOOLCHAIN_EXTERNAL_FIXUP_CMDS
222 mv $(@D)/arago-2011.09/armv7a/* $(@D)/
223 rm -rf $(@D)/arago-2011.09/
224 endef
225 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_ARAGO_ARMV5TE_201109),y)
226 TOOLCHAIN_EXTERNAL_SITE = http://software-dl.ti.com/sdoemb/sdoemb_public_sw/arago_toolchain/2011_09/exports/
227 TOOLCHAIN_EXTERNAL_SOURCE = arago-2011.09-armv5te-linux-gnueabi-sdk.tar.bz2
228 define TOOLCHAIN_EXTERNAL_FIXUP_CMDS
229 mv $(@D)/arago-2011.09/armv5te/* $(@D)/
230 rm -rf $(@D)/arago-2011.09/
231 endef
232 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_2013_06),y)
233 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/13.06/components/toolchain/binaries/
234 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-arm-linux-gnueabihf-4.8-2013.06_linux.tar.xz
235 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_2013_07),y)
236 TOOLCHAIN_EXTERNAL_SITE = http://releases.linaro.org/13.07/components/toolchain/binaries/
237 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-arm-linux-gnueabihf-4.8-2013.07-1_linux.tar.xz
238 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_2013_08),y)
239 TOOLCHAIN_EXTERNAL_SITE = http://releases.linaro.org/13.08/components/toolchain/binaries/
240 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-arm-linux-gnueabihf-4.8-2013.08_linux.tar.xz
241 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201203),y)
242 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/mips-linux-gnu/
243 TOOLCHAIN_EXTERNAL_SOURCE = mips-2012.03-63-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
244 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201209),y)
245 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/mips-linux-gnu/
246 TOOLCHAIN_EXTERNAL_SOURCE = mips-2012.09-99-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
247 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201305),y)
248 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/mips-linux-gnu/
249 TOOLCHAIN_EXTERNAL_SOURCE = mips-2013.05-66-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
250 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201305),y)
251 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/nios2-linux-gnu/
252 TOOLCHAIN_EXTERNAL_SOURCE = sourceryg++-2013.05-43-nios2-linux-gnu-i686-pc-linux-gnu.tar.bz2
253 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_POWERPC201009),y)
254 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/powerpc-linux-gnu/
255 TOOLCHAIN_EXTERNAL_SOURCE = freescale-2010.09-55-powerpc-linux-gnu-i686-pc-linux-gnu.tar.bz2
256 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_POWERPC201103),y)
257 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/powerpc-linux-gnu/
258 TOOLCHAIN_EXTERNAL_SOURCE = freescale-2011.03-38-powerpc-linux-gnu-i686-pc-linux-gnu.tar.bz2
259 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH201103),y)
260 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/sh-linux-gnu/
261 TOOLCHAIN_EXTERNAL_SOURCE = renesas-2011.03-37-sh-linux-gnu-i686-pc-linux-gnu.tar.bz2
262 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH201203),y)
263 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/sh-linux-gnu/
264 TOOLCHAIN_EXTERNAL_SOURCE = renesas-2012.03-35-sh-linux-gnu-i686-pc-linux-gnu.tar.bz2
265 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH201209),y)
266 TOOLCHAIN_EXTERNAL_SITE = https://sourcery.mentor.com/public/gnu_toolchain/sh-linux-gnu/
267 TOOLCHAIN_EXTERNAL_SOURCE = renesas-2012.09-61-sh-linux-gnu-i686-pc-linux-gnu.tar.bz2
268 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH2A_201009),y)
269 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/sh-uclinux/
270 TOOLCHAIN_EXTERNAL_SOURCE = renesas-2010.09-60-sh-uclinux-i686-pc-linux-gnu.tar.bz2
271 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH2A_201103),y)
272 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/sh-uclinux/
273 TOOLCHAIN_EXTERNAL_SOURCE = renesas-2011.03-36-sh-uclinux-i686-pc-linux-gnu.tar.bz2
274 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_X86_201109),y)
275 TOOLCHAIN_EXTERNAL_SITE = https://sourcery.mentor.com/public/gnu_toolchain/i686-pc-linux-gnu/
276 TOOLCHAIN_EXTERNAL_SOURCE = ia32-2011.09-24-i686-pc-linux-gnu-i386-linux.tar.bz2
277 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_X86_201203),y)
278 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/i686-pc-linux-gnu/
279 TOOLCHAIN_EXTERNAL_SOURCE = ia32-2012.03-27-i686-pc-linux-gnu-i386-linux.tar.bz2
280 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_X86_201209),y)
281 TOOLCHAIN_EXTERNAL_SITE = https://sourcery.mentor.com/public/gnu_toolchain/i686-pc-linux-gnu/
282 TOOLCHAIN_EXTERNAL_SOURCE = ia32-2012.09-62-i686-pc-linux-gnu-i386-linux.tar.bz2
283 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R1),y)
284 TOOLCHAIN_EXTERNAL_SITE_1 = http://blackfin.uclinux.org/gf/download/frsrelease/559/9858/
285 TOOLCHAIN_EXTERNAL_SOURCE_1 = blackfin-toolchain-2012R1-RC2.i386.tar.bz2
286 TOOLCHAIN_EXTERNAL_SITE_2 = http://blackfin.uclinux.org/gf/download/frsrelease/559/9866/
287 TOOLCHAIN_EXTERNAL_SOURCE_2 = blackfin-toolchain-uclibc-full-2012R1-RC2.i386.tar.bz2
288 TOOLCHAIN_EXTERNAL_SOURCE = $(TOOLCHAIN_EXTERNAL_SOURCE_1) $(TOOLCHAIN_EXTERNAL_SOURCE_2)
289 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R2),y)
290 TOOLCHAIN_EXTERNAL_SITE_1 = http://blackfin.uclinux.org/gf/download/frsrelease/588/10139/
291 TOOLCHAIN_EXTERNAL_SOURCE_1 = blackfin-toolchain-2012R2-RC2.i386.tar.bz2
292 TOOLCHAIN_EXTERNAL_SITE_2 = http://blackfin.uclinux.org/gf/download/frsrelease/588/10147/
293 TOOLCHAIN_EXTERNAL_SOURCE_2 = blackfin-toolchain-uclibc-full-2012R2-RC2.i386.tar.bz2
294 TOOLCHAIN_EXTERNAL_SOURCE = $(TOOLCHAIN_EXTERNAL_SOURCE_1) $(TOOLCHAIN_EXTERNAL_SOURCE_2)
295 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_XILINX_MICROBLAZEEL_14_3),y)
296 TOOLCHAIN_EXTERNAL_SITE = http://sources.buildroot.net/
297 TOOLCHAIN_EXTERNAL_SOURCE = lin32-microblazeel-unknown-linux-gnu_14.3_early.tar.xz
298 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_XILINX_MICROBLAZEEL_V2),y)
299 TOOLCHAIN_EXTERNAL_SITE = http://sources.buildroot.net/
300 TOOLCHAIN_EXTERNAL_SOURCE = microblazeel-unknown-linux-gnu.tgz
301 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_XILINX_MICROBLAZEBE_14_3),y)
302 TOOLCHAIN_EXTERNAL_SITE = http://sources.buildroot.net/
303 TOOLCHAIN_EXTERNAL_SOURCE = lin32-microblaze-unknown-linux-gnu_14.3_early.tar.xz
304 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_XILINX_MICROBLAZEBE_V2),y)
305 TOOLCHAIN_EXTERNAL_SITE = http://sources.buildroot.net/
306 TOOLCHAIN_EXTERNAL_SOURCE = microblaze-unknown-linux-gnu.tgz
307 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64_13_06),y)
308 TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/13.06/components/toolchain/binaries/
309 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-aarch64-linux-gnu-4.8-2013.06_linux.tar.xz
310 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64_13_07),y)
311 TOOLCHAIN_EXTERNAL_SITE = http://releases.linaro.org/13.07/components/toolchain/binaries/
312 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-aarch64-linux-gnu-4.8-2013.07-1_linux.tar.xz
313 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64_13_08),y)
314 TOOLCHAIN_EXTERNAL_SITE = http://releases.linaro.org/13.08/components/toolchain/binaries/
315 TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-aarch64-linux-gnu-4.8-2013.08_linux.tar.xz
316 else
317 # Custom toolchain
318 TOOLCHAIN_EXTERNAL_SITE = $(dir $(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_URL)))
319 TOOLCHAIN_EXTERNAL_SOURCE = $(notdir $(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_URL)))
321 # A value must be set (even if unused), otherwise the
322 # $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE) rule would override the main
323 # $(DL_DIR) rule
324 ifeq (,$(TOOLCHAIN_EXTERNAL_SOURCE))
325 TOOLCHAIN_EXTERNAL_SOURCE = none
326 endif
327 endif
329 # Special handling for Blackfin toolchain, because of the split in two
330 # tarballs, and the organization of tarball contents. The tarballs
331 # contain ./opt/uClinux/{bfin-uclinux,bfin-linux-uclibc} directories,
332 # which themselves contain the toolchain. This is why we strip more
333 # components than usual.
334 ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R1)$(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R2),y)
335 $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_1):
336 $(call DOWNLOAD,$(TOOLCHAIN_EXTERNAL_SITE_1:/=)/$(TOOLCHAIN_EXTERNAL_SOURCE_1))
338 $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_2):
339 $(call DOWNLOAD,$(TOOLCHAIN_EXTERNAL_SITE_2:/=)/$(TOOLCHAIN_EXTERNAL_SOURCE_2))
341 $(TOOLCHAIN_EXTERNAL_DIR)/.extracted: $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_1) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_2)
342 mkdir -p $(@D)
343 $(call suitable-extractor,$(TOOLCHAIN_EXTERNAL_SOURCE_1)) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_1) | \
344 $(TAR) $(TAR_STRIP_COMPONENTS)=3 --hard-dereference -C $(@D) $(TAR_OPTIONS) -
345 $(call suitable-extractor,$(TOOLCHAIN_EXTERNAL_SOURCE_2)) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_2) | \
346 $(TAR) $(TAR_STRIP_COMPONENTS)=3 --hard-dereference -C $(@D) $(TAR_OPTIONS) -
347 $(Q)touch $@
348 else
349 # Download and extraction of a toolchain
350 $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE):
351 $(call DOWNLOAD,$(TOOLCHAIN_EXTERNAL_SITE)$(TOOLCHAIN_EXTERNAL_SOURCE),$(TOOLCHAIN_EXTERNAL_SOURCE))
353 $(TOOLCHAIN_EXTERNAL_DIR)/.extracted: $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE)
354 mkdir -p $(@D)
355 $(call suitable-extractor,$(TOOLCHAIN_EXTERNAL_SOURCE)) $^ | \
356 $(TAR) $(TAR_STRIP_COMPONENTS)=1 --exclude='usr/lib/locale/*' -C $(@D) $(TAR_OPTIONS) -
357 $(TOOLCHAIN_EXTERNAL_FIXUP_CMDS)
358 $(Q)touch $@
359 endif
361 # Checks for an already installed toolchain: check the toolchain
362 # location, check that it supports sysroot, and then verify that it
363 # matches the configuration provided in Buildroot: ABI, C++ support,
364 # type of C library and all C library features.
365 $(STAMP_DIR)/ext-toolchain-checked: $(TOOLCHAIN_EXTERNAL_DEPENDENCIES)
366 @$(call MESSAGE,"Checking external toolchain settings")
367 $(Q)$(call check_cross_compiler_exists,$(TOOLCHAIN_EXTERNAL_CC))
368 $(Q)LIBC_A_LOCATION=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) -print-file-name=libc.a)` ; \
369 SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:usr/lib(32|64)?/(.*/)?libc\.a::'` ; \
370 if test -z "$${SYSROOT_DIR}" ; then \
371 @echo "External toolchain doesn't support --sysroot. Cannot use." ; \
372 exit 1 ; \
373 fi ; \
374 if test "$(BR2_arm)" = "y" ; then \
375 $(call check_arm_abi,\
376 "$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS)",\
377 $(TOOLCHAIN_EXTERNAL_READELF)) ; \
378 fi ; \
379 if test "$(BR2_INSTALL_LIBSTDCPP)" = "y" ; then \
380 $(call check_cplusplus,$(TOOLCHAIN_EXTERNAL_CXX)) ; \
381 fi ; \
382 if test "$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC)" = "y" ; then \
383 $(call check_uclibc,$${SYSROOT_DIR}) ; \
384 else \
385 $(call check_glibc,$${SYSROOT_DIR}) ; \
387 $(Q)touch $@
389 # Integration of the toolchain into Buildroot: find the main sysroot
390 # and the variant-specific sysroot, then copy the needed libraries to
391 # the $(TARGET_DIR) and copy the whole sysroot (libraries and headers)
392 # to $(STAGING_DIR).
394 # Variables are defined as follows:
396 # LIBC_A_LOCATION: location of the libc.a file in the default
397 # multilib variant (allows to find the main
398 # sysroot directory)
399 # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/usr/lib/libc.a
401 # SYSROOT_DIR: the main sysroot directory, deduced from
402 # LIBC_A_LOCATION by removing the
403 # usr/lib[32|64]/libc.a part of the path.
404 # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/
406 # ARCH_LIBC_A_LOCATION: location of the libc.a file in the selected
407 # multilib variant (taking into account the
408 # CFLAGS). Allows to find the sysroot of the
409 # selected multilib variant.
410 # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/mips16/soft-float/el/usr/lib/libc.a
412 # ARCH_SYSROOT_DIR: the sysroot of the selected multilib variant,
413 # deduced from ARCH_LIBC_A_LOCATION by removing
414 # usr/lib[32|64]/libc.a at the end of the path.
415 # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/mips16/soft-float/el/
417 # ARCH_LIB_DIR: 'lib', 'lib32' or 'lib64' depending on where libraries
418 # are stored. Deduced from ARCH_LIBC_A_LOCATION by
419 # looking at usr/lib??/libc.a.
420 # Ex: lib
422 # ARCH_SUBDIR: the relative location of the sysroot of the selected
423 # multilib variant compared to the main sysroot.
424 # Ex: mips16/soft-float/el
426 # SUPPORT_LIB_DIR: some toolchains, such as recent Linaro toolchains,
427 # store GCC support libraries (libstdc++,
428 # libgcc_s, etc.) outside of the sysroot. In
429 # this case, SUPPORT_LIB_DIR is set to a
430 # non-empty value, and points to the directory
431 # where these support libraries are
432 # available. Those libraries will be copied to
433 # our sysroot, and the directory will also be
434 # considered when searching libraries for copy
435 # to the target filesystem.
437 $(STAMP_DIR)/ext-toolchain-installed: $(STAMP_DIR)/ext-toolchain-checked
438 $(Q)LIBC_A_LOCATION=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) -print-file-name=libc.a)` ; \
439 SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:usr/lib(32|64)?/(.*/)?libc\.a::'` ; \
440 if test -z "$${SYSROOT_DIR}" ; then \
441 @echo "External toolchain doesn't support --sysroot. Cannot use." ; \
442 exit 1 ; \
443 fi ; \
444 ARCH_LIBC_A_LOCATION=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libc.a)` ; \
445 ARCH_SYSROOT_DIR=`echo $${ARCH_LIBC_A_LOCATION} | sed -r -e 's:usr/lib(32|64)?/(.*/)?libc\.a::'` ; \
446 ARCH_LIB_DIR=`echo $${ARCH_LIBC_A_LOCATION} | sed -r -e 's:.*/usr/(lib(32|64)?)/(.*/)?libc.a:\1:'` ; \
447 SUPPORT_LIB_DIR="" ; \
448 if test `find $${ARCH_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
449 LIBSTDCPP_A_LOCATION=$$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libstdc++.a) ; \
450 if [ -e "$${LIBSTDCPP_A_LOCATION}" ]; then \
451 SUPPORT_LIB_DIR=`readlink -f $${LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \
452 fi ; \
453 fi ; \
454 ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \
455 if test -z "$(BR2_PREFER_STATIC_LIB)" ; then \
456 $(call MESSAGE,"Copying external toolchain libraries to target...") ; \
457 for libs in $(LIB_EXTERNAL_LIBS); do \
458 $(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${SUPPORT_LIB_DIR},$${ARCH_LIB_DIR},$$libs,/lib); \
459 done ; \
460 for libs in $(USR_LIB_EXTERNAL_LIBS); do \
461 $(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${SUPPORT_LIB_DIR},$${ARCH_LIB_DIR},$$libs,/usr/lib); \
462 done ; \
463 fi ; \
464 $(call MESSAGE,"Copying external toolchain sysroot to staging...") ; \
465 $(call copy_toolchain_sysroot,$${SYSROOT_DIR},$${ARCH_SYSROOT_DIR},$${ARCH_SUBDIR},$${ARCH_LIB_DIR},$${SUPPORT_LIB_DIR}) ; \
466 if test "$(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY)" = "y"; then \
467 $(call MESSAGE,"Copying gdbserver") ; \
468 gdbserver_found=0 ; \
469 for d in $${ARCH_SYSROOT_DIR}/usr $${ARCH_SYSROOT_DIR}/../debug-root/usr $${ARCH_SYSROOT_DIR}/usr/$${ARCH_LIB_DIR} ; do \
470 if test -f $${d}/bin/gdbserver ; then \
471 install -m 0755 -D $${d}/bin/gdbserver $(TARGET_DIR)/usr/bin/gdbserver ; \
472 gdbserver_found=1 ; \
473 break ; \
474 fi ; \
475 done ; \
476 if [ $${gdbserver_found} -eq 0 ] ; then \
477 echo "Could not find gdbserver in external toolchain" ; \
478 exit 1 ; \
479 fi ; \
480 fi ; \
481 touch $@
483 # Special installation target used on the Blackfin architecture when
484 # FDPIC is not the primary binary format being used, but the user has
485 # nonetheless requested the installation of the FDPIC libraries to the
486 # target filesystem.
487 $(STAMP_DIR)/ext-toolchain-bfin-fdpic-shared-installed: $(STAMP_DIR)/ext-toolchain-checked
488 $(Q)$(call MESSAGE,"Install external toolchain FDPIC libraries to target...") ; \
489 FDPIC_EXTERNAL_CC=$(dir $(TOOLCHAIN_EXTERNAL_CC))/../../bfin-linux-uclibc/bin/bfin-linux-uclibc-gcc ; \
490 FDPIC_LIBC_A_LOCATION=`readlink -f $$(LANG=C $${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libc.a)` ; \
491 FDPIC_SYSROOT_DIR=`echo $${FDPIC_LIBC_A_LOCATION} | sed -r -e 's:usr/lib(32|64)?/(.*/)?libc\.a::'` ; \
492 FDPIC_LIB_DIR=`echo $${FDPIC_LIBC_A_LOCATION} | sed -r -e 's:.*/usr/(lib(32|64)?)/(.*/)?libc.a:\1:'` ; \
493 FDPIC_SUPPORT_LIB_DIR="" ; \
494 if test `find $${FDPIC_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
495 FDPIC_LIBSTDCPP_A_LOCATION=$$(LANG=C $${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libstdc++.a) ; \
496 if [ -e "$${FDPIC_LIBSTDCPP_A_LOCATION}" ]; then \
497 FDPIC_SUPPORT_LIB_DIR=`readlink -f $${FDPIC_LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \
498 fi ; \
499 fi ; \
500 for libs in $(LIB_EXTERNAL_LIBS); do \
501 $(call copy_toolchain_lib_root,$${FDPIC_SYSROOT_DIR},$${FDPIC_SUPPORT_LIB_DIR},$${FDPIC_LIB_DIR},$$libs,/lib); \
502 done ; \
503 for libs in $(USR_LIB_EXTERNAL_LIBS); do \
504 $(call copy_toolchain_lib_root,$${FDPIC_SYSROOT_DIR},$${FDPIC_SUPPORT_LIB_DIR},$${FDPIC_LIB_DIR},$$libs,/usr/lib); \
505 done ; \
506 touch $@
508 # Special installation target used on the Blackfin architecture when
509 # shared FLAT is not the primary format being used, but the user has
510 # nonetheless requested the installation of the shared FLAT libraries
511 # to the target filesystem. The flat libraries are found and linked
512 # according to the index in name "libN.so". Index 1 is reserved for
513 # the standard C library. Customer libraries can use 4 and above.
514 $(STAMP_DIR)/ext-toolchain-bfin-shared-flat-installed: $(STAMP_DIR)/ext-toolchain-checked
515 $(Q)$(call MESSAGE,"Install external toolchain FLAT libraries to target...") ; \
516 FLAT_EXTERNAL_CC=$(dir $(TOOLCHAIN_EXTERNAL_CC))../../bfin-uclinux/bin/bfin-uclinux-gcc ; \
517 FLAT_LIBC_A_LOCATION=`$${FLAT_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS) -mid-shared-library -print-file-name=libc`; \
518 if [ -f $${FLAT_LIBC_A_LOCATION} -a ! -h $${FLAT_LIBC_A_LOCATION} ] ; then \
519 $(INSTALL) -D $${FLAT_LIBC_A_LOCATION} $(TARGET_DIR)/lib/lib1.so; \
520 fi ; \
521 touch $@
523 TOOLCHAIN_EXTERNAL_INSTALL = $(STAMP_DIR)/ext-toolchain-installed
525 ifeq ($(BR2_BFIN_INSTALL_FDPIC_SHARED),y)
526 TOOLCHAIN_EXTERNAL_INSTALL += $(STAMP_DIR)/ext-toolchain-bfin-fdpic-shared-installed
527 endif
529 ifeq ($(BR2_BFIN_INSTALL_FLAT_SHARED),y)
530 TOOLCHAIN_EXTERNAL_INSTALL += $(STAMP_DIR)/ext-toolchain-bfin-shared-flat-installed
531 endif
533 # Build toolchain wrapper for preprocessor, C and C++ compiler and setup
534 # symlinks for everything else. Skip gdb symlink when we are building our
535 # own gdb to prevent two gdb's in output/host/usr/bin.
536 $(HOST_DIR)/usr/bin/ext-toolchain-wrapper: $(TOOLCHAIN_EXTERNAL_INSTALL)
537 $(Q)$(call MESSAGE,"Building ext-toolchain wrapper")
538 mkdir -p $(HOST_DIR)/usr/bin; cd $(HOST_DIR)/usr/bin; \
539 for i in $(TOOLCHAIN_EXTERNAL_CROSS)*; do \
540 base=$${i##*/}; \
541 case "$$base" in \
542 *cc|*cc-*|*++|*++-*|*cpp) \
543 ln -sf $(@F) $$base; \
544 ;; \
545 *gdb|*gdbtui) \
546 if test "$(BR2_PACKAGE_HOST_GDB)" != "y"; then \
547 ln -sf $$(echo $$i | sed 's%^$(HOST_DIR)%../..%') .; \
548 fi \
549 ;; \
550 *) \
551 ln -sf $$(echo $$i | sed 's%^$(HOST_DIR)%../..%') .; \
552 ;; \
553 esac; \
554 done ;
555 # We use --hash-style=both to increase the compatibility of
556 # the generated binary with older platforms
557 $(HOSTCC) $(HOST_CFLAGS) $(TOOLCHAIN_EXTERNAL_WRAPPER_ARGS) -s -Wl,--hash-style=both \
558 toolchain/toolchain-external/ext-toolchain-wrapper.c -o $@
560 toolchain-external: dependencies $(HOST_DIR)/usr/bin/ext-toolchain-wrapper
562 ifeq ($(BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD),y)
563 # download ext toolchain if so configured
564 toolchain-external-source: $(addprefix $(DL_DIR)/,$(TOOLCHAIN_EXTERNAL_SOURCE))
565 endif