ext-tool.mk 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. #
  2. # This file implements the support for external toolchains, i.e
  3. # toolchains that have not been produced by Buildroot itself and that
  4. # Buildroot can download from the Web or that are already available on
  5. # the system on which Buildroot runs. So far, we have tested this
  6. # with:
  7. #
  8. # * Toolchains generated by Crosstool-NG
  9. # * Toolchains generated by Buildroot
  10. # * ARM, MIPS and PowerPC toolchains made available by
  11. # Codesourcery. For the MIPS toolchain, the -muclibc variant isn't
  12. # supported yet, only the default glibc-based variant is.
  13. #
  14. # The basic principle is the following
  15. #
  16. # 1. a. For toolchains downloaded from the Web, Buildroot already
  17. # knows their configuration, so it just downloads them and extract
  18. # them in $(TOOLCHAIN_EXTERNAL_DIR).
  19. #
  20. # 1. b. For pre-installed 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_INET_RPC) are needed at configuration time
  28. # because these options are used as dependencies for other
  29. # options. And at configuration time, we are not able to retrieve the
  30. # external toolchain configuration.
  31. #
  32. # 2. 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.
  36. #
  37. # 3. 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.
  43. #
  44. # 4. 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.
  51. LIB_EXTERNAL_LIBS=ld*.so libc.so libcrypt.so libdl.so libgcc_s.so libm.so libnsl.so libresolv.so librt.so libutil.so
  52. LIB_EXTERNAL_LIBS+=$(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
  53. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC),y)
  54. LIB_EXTERNAL_LIBS+=libnss_files.so libnss_dns.so
  55. endif
  56. ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
  57. USR_LIB_EXTERNAL_LIBS+=libstdc++.so
  58. endif
  59. ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
  60. LIB_EXTERNAL_LIBS+=libpthread.so
  61. ifeq ($(BR2_PACKAGE_GDB_SERVER),y)
  62. LIB_EXTERNAL_LIBS+=libthread_db.so
  63. endif # gdbserver
  64. endif # ! no threads
  65. # Details about sysroot directory selection.
  66. #
  67. # To find the sysroot directory:
  68. #
  69. # * We first try the -print-sysroot option, available in gcc 4.4.x
  70. # and in some Codesourcery toolchains.
  71. #
  72. # * If this option is not available, we fallback to the value of
  73. # --with-sysroot as visible in CROSS-gcc -v.
  74. #
  75. # When doing those tests, we don't pass any option to gcc that could
  76. # select a multilib variant (such as -march) as we want the "main"
  77. # sysroot, which contains all variants of the C library in the case of
  78. # multilib toolchains. We use the TARGET_CC_NO_SYSROOT variable, which
  79. # is the path of the cross-compiler, without the
  80. # --sysroot=$(STAGING_DIR), since what we want to find is the location
  81. # of the original toolchain sysroot. This "main" sysroot directory is
  82. # stored in SYSROOT_DIR.
  83. #
  84. # Then, multilib toolchains are a little bit more complicated, since
  85. # they in fact have multiple sysroots, one for each variant supported
  86. # by the toolchain. So we need to find the particular sysroot we're
  87. # interested in.
  88. #
  89. # To do so, we ask the compiler where its sysroot is by passing all
  90. # flags (including -march and al.), except the --sysroot flag since we
  91. # want to the compiler to tell us where its original sysroot
  92. # is. ARCH_SUBDIR will contain the subdirectory, in the main
  93. # SYSROOT_DIR, that corresponds to the selected architecture
  94. # variant. ARCH_SYSROOT_DIR will contain the full path to this
  95. # location.
  96. #
  97. # One might wonder why we don't just bother with ARCH_SYSROOT_DIR. The
  98. # fact is that in multilib toolchains, the header files are often only
  99. # present in the main sysroot, and only the libraries are available in
  100. # each variant-specific sysroot directory.
  101. TOOLCHAIN_EXTERNAL_PREFIX=$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PREFIX))
  102. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD),y)
  103. TOOLCHAIN_EXTERNAL_DIR=$(HOST_DIR)/opt/ext-toolchain
  104. else
  105. TOOLCHAIN_EXTERNAL_DIR=$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PATH))
  106. endif
  107. ifeq ($(TOOLCHAIN_EXTERNAL_DIR),)
  108. # if no path set, figure it out from path
  109. TOOLCHAIN_EXTERNAL_BIN:=$(shell dirname $(shell which $(TOOLCHAIN_EXTERNAL_PREFIX)-gcc))
  110. else
  111. TOOLCHAIN_EXTERNAL_BIN:=$(TOOLCHAIN_EXTERNAL_DIR)/bin
  112. endif
  113. TOOLCHAIN_EXTERNAL_CROSS=$(TOOLCHAIN_EXTERNAL_BIN)/$(TOOLCHAIN_EXTERNAL_PREFIX)-
  114. TOOLCHAIN_EXTERNAL_CC=$(TOOLCHAIN_EXTERNAL_CROSS)gcc
  115. TOOLCHAIN_EXTERNAL_CXX=$(TOOLCHAIN_EXTERNAL_CROSS)g++
  116. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS = \
  117. -DBR_CROSS_PATH='"$(TOOLCHAIN_EXTERNAL_BIN)/"' \
  118. -DBR_SYSROOT='"$(STAGING_DIR)"'
  119. CC_TARGET_TUNE_:=$(call qstrip,$(BR2_GCC_TARGET_TUNE))
  120. CC_TARGET_CPU_:=$(call qstrip,$(BR2_GCC_TARGET_CPU))
  121. CC_TARGET_ARCH_:=$(call qstrip,$(BR2_GCC_TARGET_ARCH))
  122. CC_TARGET_ABI_:=$(call qstrip,$(BR2_GCC_TARGET_ABI))
  123. # march/mtune/floating point mode needs to be passed to the external toolchain
  124. # to select the right multilib variant
  125. ifneq ($(CC_TARGET_TUNE_),)
  126. TOOLCHAIN_EXTERNAL_CFLAGS += -mtune=$(CC_TARGET_TUNE_)
  127. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_TUNE='"$(CC_TARGET_TUNE_)"'
  128. endif
  129. ifneq ($(CC_TARGET_ARCH_),)
  130. TOOLCHAIN_EXTERNAL_CFLAGS += -march=$(CC_TARGET_ARCH_)
  131. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_ARCH='"$(CC_TARGET_ARCH_)"'
  132. endif
  133. ifneq ($(CC_TARGET_CPU_),)
  134. TOOLCHAIN_EXTERNAL_CFLAGS += -mcpu=$(CC_TARGET_CPU_)
  135. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_CPU='"$(CC_TARGET_CPU_)"'
  136. endif
  137. ifneq ($(CC_TARGET_ABI_),)
  138. TOOLCHAIN_EXTERNAL_CFLAGS += -mabi=$(CC_TARGET_ABI_)
  139. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_ABI='"$(CC_TARGET_ABI_)"'
  140. endif
  141. ifeq ($(BR2_SOFT_FLOAT),y)
  142. TOOLCHAIN_EXTERNAL_CFLAGS += -msoft-float
  143. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_SOFTFLOAT=1
  144. endif
  145. ifeq ($(BR2_VFP_FLOAT),y)
  146. TOOLCHAIN_EXTERNAL_CFLAGS += -mfpu=vfp
  147. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_VFPFLOAT=1
  148. endif
  149. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD),y)
  150. TOOLCHAIN_EXTERNAL_DEPENDENCIES = $(TOOLCHAIN_EXTERNAL_DIR)/.extracted
  151. else
  152. TOOLCHAIN_EXTERNAL_DEPENDENCIES = $(STAMP_DIR)/ext-toolchain-checked
  153. endif
  154. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM2009Q1),y)
  155. TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/arm/portal/package4571/public/arm-none-linux-gnueabi/
  156. TOOLCHAIN_EXTERNAL_SOURCE=arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
  157. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM2009Q3),y)
  158. TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/arm/portal/package5383/public/arm-none-linux-gnueabi/
  159. TOOLCHAIN_EXTERNAL_SOURCE=arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
  160. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM2010Q1),y)
  161. TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/arm/portal/package6488/public/arm-none-linux-gnueabi/
  162. TOOLCHAIN_EXTERNAL_SOURCE=arm-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
  163. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201009),y)
  164. TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/arm/portal/package7851/public/arm-none-linux-gnueabi/
  165. TOOLCHAIN_EXTERNAL_SOURCE=arm-2010.09-50-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
  166. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201103),y)
  167. TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/arm/portal/package8739/public/arm-none-linux-gnueabi/
  168. TOOLCHAIN_EXTERNAL_SOURCE=arm-2011.03-41-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
  169. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS44),y)
  170. TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/mips/portal/package7401/public/mips-linux-gnu/
  171. TOOLCHAIN_EXTERNAL_SOURCE=mips-4.4-303-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
  172. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201103),y)
  173. TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/mips/portal/package9055/public/mips-linux-gnu/
  174. TOOLCHAIN_EXTERNAL_SOURCE=mips-2011.03-93-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
  175. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_POWERPC201009),y)
  176. TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/power/portal/package7703/public/powerpc-linux-gnu/
  177. TOOLCHAIN_EXTERNAL_SOURCE=freescale-2010.09-55-powerpc-linux-gnu-i686-pc-linux-gnu.tar.bz2
  178. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH201009),y)
  179. TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/superh/portal/package7783/public/sh-linux-gnu/
  180. TOOLCHAIN_EXTERNAL_SOURCE=renesas-2010.09-45-sh-linux-gnu-i686-pc-linux-gnu.tar.bz2
  181. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH201103),y)
  182. TOOLCHAIN_EXTERNAL_SITE=https://sourcery.mentor.com/sgpp/lite/superh/portal/package8759/public/sh-linux-gnu/
  183. TOOLCHAIN_EXTERNAL_SOURCE=renesas-2011.03-37-sh-linux-gnu-i686-pc-linux-gnu.tar.bz2
  184. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH2A_201009),y)
  185. TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/superh/portal/package7859/public/sh-uclinux/
  186. TOOLCHAIN_EXTERNAL_SOURCE=renesas-2010.09-60-sh-uclinux-i686-pc-linux-gnu.tar.bz2
  187. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH2A_201103),y)
  188. TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/superh/portal/package8749/public/sh-uclinux/
  189. TOOLCHAIN_EXTERNAL_SOURCE=renesas-2011.03-36-sh-uclinux-i686-pc-linux-gnu.tar.bz2
  190. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_X86_201009),y)
  191. TOOLCHAIN_EXTERNAL_SITE=https://sourcery.mentor.com/sgpp/lite/ia32/portal/package7682/public/i686-pc-linux-gnu/
  192. TOOLCHAIN_EXTERNAL_SOURCE=ia32-2010.09-44-i686-pc-linux-gnu-i386-linux.tar.bz2
  193. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2010RC1),y)
  194. TOOLCHAIN_EXTERNAL_SITE_1 = http://blackfin.uclinux.org/gf/download/frsrelease/501/8378/
  195. TOOLCHAIN_EXTERNAL_SOURCE_1 = blackfin-toolchain-2010R1-RC4.i386.tar.bz2
  196. TOOLCHAIN_EXTERNAL_SITE_2 = http://blackfin.uclinux.org/gf/download/frsrelease/501/8386/
  197. TOOLCHAIN_EXTERNAL_SOURCE_2 = blackfin-toolchain-uclibc-full-2010R1-RC4.i386.tar.bz2
  198. TOOLCHAIN_EXTERNAL_SOURCE = $(TOOLCHAIN_EXTERNAL_SOURCE_1) $(TOOLCHAIN_EXTERNAL_SOURCE_2)
  199. else
  200. # A value must be set (even if unused), otherwise the
  201. # $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE) rule would override the main
  202. # $(DL_DIR) rule
  203. TOOLCHAIN_EXTERNAL_SOURCE=none
  204. endif
  205. # Special handling for Blackfin toolchain, because of the split in two
  206. # tarballs, and the organization of tarball contents. The tarballs
  207. # contain ./opt/uClinux/{bfin-uclinux,bfin-linux-uclibc} directories,
  208. # which themselves contain the toolchain. This is why we strip more
  209. # components than usual.
  210. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2010RC1),y)
  211. $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_1):
  212. $(call DOWNLOAD,$(TOOLCHAIN_EXTERNAL_SITE_1),$(TOOLCHAIN_EXTERNAL_SOURCE_1))
  213. $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_2):
  214. $(call DOWNLOAD,$(TOOLCHAIN_EXTERNAL_SITE_2),$(TOOLCHAIN_EXTERNAL_SOURCE_2))
  215. $(TOOLCHAIN_EXTERNAL_DIR)/.extracted: $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_1) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_2)
  216. mkdir -p $(@D)
  217. $(INFLATE$(suffix $(TOOLCHAIN_EXTERNAL_SOURCE_1))) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_1) | \
  218. $(TAR) $(TAR_STRIP_COMPONENTS)=3 --hard-dereference -C $(@D) $(TAR_OPTIONS) -
  219. $(INFLATE$(suffix $(TOOLCHAIN_EXTERNAL_SOURCE_2))) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_2) | \
  220. $(TAR) $(TAR_STRIP_COMPONENTS)=3 --hard-dereference -C $(@D) $(TAR_OPTIONS) -
  221. ifeq ($(TOOLCHAIN_EXTERNAL_PREFIX),bfin-uclinux)
  222. rm -rf $(TOOLCHAIN_EXTERNAL_DIR)/bfin-linux-uclibc
  223. mv $(TOOLCHAIN_EXTERNAL_DIR)/bfin-uclinux $(TOOLCHAIN_EXTERNAL_DIR)/tmp
  224. mv $(TOOLCHAIN_EXTERNAL_DIR)/tmp/* $(TOOLCHAIN_EXTERNAL_DIR)/
  225. rmdir $(TOOLCHAIN_EXTERNAL_DIR)/tmp
  226. else
  227. rm -rf $(TOOLCHAIN_EXTERNAL_DIR)/bfin-uclinux
  228. mv $(TOOLCHAIN_EXTERNAL_DIR)/bfin-linux-uclibc $(TOOLCHAIN_EXTERNAL_DIR)/tmp
  229. mv $(TOOLCHAIN_EXTERNAL_DIR)/tmp/* $(TOOLCHAIN_EXTERNAL_DIR)/
  230. rmdir $(TOOLCHAIN_EXTERNAL_DIR)/tmp
  231. endif
  232. $(Q)touch $@
  233. else
  234. # Download and extraction of a toolchain
  235. $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE):
  236. $(call DOWNLOAD,$(TOOLCHAIN_EXTERNAL_SITE),$(TOOLCHAIN_EXTERNAL_SOURCE))
  237. $(TOOLCHAIN_EXTERNAL_DIR)/.extracted: $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE)
  238. mkdir -p $(@D)
  239. $(INFLATE$(suffix $(TOOLCHAIN_EXTERNAL_SOURCE))) $^ | \
  240. $(TAR) $(TAR_STRIP_COMPONENTS)=1 --exclude='usr/lib/locale/*' -C $(@D) $(TAR_OPTIONS) -
  241. $(Q)touch $@
  242. endif
  243. # Checks for an already installed toolchain: check the toolchain
  244. # location, check that it supports sysroot, and then verify that it
  245. # matches the configuration provided in Buildroot: ABI, C++ support,
  246. # type of C library and all C library features.
  247. $(STAMP_DIR)/ext-toolchain-checked:
  248. @echo "Checking external toolchain settings"
  249. $(Q)$(call check_cross_compiler_exists,$(TOOLCHAIN_EXTERNAL_CC))
  250. $(Q)SYSROOT_DIR=`$(TOOLCHAIN_EXTERNAL_CC) -print-sysroot 2>/dev/null` ; \
  251. if test -z "$${SYSROOT_DIR}" ; then \
  252. SYSROOT_DIR=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) -print-file-name=libc.a) |sed -r -e 's:usr/lib/libc\.a::;'` ; \
  253. fi ; \
  254. if test -z "$${SYSROOT_DIR}" ; then \
  255. @echo "External toolchain doesn't support --sysroot. Cannot use." ; \
  256. exit 1 ; \
  257. fi ; \
  258. if test x$(BR2_arm) == x"y" ; then \
  259. $(call check_arm_abi,$(TOOLCHAIN_EXTERNAL_CC)) ; \
  260. fi ; \
  261. if test x$(BR2_INSTALL_LIBSTDCPP) == x"y" ; then \
  262. $(call check_cplusplus,$(TOOLCHAIN_EXTERNAL_CXX)) ; \
  263. fi ; \
  264. if test x$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC) == x"y" ; then \
  265. $(call check_uclibc,$${SYSROOT_DIR}) ; \
  266. else \
  267. $(call check_glibc,$${SYSROOT_DIR}) ; \
  268. fi
  269. $(Q)touch $@
  270. # Integration of the toolchain into Buildroot: find the main sysroot
  271. # and the variant-specific sysroot, then copy the needed libraries to
  272. # the $(TARGET_DIR) and copy the whole sysroot (libraries and headers)
  273. # to $(STAGING_DIR).
  274. $(STAMP_DIR)/ext-toolchain-installed: $(TOOLCHAIN_EXTERNAL_DEPENDENCIES)
  275. $(Q)SYSROOT_DIR=`$(TOOLCHAIN_EXTERNAL_CC) -print-sysroot 2>/dev/null` ; \
  276. if test -z "$${SYSROOT_DIR}" ; then \
  277. SYSROOT_DIR=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) -print-file-name=libc.a) |sed -r -e 's:usr/lib/libc\.a::;'` ; \
  278. fi ; \
  279. if test -z "$${SYSROOT_DIR}" ; then \
  280. @echo "External toolchain doesn't support --sysroot. Cannot use." ; \
  281. exit 1 ; \
  282. fi ; \
  283. ARCH_SUBDIR=`$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-multi-directory` ; \
  284. ARCH_SYSROOT_DIR=$${SYSROOT_DIR}/$${ARCH_SUBDIR} ; \
  285. mkdir -p $(TARGET_DIR)/lib ; \
  286. echo "Copy external toolchain libraries to target..." ; \
  287. for libs in $(LIB_EXTERNAL_LIBS); do \
  288. $(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$$libs,/lib); \
  289. done ; \
  290. for libs in $(USR_LIB_EXTERNAL_LIBS); do \
  291. $(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$$libs,/usr/lib); \
  292. done ; \
  293. echo "Copy external toolchain sysroot to staging..." ; \
  294. $(call copy_toolchain_sysroot,$${SYSROOT_DIR},$${ARCH_SYSROOT_DIR},$${ARCH_SUBDIR}) ; \
  295. if [ -L $${ARCH_SYSROOT_DIR}/lib64 ] ; then \
  296. $(call create_lib64_symlinks) ; \
  297. fi ; \
  298. touch $@
  299. # Build toolchain wrapper for preprocessor, C and C++ compiler, and setup
  300. # symlinks for everything else
  301. $(HOST_DIR)/usr/bin/ext-toolchain-wrapper: $(STAMP_DIR)/ext-toolchain-installed
  302. mkdir -p $(HOST_DIR)/usr/bin; cd $(HOST_DIR)/usr/bin; \
  303. for i in $(TOOLCHAIN_EXTERNAL_CROSS)*; do \
  304. base=$${i##*/}; \
  305. case "$$base" in \
  306. *cc|*cc-*|*++|*++-*|*cpp) \
  307. ln -sf $(@F) $$base; \
  308. ;; \
  309. *) \
  310. ln -sf $$i .; \
  311. ;; \
  312. esac; \
  313. done ;
  314. $(HOSTCC) $(HOST_CFLAGS) $(TOOLCHAIN_EXTERNAL_WRAPPER_ARGS) -s \
  315. toolchain/toolchain-external/ext-toolchain-wrapper.c -o $@
  316. # 'uclibc' is the target to provide toolchain / staging dir
  317. uclibc: dependencies $(HOST_DIR)/usr/bin/ext-toolchain-wrapper
  318. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD),y)
  319. # download ext toolchain if so configured
  320. uclibc-source: $(addprefix $(DL_DIR)/,$(TOOLCHAIN_EXTERNAL_SOURCE))
  321. endif