toolchain-external.mk 39 KB

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