2
1

toolchain-external.mk 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. ################################################################################
  2. #
  3. # toolchain-external
  4. #
  5. ################################################################################
  6. #
  7. # This package implements the support for external toolchains, i.e
  8. # toolchains that have not been produced by Buildroot itself and that
  9. # Buildroot can download from the Web or that are already available on
  10. # the system on which Buildroot runs. So far, we have tested this
  11. # with:
  12. #
  13. # * Toolchains generated by Crosstool-NG
  14. # * Toolchains generated by Buildroot
  15. # * Toolchains provided by Linaro for the ARM and AArch64
  16. # architectures
  17. # * Sourcery CodeBench toolchains (from Mentor Graphics) for the ARM,
  18. # MIPS, PowerPC, x86, x86_64 and NIOS 2 architectures. For the MIPS
  19. # toolchain, the -muclibc variant isn't supported yet, only the
  20. # default glibc-based variant is.
  21. # * Analog Devices toolchains for the Blackfin architecture
  22. # * Xilinx toolchains for the Microblaze architecture
  23. #
  24. # The basic principle is the following
  25. #
  26. # 1. If the toolchain is not pre-installed, download and extract it
  27. # in $(TOOLCHAIN_EXTERNAL_INSTALL_DIR). Otherwise,
  28. # $(TOOLCHAIN_EXTERNAL_INSTALL_DIR) points to were the toolchain has
  29. # already been installed by the user.
  30. #
  31. # 2. For all external toolchains, perform some checks on the
  32. # conformity between the toolchain configuration described in the
  33. # Buildroot menuconfig system, and the real configuration of the
  34. # external toolchain. This is for example important to make sure that
  35. # the Buildroot configuration system knows whether the toolchain
  36. # supports RPC, IPv6, locales, large files, etc. Unfortunately, these
  37. # things cannot be detected automatically, since the value of these
  38. # options (such as BR2_TOOLCHAIN_HAS_NATIVE_RPC) are needed at
  39. # configuration time because these options are used as dependencies
  40. # for other options. And at configuration time, we are not able to
  41. # retrieve the external toolchain configuration.
  42. #
  43. # 3. Copy the libraries needed at runtime to the target directory,
  44. # $(TARGET_DIR). Obviously, things such as the C library, the dynamic
  45. # loader and a few other utility libraries are needed if dynamic
  46. # applications are to be executed on the target system.
  47. #
  48. # 4. Copy the libraries and headers to the staging directory. This
  49. # will allow all further calls to gcc to be made using --sysroot
  50. # $(STAGING_DIR), which greatly simplifies the compilation of the
  51. # packages when using external toolchains. So in the end, only the
  52. # cross-compiler binaries remains external, all libraries and headers
  53. # are imported into the Buildroot tree.
  54. #
  55. # 5. Build a toolchain wrapper which executes the external toolchain
  56. # with a number of arguments (sysroot/march/mtune/..) hardcoded,
  57. # so we're sure the correct configuration is always used and the
  58. # toolchain behaves similar to an internal toolchain.
  59. # This toolchain wrapper and symlinks are installed into
  60. # $(HOST_DIR)/usr/bin like for the internal toolchains, and the rest
  61. # of Buildroot is handled identical for the 2 toolchain types.
  62. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC)$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC),y)
  63. LIB_EXTERNAL_LIBS+=libc.so.* libcrypt.so.* libdl.so.* libgcc_s.so.* libm.so.* libnsl.so.* libresolv.so.* librt.so.* libutil.so.*
  64. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC)$(BR2_ARM_EABIHF),yy)
  65. LIB_EXTERNAL_LIBS+=ld-linux-armhf.so.*
  66. else
  67. LIB_EXTERNAL_LIBS+=ld*.so.*
  68. endif
  69. ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
  70. LIB_EXTERNAL_LIBS+=libpthread.so.*
  71. ifneq ($(BR2_PACKAGE_GDB)$(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY),)
  72. LIB_EXTERNAL_LIBS+=libthread_db.so.*
  73. endif # gdbserver
  74. endif # ! no threads
  75. endif
  76. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC),y)
  77. LIB_EXTERNAL_LIBS+=libnss_files.so.* libnss_dns.so.*
  78. endif
  79. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_MUSL),y)
  80. LIB_EXTERNAL_LIBS += libc.so libgcc_s.so.*
  81. endif
  82. ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
  83. USR_LIB_EXTERNAL_LIBS+=libstdc++.so.*
  84. endif
  85. LIB_EXTERNAL_LIBS+=$(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
  86. # Details about sysroot directory selection.
  87. #
  88. # To find the sysroot directory, we use the trick of looking for the
  89. # 'libc.a' file with the -print-file-name gcc option, and then
  90. # mangling the path to find the base directory of the sysroot.
  91. #
  92. # Note that we do not use the -print-sysroot option, because it is
  93. # only available since gcc 4.4.x, and we still support 4.2.x (for
  94. # AVR32) and 4.3.x.
  95. #
  96. # When doing this, we don't pass any option to gcc that could select a
  97. # multilib variant (such as -march) as we want the "main" sysroot,
  98. # which contains all variants of the C library in the case of multilib
  99. # toolchains. We use the TARGET_CC_NO_SYSROOT variable, which is the
  100. # path of the cross-compiler, without the --sysroot=$(STAGING_DIR),
  101. # since what we want to find is the location of the original toolchain
  102. # sysroot. This "main" sysroot directory is stored in SYSROOT_DIR.
  103. #
  104. # Then, multilib toolchains are a little bit more complicated, since
  105. # they in fact have multiple sysroots, one for each variant supported
  106. # by the toolchain. So we need to find the particular sysroot we're
  107. # interested in.
  108. #
  109. # To do so, we ask the compiler where its sysroot is by passing all
  110. # flags (including -march and al.), except the --sysroot flag since we
  111. # want to the compiler to tell us where its original sysroot
  112. # is. ARCH_SUBDIR will contain the subdirectory, in the main
  113. # SYSROOT_DIR, that corresponds to the selected architecture
  114. # variant. ARCH_SYSROOT_DIR will contain the full path to this
  115. # location.
  116. #
  117. # One might wonder why we don't just bother with ARCH_SYSROOT_DIR. The
  118. # fact is that in multilib toolchains, the header files are often only
  119. # present in the main sysroot, and only the libraries are available in
  120. # each variant-specific sysroot directory.
  121. TOOLCHAIN_EXTERNAL_PREFIX=$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PREFIX))
  122. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD),y)
  123. TOOLCHAIN_EXTERNAL_INSTALL_DIR=$(HOST_DIR)/opt/ext-toolchain
  124. else
  125. TOOLCHAIN_EXTERNAL_INSTALL_DIR=$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PATH))
  126. endif
  127. ifeq ($(TOOLCHAIN_EXTERNAL_INSTALL_DIR),)
  128. ifneq ($(TOOLCHAIN_EXTERNAL_PREFIX),)
  129. # if no path set, figure it out from path
  130. TOOLCHAIN_EXTERNAL_BIN := $(shell dirname $(shell which $(TOOLCHAIN_EXTERNAL_PREFIX)-gcc))
  131. endif
  132. else
  133. ifeq ($(BR2_bfin),y)
  134. TOOLCHAIN_EXTERNAL_BIN := $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)/$(TOOLCHAIN_EXTERNAL_PREFIX)/bin
  135. else
  136. TOOLCHAIN_EXTERNAL_BIN := $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)/bin
  137. endif
  138. endif
  139. TOOLCHAIN_EXTERNAL_CROSS=$(TOOLCHAIN_EXTERNAL_BIN)/$(TOOLCHAIN_EXTERNAL_PREFIX)-
  140. TOOLCHAIN_EXTERNAL_CC=$(TOOLCHAIN_EXTERNAL_CROSS)gcc
  141. TOOLCHAIN_EXTERNAL_CXX=$(TOOLCHAIN_EXTERNAL_CROSS)g++
  142. TOOLCHAIN_EXTERNAL_READELF=$(TOOLCHAIN_EXTERNAL_CROSS)readelf
  143. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS = -DBR_SYSROOT='"$(STAGING_SUBDIR)"'
  144. ifeq ($(filter $(HOST_DIR)/%,$(TOOLCHAIN_EXTERNAL_BIN)),)
  145. # TOOLCHAIN_EXTERNAL_BIN points outside HOST_DIR => absolute path
  146. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += \
  147. -DBR_CROSS_PATH_ABS='"$(TOOLCHAIN_EXTERNAL_BIN)"'
  148. else
  149. # TOOLCHAIN_EXTERNAL_BIN points inside HOST_DIR => relative path
  150. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += \
  151. -DBR_CROSS_PATH_REL='"$(TOOLCHAIN_EXTERNAL_BIN:$(HOST_DIR)/%=%)"'
  152. endif
  153. CC_TARGET_TUNE_:=$(call qstrip,$(BR2_GCC_TARGET_TUNE))
  154. ifeq ($(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)),)
  155. CC_TARGET_CPU_:=$(call qstrip,$(BR2_GCC_TARGET_CPU))
  156. else
  157. CC_TARGET_CPU_:=$(call qstrip,$(BR2_GCC_TARGET_CPU)-$(BR2_GCC_TARGET_CPU_REVISION))
  158. endif
  159. CC_TARGET_ARCH_:=$(call qstrip,$(BR2_GCC_TARGET_ARCH))
  160. CC_TARGET_ABI_:=$(call qstrip,$(BR2_GCC_TARGET_ABI))
  161. CC_TARGET_FPU_:=$(call qstrip,$(BR2_GCC_TARGET_FPU))
  162. CC_TARGET_FLOAT_ABI_:=$(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
  163. CC_TARGET_MODE_:=$(call qstrip,$(BR2_GCC_TARGET_MODE))
  164. # march/mtune/floating point mode needs to be passed to the external toolchain
  165. # to select the right multilib variant
  166. ifeq ($(BR2_x86_64),y)
  167. TOOLCHAIN_EXTERNAL_CFLAGS += -m64
  168. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_64
  169. endif
  170. ifneq ($(CC_TARGET_TUNE_),)
  171. TOOLCHAIN_EXTERNAL_CFLAGS += -mtune=$(CC_TARGET_TUNE_)
  172. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_TUNE='"$(CC_TARGET_TUNE_)"'
  173. endif
  174. ifneq ($(CC_TARGET_ARCH_),)
  175. TOOLCHAIN_EXTERNAL_CFLAGS += -march=$(CC_TARGET_ARCH_)
  176. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_ARCH='"$(CC_TARGET_ARCH_)"'
  177. endif
  178. ifneq ($(CC_TARGET_CPU_),)
  179. TOOLCHAIN_EXTERNAL_CFLAGS += -mcpu=$(CC_TARGET_CPU_)
  180. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_CPU='"$(CC_TARGET_CPU_)"'
  181. endif
  182. ifneq ($(CC_TARGET_ABI_),)
  183. TOOLCHAIN_EXTERNAL_CFLAGS += -mabi=$(CC_TARGET_ABI_)
  184. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_ABI='"$(CC_TARGET_ABI_)"'
  185. endif
  186. ifneq ($(CC_TARGET_FPU_),)
  187. TOOLCHAIN_EXTERNAL_CFLAGS += -mfpu=$(CC_TARGET_FPU_)
  188. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_FPU='"$(CC_TARGET_FPU_)"'
  189. endif
  190. ifneq ($(CC_TARGET_FLOAT_ABI_),)
  191. TOOLCHAIN_EXTERNAL_CFLAGS += -mfloat-abi=$(CC_TARGET_FLOAT_ABI_)
  192. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_FLOAT_ABI='"$(CC_TARGET_FLOAT_ABI_)"'
  193. endif
  194. ifneq ($(CC_TARGET_MODE_),)
  195. TOOLCHAIN_EXTERNAL_CFLAGS += -m$(CC_TARGET_MODE_)
  196. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_MODE='"$(CC_TARGET_MODE_)"'
  197. endif
  198. ifeq ($(BR2_BINFMT_FLAT),y)
  199. TOOLCHAIN_EXTERNAL_CFLAGS += -Wl,-elf2flt
  200. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_BINFMT_FLAT
  201. endif
  202. ifeq ($(BR2_mipsel)$(BR2_mips64el),y)
  203. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_MIPS_TARGET_LITTLE_ENDIAN
  204. TOOLCHAIN_EXTERNAL_CFLAGS += -EL
  205. endif
  206. ifeq ($(BR2_mips)$(BR2_mips64),y)
  207. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_MIPS_TARGET_BIG_ENDIAN
  208. TOOLCHAIN_EXTERNAL_CFLAGS += -EB
  209. endif
  210. ifneq ($(BR2_TARGET_OPTIMIZATION),)
  211. TOOLCHAIN_EXTERNAL_CFLAGS += $(call qstrip,$(BR2_TARGET_OPTIMIZATION))
  212. # We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each
  213. # flag is a separate argument when used in execv() by the external
  214. # toolchain wrapper.
  215. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_ADDITIONAL_CFLAGS='$(foreach f,$(call qstrip,$(BR2_TARGET_OPTIMIZATION)),"$(f)",)'
  216. endif
  217. ifeq ($(BR2_SOFT_FLOAT),y)
  218. TOOLCHAIN_EXTERNAL_CFLAGS += -msoft-float
  219. TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_SOFTFLOAT=1
  220. endif
  221. # The Linaro ARMhf toolchain expects the libraries in
  222. # {/usr,}/lib/arm-linux-gnueabihf, but Buildroot copies them to
  223. # {/usr,}/lib, so we need to create a symbolic link.
  224. define TOOLCHAIN_EXTERNAL_LINARO_ARMHF_SYMLINK
  225. ln -sf . $(TARGET_DIR)/lib/arm-linux-gnueabihf
  226. ln -sf . $(TARGET_DIR)/usr/lib/arm-linux-gnueabihf
  227. endef
  228. define TOOLCHAIN_EXTERNAL_LINARO_ARMEBHF_SYMLINK
  229. ln -sf . $(TARGET_DIR)/lib/armeb-linux-gnueabihf
  230. ln -sf . $(TARGET_DIR)/usr/lib/armeb-linux-gnueabihf
  231. endef
  232. define TOOLCHAIN_EXTERNAL_LINARO_AARCH64_SYMLINK
  233. ln -sf . $(TARGET_DIR)/lib/aarch64-linux-gnu
  234. ln -sf . $(TARGET_DIR)/usr/lib/aarch64-linux-gnu
  235. endef
  236. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201203),y)
  237. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/
  238. TOOLCHAIN_EXTERNAL_SOURCE = arm-2012.03-57-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
  239. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201305),y)
  240. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/
  241. TOOLCHAIN_EXTERNAL_SOURCE = arm-2013.05-24-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
  242. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201311),y)
  243. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/
  244. TOOLCHAIN_EXTERNAL_SOURCE = arm-2013.11-33-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
  245. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_ARAGO_ARMV7A_201109),y)
  246. TOOLCHAIN_EXTERNAL_SITE = http://software-dl.ti.com/sdoemb/sdoemb_public_sw/arago_toolchain/2011_09/exports/
  247. TOOLCHAIN_EXTERNAL_SOURCE = arago-2011.09-armv7a-linux-gnueabi-sdk.tar.bz2
  248. define TOOLCHAIN_EXTERNAL_FIXUP_CMDS
  249. mv $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)/arago-2011.09/armv7a/* $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)/
  250. rm -rf $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)/arago-2011.09/
  251. endef
  252. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_ARAGO_ARMV5TE_201109),y)
  253. TOOLCHAIN_EXTERNAL_SITE = http://software-dl.ti.com/sdoemb/sdoemb_public_sw/arago_toolchain/2011_09/exports/
  254. TOOLCHAIN_EXTERNAL_SOURCE = arago-2011.09-armv5te-linux-gnueabi-sdk.tar.bz2
  255. define TOOLCHAIN_EXTERNAL_FIXUP_CMDS
  256. mv $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)/arago-2011.09/armv5te/* $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)/
  257. rm -rf $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)/arago-2011.09/
  258. endef
  259. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM),y)
  260. TOOLCHAIN_EXTERNAL_SITE = http://releases.linaro.org/14.05/components/toolchain/binaries/
  261. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-arm-linux-gnueabihf-4.9-2014.05_linux.tar.xz
  262. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_ARMHF_SYMLINK
  263. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB),y)
  264. TOOLCHAIN_EXTERNAL_SITE = http://releases.linaro.org/14.04/components/toolchain/binaries/
  265. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-armeb-linux-gnueabihf-4.8-2014.04_linux.tar.xz
  266. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_ARMEBHF_SYMLINK
  267. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201305),y)
  268. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/mips-linux-gnu/
  269. TOOLCHAIN_EXTERNAL_SOURCE = mips-2013.05-66-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
  270. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201311),y)
  271. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/mips-linux-gnu/
  272. TOOLCHAIN_EXTERNAL_SOURCE = mips-2013.11-36-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
  273. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201405),y)
  274. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/mips-linux-gnu/
  275. TOOLCHAIN_EXTERNAL_SOURCE = mips-2014.05-27-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
  276. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201305),y)
  277. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/nios2-linux-gnu/
  278. TOOLCHAIN_EXTERNAL_SOURCE = sourceryg++-2013.05-43-nios2-linux-gnu-i686-pc-linux-gnu.tar.bz2
  279. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_SANITIZE_KERNEL_HEADERS
  280. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201405),y)
  281. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/nios2-linux-gnu/
  282. TOOLCHAIN_EXTERNAL_SOURCE = sourceryg++-2014.05-47-nios2-linux-gnu-i686-pc-linux-gnu.tar.bz2
  283. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_POWERPC201009),y)
  284. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/powerpc-linux-gnu/
  285. TOOLCHAIN_EXTERNAL_SOURCE = freescale-2010.09-55-powerpc-linux-gnu-i686-pc-linux-gnu.tar.bz2
  286. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_POWERPC201103),y)
  287. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/powerpc-linux-gnu/
  288. TOOLCHAIN_EXTERNAL_SOURCE = freescale-2011.03-38-powerpc-linux-gnu-i686-pc-linux-gnu.tar.bz2
  289. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_POWERPC201203),y)
  290. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/powerpc-mentor-linux-gnu/
  291. TOOLCHAIN_EXTERNAL_SOURCE = mentor-2012.03-71-powerpc-mentor-linux-gnu-i686-pc-linux-gnu.tar.bz2
  292. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH201103),y)
  293. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/sh-linux-gnu/
  294. TOOLCHAIN_EXTERNAL_SOURCE = renesas-2011.03-37-sh-linux-gnu-i686-pc-linux-gnu.tar.bz2
  295. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH201203),y)
  296. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/sh-linux-gnu/
  297. TOOLCHAIN_EXTERNAL_SOURCE = renesas-2012.03-35-sh-linux-gnu-i686-pc-linux-gnu.tar.bz2
  298. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH201209),y)
  299. TOOLCHAIN_EXTERNAL_SITE = https://sourcery.mentor.com/public/gnu_toolchain/sh-linux-gnu/
  300. TOOLCHAIN_EXTERNAL_SOURCE = renesas-2012.09-61-sh-linux-gnu-i686-pc-linux-gnu.tar.bz2
  301. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH2A_201009),y)
  302. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/sh-uclinux/
  303. TOOLCHAIN_EXTERNAL_SOURCE = renesas-2010.09-60-sh-uclinux-i686-pc-linux-gnu.tar.bz2
  304. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH2A_201103),y)
  305. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/sh-uclinux/
  306. TOOLCHAIN_EXTERNAL_SOURCE = renesas-2011.03-36-sh-uclinux-i686-pc-linux-gnu.tar.bz2
  307. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_X86_201109),y)
  308. TOOLCHAIN_EXTERNAL_SITE = https://sourcery.mentor.com/public/gnu_toolchain/i686-pc-linux-gnu/
  309. TOOLCHAIN_EXTERNAL_SOURCE = ia32-2011.09-24-i686-pc-linux-gnu-i386-linux.tar.bz2
  310. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_X86_201203),y)
  311. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/i686-pc-linux-gnu/
  312. TOOLCHAIN_EXTERNAL_SOURCE = ia32-2012.03-27-i686-pc-linux-gnu-i386-linux.tar.bz2
  313. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_X86_201209),y)
  314. TOOLCHAIN_EXTERNAL_SITE = https://sourcery.mentor.com/public/gnu_toolchain/i686-pc-linux-gnu/
  315. TOOLCHAIN_EXTERNAL_SOURCE = ia32-2012.09-62-i686-pc-linux-gnu-i386-linux.tar.bz2
  316. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R2),y)
  317. TOOLCHAIN_EXTERNAL_SITE = http://downloads.sourceforge.net/project/adi-toolchain/2012R2/2012R2-RC2/i386/
  318. TOOLCHAIN_EXTERNAL_SOURCE = blackfin-toolchain-2012R2-RC2.i386.tar.bz2
  319. TOOLCHAIN_EXTERNAL_EXTRA_DOWNLOADS = blackfin-toolchain-uclibc-full-2012R2-RC2.i386.tar.bz2
  320. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2013R1),y)
  321. TOOLCHAIN_EXTERNAL_SITE = http://downloads.sourceforge.net/project/adi-toolchain/2013R1/2013R1-RC1/i386/
  322. TOOLCHAIN_EXTERNAL_SOURCE = blackfin-toolchain-2013R1-RC1.i386.tar.bz2
  323. TOOLCHAIN_EXTERNAL_EXTRA_DOWNLOADS = blackfin-toolchain-uclibc-full-2013R1-RC1.i386.tar.bz2
  324. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2014R1),y)
  325. TOOLCHAIN_EXTERNAL_SITE = http://downloads.sourceforge.net/project/adi-toolchain/2014R1/2014R1-RC2/i386/
  326. TOOLCHAIN_EXTERNAL_SOURCE = blackfin-toolchain-2014R1-RC2.i386.tar.bz2
  327. TOOLCHAIN_EXTERNAL_EXTRA_DOWNLOADS = blackfin-toolchain-uclibc-full-2014R1-RC2.i386.tar.bz2
  328. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_XILINX_MICROBLAZEEL_14_3),y)
  329. TOOLCHAIN_EXTERNAL_SITE = http://sources.buildroot.net/
  330. TOOLCHAIN_EXTERNAL_SOURCE = lin32-microblazeel-unknown-linux-gnu_14.3_early.tar.xz
  331. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_XILINX_MICROBLAZEEL_V2),y)
  332. TOOLCHAIN_EXTERNAL_SITE = http://sources.buildroot.net/
  333. TOOLCHAIN_EXTERNAL_SOURCE = microblazeel-unknown-linux-gnu.tgz
  334. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_XILINX_MICROBLAZEBE_14_3),y)
  335. TOOLCHAIN_EXTERNAL_SITE = http://sources.buildroot.net/
  336. TOOLCHAIN_EXTERNAL_SOURCE = lin32-microblaze-unknown-linux-gnu_14.3_early.tar.xz
  337. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_XILINX_MICROBLAZEBE_V2),y)
  338. TOOLCHAIN_EXTERNAL_SITE = http://sources.buildroot.net/
  339. TOOLCHAIN_EXTERNAL_SOURCE = microblaze-unknown-linux-gnu.tgz
  340. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64),y)
  341. TOOLCHAIN_EXTERNAL_SITE = http://releases.linaro.org/14.05/components/toolchain/binaries/
  342. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-aarch64-linux-gnu-4.9-2014.05_linux.tar.xz
  343. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_AARCH64_SYMLINK
  344. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_MUSL_CROSS),y)
  345. TOOLCHAIN_EXTERNAL_VERSION = 1.1.1
  346. TOOLCHAIN_EXTERNAL_SITE = https://googledrive.com/host/0BwnS5DMB0YQ6bDhPZkpOYVFhbk0/musl-$(TOOLCHAIN_EXTERNAL_VERSION)/
  347. ifeq ($(BR2_arm),y)
  348. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-arm-linux-musleabi-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  349. else ifeq ($(BR2_armeb),y)
  350. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-armeb-linux-musleabi-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  351. else ifeq ($(BR2_i386),y)
  352. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-i486-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  353. else ifeq ($(BR2_microblazebe),y)
  354. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-microblaze-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  355. else ifeq ($(BR2_mips),y)
  356. ifeq ($(BR2_SOFT_FLOAT),y)
  357. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-mips-sf-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  358. else
  359. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-mips-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  360. endif # BR2_SOFT_FLOAT
  361. else ifeq ($(BR2_mipsel),y)
  362. ifeq ($(BR2_SOFT_FLOAT),y)
  363. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-mipsel-sf-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  364. else
  365. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-mipsel-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  366. endif # BR2_SOFT_FLOAT
  367. else ifeq ($(BR2_powerpc),y)
  368. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-powerpc-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  369. else ifeq ($(BR2_x86_64),y)
  370. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-x86_64-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  371. endif
  372. else
  373. # Custom toolchain
  374. TOOLCHAIN_EXTERNAL_SITE = $(dir $(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_URL)))
  375. TOOLCHAIN_EXTERNAL_SOURCE = $(notdir $(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_URL)))
  376. endif
  377. # In fact, we don't need to download the toolchain, since it is already
  378. # available on the system, so force the site and source to be empty so
  379. # that nothing will be downloaded/extracted.
  380. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_PREINSTALLED),y)
  381. TOOLCHAIN_EXTERNAL_SITE =
  382. TOOLCHAIN_EXTERNAL_SOURCE =
  383. endif
  384. TOOLCHAIN_EXTERNAL_ADD_TOOLCHAIN_DEPENDENCY = NO
  385. TOOLCHAIN_EXTERNAL_INSTALL_STAGING = YES
  386. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R2)$(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2013R1)$(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2014R1),y)
  387. # Special handling for Blackfin toolchain, because of the split in two
  388. # tarballs, and the organization of tarball contents. The tarballs
  389. # contain ./opt/uClinux/{bfin-uclinux,bfin-linux-uclibc} directories,
  390. # which themselves contain the toolchain. This is why we strip more
  391. # components than usual.
  392. define TOOLCHAIN_EXTERNAL_EXTRACT_CMDS
  393. mkdir -p $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)
  394. $(call suitable-extractor,$(TOOLCHAIN_EXTERNAL_SOURCE)) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE) | \
  395. $(TAR) $(TAR_STRIP_COMPONENTS)=3 --hard-dereference -C $(TOOLCHAIN_EXTERNAL_INSTALL_DIR) $(TAR_OPTIONS) -
  396. $(call suitable-extractor,$(TOOLCHAIN_EXTERNAL_EXTRA_DOWNLOADS)) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_EXTRA_DOWNLOADS) | \
  397. $(TAR) $(TAR_STRIP_COMPONENTS)=3 --hard-dereference -C $(TOOLCHAIN_EXTERNAL_INSTALL_DIR) $(TAR_OPTIONS) -
  398. endef
  399. else ifneq ($(TOOLCHAIN_EXTERNAL_SOURCE),)
  400. # Normal handling of toolchain tarball extraction.
  401. define TOOLCHAIN_EXTERNAL_EXTRACT_CMDS
  402. mkdir -p $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)
  403. $(call suitable-extractor,$(TOOLCHAIN_EXTERNAL_SOURCE)) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE) | \
  404. $(TAR) $(TAR_STRIP_COMPONENTS)=1 --exclude='usr/lib/locale/*' -C $(TOOLCHAIN_EXTERNAL_INSTALL_DIR) $(TAR_OPTIONS) -
  405. $(TOOLCHAIN_EXTERNAL_FIXUP_CMDS)
  406. endef
  407. endif
  408. # Returns the location of the libc.a file for the given compiler + flags
  409. define toolchain_find_libc_a
  410. $$(readlink -f $$(LANG=C $(1) -print-file-name=libc.a))
  411. endef
  412. # Returns the sysroot location for the given compiler + flags
  413. define toolchain_find_sysroot
  414. $$(echo -n $(call toolchain_find_libc_a,$(1)) | sed -r -e 's:(usr/)?lib(32|64)?/([^/]*/)?libc\.a::')
  415. endef
  416. # Returns the lib subdirectory for the given compiler + flags (i.e
  417. # typically lib32 or lib64 for some toolchains)
  418. define toolchain_find_libdir
  419. $$(echo -n $(call toolchain_find_libc_a,$(1)) | sed -r -e 's:.*/(usr/)?(lib(32|64)?)/([^/]*/)?libc.a:\2:')
  420. endef
  421. # Checks for an already installed toolchain: check the toolchain
  422. # location, check that it supports sysroot, and then verify that it
  423. # matches the configuration provided in Buildroot: ABI, C++ support,
  424. # kernel headers version, type of C library and all C library features.
  425. define TOOLCHAIN_EXTERNAL_CONFIGURE_CMDS
  426. $(Q)$(call check_cross_compiler_exists,$(TOOLCHAIN_EXTERNAL_CC))
  427. $(Q)$(call check_unusable_toolchain,$(TOOLCHAIN_EXTERNAL_CC))
  428. $(Q)SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC))" ; \
  429. if test -z "$${SYSROOT_DIR}" ; then \
  430. @echo "External toolchain doesn't support --sysroot. Cannot use." ; \
  431. exit 1 ; \
  432. fi ; \
  433. $(call check_kernel_headers_version,\
  434. $(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC)),\
  435. $(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST))); \
  436. if test "$(BR2_arm)" = "y" ; then \
  437. $(call check_arm_abi,\
  438. "$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS)",\
  439. $(TOOLCHAIN_EXTERNAL_READELF)) ; \
  440. fi ; \
  441. if test "$(BR2_INSTALL_LIBSTDCPP)" = "y" ; then \
  442. $(call check_cplusplus,$(TOOLCHAIN_EXTERNAL_CXX)) ; \
  443. fi ; \
  444. if test "$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC)" = "y" ; then \
  445. $(call check_uclibc,$${SYSROOT_DIR}) ; \
  446. elif test "$(BR2_TOOLCHAIN_EXTERNAL_MUSL)" = "y" ; then \
  447. $(call check_musl,$${SYSROOT_DIR}) ; \
  448. else \
  449. $(call check_glibc,$${SYSROOT_DIR}) ; \
  450. fi
  451. endef
  452. # With the musl C library, the libc.so library directly plays the role
  453. # of the dynamic library loader. We just need to create a symbolic
  454. # link to libc.so with the appropriate name.
  455. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_MUSL),y)
  456. ifeq ($(BR2_i386),y)
  457. MUSL_ARCH = i386
  458. else
  459. MUSL_ARCH = $(ARCH)
  460. endif
  461. define TOOLCHAIN_EXTERNAL_MUSL_LD_LINK
  462. ln -sf libc.so $(TARGET_DIR)/lib/ld-musl-$(MUSL_ARCH).so.1
  463. endef
  464. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_MUSL_LD_LINK
  465. endif
  466. # Integration of the toolchain into Buildroot: find the main sysroot
  467. # and the variant-specific sysroot, then copy the needed libraries to
  468. # the $(TARGET_DIR) and copy the whole sysroot (libraries and headers)
  469. # to $(STAGING_DIR).
  470. #
  471. # Variables are defined as follows:
  472. #
  473. # LIBC_A_LOCATION: location of the libc.a file in the default
  474. # multilib variant (allows to find the main
  475. # sysroot directory)
  476. # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/usr/lib/libc.a
  477. #
  478. # SYSROOT_DIR: the main sysroot directory, deduced from
  479. # LIBC_A_LOCATION by removing the
  480. # usr/lib[32|64]/libc.a part of the path.
  481. # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/
  482. #
  483. # ARCH_LIBC_A_LOCATION: location of the libc.a file in the selected
  484. # multilib variant (taking into account the
  485. # CFLAGS). Allows to find the sysroot of the
  486. # selected multilib variant.
  487. # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/mips16/soft-float/el/usr/lib/libc.a
  488. #
  489. # ARCH_SYSROOT_DIR: the sysroot of the selected multilib variant,
  490. # deduced from ARCH_LIBC_A_LOCATION by removing
  491. # usr/lib[32|64]/libc.a at the end of the path.
  492. # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/mips16/soft-float/el/
  493. #
  494. # ARCH_LIB_DIR: 'lib', 'lib32' or 'lib64' depending on where libraries
  495. # are stored. Deduced from ARCH_LIBC_A_LOCATION by
  496. # looking at usr/lib??/libc.a.
  497. # Ex: lib
  498. #
  499. # ARCH_SUBDIR: the relative location of the sysroot of the selected
  500. # multilib variant compared to the main sysroot.
  501. # Ex: mips16/soft-float/el
  502. #
  503. # SUPPORT_LIB_DIR: some toolchains, such as recent Linaro toolchains,
  504. # store GCC support libraries (libstdc++,
  505. # libgcc_s, etc.) outside of the sysroot. In
  506. # this case, SUPPORT_LIB_DIR is set to a
  507. # non-empty value, and points to the directory
  508. # where these support libraries are
  509. # available. Those libraries will be copied to
  510. # our sysroot, and the directory will also be
  511. # considered when searching libraries for copy
  512. # to the target filesystem.
  513. define TOOLCHAIN_EXTERNAL_INSTALL_CORE
  514. $(Q)SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC))" ; \
  515. if test -z "$${SYSROOT_DIR}" ; then \
  516. @echo "External toolchain doesn't support --sysroot. Cannot use." ; \
  517. exit 1 ; \
  518. fi ; \
  519. ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  520. ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  521. SUPPORT_LIB_DIR="" ; \
  522. if test `find $${ARCH_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
  523. LIBSTDCPP_A_LOCATION=$$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libstdc++.a) ; \
  524. if [ -e "$${LIBSTDCPP_A_LOCATION}" ]; then \
  525. SUPPORT_LIB_DIR=`readlink -f $${LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \
  526. fi ; \
  527. fi ; \
  528. ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \
  529. if test -z "$(BR2_PREFER_STATIC_LIB)" ; then \
  530. $(call MESSAGE,"Copying external toolchain libraries to target...") ; \
  531. for libs in $(LIB_EXTERNAL_LIBS); do \
  532. $(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${SUPPORT_LIB_DIR},$${ARCH_LIB_DIR},$$libs,/lib); \
  533. done ; \
  534. for libs in $(USR_LIB_EXTERNAL_LIBS); do \
  535. $(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${SUPPORT_LIB_DIR},$${ARCH_LIB_DIR},$$libs,/usr/lib); \
  536. done ; \
  537. fi ; \
  538. $(call MESSAGE,"Copying external toolchain sysroot to staging...") ; \
  539. $(call copy_toolchain_sysroot,$${SYSROOT_DIR},$${ARCH_SYSROOT_DIR},$${ARCH_SUBDIR},$${ARCH_LIB_DIR},$${SUPPORT_LIB_DIR}) ; \
  540. if test "$(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY)" = "y"; then \
  541. $(call MESSAGE,"Copying gdbserver") ; \
  542. gdbserver_found=0 ; \
  543. for d in $${ARCH_SYSROOT_DIR}/usr $${ARCH_SYSROOT_DIR}/../debug-root/usr $${ARCH_SYSROOT_DIR}/usr/$${ARCH_LIB_DIR} ; do \
  544. if test -f $${d}/bin/gdbserver ; then \
  545. install -m 0755 -D $${d}/bin/gdbserver $(TARGET_DIR)/usr/bin/gdbserver ; \
  546. gdbserver_found=1 ; \
  547. break ; \
  548. fi ; \
  549. done ; \
  550. if [ $${gdbserver_found} -eq 0 ] ; then \
  551. echo "Could not find gdbserver in external toolchain" ; \
  552. exit 1 ; \
  553. fi ; \
  554. fi
  555. endef
  556. # Special installation target used on the Blackfin architecture when
  557. # FDPIC is not the primary binary format being used, but the user has
  558. # nonetheless requested the installation of the FDPIC libraries to the
  559. # target filesystem.
  560. ifeq ($(BR2_BFIN_INSTALL_FDPIC_SHARED),y)
  561. define TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FDPIC
  562. $(Q)$(call MESSAGE,"Install external toolchain FDPIC libraries to target...") ; \
  563. FDPIC_EXTERNAL_CC=$(dir $(TOOLCHAIN_EXTERNAL_CC))/../../bfin-linux-uclibc/bin/bfin-linux-uclibc-gcc ; \
  564. FDPIC_SYSROOT_DIR="$(call toolchain_find_sysroot,$${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  565. FDPIC_LIB_DIR="$(call toolchain_find_libdir,$${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  566. FDPIC_SUPPORT_LIB_DIR="" ; \
  567. if test `find $${FDPIC_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
  568. FDPIC_LIBSTDCPP_A_LOCATION=$$(LANG=C $${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libstdc++.a) ; \
  569. if [ -e "$${FDPIC_LIBSTDCPP_A_LOCATION}" ]; then \
  570. FDPIC_SUPPORT_LIB_DIR=`readlink -f $${FDPIC_LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \
  571. fi ; \
  572. fi ; \
  573. for libs in $(LIB_EXTERNAL_LIBS); do \
  574. $(call copy_toolchain_lib_root,$${FDPIC_SYSROOT_DIR},$${FDPIC_SUPPORT_LIB_DIR},$${FDPIC_LIB_DIR},$$libs,/lib); \
  575. done ; \
  576. for libs in $(USR_LIB_EXTERNAL_LIBS); do \
  577. $(call copy_toolchain_lib_root,$${FDPIC_SYSROOT_DIR},$${FDPIC_SUPPORT_LIB_DIR},$${FDPIC_LIB_DIR},$$libs,/usr/lib); \
  578. done
  579. endef
  580. endif
  581. # Special installation target used on the Blackfin architecture when
  582. # shared FLAT is not the primary format being used, but the user has
  583. # nonetheless requested the installation of the shared FLAT libraries
  584. # to the target filesystem. The flat libraries are found and linked
  585. # according to the index in name "libN.so". Index 1 is reserved for
  586. # the standard C library. Customer libraries can use 4 and above.
  587. ifeq ($(BR2_BFIN_INSTALL_FLAT_SHARED),y)
  588. define TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FLAT
  589. $(Q)$(call MESSAGE,"Install external toolchain FLAT libraries to target...") ; \
  590. FLAT_EXTERNAL_CC=$(dir $(TOOLCHAIN_EXTERNAL_CC))../../bfin-uclinux/bin/bfin-uclinux-gcc ; \
  591. FLAT_LIBC_A_LOCATION=`$${FLAT_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS) -mid-shared-library -print-file-name=libc`; \
  592. if [ -f $${FLAT_LIBC_A_LOCATION} -a ! -h $${FLAT_LIBC_A_LOCATION} ] ; then \
  593. $(INSTALL) -D $${FLAT_LIBC_A_LOCATION} $(TARGET_DIR)/lib/lib1.so; \
  594. fi
  595. endef
  596. endif
  597. # Build toolchain wrapper for preprocessor, C and C++ compiler and setup
  598. # symlinks for everything else. Skip gdb symlink when we are building our
  599. # own gdb to prevent two gdb's in output/host/usr/bin.
  600. define TOOLCHAIN_EXTERNAL_INSTALL_WRAPPER
  601. $(Q)$(call MESSAGE,"Building ext-toolchain wrapper")
  602. mkdir -p $(HOST_DIR)/usr/bin; cd $(HOST_DIR)/usr/bin; \
  603. for i in $(TOOLCHAIN_EXTERNAL_CROSS)*; do \
  604. base=$${i##*/}; \
  605. case "$$base" in \
  606. *cc|*cc-*|*++|*++-*|*cpp) \
  607. ln -sf ext-toolchain-wrapper $$base; \
  608. ;; \
  609. *gdb|*gdbtui) \
  610. if test "$(BR2_PACKAGE_HOST_GDB)" != "y"; then \
  611. ln -sf $$(echo $$i | sed 's%^$(HOST_DIR)%../..%') .; \
  612. fi \
  613. ;; \
  614. *) \
  615. ln -sf $$(echo $$i | sed 's%^$(HOST_DIR)%../..%') .; \
  616. ;; \
  617. esac; \
  618. done ;
  619. # We use --hash-style=both to increase the compatibility of
  620. # the generated binary with older platforms
  621. $(HOSTCC) $(HOST_CFLAGS) $(TOOLCHAIN_EXTERNAL_WRAPPER_ARGS) -s -Wl,--hash-style=both \
  622. toolchain/toolchain-external/ext-toolchain-wrapper.c \
  623. -o $(HOST_DIR)/usr/bin/ext-toolchain-wrapper
  624. endef
  625. # This sed magic is taken from Linux headers_install.sh script.
  626. define TOOLCHAIN_EXTERNAL_SANITIZE_KERNEL_HEADERS
  627. $(Q)$(call MESSAGE,"Sanitizing kernel headers");
  628. find $(STAGING_DIR)/usr/include/linux/ -name "*.h" | xargs sed -r -i \
  629. -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
  630. -e 's/__attribute_const__([ \t]|$$)/\1/g' \
  631. -e 's@^#include <linux/compiler.h>@@' \
  632. -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$$)/\1__attribute__((packed))\2/g' \
  633. -e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$$)/\1__\2__\3/g' \
  634. -e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @'
  635. endef
  636. define TOOLCHAIN_EXTERNAL_INSTALL_GDBINIT
  637. if test -f $(TARGET_CROSS)gdb ; then \
  638. $(call gen_gdbinit_file) ; \
  639. fi
  640. endef
  641. # Even though we're installing things in both the staging, the host
  642. # and the target directory, we do everything within the
  643. # install-staging step, arbitrarily.
  644. define TOOLCHAIN_EXTERNAL_INSTALL_STAGING_CMDS
  645. $(TOOLCHAIN_EXTERNAL_INSTALL_CORE)
  646. $(TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FDPIC)
  647. $(TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FLAT)
  648. $(TOOLCHAIN_EXTERNAL_INSTALL_WRAPPER)
  649. $(TOOLCHAIN_EXTERNAL_INSTALL_GDBINIT)
  650. endef
  651. $(eval $(generic-package))