toolchain-external.mk 34 KB

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