toolchain-external.mk 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  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),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. # musl does not provide a sys/queue.h implementation, so add the
  223. # netbsd-queue package that will install a sys/queue.h file in the
  224. # staging directory based on the NetBSD implementation.
  225. ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
  226. TOOLCHAIN_EXTERNAL_DEPENDENCIES += netbsd-queue
  227. endif
  228. # The Linaro ARMhf toolchain expects the libraries in
  229. # {/usr,}/lib/arm-linux-gnueabihf, but Buildroot copies them to
  230. # {/usr,}/lib, so we need to create a symbolic link.
  231. define TOOLCHAIN_EXTERNAL_LINARO_ARMHF_SYMLINK
  232. ln -snf . $(TARGET_DIR)/lib/arm-linux-gnueabihf
  233. ln -snf . $(TARGET_DIR)/usr/lib/arm-linux-gnueabihf
  234. endef
  235. define TOOLCHAIN_EXTERNAL_LINARO_ARMEBHF_SYMLINK
  236. ln -snf . $(TARGET_DIR)/lib/armeb-linux-gnueabihf
  237. ln -snf . $(TARGET_DIR)/usr/lib/armeb-linux-gnueabihf
  238. endef
  239. define TOOLCHAIN_EXTERNAL_LINARO_AARCH64_SYMLINK
  240. ln -snf . $(TARGET_DIR)/lib/aarch64-linux-gnu
  241. ln -snf . $(TARGET_DIR)/usr/lib/aarch64-linux-gnu
  242. endef
  243. # Special handling for Blackfin toolchain, because of the split in two
  244. # tarballs, and the organization of tarball contents. The tarballs
  245. # contain ./opt/uClinux/{bfin-uclinux,bfin-linux-uclibc} directories,
  246. # which themselves contain the toolchain. This is why we strip more
  247. # components than usual.
  248. define TOOLCHAIN_EXTERNAL_BLACKFIN_UCLIBC_EXTRA_EXTRACT
  249. $(call suitable-extractor,$(TOOLCHAIN_EXTERNAL_EXTRA_DOWNLOADS)) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_EXTRA_DOWNLOADS) | \
  250. $(TAR) --strip-components=3 --hard-dereference -C $(@D) $(TAR_OPTIONS) -
  251. endef
  252. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM),y)
  253. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi
  254. TOOLCHAIN_EXTERNAL_SOURCE = arm-2014.05-29-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
  255. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_ARAGO_ARMV7A),y)
  256. TOOLCHAIN_EXTERNAL_SITE = http://software-dl.ti.com/sdoemb/sdoemb_public_sw/arago_toolchain/2011_09/exports
  257. TOOLCHAIN_EXTERNAL_SOURCE = arago-2011.09-armv7a-linux-gnueabi-sdk.tar.bz2
  258. TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = arago-toolchain-2011.09-sources.tar.bz2
  259. define TOOLCHAIN_EXTERNAL_FIXUP_CMDS
  260. mv $(@D)/arago-2011.09/armv7a/* $(@D)/
  261. rm -rf $(@D)/arago-2011.09/
  262. endef
  263. TOOLCHAIN_EXTERNAL_POST_EXTRACT_HOOKS += TOOLCHAIN_EXTERNAL_FIXUP_CMDS
  264. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_ARAGO_ARMV5TE),y)
  265. TOOLCHAIN_EXTERNAL_SITE = http://software-dl.ti.com/sdoemb/sdoemb_public_sw/arago_toolchain/2011_09/exports
  266. TOOLCHAIN_EXTERNAL_SOURCE = arago-2011.09-armv5te-linux-gnueabi-sdk.tar.bz2
  267. TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL = arago-toolchain-2011.09-sources.tar.bz2
  268. define TOOLCHAIN_EXTERNAL_FIXUP_CMDS
  269. mv $(@D)/arago-2011.09/armv5te/* $(@D)/
  270. rm -rf $(@D)/arago-2011.09/
  271. endef
  272. TOOLCHAIN_EXTERNAL_POST_EXTRACT_HOOKS += TOOLCHAIN_EXTERNAL_FIXUP_CMDS
  273. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM),y)
  274. ifeq ($(HOSTARCH),x86)
  275. TOOLCHAIN_EXTERNAL_SITE = http://releases.linaro.org/14.09/components/toolchain/binaries
  276. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
  277. else
  278. TOOLCHAIN_EXTERNAL_SITE = http://releases.linaro.org/components/toolchain/binaries/5.1-2015.08/arm-linux-gnueabihf
  279. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.1-2015.08-x86_64_arm-linux-gnueabihf.tar.xz
  280. endif
  281. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_ARMHF_SYMLINK
  282. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB),y)
  283. ifeq ($(HOSTARCH),x86)
  284. TOOLCHAIN_EXTERNAL_SITE = http://releases.linaro.org/14.09/components/toolchain/binaries
  285. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-armeb-linux-gnueabihf-4.9-2014.09_linux.tar.xz
  286. else
  287. TOOLCHAIN_EXTERNAL_SITE = http://releases.linaro.org/components/toolchain/binaries/5.1-2015.08/armeb-linux-gnueabihf
  288. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.1-2015.08-x86_64_armeb-linux-gnueabihf.tar.xz
  289. endif
  290. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_ARMEBHF_SYMLINK
  291. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS),y)
  292. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/mips-linux-gnu
  293. TOOLCHAIN_EXTERNAL_SOURCE = mips-2015.11-32-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
  294. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII),y)
  295. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/nios2-linux-gnu
  296. TOOLCHAIN_EXTERNAL_SOURCE = sourceryg++-2015.11-27-nios2-linux-gnu-i686-pc-linux-gnu.tar.bz2
  297. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_POWERPC_E500V2),y)
  298. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/powerpc-mentor-linux-gnu
  299. TOOLCHAIN_EXTERNAL_SOURCE = mentor-2012.03-71-powerpc-mentor-linux-gnu-i686-pc-linux-gnu.tar.bz2
  300. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_POWERPC),y)
  301. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/powerpc-linux-gnu
  302. TOOLCHAIN_EXTERNAL_SOURCE = freescale-2011.03-38-powerpc-linux-gnu-i686-pc-linux-gnu.tar.bz2
  303. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH),y)
  304. TOOLCHAIN_EXTERNAL_SITE = https://sourcery.mentor.com/public/gnu_toolchain/sh-linux-gnu
  305. TOOLCHAIN_EXTERNAL_SOURCE = renesas-2012.09-61-sh-linux-gnu-i686-pc-linux-gnu.tar.bz2
  306. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_X86),y)
  307. TOOLCHAIN_EXTERNAL_SITE = https://sourcery.mentor.com/public/gnu_toolchain/i686-pc-linux-gnu
  308. TOOLCHAIN_EXTERNAL_SOURCE = ia32-2012.09-62-i686-pc-linux-gnu-i386-linux.tar.bz2
  309. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_AMD64),y)
  310. TOOLCHAIN_EXTERNAL_SITE = https://sourcery.mentor.com/public/gnu_toolchain/x86_64-amd-linux-gnu
  311. TOOLCHAIN_EXTERNAL_SOURCE = amd-2015.11-36-x86_64-amd-linux-gnu-i686-pc-linux-gnu.tar.bz2
  312. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESCAPE_IMG_MIPS),y)
  313. TOOLCHAIN_EXTERNAL_SITE = http://codescape-mips-sdk.imgtec.com/components/toolchain/2015.06-05
  314. TOOLCHAIN_EXTERNAL_SOURCE = Codescape.GNU.Tools.Package.2015.06-05.for.MIPS.IMG.Linux.CentOS-5.x86.tar.gz
  315. TOOLCHAIN_EXTERNAL_STRIP_COMPONENTS = 2
  316. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS),y)
  317. TOOLCHAIN_EXTERNAL_SITE = http://codescape-mips-sdk.imgtec.com/components/toolchain/2015.06-05
  318. TOOLCHAIN_EXTERNAL_SOURCE = Codescape.GNU.Tools.Package.2015.06-05.for.MIPS.MTI.Linux.CentOS-5.x86.tar.gz
  319. TOOLCHAIN_EXTERNAL_STRIP_COMPONENTS = 2
  320. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX),y)
  321. TOOLCHAIN_EXTERNAL_SITE = http://downloads.sourceforge.net/project/adi-toolchain/2014R1/2014R1-RC2/i386
  322. TOOLCHAIN_EXTERNAL_SOURCE = blackfin-toolchain-2014R1-RC2.i386.tar.bz2
  323. TOOLCHAIN_EXTERNAL_EXTRA_DOWNLOADS = blackfin-toolchain-uclibc-full-2014R1-RC2.i386.tar.bz2
  324. TOOLCHAIN_EXTERNAL_STRIP_COMPONENTS = 3
  325. TOOLCHAIN_EXTERNAL_POST_EXTRACT_HOOKS += TOOLCHAIN_EXTERNAL_BLACKFIN_UCLIBC_EXTRA_EXTRACT
  326. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64),y)
  327. ifeq ($(HOSTARCH),x86)
  328. TOOLCHAIN_EXTERNAL_SITE = http://releases.linaro.org/14.09/components/toolchain/binaries
  329. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux.tar.xz
  330. else
  331. TOOLCHAIN_EXTERNAL_SITE = http://releases.linaro.org/components/toolchain/binaries/5.1-2015.08/aarch64-linux-gnu
  332. TOOLCHAIN_EXTERNAL_SOURCE = gcc-linaro-5.1-2015.08-x86_64_aarch64-linux-gnu.tar.xz
  333. endif
  334. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_LINARO_AARCH64_SYMLINK
  335. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64),y)
  336. TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/aarch64-linux-gnu
  337. TOOLCHAIN_EXTERNAL_SOURCE = aarch64-2014.05-30-aarch64-linux-gnu-i686-pc-linux-gnu.tar.bz2
  338. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_MUSL_CROSS),y)
  339. TOOLCHAIN_EXTERNAL_VERSION = 1.1.6
  340. TOOLCHAIN_EXTERNAL_SITE = https://googledrive.com/host/0BwnS5DMB0YQ6bDhPZkpOYVFhbk0/musl-$(TOOLCHAIN_EXTERNAL_VERSION)
  341. ifeq ($(BR2_arm)$(BR2_ARM_EABI),yy)
  342. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-arm-linux-musleabi-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  343. else ifeq ($(BR2_arm)$(BR2_ARM_EABIHF),yy)
  344. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-arm-linux-musleabihf-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  345. else ifeq ($(BR2_armeb),y)
  346. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-armeb-linux-musleabi-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  347. else ifeq ($(BR2_i386),y)
  348. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-i486-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  349. else ifeq ($(BR2_microblazebe),y)
  350. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-microblaze-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  351. else ifeq ($(BR2_mips),y)
  352. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-mips-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  353. else ifeq ($(BR2_mipsel),y)
  354. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-mipsel-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  355. else ifeq ($(BR2_powerpc),y)
  356. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-powerpc-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  357. else ifeq ($(BR2_x86_64),y)
  358. TOOLCHAIN_EXTERNAL_SOURCE = crossx86-x86_64-linux-musl-$(TOOLCHAIN_EXTERNAL_VERSION).tar.xz
  359. endif
  360. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_SYNOPSYS_ARC),y)
  361. TOOLCHAIN_EXTERNAL_SITE = https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2014.12
  362. ifeq ($(BR2_arc750d)$(BR2_arc770d),y)
  363. TOOLCHAIN_EXTERNAL_SYNOPSYS_CORE = arc700
  364. else
  365. TOOLCHAIN_EXTERNAL_SYNOPSYS_CORE = archs
  366. endif
  367. ifeq ($(BR2_arcle),y)
  368. TOOLCHAIN_EXTERNAL_SYNOPSYS_ENDIANESS = le
  369. else
  370. TOOLCHAIN_EXTERNAL_SYNOPSYS_ENDIANESS = be
  371. endif
  372. TOOLCHAIN_EXTERNAL_SOURCE = arc_gnu_2014.12_prebuilt_uclibc_$(TOOLCHAIN_EXTERNAL_SYNOPSYS_ENDIANESS)_$(TOOLCHAIN_EXTERNAL_SYNOPSYS_CORE)_linux_install.tar.gz
  373. else
  374. # Custom toolchain
  375. TOOLCHAIN_EXTERNAL_SITE = $(patsubst %/,%,$(dir $(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_URL))))
  376. TOOLCHAIN_EXTERNAL_SOURCE = $(notdir $(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_URL)))
  377. # We can't check hashes for custom downloaded toolchains
  378. BR_NO_CHECK_HASH_FOR += $(TOOLCHAIN_EXTERNAL_SOURCE)
  379. endif
  380. # Some toolchain vendors have a regular file naming pattern.
  381. # For them, mass-define _ACTUAL_SOURCE_TARBALL based _SITE.
  382. ifneq ($(findstring sourcery.mentor.com/public/gnu_toolchain,$(TOOLCHAIN_EXTERNAL_SITE)),)
  383. TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL ?= \
  384. $(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)))
  385. else ifneq ($(findstring http://releases.linaro.org,$(TOOLCHAIN_EXTERNAL_SITE)),)
  386. TOOLCHAIN_EXTERNAL_ACTUAL_SOURCE_TARBALL ?= \
  387. $(subst _linux.tar.xz,_src.tar.bz2,$(TOOLCHAIN_EXTERNAL_SOURCE))
  388. endif
  389. # In fact, we don't need to download the toolchain, since it is already
  390. # available on the system, so force the site and source to be empty so
  391. # that nothing will be downloaded/extracted.
  392. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_PREINSTALLED),y)
  393. TOOLCHAIN_EXTERNAL_SITE =
  394. TOOLCHAIN_EXTERNAL_SOURCE =
  395. endif
  396. TOOLCHAIN_EXTERNAL_ADD_TOOLCHAIN_DEPENDENCY = NO
  397. TOOLCHAIN_EXTERNAL_INSTALL_STAGING = YES
  398. # Normal handling of downloaded toolchain tarball extraction.
  399. ifneq ($(TOOLCHAIN_EXTERNAL_SOURCE),)
  400. TOOLCHAIN_EXTERNAL_EXCLUDES = usr/lib/locale/*
  401. # As a regular package, the toolchain gets extracted in $(@D), but
  402. # since it's actually a fairly special package, we need it to be moved
  403. # into TOOLCHAIN_EXTERNAL_INSTALL_DIR.
  404. define TOOLCHAIN_EXTERNAL_MOVE
  405. rm -rf $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)/*
  406. mkdir -p $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)
  407. mv $(@D)/* $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)/
  408. endef
  409. TOOLCHAIN_EXTERNAL_POST_EXTRACT_HOOKS += \
  410. TOOLCHAIN_EXTERNAL_MOVE
  411. endif
  412. # Returns the location of the libc.a file for the given compiler + flags
  413. define toolchain_find_libc_a
  414. $$(readlink -f $$(LANG=C $(1) -print-file-name=libc.a))
  415. endef
  416. # Returns the sysroot location for the given compiler + flags. We need
  417. # to handle cases where libc.a is in:
  418. #
  419. # - lib/
  420. # - usr/lib/
  421. # - lib32/
  422. # - lib64/
  423. # - lib32-fp/ (Cavium toolchain)
  424. # - lib64-fp/ (Cavium toolchain)
  425. # - usr/lib/<tuple>/ (Linaro toolchain)
  426. #
  427. # And variations on these.
  428. define toolchain_find_sysroot
  429. $$(printf $(call toolchain_find_libc_a,$(1)) | sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::')
  430. endef
  431. # Returns the lib subdirectory for the given compiler + flags (i.e
  432. # typically lib32 or lib64 for some toolchains)
  433. define toolchain_find_libdir
  434. $$(printf $(call toolchain_find_libc_a,$(1)) | sed -r -e 's:.*/(usr/)?(lib(32|64)?([^/]*)?)/([^/]*/)?libc.a:\2:')
  435. endef
  436. # Checks for an already installed toolchain: check the toolchain
  437. # location, check that it supports sysroot, and then verify that it
  438. # matches the configuration provided in Buildroot: ABI, C++ support,
  439. # kernel headers version, type of C library and all C library features.
  440. define TOOLCHAIN_EXTERNAL_CONFIGURE_CMDS
  441. $(Q)$(call check_cross_compiler_exists,$(TOOLCHAIN_EXTERNAL_CC))
  442. $(Q)$(call check_unusable_toolchain,$(TOOLCHAIN_EXTERNAL_CC))
  443. $(Q)SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC))" ; \
  444. if test -z "$${SYSROOT_DIR}" ; then \
  445. @echo "External toolchain doesn't support --sysroot. Cannot use." ; \
  446. exit 1 ; \
  447. fi ; \
  448. $(call check_kernel_headers_version,\
  449. $(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC)),\
  450. $(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST))); \
  451. $(call check_gcc_version,$(TOOLCHAIN_EXTERNAL_CC),\
  452. $(call qstrip,$(BR2_TOOLCHAIN_GCC_AT_LEAST))); \
  453. if test "$(BR2_arm)" = "y" ; then \
  454. $(call check_arm_abi,\
  455. "$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS)",\
  456. $(TOOLCHAIN_EXTERNAL_READELF)) ; \
  457. fi ; \
  458. if test "$(BR2_INSTALL_LIBSTDCPP)" = "y" ; then \
  459. $(call check_cplusplus,$(TOOLCHAIN_EXTERNAL_CXX)) ; \
  460. fi ; \
  461. if test "$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC)" = "y" ; then \
  462. $(call check_uclibc,$${SYSROOT_DIR}) ; \
  463. elif test "$(BR2_TOOLCHAIN_EXTERNAL_MUSL)" = "y" ; then \
  464. $(call check_musl,$${SYSROOT_DIR}) ; \
  465. else \
  466. $(call check_glibc,$${SYSROOT_DIR}) ; \
  467. fi
  468. endef
  469. # With the musl C library, the libc.so library directly plays the role
  470. # of the dynamic library loader. We just need to create a symbolic
  471. # link to libc.so with the appropriate name.
  472. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_MUSL),y)
  473. ifeq ($(BR2_i386),y)
  474. MUSL_ARCH = i386
  475. else ifeq ($(BR2_ARM_EABIHF),y)
  476. MUSL_ARCH = armhf
  477. else
  478. MUSL_ARCH = $(ARCH)
  479. endif
  480. define TOOLCHAIN_EXTERNAL_MUSL_LD_LINK
  481. ln -sf libc.so $(TARGET_DIR)/lib/ld-musl-$(MUSL_ARCH).so.1
  482. endef
  483. TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_MUSL_LD_LINK
  484. endif
  485. # Create a symlink from (usr/)$(ARCH_LIB_DIR) to lib.
  486. # Note: the skeleton package additionally creates lib32->lib or lib64->lib
  487. # (as appropriate)
  488. #
  489. # $1: destination directory (TARGET_DIR / STAGING_DIR)
  490. create_lib_symlinks = \
  491. $(Q)DESTDIR="$(strip $1)" ; \
  492. ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  493. if [ ! -e "$${DESTDIR}/$${ARCH_LIB_DIR}" -a ! -e "$${DESTDIR}/usr/$${ARCH_LIB_DIR}" ]; then \
  494. ln -snf lib "$${DESTDIR}/$${ARCH_LIB_DIR}" ; \
  495. ln -snf lib "$${DESTDIR}/usr/$${ARCH_LIB_DIR}" ; \
  496. fi
  497. define TOOLCHAIN_EXTERNAL_CREATE_STAGING_LIB_SYMLINK
  498. $(call create_lib_symlinks,$(STAGING_DIR))
  499. endef
  500. define TOOLCHAIN_EXTERNAL_CREATE_TARGET_LIB_SYMLINK
  501. $(call create_lib_symlinks,$(TARGET_DIR))
  502. endef
  503. # Integration of the toolchain into Buildroot: find the main sysroot
  504. # and the variant-specific sysroot, then copy the needed libraries to
  505. # the $(TARGET_DIR) and copy the whole sysroot (libraries and headers)
  506. # to $(STAGING_DIR).
  507. #
  508. # Variables are defined as follows:
  509. #
  510. # LIBC_A_LOCATION: location of the libc.a file in the default
  511. # multilib variant (allows to find the main
  512. # sysroot directory)
  513. # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/usr/lib/libc.a
  514. #
  515. # SYSROOT_DIR: the main sysroot directory, deduced from
  516. # LIBC_A_LOCATION by removing the
  517. # usr/lib[32|64]/libc.a part of the path.
  518. # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/
  519. #
  520. # ARCH_LIBC_A_LOCATION: location of the libc.a file in the selected
  521. # multilib variant (taking into account the
  522. # CFLAGS). Allows to find the sysroot of the
  523. # selected multilib variant.
  524. # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/mips16/soft-float/el/usr/lib/libc.a
  525. #
  526. # ARCH_SYSROOT_DIR: the sysroot of the selected multilib variant,
  527. # deduced from ARCH_LIBC_A_LOCATION by removing
  528. # usr/lib[32|64]/libc.a at the end of the path.
  529. # Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/mips16/soft-float/el/
  530. #
  531. # ARCH_LIB_DIR: 'lib', 'lib32' or 'lib64' depending on where libraries
  532. # are stored. Deduced from ARCH_LIBC_A_LOCATION by
  533. # looking at usr/lib??/libc.a.
  534. # Ex: lib
  535. #
  536. # ARCH_SUBDIR: the relative location of the sysroot of the selected
  537. # multilib variant compared to the main sysroot.
  538. # Ex: mips16/soft-float/el
  539. #
  540. # SUPPORT_LIB_DIR: some toolchains, such as recent Linaro toolchains,
  541. # store GCC support libraries (libstdc++,
  542. # libgcc_s, etc.) outside of the sysroot. In
  543. # this case, SUPPORT_LIB_DIR is set to a
  544. # non-empty value, and points to the directory
  545. # where these support libraries are
  546. # available. Those libraries will be copied to
  547. # our sysroot, and the directory will also be
  548. # considered when searching libraries for copy
  549. # to the target filesystem.
  550. define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBS
  551. $(Q)SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC))" ; \
  552. if test -z "$${SYSROOT_DIR}" ; then \
  553. @echo "External toolchain doesn't support --sysroot. Cannot use." ; \
  554. exit 1 ; \
  555. fi ; \
  556. ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  557. ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  558. SUPPORT_LIB_DIR="" ; \
  559. if test `find $${ARCH_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
  560. LIBSTDCPP_A_LOCATION=$$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libstdc++.a) ; \
  561. if [ -e "$${LIBSTDCPP_A_LOCATION}" ]; then \
  562. SUPPORT_LIB_DIR=`readlink -f $${LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \
  563. fi ; \
  564. fi ; \
  565. ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \
  566. if test -z "$(BR2_STATIC_LIBS)" ; then \
  567. $(call MESSAGE,"Copying external toolchain libraries to target...") ; \
  568. for libs in $(LIB_EXTERNAL_LIBS); do \
  569. $(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${SUPPORT_LIB_DIR},$${ARCH_LIB_DIR},$$libs,/lib); \
  570. done ; \
  571. for libs in $(USR_LIB_EXTERNAL_LIBS); do \
  572. $(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${SUPPORT_LIB_DIR},$${ARCH_LIB_DIR},$$libs,/usr/lib); \
  573. done ; \
  574. fi ; \
  575. if test "$(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY)" = "y"; then \
  576. $(call MESSAGE,"Copying gdbserver") ; \
  577. gdbserver_found=0 ; \
  578. for d in $${ARCH_SYSROOT_DIR}/usr \
  579. $${ARCH_SYSROOT_DIR}/../debug-root/usr \
  580. $${ARCH_SYSROOT_DIR}/usr/$${ARCH_LIB_DIR} \
  581. $(TOOLCHAIN_EXTERNAL_INSTALL_DIR); do \
  582. if test -f $${d}/bin/gdbserver ; then \
  583. install -m 0755 -D $${d}/bin/gdbserver $(TARGET_DIR)/usr/bin/gdbserver ; \
  584. gdbserver_found=1 ; \
  585. break ; \
  586. fi ; \
  587. done ; \
  588. if [ $${gdbserver_found} -eq 0 ] ; then \
  589. echo "Could not find gdbserver in external toolchain" ; \
  590. exit 1 ; \
  591. fi ; \
  592. fi
  593. endef
  594. define TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS
  595. $(Q)SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC))" ; \
  596. if test -z "$${SYSROOT_DIR}" ; then \
  597. @echo "External toolchain doesn't support --sysroot. Cannot use." ; \
  598. exit 1 ; \
  599. fi ; \
  600. ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  601. ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  602. SUPPORT_LIB_DIR="" ; \
  603. if test `find $${ARCH_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
  604. LIBSTDCPP_A_LOCATION=$$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libstdc++.a) ; \
  605. if [ -e "$${LIBSTDCPP_A_LOCATION}" ]; then \
  606. SUPPORT_LIB_DIR=`readlink -f $${LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \
  607. fi ; \
  608. fi ; \
  609. ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \
  610. $(call MESSAGE,"Copying external toolchain sysroot to staging...") ; \
  611. $(call copy_toolchain_sysroot,$${SYSROOT_DIR},$${ARCH_SYSROOT_DIR},$${ARCH_SUBDIR},$${ARCH_LIB_DIR},$${SUPPORT_LIB_DIR})
  612. endef
  613. # Special installation target used on the Blackfin architecture when
  614. # FDPIC is not the primary binary format being used, but the user has
  615. # nonetheless requested the installation of the FDPIC libraries to the
  616. # target filesystem.
  617. ifeq ($(BR2_BFIN_INSTALL_FDPIC_SHARED),y)
  618. define TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FDPIC
  619. $(Q)$(call MESSAGE,"Install external toolchain FDPIC libraries to target...") ; \
  620. FDPIC_EXTERNAL_CC=$(dir $(TOOLCHAIN_EXTERNAL_CC))/../../bfin-linux-uclibc/bin/bfin-linux-uclibc-gcc ; \
  621. FDPIC_SYSROOT_DIR="$(call toolchain_find_sysroot,$${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  622. FDPIC_LIB_DIR="$(call toolchain_find_libdir,$${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
  623. FDPIC_SUPPORT_LIB_DIR="" ; \
  624. if test `find $${FDPIC_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
  625. FDPIC_LIBSTDCPP_A_LOCATION=$$(LANG=C $${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libstdc++.a) ; \
  626. if [ -e "$${FDPIC_LIBSTDCPP_A_LOCATION}" ]; then \
  627. FDPIC_SUPPORT_LIB_DIR=`readlink -f $${FDPIC_LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \
  628. fi ; \
  629. fi ; \
  630. for libs in $(LIB_EXTERNAL_LIBS); do \
  631. $(call copy_toolchain_lib_root,$${FDPIC_SYSROOT_DIR},$${FDPIC_SUPPORT_LIB_DIR},$${FDPIC_LIB_DIR},$$libs,/lib); \
  632. done ; \
  633. for libs in $(USR_LIB_EXTERNAL_LIBS); do \
  634. $(call copy_toolchain_lib_root,$${FDPIC_SYSROOT_DIR},$${FDPIC_SUPPORT_LIB_DIR},$${FDPIC_LIB_DIR},$$libs,/usr/lib); \
  635. done
  636. endef
  637. endif
  638. # Special installation target used on the Blackfin architecture when
  639. # shared FLAT is not the primary format being used, but the user has
  640. # nonetheless requested the installation of the shared FLAT libraries
  641. # to the target filesystem. The flat libraries are found and linked
  642. # according to the index in name "libN.so". Index 1 is reserved for
  643. # the standard C library. Customer libraries can use 4 and above.
  644. ifeq ($(BR2_BFIN_INSTALL_FLAT_SHARED),y)
  645. define TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FLAT
  646. $(Q)$(call MESSAGE,"Install external toolchain FLAT libraries to target...") ; \
  647. FLAT_EXTERNAL_CC=$(dir $(TOOLCHAIN_EXTERNAL_CC))../../bfin-uclinux/bin/bfin-uclinux-gcc ; \
  648. FLAT_LIBC_A_LOCATION=`$${FLAT_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS) -mid-shared-library -print-file-name=libc`; \
  649. if [ -f $${FLAT_LIBC_A_LOCATION} -a ! -h $${FLAT_LIBC_A_LOCATION} ] ; then \
  650. $(INSTALL) -D $${FLAT_LIBC_A_LOCATION} $(TARGET_DIR)/lib/lib1.so; \
  651. fi
  652. endef
  653. endif
  654. # Build toolchain wrapper for preprocessor, C and C++ compiler and setup
  655. # symlinks for everything else. Skip gdb symlink when we are building our
  656. # own gdb to prevent two gdb's in output/host/usr/bin.
  657. # The LTO support in gcc creates wrappers for ar, ranlib and nm which load
  658. # the lto plugin. These wrappers are called *-gcc-ar, *-gcc-ranlib, and
  659. # *-gcc-nm and should be used instead of the real programs when -flto is
  660. # used. However, we should not add the toolchain wrapper for them, and they
  661. # match the *cc-* pattern. Therefore, an additional case is added for *-ar,
  662. # *-ranlib and *-nm.
  663. define TOOLCHAIN_EXTERNAL_INSTALL_WRAPPER
  664. $(Q)cd $(HOST_DIR)/usr/bin; \
  665. for i in $(TOOLCHAIN_EXTERNAL_CROSS)*; do \
  666. base=$${i##*/}; \
  667. case "$$base" in \
  668. *-ar|*-ranlib|*-nm) \
  669. ln -sf $$(echo $$i | sed 's%^$(HOST_DIR)%../..%') .; \
  670. ;; \
  671. *cc|*cc-*|*++|*++-*|*cpp) \
  672. ln -sf toolchain-wrapper $$base; \
  673. ;; \
  674. *gdb|*gdbtui) \
  675. if test "$(BR2_PACKAGE_HOST_GDB)" != "y"; then \
  676. ln -sf $$(echo $$i | sed 's%^$(HOST_DIR)%../..%') .; \
  677. fi \
  678. ;; \
  679. *) \
  680. ln -sf $$(echo $$i | sed 's%^$(HOST_DIR)%../..%') .; \
  681. ;; \
  682. esac; \
  683. done
  684. endef
  685. #
  686. # Generate gdbinit file for use with Buildroot
  687. #
  688. define TOOLCHAIN_EXTERNAL_INSTALL_GDBINIT
  689. $(Q)if test -f $(TARGET_CROSS)gdb ; then \
  690. $(call MESSAGE,"Installing gdbinit"); \
  691. $(gen_gdbinit_file); \
  692. fi
  693. endef
  694. # uClibc-ng dynamic loader is called ld-uClibc.so.1, but gcc is not
  695. # patched specifically for uClibc-ng, so it continues to generate
  696. # binaries that expect the dynamic loader to be named ld-uClibc.so.0,
  697. # like with the original uClibc. Therefore, we create an additional
  698. # symbolic link to make uClibc-ng systems work properly.
  699. define TOOLCHAIN_EXTERNAL_FIXUP_UCLIBCNG_LDSO
  700. $(Q)if test -e $(TARGET_DIR)/lib/ld-uClibc.so.1; then \
  701. ln -sf ld-uClibc.so.1 $(TARGET_DIR)/lib/ld-uClibc.so.0 ; \
  702. fi
  703. $(Q)if test -e $(TARGET_DIR)/lib/ld64-uClibc.so.1; then \
  704. ln -sf ld64-uClibc.so.1 $(TARGET_DIR)/lib/ld64-uClibc.so.0 ; \
  705. fi
  706. endef
  707. TOOLCHAIN_EXTERNAL_BUILD_CMDS = $(TOOLCHAIN_BUILD_WRAPPER)
  708. define TOOLCHAIN_EXTERNAL_INSTALL_STAGING_CMDS
  709. $(TOOLCHAIN_EXTERNAL_CREATE_STAGING_LIB_SYMLINK)
  710. $(TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS)
  711. $(TOOLCHAIN_EXTERNAL_INSTALL_WRAPPER)
  712. $(TOOLCHAIN_EXTERNAL_INSTALL_GDBINIT)
  713. endef
  714. # Even though we're installing things in both the staging, the host
  715. # and the target directory, we do everything within the
  716. # install-staging step, arbitrarily.
  717. define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_CMDS
  718. $(TOOLCHAIN_EXTERNAL_CREATE_TARGET_LIB_SYMLINK)
  719. $(TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBS)
  720. $(TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FDPIC)
  721. $(TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FLAT)
  722. $(TOOLCHAIN_EXTERNAL_FIXUP_UCLIBCNG_LDSO)
  723. endef
  724. $(eval $(generic-package))