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