kernel-arch.bbclass 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. valid_archs = "alpha cris ia64 \
  7. i386 x86 \
  8. m68knommu m68k ppc powerpc powerpc64 ppc64 \
  9. sparc sparc64 \
  10. arm aarch64 \
  11. m32r mips \
  12. sh sh64 um h8300 \
  13. parisc s390 v850 \
  14. avr32 blackfin \
  15. microblaze \
  16. nios2 arc riscv xtensa"
  17. def map_kernel_arch(a, d):
  18. import re
  19. valid_archs = d.getVar('valid_archs').split()
  20. if re.match('(i.86|athlon|x86.64)$', a): return 'x86'
  21. elif re.match('arceb$', a): return 'arc'
  22. elif re.match('armeb$', a): return 'arm'
  23. elif re.match('aarch64$', a): return 'arm64'
  24. elif re.match('aarch64_be$', a): return 'arm64'
  25. elif re.match('aarch64_ilp32$', a): return 'arm64'
  26. elif re.match('aarch64_be_ilp32$', a): return 'arm64'
  27. elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'mips'
  28. elif re.match('mcf', a): return 'm68k'
  29. elif re.match('riscv(32|64|)(eb|)$', a): return 'riscv'
  30. elif re.match('csky', a): return 'csky'
  31. elif re.match('p(pc|owerpc)(|64)', a): return 'powerpc'
  32. elif re.match('sh(3|4)$', a): return 'sh'
  33. elif re.match('bfin', a): return 'blackfin'
  34. elif re.match('microblazee[bl]', a): return 'microblaze'
  35. elif a in valid_archs: return a
  36. else:
  37. if not d.getVar("TARGET_OS").startswith("linux"):
  38. return a
  39. bb.error("cannot map '%s' to a linux kernel architecture" % a)
  40. export ARCH = "${@map_kernel_arch(d.getVar('TARGET_ARCH'), d)}"
  41. def map_uboot_arch(a, d):
  42. import re
  43. if re.match('p(pc|owerpc)(|64)', a): return 'ppc'
  44. elif re.match('i.86$', a): return 'x86'
  45. return a
  46. export UBOOT_ARCH = "${@map_uboot_arch(d.getVar('ARCH'), d)}"
  47. # Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture
  48. # specific options necessary for building the kernel and modules.
  49. TARGET_CC_KERNEL_ARCH ?= ""
  50. HOST_CC_KERNEL_ARCH ?= "${TARGET_CC_KERNEL_ARCH}"
  51. TARGET_LD_KERNEL_ARCH ?= ""
  52. HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
  53. TARGET_AR_KERNEL_ARCH ?= ""
  54. HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
  55. 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}"
  56. KERNEL_LD = "${CCACHE}${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}"
  57. KERNEL_AR = "${CCACHE}${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}"
  58. TOOLCHAIN = "gcc"