Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # |
| 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 | |
| 7 | valid_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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 16 | microblaze \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 17 | nios2 arc riscv xtensa" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 18 | |
| 19 | def map_kernel_arch(a, d): |
| 20 | import re |
| 21 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 22 | valid_archs = d.getVar('valid_archs').split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 24 | if re.match('(i.86|athlon|x86.64)$', a): return 'x86' |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 25 | elif re.match('armeb$', a): return 'arm' |
| 26 | elif re.match('aarch64$', a): return 'arm64' |
| 27 | elif re.match('aarch64_be$', a): return 'arm64' |
Brad Bishop | 0011132 | 2018-04-01 22:23:53 -0400 | [diff] [blame] | 28 | elif re.match('aarch64_ilp32$', a): return 'arm64' |
| 29 | elif re.match('aarch64_be_ilp32$', a): return 'arm64' |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 30 | elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'mips' |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 31 | elif re.match('riscv(32|64|)(eb|)$', a): return 'riscv' |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | elif re.match('p(pc|owerpc)(|64)', a): return 'powerpc' |
| 33 | elif re.match('sh(3|4)$', a): return 'sh' |
| 34 | elif re.match('bfin', a): return 'blackfin' |
| 35 | elif re.match('microblazee[bl]', a): return 'microblaze' |
| 36 | elif a in valid_archs: return a |
| 37 | else: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 38 | if not d.getVar("TARGET_OS").startswith("linux"): |
| 39 | return a |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | bb.error("cannot map '%s' to a linux kernel architecture" % a) |
| 41 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 42 | export ARCH = "${@map_kernel_arch(d.getVar('TARGET_ARCH'), d)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 43 | |
| 44 | def map_uboot_arch(a, d): |
| 45 | import re |
| 46 | |
| 47 | if re.match('p(pc|owerpc)(|64)', a): return 'ppc' |
| 48 | elif re.match('i.86$', a): return 'x86' |
| 49 | return a |
| 50 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 51 | export UBOOT_ARCH = "${@map_uboot_arch(d.getVar('ARCH'), d)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | |
| 53 | # Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture |
| 54 | # specific options necessary for building the kernel and modules. |
| 55 | TARGET_CC_KERNEL_ARCH ?= "" |
| 56 | HOST_CC_KERNEL_ARCH ?= "${TARGET_CC_KERNEL_ARCH}" |
| 57 | TARGET_LD_KERNEL_ARCH ?= "" |
| 58 | HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}" |
| 59 | TARGET_AR_KERNEL_ARCH ?= "" |
| 60 | HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}" |
| 61 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 62 | 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}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 | KERNEL_LD = "${CCACHE}${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}" |
| 64 | KERNEL_AR = "${CCACHE}${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 65 | TOOLCHAIN = "gcc" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 66 | |