blob: 07ec242e63bbac1026ac37eccc869cac710511d8 [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 \
Patrick Williamsf1e5d692016-03-30 15:21:19 -050016 microblaze \
Brad Bishop316dfdd2018-06-25 12:45:53 -040017 nios2 arc riscv xtensa"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018
19def map_kernel_arch(a, d):
20 import re
21
Brad Bishop6e60e8b2018-02-01 10:27:11 -050022 valid_archs = d.getVar('valid_archs').split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050024 if re.match('(i.86|athlon|x86.64)$', a): return 'x86'
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080025 elif re.match('arceb$', a): return 'arc'
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026 elif re.match('armeb$', a): return 'arm'
27 elif re.match('aarch64$', a): return 'arm64'
28 elif re.match('aarch64_be$', a): return 'arm64'
Brad Bishop00111322018-04-01 22:23:53 -040029 elif re.match('aarch64_ilp32$', a): return 'arm64'
30 elif re.match('aarch64_be_ilp32$', a): return 'arm64'
Patrick Williamsc0f7c042017-02-23 20:41:17 -060031 elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'mips'
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080032 elif re.match('mcf', a): return 'm68k'
Brad Bishop316dfdd2018-06-25 12:45:53 -040033 elif re.match('riscv(32|64|)(eb|)$', a): return 'riscv'
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034 elif re.match('p(pc|owerpc)(|64)', a): return 'powerpc'
35 elif re.match('sh(3|4)$', a): return 'sh'
36 elif re.match('bfin', a): return 'blackfin'
37 elif re.match('microblazee[bl]', a): return 'microblaze'
38 elif a in valid_archs: return a
39 else:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050040 if not d.getVar("TARGET_OS").startswith("linux"):
41 return a
Patrick Williamsc124f4f2015-09-15 14:41:29 -050042 bb.error("cannot map '%s' to a linux kernel architecture" % a)
43
Brad Bishop6e60e8b2018-02-01 10:27:11 -050044export ARCH = "${@map_kernel_arch(d.getVar('TARGET_ARCH'), d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045
46def map_uboot_arch(a, d):
47 import re
48
49 if re.match('p(pc|owerpc)(|64)', a): return 'ppc'
50 elif re.match('i.86$', a): return 'x86'
51 return a
52
Brad Bishop6e60e8b2018-02-01 10:27:11 -050053export UBOOT_ARCH = "${@map_uboot_arch(d.getVar('ARCH'), d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054
55# Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture
56# specific options necessary for building the kernel and modules.
57TARGET_CC_KERNEL_ARCH ?= ""
58HOST_CC_KERNEL_ARCH ?= "${TARGET_CC_KERNEL_ARCH}"
59TARGET_LD_KERNEL_ARCH ?= ""
60HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
61TARGET_AR_KERNEL_ARCH ?= ""
62HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
63
Brad Bishop316dfdd2018-06-25 12:45:53 -040064KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH} -fuse-ld=bfd ${DEBUG_PREFIX_MAP} -fdebug-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065KERNEL_LD = "${CCACHE}${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}"
66KERNEL_AR = "${CCACHE}${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050067TOOLCHAIN = "gcc"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050068