7 HOSTMAKE := $(shell which $(HOSTMAKE) || type -p $(HOSTMAKE) || echo make)
9 # If BR2_JLEVEL is 0, scale the maximum concurrency with the number of
10 # CPUs. An additional job is used in order to keep processors busy
11 # while waiting on I/O.
12 # If the number of processors is not available, assume one.
13 ifeq ($(BR2_JLEVEL),0)
14 PARALLEL_JOBS := $(shell echo \
15 $$((1 + `getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1`)))
17 PARALLEL_JOBS := $(BR2_JLEVEL)
20 MAKE1 := $(HOSTMAKE) -j1
21 MAKE := $(HOSTMAKE) $(if $(PARALLEL_JOBS),-j$(PARALLEL_JOBS))
23 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
24 TARGET_VENDOR = $(call qstrip,$(BR2_TOOLCHAIN_BUILDROOT_VENDOR))
26 TARGET_VENDOR = buildroot
30 ifeq ($(TARGET_VENDOR),)
31 $(error BR2_TOOLCHAIN_BUILDROOT_VENDOR is not allowed to be empty)
33 ifeq ($(TARGET_VENDOR),unknown)
34 $(error BR2_TOOLCHAIN_BUILDROOT_VENDOR cannot be 'unknown'. \
35 It might be confused with the native toolchain)
38 # Compute GNU_TARGET_NAME
39 GNU_TARGET_NAME = $(ARCH)-$(TARGET_VENDOR)-$(TARGET_OS)-$(LIBC)$(ABI)
41 # FLAT binary format needs uclinux
42 ifeq ($(BR2_BINFMT_FLAT),y)
48 ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
50 else ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
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)
67 ifeq ($(BR2_ARM_EABIHF),y)
72 # For FSL PowerPC there's SPE
73 ifeq ($(BR2_powerpc_SPE),y)
75 # MPC8540s are e500v1 with single precision FP
76 ifeq ($(BR2_powerpc_8540),y)
77 TARGET_ABI += -mabi=spe -mfloat-gprs=single -Wa,-me500
79 ifeq ($(BR2_powerpc_8548),y)
80 TARGET_ABI += -mabi=spe -mfloat-gprs=double -Wa,-me500x2
82 ifeq ($(BR2_powerpc_e500mc),y)
83 TARGET_ABI += -mabi=spe -mfloat-gprs=double -Wa,-me500mc
87 # Use longcalls option for Xtensa globally.
88 # The 'longcalls' option allows calls across a greater range of addresses,
89 # and is required for some packages. While this option can degrade both
90 # code size and performance, the linker can usually optimize away the
91 # overhead when a call ends up within a certain range.
93 # Use text-section-literals for Xtensa globally.
94 # Collecting literals into separate section can be advantageous if that
95 # section is placed into DTCM at link time. This is applicable for code
96 # running on bare metal, but makes no sense under linux, where userspace
97 # is isolated from the physical memory details. OTOH placing literals into
98 # separate section breaks build of huge source files, because l32r
99 # instruction can only access literals in 256 KBytes range.
101 ifeq ($(BR2_xtensa),y)
102 TARGET_ABI += -mlongcalls -mtext-section-literals
105 ifeq ($(BR2_arc)$(BR2_ARC_ATOMIC_EXT),yy)
106 TARGET_ABI += -matomic
109 STAGING_SUBDIR = usr/$(GNU_TARGET_NAME)/sysroot
110 STAGING_DIR = $(HOST_DIR)/$(STAGING_SUBDIR)
112 TARGET_OPTIMIZATION := $(call qstrip,$(BR2_TARGET_OPTIMIZATION))
114 ifeq ($(BR2_OPTIMIZE_0),y)
115 TARGET_OPTIMIZATION += -O0
117 ifeq ($(BR2_OPTIMIZE_1),y)
118 TARGET_OPTIMIZATION += -O1
120 ifeq ($(BR2_OPTIMIZE_2),y)
121 TARGET_OPTIMIZATION += -O2
123 ifeq ($(BR2_OPTIMIZE_3),y)
124 TARGET_OPTIMIZATION += -O3
126 ifeq ($(BR2_OPTIMIZE_S),y)
127 TARGET_OPTIMIZATION += -Os
129 ifeq ($(BR2_DEBUG_1),y)
130 TARGET_DEBUGGING = -g1
132 ifeq ($(BR2_DEBUG_2),y)
133 TARGET_DEBUGGING = -g2
135 ifeq ($(BR2_DEBUG_3),y)
136 TARGET_DEBUGGING = -g3
139 TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
140 TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
141 TARGET_CXXFLAGS = $(TARGET_CFLAGS)
142 TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS))
144 ifeq ($(BR2_BINFMT_FLAT),y)
145 TARGET_CFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
147 TARGET_CXXFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
149 TARGET_LDFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),-elf2flt)
152 ifeq ($(BR2_BINFMT_FLAT_SHARED),y)
153 TARGET_LDFLAGS += -mid-shared-library -mshared-library-id=0
154 TARGET_CFLAGS += -mid-shared-library -mshared-library-id=0
155 TARGET_CXXFLAGS += -mid-shared-library -mshared-library-id=0
157 ifeq ($(BR2_BINFMT_FLAT_SEP_DATA),y)
158 TARGET_LDFLAGS += -msep-data
159 TARGET_CFLAGS += -msep-data
160 TARGET_CXXFLAGS += -msep-data
163 ifeq ($(BR2_ENABLE_SSP),y)
164 TARGET_CFLAGS += -fstack-protector-all
165 TARGET_CXXFLAGS += -fstack-protector-all
168 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
169 TARGET_CROSS = $(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-
171 TARGET_CROSS = $(HOST_DIR)/usr/bin/$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PREFIX))-
174 # Define TARGET_xx variables for all common binutils/gcc
175 TARGET_AR = $(TARGET_CROSS)ar
176 TARGET_AS = $(TARGET_CROSS)as
177 TARGET_CC = $(TARGET_CROSS)gcc
178 TARGET_CPP = $(TARGET_CROSS)cpp
179 TARGET_CXX = $(TARGET_CROSS)g++
180 TARGET_FC = $(TARGET_CROSS)gfortran
181 TARGET_LD = $(TARGET_CROSS)ld
182 TARGET_NM = $(TARGET_CROSS)nm
183 TARGET_RANLIB = $(TARGET_CROSS)ranlib
184 TARGET_READELF = $(TARGET_CROSS)readelf
185 TARGET_OBJCOPY = $(TARGET_CROSS)objcopy
186 TARGET_OBJDUMP = $(TARGET_CROSS)objdump
188 TARGET_CC_NOCCACHE := $(TARGET_CC)
189 TARGET_CXX_NOCCACHE := $(TARGET_CXX)
191 ifeq ($(BR2_CCACHE),y)
192 TARGET_CC := $(CCACHE) $(TARGET_CC)
193 TARGET_CXX := $(CCACHE) $(TARGET_CXX)
196 ifeq ($(BR2_STRIP_strip),y)
197 STRIP_STRIP_DEBUG := --strip-debug
198 STRIP_STRIP_UNNEEDED := --strip-unneeded
199 STRIP_STRIP_ALL := --strip-all
200 TARGET_STRIP = $(TARGET_CROSS)strip
201 STRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
202 KSTRIPCMD = $(STRIPCMD) $(STRIP_STRIP_UNNEEDED)
204 ifeq ($(BR2_STRIP_sstrip),y)
206 STRIP_STRIP_UNNEEDED :=
208 TARGET_STRIP = $(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-sstrip
209 STRIPCMD = $(TARGET_STRIP)
210 KSTRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note --strip-unneeded
212 ifeq ($(BR2_STRIP_none),y)
214 STRIPCMD = $(TARGET_STRIP)
215 KSTRIPCMD = $(TARGET_STRIP)
217 INSTALL := $(shell which install || type -p install)
218 FLEX := $(shell which flex || type -p flex)
219 BISON := $(shell which bison || type -p bison)
220 SED := $(shell which sed || type -p sed) -i -e
221 UNZIP := $(shell which unzip || type -p unzip) -q
223 APPLY_PATCHES = support/scripts/apply-patches.sh $(if $(QUIET),-s)
225 HOST_CPPFLAGS = -I$(HOST_DIR)/usr/include
227 HOST_CFLAGS += $(HOST_CPPFLAGS)
228 HOST_CXXFLAGS += $(HOST_CFLAGS)
229 HOST_LDFLAGS += -L$(HOST_DIR)/lib -L$(HOST_DIR)/usr/lib -Wl,-rpath,$(HOST_DIR)/usr/lib
231 # hostcc version as an integer - E.G. 4.3.2 => 432
232 HOSTCC_VERSION := $(shell $(HOSTCC_NOCCACHE) --version | \
233 sed -n 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)[ ]*.*$$/\1\2\3/p')
235 # host-intltool should be executed with the system perl, so we save
236 # the path to the system perl, before a host-perl built by Buildroot
237 # might get installed into $(HOST_DIR)/usr/bin and therefore appears
238 # in our PATH. This system perl will be used as INTLTOOL_PERL.
239 export PERL=$(shell which perl)
241 # host-intltool needs libxml-parser-perl, which Buildroot installs in
242 # $(HOST_DIR)/usr/lib/perl, so we must make sure that the system perl
243 # finds this perl module by exporting the proper value for PERL5LIB.
244 export PERL5LIB=$(HOST_DIR)/usr/lib/perl
246 TARGET_CONFIGURE_OPTS = \
254 CPP="$(TARGET_CPP)" \
255 CXX="$(TARGET_CXX)" \
257 RANLIB="$(TARGET_RANLIB)" \
258 READELF="$(TARGET_READELF)" \
259 STRIP="$(TARGET_STRIP)" \
260 OBJCOPY="$(TARGET_OBJCOPY)" \
261 OBJDUMP="$(TARGET_OBJDUMP)" \
262 AR_FOR_BUILD="$(HOSTAR)" \
263 AS_FOR_BUILD="$(HOSTAS)" \
264 CC_FOR_BUILD="$(HOSTCC)" \
265 GCC_FOR_BUILD="$(HOSTCC)" \
266 CXX_FOR_BUILD="$(HOSTCXX)" \
267 LD_FOR_BUILD="$(HOSTLD)" \
268 CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)" \
269 CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
270 CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
271 LDFLAGS_FOR_BUILD="$(HOST_LDFLAGS)" \
272 FCFLAGS_FOR_BUILD="$(HOST_FCFLAGS)" \
273 DEFAULT_ASSEMBLER="$(TARGET_AS)" \
274 DEFAULT_LINKER="$(TARGET_LD)" \
275 CPPFLAGS="$(TARGET_CPPFLAGS)" \
276 CFLAGS="$(TARGET_CFLAGS)" \
277 CXXFLAGS="$(TARGET_CXXFLAGS)" \
278 LDFLAGS="$(TARGET_LDFLAGS)" \
279 FCFLAGS="$(TARGET_FCFLAGS)" \
280 PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
281 STAGING_DIR="$(STAGING_DIR)" \
282 INTLTOOL_PERL=$(PERL)
284 TARGET_MAKE_ENV = PATH=$(BR_PATH)
287 HOST_CONFIGURE_OPTS = \
297 OBJCOPY="$(HOSTOBJCOPY)" \
298 RANLIB="$(HOSTRANLIB)" \
299 CPPFLAGS="$(HOST_CPPFLAGS)" \
300 CFLAGS="$(HOST_CFLAGS)" \
301 CXXFLAGS="$(HOST_CXXFLAGS)" \
302 LDFLAGS="$(HOST_LDFLAGS)" \
303 PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
304 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
305 PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
306 PKG_CONFIG_SYSROOT_DIR="/" \
307 PKG_CONFIG_LIBDIR="$(HOST_DIR)/usr/lib/pkgconfig:$(HOST_DIR)/usr/share/pkgconfig" \
308 LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib$(if $(LD_LIBRARY_PATH),:$(LD_LIBRARY_PATH))" \
309 INTLTOOL_PERL=$(PERL)
313 LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib$(if $(LD_LIBRARY_PATH),:$(LD_LIBRARY_PATH))" \
314 PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
315 PKG_CONFIG_SYSROOT_DIR="/" \
316 PKG_CONFIG_LIBDIR="$(HOST_DIR)/usr/lib/pkgconfig"
318 # This is extra environment we can not export ourselves (eg. because some
319 # packages use that variable internally, eg. uboot), so we have to
320 # explicitly pass it to user-supplied external hooks (eg. post-build,
324 BR2_DL_DIR=$(BR2_DL_DIR) \
325 BUILD_DIR=$(BUILD_DIR) \
326 BR2_EXTERNAL=$(BR2_EXTERNAL)
328 ################################################################################
329 # settings we need to pass to configure
331 # does unaligned access trap?
332 BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=yes
334 BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
336 ifeq ($(BR2_x86_64),y)
337 BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
340 BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
342 ifeq ($(BR2_powerpc)$(BR2_powerpc64)$(BR2_powerpc64le),y)
343 BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
346 ifeq ($(BR2_ENDIAN),"BIG")
347 BR2_AC_CV_C_BIGENDIAN = ac_cv_c_bigendian=yes
349 BR2_AC_CV_C_BIGENDIAN = ac_cv_c_bigendian=no
352 TARGET_CONFIGURE_ARGS = \
353 $(BR2_AC_CV_TRAP_CHECK) \
354 ac_cv_func_mmap_fixed_mapped=yes \
355 ac_cv_func_memcmp_working=yes \
356 ac_cv_have_decl_malloc=yes \
357 gl_cv_func_malloc_0_nonnull=yes \
358 ac_cv_func_malloc_0_nonnull=yes \
359 ac_cv_func_calloc_0_nonnull=yes \
360 ac_cv_func_realloc_0_nonnull=yes \
361 lt_cv_sys_lib_search_path_spec="" \
362 $(BR2_AC_CV_C_BIGENDIAN)
364 ################################################################################
366 ifeq ($(BR2_ENABLE_LOCALE),y)
369 DISABLE_NLS :=--disable-nls
372 ifneq ($(BR2_INSTALL_LIBSTDCPP),y)
373 TARGET_CONFIGURE_OPTS += CXX=false
376 ifeq ($(BR2_ENABLE_DEBUG),y)
377 ENABLE_DEBUG := --enable-debug
379 ENABLE_DEBUG := --disable-debug
382 ifeq ($(BR2_STATIC_LIBS),y)
383 SHARED_STATIC_LIBS_OPTS = --enable-static --disable-shared
384 TARGET_CFLAGS += -static
385 TARGET_CXXFLAGS += -static
386 TARGET_LDFLAGS += -static
387 else ifeq ($(BR2_SHARED_LIBS),y)
388 SHARED_STATIC_LIBS_OPTS = --disable-static --enable-shared
389 else ifeq ($(BR2_SHARED_STATIC_LIBS),y)
390 SHARED_STATIC_LIBS_OPTS = --enable-static --enable-shared
393 ifeq ($(BR2_COMPILER_PARANOID_UNSAFE_PATH),y)
394 export BR_COMPILER_PARANOID_UNSAFE_PATH=enabled
397 include package/pkg-download.mk
398 include package/pkg-autotools.mk
399 include package/pkg-cmake.mk
400 include package/pkg-luarocks.mk
401 include package/pkg-perl.mk
402 include package/pkg-python.mk
403 include package/pkg-virtual.mk
404 include package/pkg-generic.mk
405 include package/pkg-kconfig.mk
406 include package/pkg-rebar.mk