Makefile.in 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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 FSL PowerPC there's SPE
  64. ifeq ($(BR2_powerpc_SPE),y)
  65. ABI = spe
  66. # MPC8540s are e500v1 with single precision FP
  67. ifeq ($(BR2_powerpc_8540),y)
  68. TARGET_ABI += -mabi=spe -mfloat-gprs=single -Wa,-me500
  69. endif
  70. ifeq ($(BR2_powerpc_8548),y)
  71. TARGET_ABI += -mabi=spe -mfloat-gprs=double -Wa,-me500x2
  72. endif
  73. ifeq ($(BR2_powerpc_e500mc),y)
  74. TARGET_ABI += -mabi=spe -mfloat-gprs=double -Wa,-me500mc
  75. endif
  76. endif
  77. # Use longcalls option for Xtensa globally.
  78. # The 'longcalls' option allows calls across a greater range of addresses,
  79. # and is required for some packages. While this option can degrade both
  80. # code size and performance, the linker can usually optimize away the
  81. # overhead when a call ends up within a certain range.
  82. #
  83. # Use auto-litpools for Xtensa globally.
  84. # Collecting literals into separate section can be advantageous if that
  85. # section is placed into DTCM at link time. This is applicable for code
  86. # running on bare metal, but makes no sense under linux, where userspace
  87. # is isolated from the physical memory details. OTOH placing literals into
  88. # separate section breaks build of huge source files, because l32r
  89. # instruction can only access literals in 256 KBytes range.
  90. #
  91. ifeq ($(BR2_xtensa),y)
  92. TARGET_ABI += -mlongcalls -mauto-litpools
  93. endif
  94. ifeq ($(BR2_arc)$(BR2_ARC_ATOMIC_EXT),yy)
  95. TARGET_ABI += -matomic
  96. endif
  97. STAGING_SUBDIR = $(GNU_TARGET_NAME)/sysroot
  98. STAGING_DIR = $(HOST_DIR)/$(STAGING_SUBDIR)
  99. ifeq ($(BR2_OPTIMIZE_0),y)
  100. TARGET_OPTIMIZATION = -O0
  101. endif
  102. ifeq ($(BR2_OPTIMIZE_1),y)
  103. TARGET_OPTIMIZATION = -O1
  104. endif
  105. ifeq ($(BR2_OPTIMIZE_2),y)
  106. TARGET_OPTIMIZATION = -O2
  107. endif
  108. ifeq ($(BR2_OPTIMIZE_3),y)
  109. TARGET_OPTIMIZATION = -O3
  110. endif
  111. ifeq ($(BR2_OPTIMIZE_G),y)
  112. TARGET_OPTIMIZATION = -Og
  113. endif
  114. ifeq ($(BR2_OPTIMIZE_S),y)
  115. TARGET_OPTIMIZATION = -Os
  116. endif
  117. ifeq ($(BR2_OPTIMIZE_FAST),y)
  118. TARGET_OPTIMIZATION = -Ofast
  119. endif
  120. ifeq ($(BR2_DEBUG_1),y)
  121. TARGET_DEBUGGING = -g1
  122. endif
  123. ifeq ($(BR2_DEBUG_2),y)
  124. TARGET_DEBUGGING = -g2
  125. endif
  126. ifeq ($(BR2_DEBUG_3),y)
  127. TARGET_DEBUGGING = -g3
  128. endif
  129. TARGET_CFLAGS_RELRO = -Wl,-z,relro
  130. TARGET_CFLAGS_RELRO_FULL = -Wl,-z,now $(TARGET_CFLAGS_RELRO)
  131. TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS))
  132. ifeq ($(BR2_SSP_REGULAR),y)
  133. TARGET_CPPFLAGS += -fstack-protector
  134. else ifeq ($(BR2_SSP_STRONG),y)
  135. TARGET_CPPFLAGS += -fstack-protector-strong
  136. else ifeq ($(BR2_SSP_ALL),y)
  137. TARGET_CPPFLAGS += -fstack-protector-all
  138. endif
  139. ifeq ($(BR2_RELRO_PARTIAL),y)
  140. TARGET_CPPFLAGS += $(TARGET_CFLAGS_RELRO)
  141. TARGET_LDFLAGS += $(TARGET_CFLAGS_RELRO)
  142. else ifeq ($(BR2_RELRO_FULL),y)
  143. TARGET_CPPFLAGS += -fPIE $(TARGET_CFLAGS_RELRO_FULL)
  144. TARGET_LDFLAGS += -pie
  145. endif
  146. ifeq ($(BR2_FORTIFY_SOURCE_1),y)
  147. TARGET_CPPFLAGS += -D_FORTIFY_SOURCE=1
  148. else ifeq ($(BR2_FORTIFY_SOURCE_2),y)
  149. TARGET_CPPFLAGS += -D_FORTIFY_SOURCE=2
  150. endif
  151. TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
  152. TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
  153. TARGET_CXXFLAGS = $(TARGET_CFLAGS)
  154. TARGET_FCFLAGS = $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
  155. ifeq ($(BR2_BINFMT_FLAT),y)
  156. TARGET_CFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
  157. -Wl$(comma)-elf2flt)
  158. TARGET_CXXFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
  159. -Wl$(comma)-elf2flt)
  160. TARGET_FCFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
  161. -Wl$(comma)-elf2flt)
  162. TARGET_LDFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt)
  163. endif
  164. ifeq ($(BR2_BINFMT_FLAT_SHARED),y)
  165. TARGET_LDFLAGS += -mid-shared-library -mshared-library-id=0
  166. TARGET_CFLAGS += -mid-shared-library -mshared-library-id=0
  167. TARGET_FCFLAGS += -mid-shared-library -mshared-library-id=0
  168. TARGET_CXXFLAGS += -mid-shared-library -mshared-library-id=0
  169. endif
  170. ifeq ($(BR2_BINFMT_FLAT_SEP_DATA),y)
  171. TARGET_LDFLAGS += -msep-data
  172. TARGET_CFLAGS += -msep-data
  173. TARGET_FCFLAGS += -msep-data
  174. TARGET_CXXFLAGS += -msep-data
  175. endif
  176. ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
  177. TARGET_CROSS = $(HOST_DIR)/bin/$(GNU_TARGET_NAME)-
  178. else
  179. TARGET_CROSS = $(HOST_DIR)/bin/$(TOOLCHAIN_EXTERNAL_PREFIX)-
  180. endif
  181. # Define TARGET_xx variables for all common binutils/gcc
  182. TARGET_AR = $(TARGET_CROSS)ar
  183. TARGET_AS = $(TARGET_CROSS)as
  184. TARGET_CC = $(TARGET_CROSS)gcc
  185. TARGET_CPP = $(TARGET_CROSS)cpp
  186. TARGET_CXX = $(TARGET_CROSS)g++
  187. TARGET_FC = $(TARGET_CROSS)gfortran
  188. TARGET_LD = $(TARGET_CROSS)ld
  189. TARGET_NM = $(TARGET_CROSS)nm
  190. TARGET_RANLIB = $(TARGET_CROSS)ranlib
  191. TARGET_READELF = $(TARGET_CROSS)readelf
  192. TARGET_OBJCOPY = $(TARGET_CROSS)objcopy
  193. TARGET_OBJDUMP = $(TARGET_CROSS)objdump
  194. ifeq ($(BR2_STRIP_strip),y)
  195. STRIP_STRIP_DEBUG := --strip-debug
  196. TARGET_STRIP = $(TARGET_CROSS)strip
  197. STRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
  198. else
  199. TARGET_STRIP = /bin/true
  200. STRIPCMD = $(TARGET_STRIP)
  201. endif
  202. INSTALL := $(shell which install || type -p install)
  203. FLEX := $(shell which flex || type -p flex)
  204. BISON := $(shell which bison || type -p bison)
  205. UNZIP := $(shell which unzip || type -p unzip) -q
  206. APPLY_PATCHES = PATH=$(HOST_DIR)/bin:$$PATH support/scripts/apply-patches.sh $(if $(QUIET),-s)
  207. HOST_CPPFLAGS = -I$(HOST_DIR)/include
  208. HOST_CFLAGS ?= -O2
  209. HOST_CFLAGS += $(HOST_CPPFLAGS)
  210. HOST_CXXFLAGS += $(HOST_CFLAGS)
  211. HOST_LDFLAGS += -L$(HOST_DIR)/lib -Wl,-rpath,$(HOST_DIR)/lib
  212. # The macros below are taken from linux 4.11 and adapted slightly.
  213. # Copy more when needed.
  214. # try-run
  215. # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
  216. # Exit code chooses option. "$$TMP" is can be used as temporary file and
  217. # is automatically cleaned up.
  218. try-run = $(shell set -e; \
  219. TMP="$$(tempfile)"; \
  220. if ($(1)) >/dev/null 2>&1; \
  221. then echo "$(2)"; \
  222. else echo "$(3)"; \
  223. fi; \
  224. rm -f "$$TMP")
  225. # host-cc-option
  226. # Usage: HOST_FOO_CFLAGS += $(call host-cc-option,-no-pie,)
  227. host-cc-option = $(call try-run,\
  228. $(HOSTCC) $(HOST_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
  229. # host-intltool should be executed with the system perl, so we save
  230. # the path to the system perl, before a host-perl built by Buildroot
  231. # might get installed into $(HOST_DIR)/bin and therefore appears
  232. # in our PATH. This system perl will be used as INTLTOOL_PERL.
  233. export PERL=$(shell which perl)
  234. # host-intltool needs libxml-parser-perl, which Buildroot installs in
  235. # $(HOST_DIR)/lib/perl, so we must make sure that the system perl
  236. # finds this perl module by exporting the proper value for PERL5LIB.
  237. export PERL5LIB=$(HOST_DIR)/lib/perl
  238. TARGET_MAKE_ENV = PATH=$(BR_PATH)
  239. TARGET_CONFIGURE_OPTS = \
  240. $(TARGET_MAKE_ENV) \
  241. AR="$(TARGET_AR)" \
  242. AS="$(TARGET_AS)" \
  243. LD="$(TARGET_LD)" \
  244. NM="$(TARGET_NM)" \
  245. CC="$(TARGET_CC)" \
  246. GCC="$(TARGET_CC)" \
  247. CPP="$(TARGET_CPP)" \
  248. CXX="$(TARGET_CXX)" \
  249. FC="$(TARGET_FC)" \
  250. F77="$(TARGET_FC)" \
  251. RANLIB="$(TARGET_RANLIB)" \
  252. READELF="$(TARGET_READELF)" \
  253. STRIP="$(TARGET_STRIP)" \
  254. OBJCOPY="$(TARGET_OBJCOPY)" \
  255. OBJDUMP="$(TARGET_OBJDUMP)" \
  256. AR_FOR_BUILD="$(HOSTAR)" \
  257. AS_FOR_BUILD="$(HOSTAS)" \
  258. CC_FOR_BUILD="$(HOSTCC)" \
  259. GCC_FOR_BUILD="$(HOSTCC)" \
  260. CXX_FOR_BUILD="$(HOSTCXX)" \
  261. LD_FOR_BUILD="$(HOSTLD)" \
  262. CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)" \
  263. CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
  264. CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
  265. LDFLAGS_FOR_BUILD="$(HOST_LDFLAGS)" \
  266. FCFLAGS_FOR_BUILD="$(HOST_FCFLAGS)" \
  267. DEFAULT_ASSEMBLER="$(TARGET_AS)" \
  268. DEFAULT_LINKER="$(TARGET_LD)" \
  269. CPPFLAGS="$(TARGET_CPPFLAGS)" \
  270. CFLAGS="$(TARGET_CFLAGS)" \
  271. CXXFLAGS="$(TARGET_CXXFLAGS)" \
  272. LDFLAGS="$(TARGET_LDFLAGS)" \
  273. FCFLAGS="$(TARGET_FCFLAGS)" \
  274. FFLAGS="$(TARGET_FCFLAGS)" \
  275. PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
  276. STAGING_DIR="$(STAGING_DIR)" \
  277. INTLTOOL_PERL=$(PERL)
  278. HOST_MAKE_ENV = \
  279. PATH=$(BR_PATH) \
  280. PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
  281. PKG_CONFIG_SYSROOT_DIR="/" \
  282. PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
  283. PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
  284. PKG_CONFIG_LIBDIR="$(HOST_DIR)/lib/pkgconfig:$(HOST_DIR)/share/pkgconfig"
  285. HOST_CONFIGURE_OPTS = \
  286. $(HOST_MAKE_ENV) \
  287. AR="$(HOSTAR)" \
  288. AS="$(HOSTAS)" \
  289. LD="$(HOSTLD)" \
  290. NM="$(HOSTNM)" \
  291. CC="$(HOSTCC)" \
  292. GCC="$(HOSTCC)" \
  293. CXX="$(HOSTCXX)" \
  294. CPP="$(HOSTCPP)" \
  295. OBJCOPY="$(HOSTOBJCOPY)" \
  296. RANLIB="$(HOSTRANLIB)" \
  297. CPPFLAGS="$(HOST_CPPFLAGS)" \
  298. CFLAGS="$(HOST_CFLAGS)" \
  299. CXXFLAGS="$(HOST_CXXFLAGS)" \
  300. LDFLAGS="$(HOST_LDFLAGS)" \
  301. INTLTOOL_PERL=$(PERL)
  302. # This is extra environment we can not export ourselves (eg. because some
  303. # packages use that variable internally, eg. uboot), so we have to
  304. # explicitly pass it to user-supplied external hooks (eg. post-build,
  305. # post-images)
  306. EXTRA_ENV = \
  307. PATH=$(BR_PATH) \
  308. BR2_DL_DIR=$(BR2_DL_DIR) \
  309. BUILD_DIR=$(BUILD_DIR) \
  310. O=$(CANONICAL_O)
  311. ################################################################################
  312. # settings we need to pass to configure
  313. # does unaligned access trap?
  314. BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=yes
  315. ifeq ($(BR2_i386),y)
  316. BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
  317. endif
  318. ifeq ($(BR2_x86_64),y)
  319. BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
  320. endif
  321. ifeq ($(BR2_m68k),y)
  322. BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
  323. endif
  324. ifeq ($(BR2_powerpc)$(BR2_powerpc64)$(BR2_powerpc64le),y)
  325. BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
  326. endif
  327. ifeq ($(BR2_ENDIAN),"BIG")
  328. BR2_AC_CV_C_BIGENDIAN = ac_cv_c_bigendian=yes
  329. else
  330. BR2_AC_CV_C_BIGENDIAN = ac_cv_c_bigendian=no
  331. endif
  332. # AM_GNU_GETTEXT misdetects musl gettext support.
  333. # musl currently implements api level 1 and 2 (basic + ngettext)
  334. # http://www.openwall.com/lists/musl/2015/04/16/3
  335. #
  336. # These autoconf variables should only be pre-seeded when the minimal
  337. # gettext implementation of musl is used. When the full blown
  338. # implementation provided by gettext libintl is used, auto-detection
  339. # works fine, and pre-seeding those values is actually wrong.
  340. ifeq ($(BR2_TOOLCHAIN_USES_MUSL):$(BR2_PACKAGE_GETTEXT_PROVIDES_LIBINTL),y:)
  341. BR2_GT_CV_FUNC_GNUGETTEXT_LIBC = \
  342. gt_cv_func_gnugettext1_libc=yes \
  343. gt_cv_func_gnugettext2_libc=yes
  344. endif
  345. TARGET_CONFIGURE_ARGS = \
  346. $(BR2_AC_CV_TRAP_CHECK) \
  347. ac_cv_func_mmap_fixed_mapped=yes \
  348. ac_cv_func_memcmp_working=yes \
  349. ac_cv_have_decl_malloc=yes \
  350. gl_cv_func_malloc_0_nonnull=yes \
  351. ac_cv_func_malloc_0_nonnull=yes \
  352. ac_cv_func_calloc_0_nonnull=yes \
  353. ac_cv_func_realloc_0_nonnull=yes \
  354. lt_cv_sys_lib_search_path_spec="" \
  355. $(BR2_AC_CV_C_BIGENDIAN) \
  356. $(BR2_GT_CV_FUNC_GNUGETTEXT_LIBC)
  357. ################################################################################
  358. ifeq ($(BR2_SYSTEM_ENABLE_NLS),y)
  359. NLS_OPTS = --enable-nls
  360. TARGET_NLS_DEPENDENCIES = host-gettext
  361. ifeq ($(BR2_PACKAGE_GETTEXT_PROVIDES_LIBINTL),y)
  362. TARGET_NLS_DEPENDENCIES += gettext
  363. TARGET_NLS_LIBS += -lintl
  364. endif
  365. else
  366. NLS_OPTS = --disable-nls
  367. endif
  368. ifneq ($(BR2_INSTALL_LIBSTDCPP),y)
  369. TARGET_CONFIGURE_OPTS += CXX=false CXXCPP=cpp
  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. ifeq ($(BR2_COMPILER_PARANOID_UNSAFE_PATH),y)
  383. export BR_COMPILER_PARANOID_UNSAFE_PATH=enabled
  384. endif
  385. include package/pkg-download.mk
  386. include package/pkg-autotools.mk
  387. include package/pkg-cmake.mk
  388. include package/pkg-luarocks.mk
  389. include package/pkg-perl.mk
  390. include package/pkg-python.mk
  391. include package/pkg-virtual.mk
  392. include package/pkg-generic.mk
  393. include package/pkg-kconfig.mk
  394. include package/pkg-rebar.mk
  395. include package/pkg-kernel-module.mk
  396. include package/pkg-waf.mk