summaryrefslogtreecommitdiff
path: root/package/Makefile.in
blob: 97053bad918df3c10a0e77627fe87d1025962971 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
ifndef MAKE
MAKE:=make
endif
ifndef HOSTMAKE
HOSTMAKE=$(MAKE)
endif
HOSTMAKE :=$(shell which $(HOSTMAKE) || type -p $(HOSTMAKE) || echo make)

# If BR2_LEVEL is 0, scale the maximum concurrency with the number of
# CPUs. An additional job is used in order to keep processors busy
# while waiting on I/O.
# If the number of processors is not available, assume one.
ifeq ($(BR2_JLEVEL),0)
PARALLEL_JOBS:=$(shell echo \
	$$((1 + `getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1`)))
else
PARALLEL_JOBS:=$(BR2_JLEVEL)
endif

MAKE1:=$(HOSTMAKE) -j1
MAKE:=$(HOSTMAKE) $(if $(PARALLEL_JOBS),-j$(PARALLEL_JOBS))

ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
TARGET_VENDOR = $(call qstrip,$(BR2_TOOLCHAIN_BUILDROOT_VENDOR))
else
TARGET_VENDOR = buildroot
endif

# Sanity checks
ifeq ($(TARGET_VENDOR),)
$(error BR2_TOOLCHAIN_BUILDROOT_VENDOR is not allowed to be empty)
endif
ifeq ($(TARGET_VENDOR),unknown)
$(error BR2_TOOLCHAIN_BUILDROOT_VENDOR cannot be 'unknown'. \
        It might be confused with the native toolchain)
endif

# Compute GNU_TARGET_NAME
GNU_TARGET_NAME=$(ARCH)-$(TARGET_VENDOR)-$(TARGET_OS)-$(LIBC)$(ABI)

# Blackfin FLAT needs uclinux
ifeq ($(BR2_bfin)$(BR2_BINFMT_FLAT),yy)
TARGET_OS=uclinux
else
TARGET_OS=linux
endif

ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
LIBC=uclibc
else ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
LIBC=musl
else
LIBC=gnu
endif

# The ABI suffix is a bit special on ARM, as it needs to be
# -uclibcgnueabi for uClibc EABI, and -gnueabi for glibc EABI.
# This means that the LIBC and ABI aren't strictly orthogonal,
# which explains why we need the test on LIBC below.
ifeq ($(BR2_arm)$(BR2_armeb),y)
ifeq ($(LIBC),uclibc)
ABI=gnueabi
else
ABI=eabi
endif

ifeq ($(BR2_ARM_EABIHF),y)
ABI:=$(ABI)hf
endif
endif

# For FSL PowerPC there's SPE
ifeq ($(BR2_powerpc_SPE),y)
ABI=spe
# MPC8540s are e500v1 with single precision FP
ifeq ($(BR2_powerpc_8540),y)
TARGET_ABI+=-mabi=spe -mfloat-gprs=single -Wa,-me500
endif
ifeq ($(BR2_powerpc_8548),y)
TARGET_ABI+=-mabi=spe -mfloat-gprs=double -Wa,-me500x2
endif
ifeq ($(BR2_powerpc_e500mc),y)
TARGET_ABI+=-mabi=spe -mfloat-gprs=double -Wa,-me500mc
endif
endif

# Use longcalls option for Xtensa globally.
# The 'longcalls' option allows calls across a greater range of addresses,
# and is required for some packages. While this option can degrade both
# code size and performance, the linker can usually optimize away the
# overhead when a call ends up within a certain range.
#
# Use text-section-literals for Xtensa globally.
# Collecting literals into separate section can be advantageous if that
# section is placed into DTCM at link time. This is applicable for code
# running on bare metal, but makes no sense under linux, where userspace
# is isolated from the physical memory details. OTOH placing literals into
# separate section breaks build of huge source files, because l32r
# instruction can only access literals in 256 KBytes range.
#
ifeq ($(BR2_xtensa),y)
TARGET_ABI += -mlongcalls -mtext-section-literals
endif

STAGING_SUBDIR = usr/$(GNU_TARGET_NAME)/sysroot
STAGING_DIR    = $(HOST_DIR)/$(STAGING_SUBDIR)

TARGET_OPTIMIZATION:=$(call qstrip,$(BR2_TARGET_OPTIMIZATION))

ifeq ($(BR2_OPTIMIZE_0),y)
TARGET_OPTIMIZATION+=-O0
endif
ifeq ($(BR2_OPTIMIZE_1),y)
TARGET_OPTIMIZATION+=-O1
endif
ifeq ($(BR2_OPTIMIZE_2),y)
TARGET_OPTIMIZATION+=-O2
endif
ifeq ($(BR2_OPTIMIZE_3),y)
TARGET_OPTIMIZATION+=-O3
endif
ifeq ($(BR2_OPTIMIZE_S),y)
TARGET_OPTIMIZATION+=-Os
endif
ifeq ($(BR2_DEBUG_1),y)
TARGET_DEBUGGING=-g1
endif
ifeq ($(BR2_DEBUG_2),y)
TARGET_DEBUGGING=-g2
endif
ifeq ($(BR2_DEBUG_3),y)
TARGET_DEBUGGING=-g3
endif

ifeq ($(BR2_LARGEFILE),y)
TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
endif

TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
TARGET_CXXFLAGS = $(TARGET_CFLAGS)
TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS))

ifeq ($(BR2_BINFMT_FLAT),y)
TARGET_CFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
	-Wl$(comma)-elf2flt)
TARGET_CXXFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
	-Wl$(comma)-elf2flt)
TARGET_LDFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),-elf2flt)
endif

ifeq ($(BR2_BINFMT_FLAT_SHARED),y)
TARGET_LDFLAGS += -mid-shared-library -mshared-library-id=0
TARGET_CFLAGS += -mid-shared-library -mshared-library-id=0
TARGET_CXXFLAGS += -mid-shared-library -mshared-library-id=0
endif
ifeq ($(BR2_BINFMT_FLAT_SEP_DATA),y)
TARGET_LDFLAGS += -msep-data
TARGET_CFLAGS += -msep-data
TARGET_CXXFLAGS += -msep-data
endif

ifeq ($(BR2_ENABLE_SSP),y)
TARGET_CFLAGS += -fstack-protector-all
TARGET_CXXFLAGS += -fstack-protector-all
endif

ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
TARGET_CROSS=$(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-
else
TARGET_CROSS=$(HOST_DIR)/usr/bin/$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PREFIX))-
endif

# Define TARGET_xx variables for all common binutils/gcc
TARGET_AR       = $(TARGET_CROSS)ar
TARGET_AS       = $(TARGET_CROSS)as
TARGET_CC       = $(TARGET_CROSS)gcc
TARGET_CPP      = $(TARGET_CROSS)cpp
TARGET_CXX      = $(TARGET_CROSS)g++
TARGET_FC       = $(TARGET_CROSS)gfortran
TARGET_LD       = $(TARGET_CROSS)ld
TARGET_NM       = $(TARGET_CROSS)nm
TARGET_RANLIB   = $(TARGET_CROSS)ranlib
TARGET_READELF  = $(TARGET_CROSS)readelf
TARGET_OBJCOPY  = $(TARGET_CROSS)objcopy
TARGET_OBJDUMP  = $(TARGET_CROSS)objdump

TARGET_CC_NOCCACHE  := $(TARGET_CC)
TARGET_CXX_NOCCACHE := $(TARGET_CXX)

ifeq ($(BR2_CCACHE),y)
TARGET_CC  := $(CCACHE) $(TARGET_CC)
TARGET_CXX := $(CCACHE) $(TARGET_CXX)
endif

ifeq ($(BR2_STRIP_strip),y)
STRIP_STRIP_DEBUG:=--strip-debug
STRIP_STRIP_UNNEEDED:=--strip-unneeded
STRIP_STRIP_ALL:=--strip-all
TARGET_STRIP=$(TARGET_CROSS)strip
STRIPCMD=$(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
KSTRIPCMD=$(STRIPCMD) $(STRIP_STRIP_UNNEEDED)
endif
ifeq ($(BR2_STRIP_sstrip),y)
STRIP_STRIP_DEBUG:=
STRIP_STRIP_UNNEEDED:=
STRIP_STRIP_ALL:=
TARGET_STRIP=$(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-sstrip
STRIPCMD=$(TARGET_STRIP)
KSTRIPCMD=$(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note --strip-unneeded
endif
ifeq ($(BR2_STRIP_none),y)
TARGET_STRIP=true
STRIPCMD=$(TARGET_STRIP)
KSTRIPCMD=$(TARGET_STRIP)
endif
INSTALL:=$(shell which install || type -p install)
FLEX:=$(shell which flex || type -p flex)
BISON:=$(shell which bison || type -p bison)
SED:=$(shell which sed || type -p sed) -i -e

HOST_CPPFLAGS  = -I$(HOST_DIR)/usr/include
HOST_CFLAGS   ?= -O2
HOST_CFLAGS   += $(HOST_CPPFLAGS)
HOST_CXXFLAGS += $(HOST_CFLAGS)
HOST_LDFLAGS  += -L$(HOST_DIR)/lib -L$(HOST_DIR)/usr/lib -Wl,-rpath,$(HOST_DIR)/usr/lib

# hostcc version as an integer - E.G. 4.3.2 => 432
HOSTCC_VERSION:=$(shell $(HOSTCC_NOCCACHE) --version | \
	sed -n 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)[ ]*.*$$/\1\2\3/p')

HOST_PERL_ARCHNAME := $(shell perl -MConfig -e "print Config->{archname}")
export PERL5LIB := $(HOST_DIR)/usr/lib/perl5/$(HOST_PERL_ARCHNAME):$(HOST_DIR)/usr/lib/perl5

TARGET_CONFIGURE_OPTS=PATH=$(BR_PATH) \
		AR="$(TARGET_AR)" \
		AS="$(TARGET_AS)" \
		LD="$(TARGET_LD)" \
		NM="$(TARGET_NM)" \
		CC="$(TARGET_CC)" \
		GCC="$(TARGET_CC)" \
		CPP="$(TARGET_CPP)" \
		CXX="$(TARGET_CXX)" \
		FC="$(TARGET_FC)" \
		RANLIB="$(TARGET_RANLIB)" \
		READELF="$(TARGET_READELF)" \
		STRIP="$(TARGET_STRIP)" \
		OBJCOPY="$(TARGET_OBJCOPY)" \
		OBJDUMP="$(TARGET_OBJDUMP)" \
		AR_FOR_BUILD="$(HOSTAR)" \
		AS_FOR_BUILD="$(HOSTAS)" \
		CC_FOR_BUILD="$(HOSTCC)" \
		GCC_FOR_BUILD="$(HOSTCC)" \
		CXX_FOR_BUILD="$(HOSTCXX)" \
		FC_FOR_BUILD="$(HOSTFC)" \
		LD_FOR_BUILD="$(HOSTLD)" \
		CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)" \
		CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
		CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
		LDFLAGS_FOR_BUILD="$(HOST_LDFLAGS)" \
		FCFLAGS_FOR_BUILD="$(HOST_FCFLAGS)" \
		DEFAULT_ASSEMBLER="$(TARGET_AS)" \
		DEFAULT_LINKER="$(TARGET_LD)" \
		CPPFLAGS="$(TARGET_CPPFLAGS)" \
		CFLAGS="$(TARGET_CFLAGS)" \
		CXXFLAGS="$(TARGET_CXXFLAGS)" \
		LDFLAGS="$(TARGET_LDFLAGS)" \
		FCFLAGS="$(TARGET_FCFLAGS)" \
		PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
		STAGING_DIR="$(STAGING_DIR)"

TARGET_MAKE_ENV=PATH=$(BR_PATH)


HOST_CONFIGURE_OPTS=PATH=$(BR_PATH) \
		AR="$(HOSTAR)" \
		AS="$(HOSTAS)" \
		LD="$(HOSTLD)" \
		NM="$(HOSTNM)" \
		CC="$(HOSTCC)" \
		GCC="$(HOSTCC)" \
		CXX="$(HOSTCXX)" \
		CPP="$(HOSTCPP)" \
		OBJCOPY="$(HOSTOBJCOPY)" \
		RANLIB="$(HOSTRANLIB)" \
		CPPFLAGS="$(HOST_CPPFLAGS)" \
		CFLAGS="$(HOST_CFLAGS)" \
		CXXFLAGS="$(HOST_CXXFLAGS)" \
		LDFLAGS="$(HOST_LDFLAGS)" \
		PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
		PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
		PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
		PKG_CONFIG_SYSROOT_DIR="/" \
		PKG_CONFIG_LIBDIR="$(HOST_DIR)/usr/lib/pkgconfig:$(HOST_DIR)/usr/share/pkgconfig" \
		LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib:$(LD_LIBRARY_PATH)"

HOST_MAKE_ENV=PATH=$(BR_PATH) \
		LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib:$(LD_LIBRARY_PATH)" \
		PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
		PKG_CONFIG_SYSROOT_DIR="/" \
		PKG_CONFIG_LIBDIR="$(HOST_DIR)/usr/lib/pkgconfig"

# This is extra environment we can not export ourselves (eg. because some
# packages use that variable internally, eg. uboot), so we have to
# explicitly pass it to user-supplied external hooks (eg. post-build,
# post-images)
EXTRA_ENV=\
	PATH=$(BR_PATH) \
	BR2_DL_DIR=$(BR2_DL_DIR) \
	BUILD_DIR=$(BUILD_DIR)

################################################################################
# settings we need to pass to configure

# does unaligned access trap?
BR2_AC_CV_TRAP_CHECK=ac_cv_lbl_unaligned_fail=yes
ifeq ($(BR2_i386),y)
BR2_AC_CV_TRAP_CHECK=ac_cv_lbl_unaligned_fail=no
endif
ifeq ($(BR2_x86_64),y)
BR2_AC_CV_TRAP_CHECK=ac_cv_lbl_unaligned_fail=no
endif
ifeq ($(BR2_m68k),y)
BR2_AC_CV_TRAP_CHECK=ac_cv_lbl_unaligned_fail=no
endif
ifeq ($(BR2_powerpc)$(BR2_powerpc64)$(BR2_powerpc64le),y)
BR2_AC_CV_TRAP_CHECK=ac_cv_lbl_unaligned_fail=no
endif

ifeq ($(BR2_ENDIAN),"BIG")
BR2_AC_CV_C_BIGENDIAN=ac_cv_c_bigendian=yes
else
BR2_AC_CV_C_BIGENDIAN=ac_cv_c_bigendian=no
endif

TARGET_CONFIGURE_ARGS= \
	$(BR2_AC_CV_TRAP_CHECK) \
	ac_cv_func_mmap_fixed_mapped=yes \
	ac_cv_func_memcmp_working=yes \
	ac_cv_have_decl_malloc=yes \
	gl_cv_func_malloc_0_nonnull=yes \
	ac_cv_func_malloc_0_nonnull=yes \
	ac_cv_func_calloc_0_nonnull=yes \
	ac_cv_func_realloc_0_nonnull=yes \
	lt_cv_sys_lib_search_path_spec="" \
	$(BR2_AC_CV_C_BIGENDIAN)

################################################################################

ifeq ($(BR2_ENABLE_LOCALE),y)
DISABLE_NLS:=
else
DISABLE_NLS:=--disable-nls
endif

ifneq ($(BR2_LARGEFILE),y)
DISABLE_LARGEFILE= --disable-largefile
endif

ifeq ($(BR2_INET_IPV6),y)
DISABLE_IPV6= --enable-ipv6
else
DISABLE_IPV6= --disable-ipv6
endif

ifneq ($(BR2_INSTALL_LIBSTDCPP),y)
TARGET_CONFIGURE_OPTS+=CXX=false
endif

ifeq ($(BR2_ENABLE_DEBUG),y)
ENABLE_DEBUG:=--enable-debug
else
ENABLE_DEBUG:=
endif

ifeq ($(BR2_PREFER_STATIC_LIB),y)
SHARED_STATIC_LIBS_OPTS=--enable-static --disable-shared
TARGET_LDFLAGS += --static
else
SHARED_STATIC_LIBS_OPTS=--enable-static --enable-shared
endif

include package/pkg-utils.mk
include package/pkg-download.mk
include package/pkg-autotools.mk
include package/pkg-cmake.mk
include package/pkg-luarocks.mk
include package/pkg-perl.mk
include package/pkg-python.mk
include package/pkg-virtual.mk
include package/pkg-generic.mk