toolchain-external.mk 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  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. TOOLCHAIN_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. TOOLCHAIN_EXTERNAL_LIBS += ld-linux-armhf.so.*
  68. else
  69. TOOLCHAIN_EXTERNAL_LIBS += ld*.so.*
  70. endif
  71. ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
  72. TOOLCHAIN_EXTERNAL_LIBS += libpthread.so.*
  73. ifneq ($(BR2_PACKAGE_GDB)$(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY),)
  74. TOOLCHAIN_EXTERNAL_LIBS += libthread_db.so.*
  75. endif # gdbserver
  76. endif # ! no threads
  77. endif
  78. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC),y)
  79. TOOLCHAIN_EXTERNAL_LIBS += libnss_files.so.* libnss_dns.so.*
  80. endif
  81. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_MUSL),y)
  82. TOOLCHAIN_EXTERNAL_LIBS += libc.so libgcc_s.so.*
  83. endif
  84. ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
  85. TOOLCHAIN_EXTERNAL_LIBS += libstdc++.so.*
  86. endif
  87. ifeq ($(BR2_TOOLCHAIN_HAS_FORTRAN),y)
  88. TOOLCHAIN_EXTERNAL_LIBS += libgfortran.so.*
  89. # fortran needs quadmath on x86 and x86_64
  90. ifeq ($(BR2_TOOLCHAIN_HAS_LIBQUADMATH),y)
  91. TOOLCHAIN_EXTERNAL_LIBS += libquadmath.so*
  92. endif
  93. endif
  94. TOOLCHAIN_EXTERNAL_LIBS += $(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
  95. # Details about sysroot directory selection.
  96. #
  97. # To find the sysroot directory, we use the trick of looking for the
  98. # 'libc.a' file with the -print-file-name gcc option, and then
  99. # mangling the path to find the base directory of the sysroot.
  100. #
  101. # Note that we do not use the -print-sysroot option, because it is
  102. # only available since gcc 4.4.x, and we only recently dropped support
  103. # for 4.2.x and 4.3.x.
  104. #
  105. # When doing this, we don't pass any option to gcc that could select a
  106. # multilib variant (such as -march) as we want the "main" sysroot,
  107. # which contains all variants of the C library in the case of multilib
  108. # toolchains. We use the TARGET_CC_NO_SYSROOT variable, which is the
  109. # path of the cross-compiler, without the --sysroot=$(STAGING_DIR),
  110. # since what we want to find is the location of the original toolchain
  111. # sysroot. This "main" sysroot directory is stored in SYSROOT_DIR.
  112. #
  113. # Then, multilib toolchains are a little bit more complicated, since
  114. # they in fact have multiple sysroots, one for each variant supported
  115. # by the toolchain. So we need to find the particular sysroot we're
  116. # interested in.
  117. #
  118. # To do so, we ask the compiler where its sysroot is by passing all
  119. # flags (including -march and al.), except the --sysroot flag since we
  120. # want to the compiler to tell us where its original sysroot
  121. # is. ARCH_SUBDIR will contain the subdirectory, in the main
  122. # SYSROOT_DIR, that corresponds to the selected architecture
  123. # variant. ARCH_SYSROOT_DIR will contain the full path to this
  124. # location.
  125. #
  126. # One might wonder why we don't just bother with ARCH_SYSROOT_DIR. The
  127. # fact is that in multilib toolchains, the header files are often only
  128. # present in the main sysroot, and only the libraries are available in
  129. # each variant-specific sysroot directory.
  130. TOOLCHAIN_EXTERNAL_PREFIX = $(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PREFIX))
  131. TOOLCHAIN_EXTERNAL_DOWNLOAD_INSTALL_DIR = $(HOST_DIR)/opt/ext-toolchain
  132. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD),y)
  133. TOOLCHAIN_EXTERNAL_INSTALL_DIR = $(TOOLCHAIN_EXTERNAL_DOWNLOAD_INSTALL_DIR)
  134. else
  135. TOOLCHAIN_EXTERNAL_INSTALL_DIR = $(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PATH))
  136. endif
  137. ifeq ($(TOOLCHAIN_EXTERNAL_INSTALL_DIR),)
  138. ifneq ($(TOOLCHAIN_EXTERNAL_PREFIX),)
  139. # if no path set, figure it out from path
  140. TOOLCHAIN_EXTERNAL_BIN := $(shell dirname $(shell which $(TOOLCHAIN_EXTERNAL_PREFIX)-gcc))
  141. endif
  142. else
  143. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX),y)
  144. TOOLCHAIN_EXTERNAL_BIN := $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)/$(TOOLCHAIN_EXTERNAL_PREFIX)/bin
  145. else
  146. TOOLCHAIN_EXTERNAL_BIN := $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)/bin
  147. endif
  148. endif
  149. # If this is a buildroot toolchain, it already has a wrapper which we want to
  150. # bypass. Since this is only evaluated after it has been extracted, we can use
  151. # $(wildcard ...) here.
  152. TOOLCHAIN_EXTERNAL_SUFFIX = \
  153. $(if $(wildcard $(TOOLCHAIN_EXTERNAL_BIN)/*.br_real),.br_real)
  154. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += \
  155. -DBR_CROSS_PATH_SUFFIX='"$(TOOLCHAIN_EXTERNAL_SUFFIX)"'
  156. TOOLCHAIN_EXTERNAL_CROSS = $(TOOLCHAIN_EXTERNAL_BIN)/$(TOOLCHAIN_EXTERNAL_PREFIX)-
  157. TOOLCHAIN_EXTERNAL_CC = $(TOOLCHAIN_EXTERNAL_CROSS)gcc$(TOOLCHAIN_EXTERNAL_SUFFIX)
  158. TOOLCHAIN_EXTERNAL_CXX = $(TOOLCHAIN_EXTERNAL_CROSS)g++$(TOOLCHAIN_EXTERNAL_SUFFIX)
  159. TOOLCHAIN_EXTERNAL_FC = $(TOOLCHAIN_EXTERNAL_CROSS)gfortran$(TOOLCHAIN_EXTERNAL_SUFFIX)
  160. TOOLCHAIN_EXTERNAL_READELF = $(TOOLCHAIN_EXTERNAL_CROSS)readelf$(TOOLCHAIN_EXTERNAL_SUFFIX)
  161. ifeq ($(filter $(HOST_DIR)/%,$(TOOLCHAIN_EXTERNAL_BIN)),)
  162. # TOOLCHAIN_EXTERNAL_BIN points outside HOST_DIR => absolute path
  163. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += \
  164. -DBR_CROSS_PATH_ABS='"$(TOOLCHAIN_EXTERNAL_BIN)"'
  165. else
  166. # TOOLCHAIN_EXTERNAL_BIN points inside HOST_DIR => relative path
  167. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += \
  168. -DBR_CROSS_PATH_REL='"$(TOOLCHAIN_EXTERNAL_BIN:$(HOST_DIR)/%=%)"'
  169. endif
  170. ifeq ($(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)),)
  171. CC_TARGET_CPU_ := $(call qstrip,$(BR2_GCC_TARGET_CPU))
  172. else
  173. CC_TARGET_CPU_ := $(call qstrip,$(BR2_GCC_TARGET_CPU)-$(BR2_GCC_TARGET_CPU_REVISION))
  174. endif
  175. CC_TARGET_ARCH_ := $(call qstrip,$(BR2_GCC_TARGET_ARCH))
  176. CC_TARGET_ABI_ := $(call qstrip,$(BR2_GCC_TARGET_ABI))
  177. CC_TARGET_FPU_ := $(call qstrip,$(BR2_GCC_TARGET_FPU))
  178. CC_TARGET_FLOAT_ABI_ := $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
  179. CC_TARGET_MODE_ := $(call qstrip,$(BR2_GCC_TARGET_MODE))
  180. # march/mtune/floating point mode needs to be passed to the external toolchain
  181. # to select the right multilib variant
  182. ifeq ($(BR2_x86_64),y)
  183. TOOLCHAIN_EXTERNAL_CFLAGS += -m64
  184. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_64
  185. endif
  186. ifneq ($(CC_TARGET_ARCH_),)
  187. TOOLCHAIN_EXTERNAL_CFLAGS += -march=$(CC_TARGET_ARCH_)
  188. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_ARCH='"$(CC_TARGET_ARCH_)"'
  189. endif
  190. ifneq ($(CC_TARGET_CPU_),)
  191. TOOLCHAIN_EXTERNAL_CFLAGS += -mcpu=$(CC_TARGET_CPU_)
  192. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_CPU='"$(CC_TARGET_CPU_)"'
  193. endif
  194. ifneq ($(CC_TARGET_ABI_),)
  195. TOOLCHAIN_EXTERNAL_CFLAGS += -mabi=$(CC_TARGET_ABI_)
  196. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_ABI='"$(CC_TARGET_ABI_)"'
  197. endif
  198. ifneq ($(CC_TARGET_FPU_),)
  199. TOOLCHAIN_EXTERNAL_CFLAGS += -mfpu=$(CC_TARGET_FPU_)
  200. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_FPU='"$(CC_TARGET_FPU_)"'
  201. endif
  202. ifneq ($(CC_TARGET_FLOAT_ABI_),)
  203. TOOLCHAIN_EXTERNAL_CFLAGS += -mfloat-abi=$(CC_TARGET_FLOAT_ABI_)
  204. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_FLOAT_ABI='"$(CC_TARGET_FLOAT_ABI_)"'
  205. endif
  206. ifneq ($(CC_TARGET_MODE_),)
  207. TOOLCHAIN_EXTERNAL_CFLAGS += -m$(CC_TARGET_MODE_)
  208. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_MODE='"$(CC_TARGET_MODE_)"'
  209. endif
  210. ifeq ($(BR2_BINFMT_FLAT),y)
  211. TOOLCHAIN_EXTERNAL_CFLAGS += -Wl,-elf2flt
  212. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_BINFMT_FLAT
  213. endif
  214. ifeq ($(BR2_mipsel)$(BR2_mips64el),y)
  215. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_MIPS_TARGET_LITTLE_ENDIAN
  216. TOOLCHAIN_EXTERNAL_CFLAGS += -EL
  217. endif
  218. ifeq ($(BR2_mips)$(BR2_mips64),y)
  219. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_MIPS_TARGET_BIG_ENDIAN
  220. TOOLCHAIN_EXTERNAL_CFLAGS += -EB
  221. endif
  222. ifeq ($(BR2_arceb),y)
  223. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_ARC_TARGET_BIG_ENDIAN
  224. TOOLCHAIN_EXTERNAL_CFLAGS += -EB
  225. endif
  226. TOOLCHAIN_EXTERNAL_CFLAGS += $(call qstrip,$(BR2_TARGET_OPTIMIZATION))
  227. ifeq ($(BR2_SOFT_FLOAT),y)
  228. TOOLCHAIN_EXTERNAL_CFLAGS += -msoft-float
  229. TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_SOFTFLOAT=1
  230. endif
  231. # musl does not provide an implementation for sys/queue.h or sys/cdefs.h.
  232. # So, add the musl-compat-headers package that will install those files,
  233. # into the staging directory:
  234. # sys/queue.h: header from NetBSD
  235. # sys/cdefs.h: minimalist header bundled in Buildroot
  236. ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
  237. TOOLCHAIN_EXTERNAL_DEPENDENCIES += musl-compat-headers
  238. endif
  239. # The Linaro toolchain expects the libraries in
  240. # {/usr,}/lib/<tuple>, but Buildroot copies them to
  241. # {/usr,}/lib, so we need to create a symbolic link.
  242. define TOOLCHAIN_EXTERNAL_LINARO_SYMLINK
  243. ln -snf . $(TARGET_DIR)/lib/$(TOOLCHAIN_EXTERNAL_PREFIX)
  244. ln -snf . $(TARGET_DIR)/usr/lib/$(TOOLCHAIN_EXTERNAL_PREFIX)
  245. endef
  246. # The Codescape toolchain uses a sysroot layout that places them
  247. # side-by-side instead of nested like multilibs. A symlink is needed
  248. # much like for the nested sysroots which are handled in
  249. # copy_toolchain_sysroot but there is not enough information in there
  250. # to determine whether the sysroot layout was nested or side-by-side.
  251. # Add the symlink here for now.
  252. define TOOLCHAIN_EXTERNAL_CODESCAPE_MIPS_SYMLINK
  253. $(Q)ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))"; \
  254. ARCH_SUBDIR=`basename $${ARCH_SYSROOT_DIR}`; \
  255. ln -snf . $(STAGING_DIR)/$${ARCH_SUBDIR}
  256. endef
  257. # Special fixup for Codescape MIPS toolchains, that have bin-<abi> and
  258. # sbin-<abi> directories. We create symlinks bin -> bin-<abi> and sbin
  259. # -> sbin-<abi> so that the rest of Buildroot can find the toolchain
  260. # tools in the appropriate location.
  261. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESCAPE_IMG_MIPS)$(BR2_TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS),y)
  262. ifeq ($(BR2_MIPS_OABI32),y)
  263. TOOLCHAIN_EXTERNAL_CODESCAPE_MIPS_BIN_DIR_SUFFIX = o32
  264. else ifeq ($(BR2_MIPS_NABI32),y)
  265. TOOLCHAIN_EXTERNAL_CODESCAPE_MIPS_BIN_DIR_SUFFIX = n32
  266. else ifeq ($(BR2_MIPS_NABI64),y)
  267. TOOLCHAIN_EXTERNAL_CODESCAPE_MIPS_BIN_DIR_SUFFIX = n64
  268. endif
  269. define TOOLCHAIN_EXTERNAL_CODESCAPE_MIPS_STAGING_FIXUPS
  270. rmdir $(STAGING_DIR)/usr/bin $(STAGING_DIR)/usr/sbin
  271. ln -sf bin-$(TOOLCHAIN_EXTERNAL_CODESCAPE_MIPS_BIN_DIR_SUFFIX) $(STAGING_DIR)/usr/bin
  272. ln -sf sbin-$(TOOLCHAIN_EXTERNAL_CODESCAPE_MIPS_BIN_DIR_SUFFIX) $(STAGING_DIR)/usr/sbin
  273. endef
  274. endif
  275. # Special handling for Blackfin toolchain, because of the split in two
  276. # tarballs, and the organization of tarball contents. The tarballs
  277. # contain ./opt/uClinux/{bfin-uclinux,bfin-linux-uclibc} directories,
  278. # which themselves contain the toolchain. This is why we strip more
  279. # components than usual.
  280. define TOOLCHAIN_EXTERNAL_BLACKFIN_UCLIBC_EXTRA_EXTRACT
  281. $(call suitable-extractor,$(TOOLCHAIN_EXTERNAL_EXTRA_DOWNLOADS)) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_EXTRA_DOWNLOADS) | \
  282. $(TAR) --strip-components=3 --hard-dereference -C $(@D) $(TAR_OPTIONS) -
  283. endef
  284. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM),y)
  285. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi
  286. TOOLCHAIN_EXTERNAL_SOURCE = arm-2014.05-29-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
  287. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_ARAGO_ARMV7A),y)
  288. TOOLCHAIN_EXTERNAL_SITE = http://software-dl.ti.com/sdoemb/sdoemb_public_sw/arago_toolchain/2011_09/exports
  289. TOOLCHAIN_EXTERNAL_SOURCE = arago-2011.09-armv7a-linux-gnueabi-sdk.tar.bz2
  290. TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = arago-toolchain-2011.09-sources.tar.bz2
  291. define TOOLCHAIN_EXTERNAL_FIXUP_CMDS
  292. mv $(@D)/arago-2011.09/armv7a/* $(@D)/
  293. rm -rf $(@D)/arago-2011.09/
  294. endef
  295. TOOLCHAIN_EXTERNAL_POST_EXTRACT_HOOKS += TOOLCHAIN_EXTERNAL_FIXUP_CMDS
  296. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_ARAGO_ARMV5TE),y)
  297. TOOLCHAIN_EXTERNAL_SITE = http://software-dl.ti.com/sdoemb/sdoemb_public_sw/arago_toolchain/2011_09/exports
  298. TOOLCHAIN_EXTERNAL_SOURCE = arago-2011.09-armv5te-linux-gnueabi-sdk.tar.bz2
  299. TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = arago-toolchain-2011.09-sources.tar.bz2
  300. define TOOLCHAIN_EXTERNAL_FIXUP_CMDS
  301. mv $(@D)/arago-2011.09/armv5te/* $(@D)/
  302. rm -rf $(@D)/arago-2011.09/
  303. endef
  304. TOOLCHAIN_EXTERNAL_POST_EXTRACT_HOOKS += TOOLCHAIN_EXTERNAL_FIXUP_CMDS
  305. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM),y)
  306. ifeq ($(HOSTARCH),x86)
  307. TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
  308. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
  309. TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_src.tar.bz2
  310. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_SYMLINK
  311. else
  312. TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/arm-linux-gnueabihf
  313. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz
  314. endif
  315. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB),y)
  316. ifeq ($(HOSTARCH),x86)
  317. TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
  318. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-armeb-linux-gnueabihf-4.9-2014.09_linux.tar.xz
  319. TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-armeb-linux-gnueabihf-4.9-2014.09_src.tar.bz2
  320. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_SYMLINK
  321. else
  322. TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/armeb-linux-gnueabihf
  323. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.3-2016.02-x86_64_armeb-linux-gnueabihf.tar.xz
  324. endif
  325. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS),y)
  326. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/mips-linux-gnu
  327. TOOLCHAIN_EXTERNAL_SOURCE = mips-2016.05-8-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
  328. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII),y)
  329. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/nios2-linux-gnu
  330. TOOLCHAIN_EXTERNAL_SOURCE = sourceryg++-2016.05-10-nios2-linux-gnu-i686-pc-linux-gnu.tar.bz2
  331. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH),y)
  332. TOOLCHAIN_EXTERNAL_SITE = https://sourcery.mentor.com/public/gnu_toolchain/sh-linux-gnu
  333. TOOLCHAIN_EXTERNAL_SOURCE = renesas-2012.09-61-sh-linux-gnu-i686-pc-linux-gnu.tar.bz2
  334. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_X86),y)
  335. TOOLCHAIN_EXTERNAL_SITE = https://sourcery.mentor.com/public/gnu_toolchain/i686-pc-linux-gnu
  336. TOOLCHAIN_EXTERNAL_SOURCE = ia32-2012.09-62-i686-pc-linux-gnu-i386-linux.tar.bz2
  337. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_AMD64),y)
  338. TOOLCHAIN_EXTERNAL_SITE = https://sourcery.mentor.com/public/gnu_toolchain/x86_64-amd-linux-gnu
  339. TOOLCHAIN_EXTERNAL_SOURCE = amd-2015.11-139-x86_64-amd-linux-gnu-i686-pc-linux-gnu.tar.bz2
  340. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESCAPE_IMG_MIPS),y)
  341. TOOLCHAIN_EXTERNAL_SITE = http://codescape-mips-sdk.imgtec.com/components/toolchain/2016.05-03
  342. TOOLCHAIN_EXTERNAL_SOURCE = Codescape.GNU.Tools.Package.2016.05-03.for.MIPS.IMG.Linux.CentOS-5.x86.tar.gz
  343. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_CODESCAPE_MIPS_SYMLINK
  344. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_CODESCAPE_MIPS_STAGING_FIXUPS
  345. TOOLCHAIN_EXTERNAL_STRIP_COMPONENTS = 2
  346. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS),y)
  347. TOOLCHAIN_EXTERNAL_SITE = http://codescape-mips-sdk.imgtec.com/components/toolchain/2016.05-03
  348. TOOLCHAIN_EXTERNAL_SOURCE = Codescape.GNU.Tools.Package.2016.05-03.for.MIPS.MTI.Linux.CentOS-5.x86.tar.gz
  349. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_CODESCAPE_MIPS_SYMLINK
  350. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_CODESCAPE_MIPS_STAGING_FIXUPS
  351. TOOLCHAIN_EXTERNAL_STRIP_COMPONENTS = 2
  352. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX),y)
  353. TOOLCHAIN_EXTERNAL_SITE = http://downloads.sourceforge.net/project/adi-toolchain/2014R1/2014R1-RC2/i386
  354. TOOLCHAIN_EXTERNAL_SOURCE = blackfin-toolchain-2014R1-RC2.i386.tar.bz2
  355. TOOLCHAIN_EXTERNAL_EXTRA_DOWNLOADS = blackfin-toolchain-uclibc-full-2014R1-RC2.i386.tar.bz2
  356. TOOLCHAIN_EXTERNAL_STRIP_COMPONENTS = 3
  357. TOOLCHAIN_EXTERNAL_POST_EXTRACT_HOOKS += TOOLCHAIN_EXTERNAL_BLACKFIN_UCLIBC_EXTRA_EXTRACT
  358. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64),y)
  359. ifeq ($(HOSTARCH),x86)
  360. TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/14.09/components/toolchain/binaries
  361. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux.tar.xz
  362. TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = gcc-linaro-aarch64-linux-gnu-4.9-2014.09_src.tar.bz2
  363. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_SYMLINK
  364. else
  365. TOOLCHAIN_EXTERNAL_SITE = https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/aarch64-linux-gnu
  366. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu.tar.xz
  367. endif
  368. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64),y)
  369. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/aarch64-amd-linux-gnu
  370. TOOLCHAIN_EXTERNAL_SOURCE = aarch64-amd-2014.11-95-aarch64-amd-linux-gnu-i686-pc-linux-gnu.tar.bz2
  371. define TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_STAGING_FIXUP
  372. ln -sf ld-2.20.so $(STAGING_DIR)/lib/ld-linux-aarch64.so.1
  373. endef
  374. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_STAGING_FIXUP
  375. define TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_TARGET_FIXUP
  376. ln -sf ld-2.20.so $(TARGET_DIR)/lib/ld-linux-aarch64.so.1
  377. endef
  378. TOOLCHAIN_EXTERNAL_POST_INSTALL_TARGET_HOOKS += TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64_TARGET_FIXUP
  379. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_MUSL_CROSS),y)
  380. TOOLCHAIN_EXTERNAL_VERSION = 1.1.12
  381. TOOLCHAIN_EXTERNAL_SITE = https://googledrive.com/host/0BwnS5DMB0YQ6bDhPZkpOYVFhbk0/musl-$(TOOLCHAIN_EXTERNAL_VERSION)
  382. ifeq ($(BR2_arm)$(BR2_ARM_EABI),yy)
  383. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-arm-linux-musleabi-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  384. else ifeq ($(BR2_arm)$(BR2_ARM_EABIHF),yy)
  385. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-arm-linux-musleabihf-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  386. else ifeq ($(BR2_armeb),y)
  387. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-armeb-linux-musleabi-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  388. else ifeq ($(BR2_i386),y)
  389. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-i486-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  390. else ifeq ($(BR2_mips),y)
  391. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-mips-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  392. else ifeq ($(BR2_mipsel):$(BR2_SOFT_FLOAT),y:)
  393. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-mipsel-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  394. else ifeq ($(BR2_mipsel):$(BR2_SOFT_FLOAT),y:y)
  395. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-mipsel-sf-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  396. else ifeq ($(BR2_powerpc),y)
  397. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-powerpc-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  398. else ifeq ($(BR2_sh4),y)
  399. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-sh4-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  400. else ifeq ($(BR2_sh4eb),y)
  401. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-sh4eb-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  402. else ifeq ($(BR2_x86_64),y)
  403. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-x86_64-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  404. endif
  405. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_SYNOPSYS_ARC),y)
  406. TOOLCHAIN_EXTERNAL_SITE = https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2014.12
  407. ifeq ($(BR2_arc750d)$(BR2_arc770d),y)
  408. TOOLCHAIN_EXTERNAL_SYNOPSYS_CORE = arc700
  409. else
  410. TOOLCHAIN_EXTERNAL_SYNOPSYS_CORE = archs
  411. endif
  412. ifeq ($(BR2_arcle),y)
  413. TOOLCHAIN_EXTERNAL_SYNOPSYS_ENDIANESS = le
  414. else
  415. TOOLCHAIN_EXTERNAL_SYNOPSYS_ENDIANESS = be
  416. endif
  417. TOOLCHAIN_EXTERNAL_SOURCE = arc_gnu_2014.12_prebuilt_uclibc_$(TOOLCHAIN_EXTERNAL_SYNOPSYS_ENDIANESS)_$(TOOLCHAIN_EXTERNAL_SYNOPSYS_CORE)_linux_install.tar.gz
  418. else
  419. # Custom toolchain
  420. TOOLCHAIN_EXTERNAL_SITE = $(patsubst %/,%,$(dir $(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_URL))))
  421. TOOLCHAIN_EXTERNAL_SOURCE = $(notdir $(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_URL)))
  422. # We can't check hashes for custom downloaded toolchains
  423. BR_NO_CHECK_HASH_FOR += $(TOOLCHAIN_EXTERNAL_SOURCE)
  424. endif
  425. # Some toolchain vendors have a regular file naming pattern.
  426. # For them, mass-define _ACTUAL_SOURCE_TARBALL based _SITE.
  427. ifneq ($(findstring sourcery.mentor.com/public/gnu_toolchain,$(TOOLCHAIN_EXTERNAL_SITE)),)
  428. TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL ?= \
  429. $(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)))
  430. endif
  431. # In fact, we don't need to download the toolchain, since it is already
  432. # available on the system, so force the site and source to be empty so
  433. # that nothing will be downloaded/extracted.
  434. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_PREINSTALLED),y)
  435. TOOLCHAIN_EXTERNAL_SITE =
  436. TOOLCHAIN_EXTERNAL_SOURCE =
  437. endif
  438. TOOLCHAIN_EXTERNAL_ADD_TOOLCHAIN_DEPENDENCY = NO
  439. TOOLCHAIN_EXTERNAL_INSTALL_STAGING = YES
  440. # Normal handling of downloaded toolchain tarball extraction.
  441. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD),y)
  442. TOOLCHAIN_EXTERNAL_EXCLUDES = usr/lib/locale/*
  443. # As a regular package, the toolchain gets extracted in $(@D), but
  444. # since it's actually a fairly special package, we need it to be moved
  445. # into TOOLCHAIN_EXTERNAL_DOWNLOAD_INSTALL_DIR.
  446. define TOOLCHAIN_EXTERNAL_MOVE
  447. rm -rf $(TOOLCHAIN_EXTERNAL_DOWNLOAD_INSTALL_DIR)
  448. mkdir -p $(TOOLCHAIN_EXTERNAL_DOWNLOAD_INSTALL_DIR)
  449. mv $(@D)/* $(TOOLCHAIN_EXTERNAL_DOWNLOAD_INSTALL_DIR)/
  450. endef
  451. TOOLCHAIN_EXTERNAL_POST_EXTRACT_HOOKS += \
  452. TOOLCHAIN_EXTERNAL_MOVE
  453. endif
  454. # Returns the location of the libc.a file for the given compiler + flags
  455. define toolchain_find_libc_a
  456. $$(readlink -f $$(LANG=C $(1) -print-file-name=libc.a))
  457. endef
  458. # Returns the sysroot location for the given compiler + flags. We need
  459. # to handle cases where libc.a is in:
  460. #
  461. # - lib/
  462. # - usr/lib/
  463. # - lib32/
  464. # - lib64/
  465. # - lib32-fp/ (Cavium toolchain)
  466. # - lib64-fp/ (Cavium toolchain)
  467. # - usr/lib/<tuple>/ (Linaro toolchain)
  468. #
  469. # And variations on these.
  470. define toolchain_find_sysroot
  471. $$(printf $(call toolchain_find_libc_a,$(1)) | sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::')
  472. endef
  473. # Returns the lib subdirectory for the given compiler + flags (i.e
  474. # typically lib32 or lib64 for some toolchains)
  475. define toolchain_find_libdir
  476. $$(printf $(call toolchain_find_libc_a,$(1)) | sed -r -e 's:.*/(usr/)?(lib(32|64)?([^/]*)?)/([^/]*/)?libc.a:\2:')
  477. endef
  478. # Checks for an already installed toolchain: check the toolchain
  479. # location, check that it is usable, and then verify that it
  480. # matches the configuration provided in Buildroot: ABI, C++ support,
  481. # kernel headers version, type of C library and all C library features.
  482. define TOOLCHAIN_EXTERNAL_CONFIGURE_CMDS
  483. $(Q)$(call check_cross_compiler_exists,$(TOOLCHAIN_EXTERNAL_CC))
  484. $(Q)$(call check_unusable_toolchain,$(TOOLCHAIN_EXTERNAL_CC))
  485. $(Q)SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC))" ; \
  486. $(call check_kernel_headers_version,\
  487. $(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC)),\
  488. $(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST))); \
  489. $(call check_gcc_version,$(TOOLCHAIN_EXTERNAL_CC),\
  490. $(call qstrip,$(BR2_TOOLCHAIN_GCC_AT_LEAST))); \
  491. if test "$(BR2_arm)" = "y" ; then \
  492. $(call check_arm_abi,\
  493. "$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS)",\
  494. $(TOOLCHAIN_EXTERNAL_READELF)) ; \
  495. fi ; \
  496. if test "$(BR2_INSTALL_LIBSTDCPP)" = "y" ; then \
  497. $(call check_cplusplus,$(TOOLCHAIN_EXTERNAL_CXX)) ; \
  498. fi ; \
  499. if test "$(BR2_TOOLCHAIN_HAS_FORTRAN)" = "y" ; then \
  500. $(call check_fortran,$(TOOLCHAIN_EXTERNAL_FC)) ; \
  501. fi ; \
  502. if test "$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC)" = "y" ; then \
  503. $(call check_uclibc,$${SYSROOT_DIR}) ; \
  504. elif test "$(BR2_TOOLCHAIN_EXTERNAL_MUSL)" = "y" ; then \
  505. $(call check_musl,$${SYSROOT_DIR}) ; \
  506. else \
  507. $(call check_glibc,$${SYSROOT_DIR}) ; \
  508. fi
  509. $(Q)$(call check_toolchain_ssp,$(TOOLCHAIN_EXTERNAL_CC))
  510. endef
  511. # With the musl C library, the libc.so library directly plays the role
  512. # of the dynamic library loader. We just need to create a symbolic
  513. # link to libc.so with the appropriate name.
  514. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_MUSL),y)
  515. ifeq ($(BR2_i386),y)
  516. MUSL_ARCH = i386
  517. else ifeq ($(BR2_ARM_EABIHF),y)
  518. MUSL_ARCH = armhf
  519. else ifeq ($(BR2_mipsel):$(BR2_SOFT_FLOAT),y:y)
  520. MUSL_ARCH = mipsel-sf
  521. else ifeq ($(BR2_sh),y)
  522. MUSL_ARCH = sh
  523. else
  524. MUSL_ARCH = $(ARCH)
  525. endif
  526. define TOOLCHAIN_EXTERNAL_MUSL_LD_LINK
  527. ln -sf libc.so $(TARGET_DIR)/lib/ld-musl-$(MUSL_ARCH).so.1
  528. endef
  529. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_MUSL_LD_LINK
  530. endif
  531. # Create a symlink from (usr/)$(ARCH_LIB_DIR) to lib.
  532. # Note: the skeleton package additionally creates lib32->lib or lib64->lib
  533. # (as appropriate)
  534. #
  535. # $1: destination directory (TARGET_DIR / STAGING_DIR)
  536. create_lib_symlinks = \
  537. $(Q)DESTDIR="$(strip $1)" ; \
  538. ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  539. if [ ! -e "$${DESTDIR}/$${ARCH_LIB_DIR}" -a ! -e "$${DESTDIR}/usr/$${ARCH_LIB_DIR}" ]; then \
  540. ln -snf lib "$${DESTDIR}/$${ARCH_LIB_DIR}" ; \
  541. ln -snf lib "$${DESTDIR}/usr/$${ARCH_LIB_DIR}" ; \
  542. fi
  543. define TOOLCHAIN_EXTERNAL_CREATE_STAGING_LIB_SYMLINK
  544. $(call create_lib_symlinks,$(STAGING_DIR))
  545. endef
  546. define TOOLCHAIN_EXTERNAL_CREATE_TARGET_LIB_SYMLINK
  547. $(call create_lib_symlinks,$(TARGET_DIR))
  548. endef
  549. # Integration of the toolchain into Buildroot: find the main sysroot
  550. # and the variant-specific sysroot, then copy the needed libraries to
  551. # the $(TARGET_DIR) and copy the whole sysroot (libraries and headers)
  552. # to $(STAGING_DIR).
  553. #
  554. # Variables are defined as follows:
  555. #
  556. # LIBC_A_LOCATION: location of the libc.a file in the default
  557. # multilib variant (allows to find the main
  558. # sysroot directory)
  559. # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/usr/lib/libc.a
  560. #
  561. # SYSROOT_DIR: the main sysroot directory, deduced from
  562. # LIBC_A_LOCATION by removing the
  563. # usr/lib[32|64]/libc.a part of the path.
  564. # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/
  565. #
  566. # ARCH_LIBC_A_LOCATION: location of the libc.a file in the selected
  567. # multilib variant (taking into account the
  568. # CFLAGS). Allows to find the sysroot of the
  569. # selected multilib variant.
  570. # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/mips16/soft-float/el/usr/lib/libc.a
  571. #
  572. # ARCH_SYSROOT_DIR: the sysroot of the selected multilib variant,
  573. # deduced from ARCH_LIBC_A_LOCATION by removing
  574. # usr/lib[32|64]/libc.a at the end of the path.
  575. # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/mips16/soft-float/el/
  576. #
  577. # ARCH_LIB_DIR: 'lib', 'lib32' or 'lib64' depending on where libraries
  578. # are stored. Deduced from ARCH_LIBC_A_LOCATION by
  579. # looking at usr/lib??/libc.a.
  580. # Ex: lib
  581. #
  582. # ARCH_SUBDIR: the relative location of the sysroot of the selected
  583. # multilib variant compared to the main sysroot.
  584. # Ex: mips16/soft-float/el
  585. #
  586. # SUPPORT_LIB_DIR: some toolchains, such as recent Linaro toolchains,
  587. # store GCC support libraries (libstdc++,
  588. # libgcc_s, etc.) outside of the sysroot. In
  589. # this case, SUPPORT_LIB_DIR is set to a
  590. # non-empty value, and points to the directory
  591. # where these support libraries are
  592. # available. Those libraries will be copied to
  593. # our sysroot, and the directory will also be
  594. # considered when searching libraries for copy
  595. # to the target filesystem.
  596. #
  597. # Please be very careful to check the major toolchain sources:
  598. # Buildroot, Crosstool-NG, CodeSourcery and Linaro
  599. # before doing any modification on the below logic.
  600. ifeq ($(BR2_STATIC_LIBS),)
  601. define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBS
  602. $(Q)$(call MESSAGE,"Copying external toolchain libraries to target...")
  603. $(Q)for libs in $(TOOLCHAIN_EXTERNAL_LIBS); do \
  604. $(call copy_toolchain_lib_root,$$libs); \
  605. done
  606. endef
  607. endif
  608. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY),y)
  609. define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_GDBSERVER
  610. $(Q)$(call MESSAGE,"Copying gdbserver")
  611. $(Q)ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  612. ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  613. gdbserver_found=0 ; \
  614. for d in $${ARCH_SYSROOT_DIR}/usr \
  615. $${ARCH_SYSROOT_DIR}/../debug-root/usr \
  616. $${ARCH_SYSROOT_DIR}/usr/$${ARCH_LIB_DIR} \
  617. $(TOOLCHAIN_EXTERNAL_INSTALL_DIR); do \
  618. if test -f $${d}/bin/gdbserver ; then \
  619. install -m 0755 -D $${d}/bin/gdbserver $(TARGET_DIR)/usr/bin/gdbserver ; \
  620. gdbserver_found=1 ; \
  621. break ; \
  622. fi ; \
  623. done ; \
  624. if [ $${gdbserver_found} -eq 0 ] ; then \
  625. echo "Could not find gdbserver in external toolchain" ; \
  626. exit 1 ; \
  627. fi
  628. endef
  629. endif
  630. define TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS
  631. $(Q)SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC))" ; \
  632. ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  633. ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  634. SUPPORT_LIB_DIR="" ; \
  635. if test `find $${ARCH_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
  636. LIBSTDCPP_A_LOCATION=$$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libstdc++.a) ; \
  637. if [ -e "$${LIBSTDCPP_A_LOCATION}" ]; then \
  638. SUPPORT_LIB_DIR=`readlink -f $${LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \
  639. fi ; \
  640. fi ; \
  641. ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \
  642. $(call MESSAGE,"Copying external toolchain sysroot to staging...") ; \
  643. $(call copy_toolchain_sysroot,$${SYSROOT_DIR},$${ARCH_SYSROOT_DIR},$${ARCH_SUBDIR},$${ARCH_LIB_DIR},$${SUPPORT_LIB_DIR})
  644. endef
  645. # Special installation target used on the Blackfin architecture when
  646. # FDPIC is not the primary binary format being used, but the user has
  647. # nonetheless requested the installation of the FDPIC libraries to the
  648. # target filesystem.
  649. ifeq ($(BR2_BFIN_INSTALL_FDPIC_SHARED),y)
  650. define TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS_BFIN_FDPIC
  651. $(Q)$(call MESSAGE,"Install external toolchain FDPIC libraries to staging...")
  652. $(Q)FDPIC_EXTERNAL_CC=$(dir $(TOOLCHAIN_EXTERNAL_CC))/../../bfin-linux-uclibc/bin/bfin-linux-uclibc-gcc ; \
  653. FDPIC_SYSROOT_DIR="$(call toolchain_find_sysroot,$${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  654. FDPIC_LIB_DIR="$(call toolchain_find_libdir,$${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  655. FDPIC_SUPPORT_LIB_DIR="" ; \
  656. if test `find $${FDPIC_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
  657. FDPIC_LIBSTDCPP_A_LOCATION=$$(LANG=C $${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libstdc++.a) ; \
  658. if [ -e "$${FDPIC_LIBSTDCPP_A_LOCATION}" ]; then \
  659. FDPIC_SUPPORT_LIB_DIR=`readlink -f $${FDPIC_LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \
  660. fi ; \
  661. fi ; \
  662. $(call copy_toolchain_sysroot,$${FDPIC_SYSROOT_DIR},$${FDPIC_SYSROOT_DIR},,$${FDPIC_LIB_DIR},$${FDPIC_SUPPORT_LIB_DIR})
  663. endef
  664. define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_BFIN_FDPIC
  665. $(Q)$(call MESSAGE,"Install external toolchain FDPIC libraries to target...")
  666. $(Q)for libs in $(TOOLCHAIN_EXTERNAL_LIBS); do \
  667. $(call copy_toolchain_lib_root,$$libs); \
  668. done
  669. endef
  670. endif
  671. # Special installation target used on the Blackfin architecture when
  672. # shared FLAT is not the primary format being used, but the user has
  673. # nonetheless requested the installation of the shared FLAT libraries
  674. # to the target filesystem. The flat libraries are found and linked
  675. # according to the index in name "libN.so". Index 1 is reserved for
  676. # the standard C library. Customer libraries can use 4 and above.
  677. ifeq ($(BR2_BFIN_INSTALL_FLAT_SHARED),y)
  678. define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_BFIN_FLAT
  679. $(Q)$(call MESSAGE,"Install external toolchain FLAT libraries to target...")
  680. $(Q)FLAT_EXTERNAL_CC=$(dir $(TOOLCHAIN_EXTERNAL_CC))../../bfin-uclinux/bin/bfin-uclinux-gcc ; \
  681. FLAT_LIBC_A_LOCATION=`$${FLAT_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS) -mid-shared-library -print-file-name=libc`; \
  682. if [ -f $${FLAT_LIBC_A_LOCATION} -a ! -h $${FLAT_LIBC_A_LOCATION} ] ; then \
  683. $(INSTALL) -D $${FLAT_LIBC_A_LOCATION} $(TARGET_DIR)/lib/lib1.so; \
  684. fi
  685. endef
  686. endif
  687. # Build toolchain wrapper for preprocessor, C, C++ and Fortran compilers
  688. # and setup symlinks for everything else. Skip gdb symlink when we are
  689. # building our own gdb to prevent two gdb's in output/host/usr/bin.
  690. # The LTO support in gcc creates wrappers for ar, ranlib and nm which load
  691. # the lto plugin. These wrappers are called *-gcc-ar, *-gcc-ranlib, and
  692. # *-gcc-nm and should be used instead of the real programs when -flto is
  693. # used. However, we should not add the toolchain wrapper for them, and they
  694. # match the *cc-* pattern. Therefore, an additional case is added for *-ar,
  695. # *-ranlib and *-nm.
  696. define TOOLCHAIN_EXTERNAL_INSTALL_WRAPPER
  697. $(Q)cd $(HOST_DIR)/usr/bin; \
  698. for i in $(TOOLCHAIN_EXTERNAL_CROSS)*; do \
  699. base=$${i##*/}; \
  700. case "$$base" in \
  701. *-ar|*-ranlib|*-nm) \
  702. ln -sf $$(echo $$i | sed 's%^$(HOST_DIR)%../..%') .; \
  703. ;; \
  704. *cc|*cc-*|*++|*++-*|*cpp|*-gfortran) \
  705. ln -sf toolchain-wrapper $$base; \
  706. ;; \
  707. *gdb|*gdbtui) \
  708. if test "$(BR2_PACKAGE_HOST_GDB)" != "y"; then \
  709. ln -sf $$(echo $$i | sed 's%^$(HOST_DIR)%../..%') .; \
  710. fi \
  711. ;; \
  712. *) \
  713. ln -sf $$(echo $$i | sed 's%^$(HOST_DIR)%../..%') .; \
  714. ;; \
  715. esac; \
  716. done
  717. endef
  718. #
  719. # Generate gdbinit file for use with Buildroot
  720. #
  721. define TOOLCHAIN_EXTERNAL_INSTALL_GDBINIT
  722. $(Q)if test -f $(TARGET_CROSS)gdb ; then \
  723. $(call MESSAGE,"Installing gdbinit"); \
  724. $(gen_gdbinit_file); \
  725. fi
  726. endef
  727. # uClibc-ng dynamic loader is called ld-uClibc.so.1, but gcc is not
  728. # patched specifically for uClibc-ng, so it continues to generate
  729. # binaries that expect the dynamic loader to be named ld-uClibc.so.0,
  730. # like with the original uClibc. Therefore, we create an additional
  731. # symbolic link to make uClibc-ng systems work properly.
  732. define TOOLCHAIN_EXTERNAL_FIXUP_UCLIBCNG_LDSO
  733. $(Q)if test -e $(TARGET_DIR)/lib/ld-uClibc.so.1; then \
  734. ln -sf ld-uClibc.so.1 $(TARGET_DIR)/lib/ld-uClibc.so.0 ; \
  735. fi
  736. $(Q)if test -e $(TARGET_DIR)/lib/ld64-uClibc.so.1; then \
  737. ln -sf ld64-uClibc.so.1 $(TARGET_DIR)/lib/ld64-uClibc.so.0 ; \
  738. fi
  739. endef
  740. TOOLCHAIN_EXTERNAL_BUILD_CMDS = $(TOOLCHAIN_BUILD_WRAPPER)
  741. define TOOLCHAIN_EXTERNAL_INSTALL_STAGING_CMDS
  742. $(TOOLCHAIN_EXTERNAL_CREATE_STAGING_LIB_SYMLINK)
  743. $(TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS)
  744. $(TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS_BFIN_FDPIC)
  745. $(TOOLCHAIN_EXTERNAL_INSTALL_WRAPPER)
  746. $(TOOLCHAIN_EXTERNAL_INSTALL_GDBINIT)
  747. endef
  748. # Even though we're installing things in both the staging, the host
  749. # and the target directory, we do everything within the
  750. # install-staging step, arbitrarily.
  751. define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_CMDS
  752. $(TOOLCHAIN_EXTERNAL_CREATE_TARGET_LIB_SYMLINK)
  753. $(TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBS)
  754. $(TOOLCHAIN_EXTERNAL_INSTALL_TARGET_GDBSERVER)
  755. $(TOOLCHAIN_EXTERNAL_INSTALL_TARGET_BFIN_FDPIC)
  756. $(TOOLCHAIN_EXTERNAL_INSTALL_TARGET_BFIN_FLAT)
  757. $(TOOLCHAIN_EXTERNAL_FIXUP_UCLIBCNG_LDSO)
  758. endef
  759. $(eval $(generic-package))