Makefile.in 13 KB

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