Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | # |
| 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 | |
| 13 | valid_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 \ |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 22 | loongarch64 \ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 23 | microblaze \ |
| 24 | nios2 arc riscv xtensa" |
| 25 | |
| 26 | def map_kernel_arch(a, d): |
| 27 | import re |
| 28 | |
| 29 | valid_archs = d.getVar('valid_archs').split() |
| 30 | |
| 31 | if re.match('(i.86|athlon|x86.64)$', a): return 'x86' |
| 32 | elif re.match('arceb$', a): return 'arc' |
| 33 | elif re.match('armeb$', a): return 'arm' |
| 34 | elif re.match('aarch64$', a): return 'arm64' |
| 35 | elif re.match('aarch64_be$', a): return 'arm64' |
| 36 | elif re.match('aarch64_ilp32$', a): return 'arm64' |
| 37 | elif re.match('aarch64_be_ilp32$', a): return 'arm64' |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 38 | elif re.match('loongarch(32|64|)$', a): return 'loongarch' |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 39 | elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'mips' |
| 40 | elif re.match('mcf', a): return 'm68k' |
| 41 | elif re.match('riscv(32|64|)(eb|)$', a): return 'riscv' |
| 42 | elif re.match('p(pc|owerpc)(|64)', a): return 'powerpc' |
| 43 | elif re.match('sh(3|4)$', a): return 'sh' |
| 44 | elif re.match('bfin', a): return 'blackfin' |
| 45 | elif re.match('microblazee[bl]', a): return 'microblaze' |
| 46 | elif a in valid_archs: return a |
| 47 | else: |
| 48 | if not d.getVar("TARGET_OS").startswith("linux"): |
| 49 | return a |
| 50 | bb.error("cannot map '%s' to a linux kernel architecture" % a) |
| 51 | |
| 52 | export ARCH = "${@map_kernel_arch(d.getVar('TARGET_ARCH'), d)}" |
| 53 | |
| 54 | def map_uboot_arch(a, d): |
| 55 | import re |
| 56 | |
| 57 | if re.match('p(pc|owerpc)(|64)', a): return 'ppc' |
| 58 | elif re.match('i.86$', a): return 'x86' |
| 59 | return a |
| 60 | |
| 61 | export UBOOT_ARCH = "${@map_uboot_arch(d.getVar('ARCH'), d)}" |
| 62 | |
| 63 | # Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture |
| 64 | # specific options necessary for building the kernel and modules. |
| 65 | TARGET_CC_KERNEL_ARCH ?= "" |
| 66 | HOST_CC_KERNEL_ARCH ?= "${TARGET_CC_KERNEL_ARCH}" |
| 67 | TARGET_LD_KERNEL_ARCH ?= "" |
| 68 | HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}" |
| 69 | TARGET_AR_KERNEL_ARCH ?= "" |
| 70 | HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}" |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 71 | TARGET_OBJCOPY_KERNEL_ARCH ?= "" |
| 72 | HOST_OBJCOPY_KERNEL_ARCH ?= "${TARGET_OBJCOPY_KERNEL_ARCH}" |
Patrick Williams | 520786c | 2023-06-25 16:20:36 -0500 | [diff] [blame] | 73 | TARGET_STRIP_KERNEL_ARCH ?= "" |
| 74 | HOST_STRIP_KERNEL_ARCH ?= "${TARGET_STRIP_KERNEL_ARCH}" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 75 | |
| 76 | KERNEL_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}" |
Patrick Williams | ac13d5f | 2023-11-24 18:59:46 -0600 | [diff] [blame] | 77 | KERNEL_LD = "${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}" |
| 78 | KERNEL_AR = "${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}" |
| 79 | KERNEL_OBJCOPY = "${HOST_PREFIX}objcopy ${HOST_OBJCOPY_KERNEL_ARCH}" |
| 80 | KERNEL_STRIP = "${HOST_PREFIX}strip ${HOST_STRIP_KERNEL_ARCH}" |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 81 | TOOLCHAIN ?= "gcc" |