luv: remove the default value of the $(PKG)_SOURCE variable
[buildroot-gz.git] / package / Makefile.in
blobca34660a6f6265a534be3f26c8387fdd78f6b42a
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)
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
20 MAKE1 := $(HOSTMAKE) -j1
21 override MAKE = $(HOSTMAKE) \
22 $(if $(findstring j,$(filter-out --%,$(MAKEFLAGS))),,-j$(PARALLEL_JOBS))
24 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
25 TARGET_VENDOR = $(call qstrip,$(BR2_TOOLCHAIN_BUILDROOT_VENDOR))
26 else
27 TARGET_VENDOR = buildroot
28 endif
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
39 # Compute GNU_TARGET_NAME
40 GNU_TARGET_NAME = $(ARCH)-$(TARGET_VENDOR)-$(TARGET_OS)-$(LIBC)$(ABI)
42 # FLAT binary format needs uclinux
43 ifeq ($(BR2_BINFMT_FLAT),y)
44 TARGET_OS = uclinux
45 else
46 TARGET_OS = linux
47 endif
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
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
68 ifeq ($(BR2_ARM_EABIHF),y)
69 ABI := $(ABI)hf
70 endif
71 endif
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
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.
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.
102 ifeq ($(BR2_xtensa),y)
103 TARGET_ABI += -mlongcalls -mauto-litpools
104 endif
106 ifeq ($(BR2_arc)$(BR2_ARC_ATOMIC_EXT),yy)
107 TARGET_ABI += -matomic
108 endif
110 STAGING_SUBDIR = usr/$(GNU_TARGET_NAME)/sysroot
111 STAGING_DIR = $(HOST_DIR)/$(STAGING_SUBDIR)
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_S),y)
126 TARGET_OPTIMIZATION = -Os
127 endif
128 ifeq ($(BR2_DEBUG_1),y)
129 TARGET_DEBUGGING = -g1
130 endif
131 ifeq ($(BR2_DEBUG_2),y)
132 TARGET_DEBUGGING = -g2
133 endif
134 ifeq ($(BR2_DEBUG_3),y)
135 TARGET_DEBUGGING = -g3
136 endif
138 TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
139 TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
140 TARGET_CXXFLAGS = $(TARGET_CFLAGS)
141 TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS))
143 ifeq ($(BR2_BINFMT_FLAT),y)
144 TARGET_CFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
145 -Wl$(comma)-elf2flt)
146 TARGET_CXXFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
147 -Wl$(comma)-elf2flt)
148 TARGET_LDFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),-elf2flt)
149 endif
151 ifeq ($(BR2_BINFMT_FLAT_SHARED),y)
152 TARGET_LDFLAGS += -mid-shared-library -mshared-library-id=0
153 TARGET_CFLAGS += -mid-shared-library -mshared-library-id=0
154 TARGET_CXXFLAGS += -mid-shared-library -mshared-library-id=0
155 endif
156 ifeq ($(BR2_BINFMT_FLAT_SEP_DATA),y)
157 TARGET_LDFLAGS += -msep-data
158 TARGET_CFLAGS += -msep-data
159 TARGET_CXXFLAGS += -msep-data
160 endif
162 ifeq ($(BR2_ENABLE_SSP),y)
163 TARGET_CFLAGS += -fstack-protector-all
164 TARGET_CXXFLAGS += -fstack-protector-all
165 endif
167 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
168 TARGET_CROSS = $(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-
169 else
170 TARGET_CROSS = $(HOST_DIR)/usr/bin/$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PREFIX))-
171 endif
173 # Define TARGET_xx variables for all common binutils/gcc
174 TARGET_AR = $(TARGET_CROSS)ar
175 TARGET_AS = $(TARGET_CROSS)as
176 TARGET_CC = $(TARGET_CROSS)gcc
177 TARGET_CPP = $(TARGET_CROSS)cpp
178 TARGET_CXX = $(TARGET_CROSS)g++
179 TARGET_FC = $(TARGET_CROSS)gfortran
180 TARGET_LD = $(TARGET_CROSS)ld
181 TARGET_NM = $(TARGET_CROSS)nm
182 TARGET_RANLIB = $(TARGET_CROSS)ranlib
183 TARGET_READELF = $(TARGET_CROSS)readelf
184 TARGET_OBJCOPY = $(TARGET_CROSS)objcopy
185 TARGET_OBJDUMP = $(TARGET_CROSS)objdump
187 ifeq ($(BR2_STRIP_strip),y)
188 STRIP_STRIP_DEBUG := --strip-debug
189 STRIP_STRIP_UNNEEDED := --strip-unneeded
190 STRIP_STRIP_ALL := --strip-all
191 TARGET_STRIP = $(TARGET_CROSS)strip
192 STRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
193 KSTRIPCMD = $(STRIPCMD) $(STRIP_STRIP_UNNEEDED)
194 endif
195 ifeq ($(BR2_STRIP_sstrip),y)
196 STRIP_STRIP_DEBUG :=
197 STRIP_STRIP_UNNEEDED :=
198 STRIP_STRIP_ALL :=
199 TARGET_STRIP = $(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-sstrip
200 STRIPCMD = $(TARGET_STRIP)
201 KSTRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note --strip-unneeded
202 endif
203 ifeq ($(BR2_STRIP_none),y)
204 TARGET_STRIP = true
205 STRIPCMD = $(TARGET_STRIP)
206 KSTRIPCMD = $(TARGET_STRIP)
207 endif
208 INSTALL := $(shell which install || type -p install)
209 FLEX := $(shell which flex || type -p flex)
210 BISON := $(shell which bison || type -p bison)
211 SED := $(shell which sed || type -p sed) -i -e
212 UNZIP := $(shell which unzip || type -p unzip) -q
214 APPLY_PATCHES = support/scripts/apply-patches.sh $(if $(QUIET),-s)
216 HOST_CPPFLAGS = -I$(HOST_DIR)/usr/include
217 HOST_CFLAGS ?= -O2
218 HOST_CFLAGS += $(HOST_CPPFLAGS)
219 HOST_CXXFLAGS += $(HOST_CFLAGS)
220 HOST_LDFLAGS += -L$(HOST_DIR)/lib -L$(HOST_DIR)/usr/lib -Wl,-rpath,$(HOST_DIR)/usr/lib
222 # hostcc version as an integer - E.G. 4.3.2 => 432
223 HOSTCC_VERSION := $(shell $(HOSTCC_NOCCACHE) --version | \
224 sed -n 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)[ ]*.*$$/\1\2\3/p')
226 # host-intltool should be executed with the system perl, so we save
227 # the path to the system perl, before a host-perl built by Buildroot
228 # might get installed into $(HOST_DIR)/usr/bin and therefore appears
229 # in our PATH. This system perl will be used as INTLTOOL_PERL.
230 export PERL=$(shell which perl)
232 # host-intltool needs libxml-parser-perl, which Buildroot installs in
233 # $(HOST_DIR)/usr/lib/perl, so we must make sure that the system perl
234 # finds this perl module by exporting the proper value for PERL5LIB.
235 export PERL5LIB=$(HOST_DIR)/usr/lib/perl
237 TARGET_CONFIGURE_OPTS = \
238 PATH=$(BR_PATH) \
239 AR="$(TARGET_AR)" \
240 AS="$(TARGET_AS)" \
241 LD="$(TARGET_LD)" \
242 NM="$(TARGET_NM)" \
243 CC="$(TARGET_CC)" \
244 GCC="$(TARGET_CC)" \
245 CPP="$(TARGET_CPP)" \
246 CXX="$(TARGET_CXX)" \
247 FC="$(TARGET_FC)" \
248 RANLIB="$(TARGET_RANLIB)" \
249 READELF="$(TARGET_READELF)" \
250 STRIP="$(TARGET_STRIP)" \
251 OBJCOPY="$(TARGET_OBJCOPY)" \
252 OBJDUMP="$(TARGET_OBJDUMP)" \
253 AR_FOR_BUILD="$(HOSTAR)" \
254 AS_FOR_BUILD="$(HOSTAS)" \
255 CC_FOR_BUILD="$(HOSTCC)" \
256 GCC_FOR_BUILD="$(HOSTCC)" \
257 CXX_FOR_BUILD="$(HOSTCXX)" \
258 LD_FOR_BUILD="$(HOSTLD)" \
259 CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)" \
260 CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
261 CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
262 LDFLAGS_FOR_BUILD="$(HOST_LDFLAGS)" \
263 FCFLAGS_FOR_BUILD="$(HOST_FCFLAGS)" \
264 DEFAULT_ASSEMBLER="$(TARGET_AS)" \
265 DEFAULT_LINKER="$(TARGET_LD)" \
266 CPPFLAGS="$(TARGET_CPPFLAGS)" \
267 CFLAGS="$(TARGET_CFLAGS)" \
268 CXXFLAGS="$(TARGET_CXXFLAGS)" \
269 LDFLAGS="$(TARGET_LDFLAGS)" \
270 FCFLAGS="$(TARGET_FCFLAGS)" \
271 PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
272 STAGING_DIR="$(STAGING_DIR)" \
273 INTLTOOL_PERL=$(PERL)
275 TARGET_MAKE_ENV = PATH=$(BR_PATH)
278 HOST_CONFIGURE_OPTS = \
279 PATH=$(BR_PATH) \
280 AR="$(HOSTAR)" \
281 AS="$(HOSTAS)" \
282 LD="$(HOSTLD)" \
283 NM="$(HOSTNM)" \
284 CC="$(HOSTCC)" \
285 GCC="$(HOSTCC)" \
286 CXX="$(HOSTCXX)" \
287 CPP="$(HOSTCPP)" \
288 OBJCOPY="$(HOSTOBJCOPY)" \
289 RANLIB="$(HOSTRANLIB)" \
290 CPPFLAGS="$(HOST_CPPFLAGS)" \
291 CFLAGS="$(HOST_CFLAGS)" \
292 CXXFLAGS="$(HOST_CXXFLAGS)" \
293 LDFLAGS="$(HOST_LDFLAGS)" \
294 PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
295 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
296 PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
297 PKG_CONFIG_SYSROOT_DIR="/" \
298 PKG_CONFIG_LIBDIR="$(HOST_DIR)/usr/lib/pkgconfig:$(HOST_DIR)/usr/share/pkgconfig" \
299 LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib$(if $(LD_LIBRARY_PATH),:$(LD_LIBRARY_PATH))" \
300 INTLTOOL_PERL=$(PERL)
302 HOST_MAKE_ENV = \
303 PATH=$(BR_PATH) \
304 LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib$(if $(LD_LIBRARY_PATH),:$(LD_LIBRARY_PATH))" \
305 PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
306 PKG_CONFIG_SYSROOT_DIR="/" \
307 PKG_CONFIG_LIBDIR="$(HOST_DIR)/usr/lib/pkgconfig"
309 # This is extra environment we can not export ourselves (eg. because some
310 # packages use that variable internally, eg. uboot), so we have to
311 # explicitly pass it to user-supplied external hooks (eg. post-build,
312 # post-images)
313 EXTRA_ENV = \
314 PATH=$(BR_PATH) \
315 BR2_DL_DIR=$(BR2_DL_DIR) \
316 BUILD_DIR=$(BUILD_DIR) \
317 BR2_EXTERNAL=$(BR2_EXTERNAL)
319 ################################################################################
320 # settings we need to pass to configure
322 # does unaligned access trap?
323 BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=yes
324 ifeq ($(BR2_i386),y)
325 BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
326 endif
327 ifeq ($(BR2_x86_64),y)
328 BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
329 endif
330 ifeq ($(BR2_m68k),y)
331 BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
332 endif
333 ifeq ($(BR2_powerpc)$(BR2_powerpc64)$(BR2_powerpc64le),y)
334 BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
335 endif
337 ifeq ($(BR2_ENDIAN),"BIG")
338 BR2_AC_CV_C_BIGENDIAN = ac_cv_c_bigendian=yes
339 else
340 BR2_AC_CV_C_BIGENDIAN = ac_cv_c_bigendian=no
341 endif
343 TARGET_CONFIGURE_ARGS = \
344 $(BR2_AC_CV_TRAP_CHECK) \
345 ac_cv_func_mmap_fixed_mapped=yes \
346 ac_cv_func_memcmp_working=yes \
347 ac_cv_have_decl_malloc=yes \
348 gl_cv_func_malloc_0_nonnull=yes \
349 ac_cv_func_malloc_0_nonnull=yes \
350 ac_cv_func_calloc_0_nonnull=yes \
351 ac_cv_func_realloc_0_nonnull=yes \
352 lt_cv_sys_lib_search_path_spec="" \
353 $(BR2_AC_CV_C_BIGENDIAN)
355 ################################################################################
357 ifeq ($(BR2_ENABLE_LOCALE),y)
358 DISABLE_NLS :=
359 else
360 DISABLE_NLS :=--disable-nls
361 endif
363 ifneq ($(BR2_INSTALL_LIBSTDCPP),y)
364 TARGET_CONFIGURE_OPTS += CXX=false
365 endif
367 ifeq ($(BR2_STATIC_LIBS),y)
368 SHARED_STATIC_LIBS_OPTS = --enable-static --disable-shared
369 TARGET_CFLAGS += -static
370 TARGET_CXXFLAGS += -static
371 TARGET_LDFLAGS += -static
372 else ifeq ($(BR2_SHARED_LIBS),y)
373 SHARED_STATIC_LIBS_OPTS = --disable-static --enable-shared
374 else ifeq ($(BR2_SHARED_STATIC_LIBS),y)
375 SHARED_STATIC_LIBS_OPTS = --enable-static --enable-shared
376 endif
378 ifeq ($(BR2_COMPILER_PARANOID_UNSAFE_PATH),y)
379 export BR_COMPILER_PARANOID_UNSAFE_PATH=enabled
380 endif
382 include package/pkg-download.mk
383 include package/pkg-autotools.mk
384 include package/pkg-cmake.mk
385 include package/pkg-luarocks.mk
386 include package/pkg-perl.mk
387 include package/pkg-python.mk
388 include package/pkg-virtual.mk
389 include package/pkg-generic.mk
390 include package/pkg-kconfig.mk
391 include package/pkg-rebar.mk
392 include package/pkg-kernel-module.mk