pkg-autotools: move the libtool patching call out of the autoreconf hook
[buildroot-gz.git] / package / Makefile.in
blobdf39afd67b8aed645643155738cb95d30f136481
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_LEVEL 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 MAKE := $(HOSTMAKE) $(if $(PARALLEL_JOBS),-j$(PARALLEL_JOBS))
23 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
24 TARGET_VENDOR = $(call qstrip,$(BR2_TOOLCHAIN_BUILDROOT_VENDOR))
25 else
26 TARGET_VENDOR = buildroot
27 endif
29 # Sanity checks
30 ifeq ($(TARGET_VENDOR),)
31 $(error BR2_TOOLCHAIN_BUILDROOT_VENDOR is not allowed to be empty)
32 endif
33 ifeq ($(TARGET_VENDOR),unknown)
34 $(error BR2_TOOLCHAIN_BUILDROOT_VENDOR cannot be 'unknown'. \
35 It might be confused with the native toolchain)
36 endif
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)
43 TARGET_OS = uclinux
44 else
45 TARGET_OS = linux
46 endif
48 ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
49 LIBC = uclibc
50 else ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
51 LIBC = musl
52 else
53 LIBC = gnu
54 endif
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)
61 ifeq ($(LIBC),uclibc)
62 ABI = gnueabi
63 else
64 ABI = eabi
65 endif
67 ifeq ($(BR2_ARM_EABIHF),y)
68 ABI := $(ABI)hf
69 endif
70 endif
72 # For FSL PowerPC there's SPE
73 ifeq ($(BR2_powerpc_SPE),y)
74 ABI = spe
75 # MPC8540s are e500v1 with single precision FP
76 ifeq ($(BR2_powerpc_8540),y)
77 TARGET_ABI += -mabi=spe -mfloat-gprs=single -Wa,-me500
78 endif
79 ifeq ($(BR2_powerpc_8548),y)
80 TARGET_ABI += -mabi=spe -mfloat-gprs=double -Wa,-me500x2
81 endif
82 ifeq ($(BR2_powerpc_e500mc),y)
83 TARGET_ABI += -mabi=spe -mfloat-gprs=double -Wa,-me500mc
84 endif
85 endif
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
103 endif
105 ifeq ($(BR2_arc)$(BR2_ARC_ATOMIC_EXT),yy)
106 TARGET_ABI += -matomic
107 endif
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
116 endif
117 ifeq ($(BR2_OPTIMIZE_1),y)
118 TARGET_OPTIMIZATION += -O1
119 endif
120 ifeq ($(BR2_OPTIMIZE_2),y)
121 TARGET_OPTIMIZATION += -O2
122 endif
123 ifeq ($(BR2_OPTIMIZE_3),y)
124 TARGET_OPTIMIZATION += -O3
125 endif
126 ifeq ($(BR2_OPTIMIZE_S),y)
127 TARGET_OPTIMIZATION += -Os
128 endif
129 ifeq ($(BR2_DEBUG_1),y)
130 TARGET_DEBUGGING = -g1
131 endif
132 ifeq ($(BR2_DEBUG_2),y)
133 TARGET_DEBUGGING = -g2
134 endif
135 ifeq ($(BR2_DEBUG_3),y)
136 TARGET_DEBUGGING = -g3
137 endif
139 ifeq ($(BR2_LARGEFILE),y)
140 TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
141 endif
143 TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
144 TARGET_CXXFLAGS = $(TARGET_CFLAGS)
145 TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS))
147 ifeq ($(BR2_BINFMT_FLAT),y)
148 TARGET_CFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
149 -Wl$(comma)-elf2flt)
150 TARGET_CXXFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
151 -Wl$(comma)-elf2flt)
152 TARGET_LDFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),-elf2flt)
153 endif
155 ifeq ($(BR2_BINFMT_FLAT_SHARED),y)
156 TARGET_LDFLAGS += -mid-shared-library -mshared-library-id=0
157 TARGET_CFLAGS += -mid-shared-library -mshared-library-id=0
158 TARGET_CXXFLAGS += -mid-shared-library -mshared-library-id=0
159 endif
160 ifeq ($(BR2_BINFMT_FLAT_SEP_DATA),y)
161 TARGET_LDFLAGS += -msep-data
162 TARGET_CFLAGS += -msep-data
163 TARGET_CXXFLAGS += -msep-data
164 endif
166 ifeq ($(BR2_ENABLE_SSP),y)
167 TARGET_CFLAGS += -fstack-protector-all
168 TARGET_CXXFLAGS += -fstack-protector-all
169 endif
171 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
172 TARGET_CROSS = $(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-
173 else
174 TARGET_CROSS = $(HOST_DIR)/usr/bin/$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PREFIX))-
175 endif
177 # Define TARGET_xx variables for all common binutils/gcc
178 TARGET_AR = $(TARGET_CROSS)ar
179 TARGET_AS = $(TARGET_CROSS)as
180 TARGET_CC = $(TARGET_CROSS)gcc
181 TARGET_CPP = $(TARGET_CROSS)cpp
182 TARGET_CXX = $(TARGET_CROSS)g++
183 TARGET_FC = $(TARGET_CROSS)gfortran
184 TARGET_LD = $(TARGET_CROSS)ld
185 TARGET_NM = $(TARGET_CROSS)nm
186 TARGET_RANLIB = $(TARGET_CROSS)ranlib
187 TARGET_READELF = $(TARGET_CROSS)readelf
188 TARGET_OBJCOPY = $(TARGET_CROSS)objcopy
189 TARGET_OBJDUMP = $(TARGET_CROSS)objdump
191 TARGET_CC_NOCCACHE := $(TARGET_CC)
192 TARGET_CXX_NOCCACHE := $(TARGET_CXX)
194 ifeq ($(BR2_CCACHE),y)
195 TARGET_CC := $(CCACHE) $(TARGET_CC)
196 TARGET_CXX := $(CCACHE) $(TARGET_CXX)
197 endif
199 ifeq ($(BR2_STRIP_strip),y)
200 STRIP_STRIP_DEBUG := --strip-debug
201 STRIP_STRIP_UNNEEDED := --strip-unneeded
202 STRIP_STRIP_ALL := --strip-all
203 TARGET_STRIP = $(TARGET_CROSS)strip
204 STRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
205 KSTRIPCMD = $(STRIPCMD) $(STRIP_STRIP_UNNEEDED)
206 endif
207 ifeq ($(BR2_STRIP_sstrip),y)
208 STRIP_STRIP_DEBUG :=
209 STRIP_STRIP_UNNEEDED :=
210 STRIP_STRIP_ALL :=
211 TARGET_STRIP = $(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-sstrip
212 STRIPCMD = $(TARGET_STRIP)
213 KSTRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note --strip-unneeded
214 endif
215 ifeq ($(BR2_STRIP_none),y)
216 TARGET_STRIP = true
217 STRIPCMD = $(TARGET_STRIP)
218 KSTRIPCMD = $(TARGET_STRIP)
219 endif
220 INSTALL := $(shell which install || type -p install)
221 FLEX := $(shell which flex || type -p flex)
222 BISON := $(shell which bison || type -p bison)
223 SED := $(shell which sed || type -p sed) -i -e
224 UNZIP := $(shell which unzip || type -p unzip) -q
226 APPLY_PATCHES = support/scripts/apply-patches.sh $(if $(QUIET),-s)
228 HOST_CPPFLAGS = -I$(HOST_DIR)/usr/include
229 HOST_CFLAGS ?= -O2
230 HOST_CFLAGS += $(HOST_CPPFLAGS)
231 HOST_CXXFLAGS += $(HOST_CFLAGS)
232 HOST_LDFLAGS += -L$(HOST_DIR)/lib -L$(HOST_DIR)/usr/lib -Wl,-rpath,$(HOST_DIR)/usr/lib
234 # hostcc version as an integer - E.G. 4.3.2 => 432
235 HOSTCC_VERSION := $(shell $(HOSTCC_NOCCACHE) --version | \
236 sed -n 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)[ ]*.*$$/\1\2\3/p')
238 # host-intltool should be executed with the system perl, so we save
239 # the path to the system perl, before a host-perl built by Buildroot
240 # might get installed into $(HOST_DIR)/usr/bin and therefore appears
241 # in our PATH. This system perl will be used as INTLTOOL_PERL.
242 export PERL=$(shell which perl)
244 # host-intltool needs libxml-parser-perl, which Buildroot installs in
245 # $(HOST_DIR)/usr/lib/perl, so we must make sure that the system perl
246 # finds this perl module by exporting the proper value for PERL5LIB.
247 export PERL5LIB=$(HOST_DIR)/usr/lib/perl
249 TARGET_CONFIGURE_OPTS = PATH=$(BR_PATH) \
250 AR="$(TARGET_AR)" \
251 AS="$(TARGET_AS)" \
252 LD="$(TARGET_LD)" \
253 NM="$(TARGET_NM)" \
254 CC="$(TARGET_CC)" \
255 GCC="$(TARGET_CC)" \
256 CPP="$(TARGET_CPP)" \
257 CXX="$(TARGET_CXX)" \
258 FC="$(TARGET_FC)" \
259 RANLIB="$(TARGET_RANLIB)" \
260 READELF="$(TARGET_READELF)" \
261 STRIP="$(TARGET_STRIP)" \
262 OBJCOPY="$(TARGET_OBJCOPY)" \
263 OBJDUMP="$(TARGET_OBJDUMP)" \
264 AR_FOR_BUILD="$(HOSTAR)" \
265 AS_FOR_BUILD="$(HOSTAS)" \
266 CC_FOR_BUILD="$(HOSTCC)" \
267 GCC_FOR_BUILD="$(HOSTCC)" \
268 CXX_FOR_BUILD="$(HOSTCXX)" \
269 FC_FOR_BUILD="$(HOSTFC)" \
270 LD_FOR_BUILD="$(HOSTLD)" \
271 CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)" \
272 CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
273 CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
274 LDFLAGS_FOR_BUILD="$(HOST_LDFLAGS)" \
275 FCFLAGS_FOR_BUILD="$(HOST_FCFLAGS)" \
276 DEFAULT_ASSEMBLER="$(TARGET_AS)" \
277 DEFAULT_LINKER="$(TARGET_LD)" \
278 CPPFLAGS="$(TARGET_CPPFLAGS)" \
279 CFLAGS="$(TARGET_CFLAGS)" \
280 CXXFLAGS="$(TARGET_CXXFLAGS)" \
281 LDFLAGS="$(TARGET_LDFLAGS)" \
282 FCFLAGS="$(TARGET_FCFLAGS)" \
283 PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
284 STAGING_DIR="$(STAGING_DIR)" \
285 INTLTOOL_PERL=$(PERL)
287 TARGET_MAKE_ENV = PATH=$(BR_PATH)
290 HOST_CONFIGURE_OPTS = PATH=$(BR_PATH) \
291 AR="$(HOSTAR)" \
292 AS="$(HOSTAS)" \
293 LD="$(HOSTLD)" \
294 NM="$(HOSTNM)" \
295 CC="$(HOSTCC)" \
296 GCC="$(HOSTCC)" \
297 CXX="$(HOSTCXX)" \
298 CPP="$(HOSTCPP)" \
299 OBJCOPY="$(HOSTOBJCOPY)" \
300 RANLIB="$(HOSTRANLIB)" \
301 CPPFLAGS="$(HOST_CPPFLAGS)" \
302 CFLAGS="$(HOST_CFLAGS)" \
303 CXXFLAGS="$(HOST_CXXFLAGS)" \
304 LDFLAGS="$(HOST_LDFLAGS)" \
305 PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
306 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
307 PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
308 PKG_CONFIG_SYSROOT_DIR="/" \
309 PKG_CONFIG_LIBDIR="$(HOST_DIR)/usr/lib/pkgconfig:$(HOST_DIR)/usr/share/pkgconfig" \
310 LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib:$(LD_LIBRARY_PATH)" \
311 INTLTOOL_PERL=$(PERL)
313 HOST_MAKE_ENV = PATH=$(BR_PATH) \
314 LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib:$(LD_LIBRARY_PATH)" \
315 PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
316 PKG_CONFIG_SYSROOT_DIR="/" \
317 PKG_CONFIG_LIBDIR="$(HOST_DIR)/usr/lib/pkgconfig"
319 # This is extra environment we can not export ourselves (eg. because some
320 # packages use that variable internally, eg. uboot), so we have to
321 # explicitly pass it to user-supplied external hooks (eg. post-build,
322 # post-images)
323 EXTRA_ENV = \
324 PATH=$(BR_PATH) \
325 BR2_DL_DIR=$(BR2_DL_DIR) \
326 BUILD_DIR=$(BUILD_DIR)
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
333 ifeq ($(BR2_i386),y)
334 BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
335 endif
336 ifeq ($(BR2_x86_64),y)
337 BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
338 endif
339 ifeq ($(BR2_m68k),y)
340 BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
341 endif
342 ifeq ($(BR2_powerpc)$(BR2_powerpc64)$(BR2_powerpc64le),y)
343 BR2_AC_CV_TRAP_CHECK = ac_cv_lbl_unaligned_fail=no
344 endif
346 ifeq ($(BR2_ENDIAN),"BIG")
347 BR2_AC_CV_C_BIGENDIAN = ac_cv_c_bigendian=yes
348 else
349 BR2_AC_CV_C_BIGENDIAN = ac_cv_c_bigendian=no
350 endif
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)
367 DISABLE_NLS :=
368 else
369 DISABLE_NLS :=--disable-nls
370 endif
372 ifneq ($(BR2_LARGEFILE),y)
373 DISABLE_LARGEFILE = --disable-largefile
374 endif
376 ifeq ($(BR2_INET_IPV6),y)
377 DISABLE_IPV6 = --enable-ipv6
378 else
379 DISABLE_IPV6 = --disable-ipv6
380 endif
382 ifneq ($(BR2_INSTALL_LIBSTDCPP),y)
383 TARGET_CONFIGURE_OPTS += CXX=false
384 endif
386 ifeq ($(BR2_ENABLE_DEBUG),y)
387 ENABLE_DEBUG := --enable-debug
388 else
389 ENABLE_DEBUG := --disable-debug
390 endif
392 ifeq ($(BR2_PREFER_STATIC_LIB),y)
393 SHARED_STATIC_LIBS_OPTS = --enable-static --disable-shared
394 TARGET_CFLAGS += -static
395 TARGET_CXXFLAGS += -static
396 TARGET_LDFLAGS += -static
397 else
398 SHARED_STATIC_LIBS_OPTS = --enable-static --enable-shared
399 endif
401 include package/pkg-download.mk
402 include package/pkg-autotools.mk
403 include package/pkg-cmake.mk
404 include package/pkg-luarocks.mk
405 include package/pkg-perl.mk
406 include package/pkg-python.mk
407 include package/pkg-virtual.mk
408 include package/pkg-generic.mk
409 include package/pkg-kconfig.mk