blob: 1531ae6cd55b6b8a22268ce534c47f0c1ed3f109 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7#
8# set the ARCH environment variable for kernel compilation (including
9# modules). return value must match one of the architecture directories
10# in the kernel source "arch" directory
11#
12
13valid_archs = "alpha cris ia64 \
14 i386 x86 \
15 m68knommu m68k ppc powerpc powerpc64 ppc64 \
16 sparc sparc64 \
17 arm aarch64 \
18 m32r mips \
19 sh sh64 um h8300 \
20 parisc s390 v850 \
21 avr32 blackfin \
22 microblaze \
23 nios2 arc riscv xtensa"
24
25def map_kernel_arch(a, d):
26 import re
27
28 valid_archs = d.getVar('valid_archs').split()
29
30 if re.match('(i.86|athlon|x86.64)$', a): return 'x86'
31 elif re.match('arceb$', a): return 'arc'
32 elif re.match('armeb$', a): return 'arm'
33 elif re.match('aarch64$', a): return 'arm64'
34 elif re.match('aarch64_be$', a): return 'arm64'
35 elif re.match('aarch64_ilp32$', a): return 'arm64'
36 elif re.match('aarch64_be_ilp32$', a): return 'arm64'
37 elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'mips'
38 elif re.match('mcf', a): return 'm68k'
39 elif re.match('riscv(32|64|)(eb|)$', a): return 'riscv'
40 elif re.match('p(pc|owerpc)(|64)', a): return 'powerpc'
41 elif re.match('sh(3|4)$', a): return 'sh'
42 elif re.match('bfin', a): return 'blackfin'
43 elif re.match('microblazee[bl]', a): return 'microblaze'
44 elif a in valid_archs: return a
45 else:
46 if not d.getVar("TARGET_OS").startswith("linux"):
47 return a
48 bb.error("cannot map '%s' to a linux kernel architecture" % a)
49
50export ARCH = "${@map_kernel_arch(d.getVar('TARGET_ARCH'), d)}"
51
52def map_uboot_arch(a, d):
53 import re
54
55 if re.match('p(pc|owerpc)(|64)', a): return 'ppc'
56 elif re.match('i.86$', a): return 'x86'
57 return a
58
59export UBOOT_ARCH = "${@map_uboot_arch(d.getVar('ARCH'), d)}"
60
61# Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture
62# specific options necessary for building the kernel and modules.
63TARGET_CC_KERNEL_ARCH ?= ""
64HOST_CC_KERNEL_ARCH ?= "${TARGET_CC_KERNEL_ARCH}"
65TARGET_LD_KERNEL_ARCH ?= ""
66HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
67TARGET_AR_KERNEL_ARCH ?= ""
68HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
69
70KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH} -fuse-ld=bfd ${DEBUG_PREFIX_MAP} -fdebug-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH} -fdebug-prefix-map=${STAGING_KERNEL_BUILDDIR}=${KERNEL_SRC_PATH}"
71KERNEL_LD = "${CCACHE}${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}"
72KERNEL_AR = "${CCACHE}${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}"
Andrew Geissler517393d2023-01-13 08:55:19 -060073TOOLCHAIN ?= "gcc"
Patrick Williams92b42cb2022-09-03 06:53:57 -050074