Makefile.in 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. ifndef MAKE
  2. MAKE := make
  3. endif
  4. ifndef HOSTMAKE
  5. HOSTMAKE = $(MAKE)
  6. endif
  7. HOSTMAKE := $(shell which $(HOSTMAKE) || type -p $(HOSTMAKE) || echo make)
  8. # If BR2_JLEVEL is 0, scale the maximum concurrency with the number of
  9. # CPUs. An additional job is used in order to keep processors busy
  10. # while waiting on I/O.
  11. # If the number of processors is not available, assume one.
  12. ifeq ($(BR2_JLEVEL),0)
  13. PARALLEL_JOBS := $(shell echo \
  14. $$((1 + `getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1`)))
  15. else
  16. PARALLEL_JOBS := $(BR2_JLEVEL)
  17. endif
  18. # Only build one job at a time, *and* to not randomise goals and
  19. # prerequisites ordering in make 4.4+
  20. MAKE1 := $(HOSTMAKE) -j1 $(if $(findstring --shuffle,$(MAKEFLAGS)),--shuffle=none)
  21. override MAKE = $(HOSTMAKE) \
  22. $(if $(findstring j,$(filter-out --%,$(MAKEFLAGS))),,-j$(PARALLEL_JOBS))
  23. ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
  24. TARGET_VENDOR = $(call qstrip,$(BR2_TOOLCHAIN_BUILDROOT_VENDOR))
  25. else
  26. TARGET_VENDOR = buildroot
  27. endif
  28. # Sanity checks
  29. ifeq ($(TARGET_VENDOR),)
  30. $(error BR2_TOOLCHAIN_BUILDROOT_VENDOR is not allowed to be empty)
  31. endif
  32. ifeq ($(TARGET_VENDOR),unknown)
  33. $(error BR2_TOOLCHAIN_BUILDROOT_VENDOR cannot be 'unknown'. \
  34. It might be confused with the native toolchain)
  35. endif
  36. # Compute GNU_TARGET_NAME
  37. GNU_TARGET_NAME = $(ARCH)-$(TARGET_VENDOR)-$(TARGET_OS)-$(LIBC)$(ABI)
  38. # FLAT binary format needs uclinux, except RISC-V which needs the
  39. # regular linux name.
  40. ifeq ($(BR2_BINFMT_FLAT):$(BR2_riscv),y:)
  41. TARGET_OS = uclinux
  42. else
  43. TARGET_OS = linux
  44. endif
  45. ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
  46. LIBC = uclibc
  47. else ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
  48. LIBC = musl
  49. else ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
  50. LIBC = gnu
  51. else ifeq ($(BR_BUILDING),y)
  52. # This happens if there is a bug in Buildroot that allows an
  53. # architecture configuration that isn't supported by any library.
  54. $(error No C library enabled, this is not possible.)
  55. endif
  56. # The ABI suffix is a bit special on ARM, as it needs to be
  57. # -uclibcgnueabi for uClibc EABI, and -gnueabi for glibc EABI.
  58. # This means that the LIBC and ABI aren't strictly orthogonal,
  59. # which explains why we need the test on LIBC below.
  60. ifeq ($(BR2_arm)$(BR2_armeb),y)
  61. ifeq ($(LIBC),uclibc)
  62. ABI = gnueabi
  63. else
  64. ABI = eabi
  65. endif
  66. ifeq ($(BR2_ARM_EABIHF),y)
  67. ABI := $(ABI)hf
  68. endif
  69. endif
  70. # For FSL PowerPC there's SPE
  71. ifeq ($(BR2_POWERPC_CPU_HAS_SPE),y)
  72. ABI = spe
  73. # MPC8540s are e500v1 with single precision FP
  74. ifeq ($(BR2_powerpc_8540),y)
  75. TARGET_ABI += -mabi=spe -mfloat-gprs=single -Wa,-me500
  76. endif
  77. ifeq ($(BR2_powerpc_8548),y)
  78. TARGET_ABI += -mabi=spe -mfloat-gprs=double -Wa,-me500x2
  79. endif
  80. ifeq ($(BR2_powerpc_e500mc),y)
  81. TARGET_ABI += -mabi=spe -mfloat-gprs=double -Wa,-me500mc
  82. endif
  83. endif
  84. # Use longcalls option for Xtensa globally.
  85. # The 'longcalls' option allows calls across a greater range of addresses,
  86. # and is required for some packages. While this option can degrade both
  87. # code size and performance, the linker can usually optimize away the
  88. # overhead when a call ends up within a certain range.
  89. #
  90. # Use auto-litpools for Xtensa globally.
  91. # Collecting literals into separate section can be advantageous if that
  92. # section is placed into DTCM at link time. This is applicable for code
  93. # running on bare metal, but makes no sense under linux, where userspace
  94. # is isolated from the physical memory details. OTOH placing literals into
  95. # separate section breaks build of huge source files, because l32r
  96. # instruction can only access literals in 256 KBytes range.
  97. #
  98. ifeq ($(BR2_xtensa),y)
  99. TARGET_ABI += -mlongcalls -mauto-litpools
  100. endif
  101. STAGING_SUBDIR = $(GNU_TARGET_NAME)/sysroot
  102. STAGING_DIR = $(HOST_DIR)/$(STAGING_SUBDIR)
  103. ifeq ($(BR2_OPTIMIZE_0),y)
  104. TARGET_OPTIMIZATION = -O0
  105. endif
  106. ifeq ($(BR2_OPTIMIZE_1),y)
  107. TARGET_OPTIMIZATION = -O1
  108. endif
  109. ifeq ($(BR2_OPTIMIZE_2),y)
  110. TARGET_OPTIMIZATION = -O2
  111. endif
  112. ifeq ($(BR2_OPTIMIZE_3),y)
  113. TARGET_OPTIMIZATION = -O3
  114. endif
  115. ifeq ($(BR2_OPTIMIZE_G),y)
  116. TARGET_OPTIMIZATION = -Og
  117. endif
  118. ifeq ($(BR2_OPTIMIZE_S),y)
  119. TARGET_OPTIMIZATION = -Os
  120. endif
  121. ifeq ($(BR2_OPTIMIZE_FAST),y)
  122. TARGET_OPTIMIZATION = -Ofast
  123. endif
  124. ifeq ($(BR2_ENABLE_DEBUG),)
  125. TARGET_DEBUGGING = -g0
  126. endif
  127. ifeq ($(BR2_DEBUG_1),y)
  128. TARGET_DEBUGGING = -g1
  129. endif
  130. ifeq ($(BR2_DEBUG_2),y)
  131. TARGET_DEBUGGING = -g2
  132. endif
  133. ifeq ($(BR2_DEBUG_3),y)
  134. TARGET_DEBUGGING = -g3
  135. endif
  136. TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS))
  137. # By design, _FORTIFY_SOURCE requires gcc optimization to be enabled.
  138. # Therefore, we need to pass _FORTIFY_SOURCE and the optimization level
  139. # through the same mechanism, i.e currently through CFLAGS. Passing
  140. # _FORTIFY_SOURCE through the wrapper and the optimization level
  141. # through CFLAGS would not work, because CFLAGS are sometimes
  142. # ignored/overridden by packages, but the flags passed by the wrapper
  143. # are enforced: this would cause _FORTIFY_SOURCE to be used without any
  144. # optimization level, leading to a build / configure failure. So we keep
  145. # passing _FORTIFY_SOURCE and the optimization level both through CFLAGS.
  146. ifeq ($(BR2_FORTIFY_SOURCE_1),y)
  147. TARGET_HARDENED += -D_FORTIFY_SOURCE=1
  148. else ifeq ($(BR2_FORTIFY_SOURCE_2),y)
  149. TARGET_HARDENED += -D_FORTIFY_SOURCE=2
  150. else ifeq ($(BR2_FORTIFY_SOURCE_3),y)
  151. TARGET_HARDENED += -D_FORTIFY_SOURCE=3
  152. endif
  153. TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
  154. ifeq ($(BR2_TIME_BITS_64),y)
  155. TARGET_CPPFLAGS += -D_TIME_BITS=64
  156. endif
  157. TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) $(TARGET_HARDENED)
  158. TARGET_CXXFLAGS = $(TARGET_CFLAGS)
  159. TARGET_FCFLAGS = $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
  160. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79509
  161. ifeq ($(BR2_m68k_cf),y)
  162. TARGET_CFLAGS += -fno-dwarf2-cfi-asm
  163. TARGET_CXXFLAGS += -fno-dwarf2-cfi-asm
  164. endif
  165. ifeq ($(BR2_BINFMT_FLAT),y)
  166. ifeq ($(BR2_riscv),y)
  167. TARGET_CFLAGS += -fPIC
  168. endif
  169. ELF2FLT_FLAGS = $(if $($(PKG)_FLAT_STACKSIZE),\
  170. -Wl$(comma)-elf2flt="-r -s$($(PKG)_FLAT_STACKSIZE)",\
  171. -Wl$(comma)-elf2flt=-r)
  172. TARGET_CFLAGS += $(ELF2FLT_FLAGS)
  173. TARGET_CXXFLAGS += $(ELF2FLT_FLAGS)
  174. TARGET_FCFLAGS += $(ELF2FLT_FLAGS)
  175. TARGET_LDFLAGS += $(ELF2FLT_FLAGS)
  176. endif
  177. ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
  178. TARGET_CROSS = $(HOST_DIR)/bin/$(GNU_TARGET_NAME)-
  179. else
  180. TARGET_CROSS = $(HOST_DIR)/bin/$(TOOLCHAIN_EXTERNAL_PREFIX)-
  181. endif
  182. # gcc-4.7 and later ships with wrappers that will automatically pass
  183. # arguments to the binutils tools. Those are paths to necessary linker
  184. # plugins.
  185. ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_4_7),y)
  186. TARGET_GCC_WRAPPERS_PREFIX = gcc-
  187. endif
  188. # Define TARGET_xx variables for all common binutils/gcc
  189. TARGET_AR = $(TARGET_CROSS)$(TARGET_GCC_WRAPPERS_PREFIX)ar
  190. TARGET_AS = $(TARGET_CROSS)as
  191. TARGET_CC = $(TARGET_CROSS)gcc
  192. TARGET_CPP = $(TARGET_CROSS)cpp
  193. TARGET_CXX = $(TARGET_CROSS)g++
  194. TARGET_FC = $(TARGET_CROSS)gfortran
  195. TARGET_LD = $(TARGET_CROSS)ld
  196. TARGET_NM = $(TARGET_CROSS)$(TARGET_GCC_WRAPPERS_PREFIX)nm
  197. TARGET_RANLIB = $(TARGET_CROSS)$(TARGET_GCC_WRAPPERS_PREFIX)ranlib
  198. TARGET_READELF = $(TARGET_CROSS)readelf
  199. TARGET_OBJCOPY = $(TARGET_CROSS)objcopy
  200. TARGET_OBJDUMP = $(TARGET_CROSS)objdump
  201. ifeq ($(BR2_STRIP_strip),y)
  202. STRIP_STRIP_DEBUG := --strip-debug
  203. TARGET_STRIP = $(TARGET_CROSS)strip
  204. STRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
  205. else
  206. TARGET_STRIP = /bin/true
  207. STRIPCMD = $(TARGET_STRIP)
  208. endif
  209. INSTALL := $(shell which install || type -p install)
  210. UNZIP := $(shell which unzip || type -p unzip) -q
  211. APPLY_PATCHES = PATH=$(HOST_DIR)/bin:$$PATH support/scripts/apply-patches.sh $(if $(QUIET),-s)
  212. HOST_CPPFLAGS = -I$(HOST_DIR)/include
  213. HOST_CFLAGS ?= -O2
  214. HOST_CFLAGS += $(HOST_CPPFLAGS)
  215. HOST_CXXFLAGS += $(HOST_CFLAGS)
  216. HOST_LDFLAGS += -L$(HOST_DIR)/lib -Wl,-rpath,$(HOST_DIR)/lib
  217. # host-intltool should be executed with the system perl, so we save
  218. # the path to the system perl, before a host-perl built by Buildroot
  219. # might get installed into $(HOST_DIR)/bin and therefore appears
  220. # in our PATH. This system perl will be used as INTLTOOL_PERL.
  221. export PERL=$(shell which perl)
  222. # host-intltool needs libxml-parser-perl, which Buildroot installs in
  223. # $(HOST_DIR)/lib/perl, so we must make sure that the system perl
  224. # finds this perl module by exporting the proper value for PERL5LIB.
  225. export PERL5LIB=$(HOST_DIR)/lib/perl
  226. TARGET_MAKE_ENV = \
  227. GIT_DIR=. \
  228. PATH=$(BR_PATH)
  229. TARGET_CONFIGURE_OPTS = \
  230. $(TARGET_MAKE_ENV) \
  231. AR="$(TARGET_AR)" \
  232. AS="$(TARGET_AS)" \
  233. LD="$(TARGET_LD)" \
  234. NM="$(TARGET_NM)" \
  235. CC="$(TARGET_CC)" \
  236. GCC="$(TARGET_CC)" \
  237. CPP="$(TARGET_CPP)" \
  238. CXX="$(TARGET_CXX)" \
  239. FC="$(TARGET_FC)" \
  240. F77="$(TARGET_FC)" \
  241. RANLIB="$(TARGET_RANLIB)" \
  242. READELF="$(TARGET_READELF)" \
  243. STRIP="$(TARGET_STRIP)" \
  244. OBJCOPY="$(TARGET_OBJCOPY)" \
  245. OBJDUMP="$(TARGET_OBJDUMP)" \
  246. AR_FOR_BUILD="$(HOSTAR)" \
  247. AS_FOR_BUILD="$(HOSTAS)" \
  248. CC_FOR_BUILD="$(HOSTCC)" \
  249. GCC_FOR_BUILD="$(HOSTCC)" \
  250. CXX_FOR_BUILD="$(HOSTCXX)" \
  251. LD_FOR_BUILD="$(HOSTLD)" \
  252. CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)" \
  253. CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
  254. CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
  255. LDFLAGS_FOR_BUILD="$(HOST_LDFLAGS)" \
  256. FCFLAGS_FOR_BUILD="$(HOST_FCFLAGS)" \
  257. DEFAULT_ASSEMBLER="$(TARGET_AS)" \
  258. DEFAULT_LINKER="$(TARGET_LD)" \
  259. CPPFLAGS="$(TARGET_CPPFLAGS)" \
  260. CFLAGS="$(TARGET_CFLAGS)" \
  261. CXXFLAGS="$(TARGET_CXXFLAGS)" \
  262. LDFLAGS="$(TARGET_LDFLAGS)" \
  263. FCFLAGS="$(TARGET_FCFLAGS)" \
  264. FFLAGS="$(TARGET_FCFLAGS)" \
  265. PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
  266. STAGING_DIR="$(STAGING_DIR)" \
  267. INTLTOOL_PERL=$(PERL)
  268. HOST_MAKE_ENV = \
  269. GIT_DIR=. \
  270. PATH=$(BR_PATH) \
  271. PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
  272. PKG_CONFIG_SYSROOT_DIR="/" \
  273. PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
  274. PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
  275. PKG_CONFIG_LIBDIR="$(HOST_DIR)/lib/pkgconfig:$(HOST_DIR)/share/pkgconfig"
  276. HOST_CONFIGURE_OPTS = \
  277. $(HOST_MAKE_ENV) \
  278. AR="$(HOSTAR)" \
  279. AS="$(HOSTAS)" \
  280. LD="$(HOSTLD)" \
  281. NM="$(HOSTNM)" \
  282. CC="$(HOSTCC)" \
  283. GCC="$(HOSTCC)" \
  284. CXX="$(HOSTCXX)" \
  285. CPP="$(HOSTCPP)" \
  286. OBJCOPY="$(HOSTOBJCOPY)" \
  287. RANLIB="$(HOSTRANLIB)" \
  288. CPPFLAGS="$(HOST_CPPFLAGS)" \
  289. CFLAGS="$(HOST_CFLAGS)" \
  290. CXXFLAGS="$(HOST_CXXFLAGS)" \
  291. LDFLAGS="$(HOST_LDFLAGS)" \
  292. INTLTOOL_PERL=$(PERL)
  293. # This is extra environment we can not export ourselves (eg. because some
  294. # packages use that variable internally, eg. uboot), so we have to
  295. # explicitly pass it to user-supplied external hooks (eg. post-build,
  296. # post-images)
  297. EXTRA_ENV = \
  298. PATH=$(BR_PATH) \
  299. BR2_DL_DIR=$(BR2_DL_DIR) \
  300. BUILD_DIR=$(BUILD_DIR) \
  301. CONFIG_DIR=$(CONFIG_DIR) \
  302. O=$(CANONICAL_O)
  303. ################################################################################
  304. # settings we need to pass to configure
  305. # does unaligned access trap?
  306. BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=yes
  307. ifeq ($(BR2_i386),y)
  308. BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
  309. endif
  310. ifeq ($(BR2_x86_64),y)
  311. BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
  312. endif
  313. ifeq ($(BR2_m68k),y)
  314. BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
  315. endif
  316. ifeq ($(BR2_powerpc)$(BR2_powerpc64)$(BR2_powerpc64le),y)
  317. BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
  318. endif
  319. ifeq ($(BR2_ENDIAN),"BIG")
  320. BR2_AC_CV_C_BIGENDIAN = ac_cv_c_bigendian=yes
  321. else
  322. BR2_AC_CV_C_BIGENDIAN = ac_cv_c_bigendian=no
  323. endif
  324. # AM_GNU_GETTEXT misdetects musl gettext support.
  325. # musl currently implements api level 1 and 2 (basic + ngettext)
  326. # http://www.openwall.com/lists/musl/2015/04/16/3
  327. #
  328. # These autoconf variables should only be pre-seeded when the minimal
  329. # gettext implementation of musl is used. When the full blown
  330. # implementation provided by gettext libintl is used, auto-detection
  331. # works fine, and pre-seeding those values is actually wrong.
  332. ifeq ($(BR2_TOOLCHAIN_USES_MUSL):$(BR2_PACKAGE_GETTEXT_PROVIDES_LIBINTL),y:)
  333. BR2_GT_CV_FUNC_GNUGETTEXT_LIBC = \
  334. gt_cv_func_gnugettext1_libc=yes \
  335. gt_cv_func_gnugettext2_libc=yes
  336. endif
  337. TARGET_CONFIGURE_ARGS = \
  338. $(BR2_AC_CV_TRAP_CHECK) \
  339. ac_cv_func_mmap_fixed_mapped=yes \
  340. ac_cv_func_memcmp_working=yes \
  341. ac_cv_have_decl_malloc=yes \
  342. gl_cv_func_malloc_0_nonnull=yes \
  343. ac_cv_func_malloc_0_nonnull=yes \
  344. ac_cv_func_calloc_0_nonnull=yes \
  345. ac_cv_func_realloc_0_nonnull=yes \
  346. lt_cv_sys_lib_search_path_spec="" \
  347. $(BR2_AC_CV_C_BIGENDIAN) \
  348. $(BR2_GT_CV_FUNC_GNUGETTEXT_LIBC)
  349. ################################################################################
  350. ifeq ($(BR2_SYSTEM_ENABLE_NLS),y)
  351. NLS_OPTS = --enable-nls
  352. TARGET_NLS_DEPENDENCIES = host-gettext
  353. ifeq ($(BR2_PACKAGE_GETTEXT_PROVIDES_LIBINTL),y)
  354. TARGET_NLS_DEPENDENCIES += gettext
  355. TARGET_NLS_LIBS += -lintl
  356. endif
  357. else
  358. NLS_OPTS = --disable-nls
  359. endif
  360. # We need anything that is invalid. Traditionally, we'd have used 'false' (and
  361. # we did so in the past). However, that breaks libtool for packages that have
  362. # optional C++ support (e.g. gnutls), because libtool will *require* a *valid*
  363. # C++ preprocessor as long as CXX is not 'no'.
  364. # Now, whether we use 'no' or 'false' for CXX as the same side effect: it is an
  365. # invalid C++ compiler, and thus will cause detection of C++ to fail (which is
  366. # expected and what we want), while at the same time taming libtool into
  367. # silence.
  368. ifneq ($(BR2_INSTALL_LIBSTDCPP),y)
  369. TARGET_CONFIGURE_OPTS += CXX=no
  370. endif
  371. ifeq ($(BR2_STATIC_LIBS),y)
  372. SHARED_STATIC_LIBS_OPTS = --enable-static --disable-shared
  373. TARGET_CFLAGS += -static
  374. TARGET_CXXFLAGS += -static
  375. TARGET_FCFLAGS += -static
  376. TARGET_LDFLAGS += -static
  377. else ifeq ($(BR2_SHARED_LIBS),y)
  378. SHARED_STATIC_LIBS_OPTS = --disable-static --enable-shared
  379. else ifeq ($(BR2_SHARED_STATIC_LIBS),y)
  380. SHARED_STATIC_LIBS_OPTS = --enable-static --enable-shared
  381. endif
  382. # Used by our binutils patches.
  383. export BR_COMPILER_PARANOID_UNSAFE_PATH=enabled
  384. include package/pkg-download.mk
  385. include package/pkg-autotools.mk
  386. include package/pkg-cmake.mk
  387. include package/pkg-luarocks.mk
  388. include package/pkg-perl.mk
  389. include package/pkg-python.mk
  390. include package/pkg-virtual.mk
  391. include package/pkg-generic.mk
  392. include package/pkg-kconfig.mk
  393. include package/pkg-rebar.mk
  394. include package/pkg-kernel-module.mk
  395. include package/pkg-waf.mk
  396. include package/pkg-golang.mk
  397. include package/pkg-meson.mk
  398. include package/pkg-qmake.mk
  399. include package/pkg-cargo.mk