blob: 211b72bee62fb5be02ee288e677513d8daae5546 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#
2# set the ARCH environment variable for kernel compilation (including
3# modules). return value must match one of the architecture directories
4# in the kernel source "arch" directory
5#
6
7valid_archs = "alpha cris ia64 \
8 i386 x86 \
9 m68knommu m68k ppc powerpc powerpc64 ppc64 \
10 sparc sparc64 \
11 arm aarch64 \
12 m32r mips \
13 sh sh64 um h8300 \
14 parisc s390 v850 \
15 avr32 blackfin \
16 microblaze"
17
18def map_kernel_arch(a, d):
19 import re
20
21 valid_archs = d.getVar('valid_archs', True).split()
22
23 if re.match('(i.86|athlon|x86.64)$', a): return 'x86'
24 elif re.match('armeb$', a): return 'arm'
25 elif re.match('aarch64$', a): return 'arm64'
26 elif re.match('aarch64_be$', a): return 'arm64'
27 elif re.match('mips(el|64|64el)$', a): return 'mips'
28 elif re.match('p(pc|owerpc)(|64)', a): return 'powerpc'
29 elif re.match('sh(3|4)$', a): return 'sh'
30 elif re.match('bfin', a): return 'blackfin'
31 elif re.match('microblazee[bl]', a): return 'microblaze'
32 elif a in valid_archs: return a
33 else:
34 bb.error("cannot map '%s' to a linux kernel architecture" % a)
35
36export ARCH = "${@map_kernel_arch(d.getVar('TARGET_ARCH', True), d)}"
37
38def map_uboot_arch(a, d):
39 import re
40
41 if re.match('p(pc|owerpc)(|64)', a): return 'ppc'
42 elif re.match('i.86$', a): return 'x86'
43 return a
44
45export UBOOT_ARCH = "${@map_uboot_arch(d.getVar('ARCH', True), d)}"
46
47# Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture
48# specific options necessary for building the kernel and modules.
49TARGET_CC_KERNEL_ARCH ?= ""
50HOST_CC_KERNEL_ARCH ?= "${TARGET_CC_KERNEL_ARCH}"
51TARGET_LD_KERNEL_ARCH ?= ""
52HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
53TARGET_AR_KERNEL_ARCH ?= ""
54HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
55
56KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH} -fuse-ld=bfd"
57KERNEL_LD = "${CCACHE}${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}"
58KERNEL_AR = "${CCACHE}${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}"
59