Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # This file is included by the global makefile so that you can add your own
  2. # architecture-specific flags and dependencies. Remember to do have actions
  3. # for "archclean" and "archdep" for cleaning up and making dependencies for
  4. # this architecture
  5. #
  6. # This file is subject to the terms and conditions of the GNU General Public
  7. # License. See the file "COPYING" in the main directory of this archive
  8. # for more details.
  9. #
  10. OBJCOPYFLAGS := -O binary
  11. LDFLAGS_vmlinux :=
  12. ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
  13. LDFLAGS_vmlinux := --no-relax
  14. endif
  15. KBUILD_AFLAGS_MODULE += -fPIC
  16. KBUILD_CFLAGS_MODULE += -fPIC
  17. KBUILD_DEFCONFIG = defconfig
  18. export BITS
  19. ifeq ($(CONFIG_ARCH_RV64I),y)
  20. BITS := 64
  21. UTS_MACHINE := riscv64
  22. KBUILD_CFLAGS += -mabi=lp64
  23. KBUILD_AFLAGS += -mabi=lp64
  24. KBUILD_CFLAGS += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128)
  25. KBUILD_MARCH = rv64im
  26. KBUILD_LDFLAGS += -melf64lriscv
  27. else
  28. BITS := 32
  29. UTS_MACHINE := riscv32
  30. KBUILD_CFLAGS += -mabi=ilp32
  31. KBUILD_AFLAGS += -mabi=ilp32
  32. KBUILD_MARCH = rv32im
  33. KBUILD_LDFLAGS += -melf32lriscv
  34. endif
  35. KBUILD_CFLAGS += -Wall
  36. ifeq ($(CONFIG_RISCV_ISA_A),y)
  37. KBUILD_ARCH_A = a
  38. endif
  39. ifeq ($(CONFIG_RISCV_ISA_C),y)
  40. KBUILD_ARCH_C = c
  41. endif
  42. KBUILD_AFLAGS += -march=$(KBUILD_MARCH)$(KBUILD_ARCH_A)fd$(KBUILD_ARCH_C)
  43. KBUILD_CFLAGS += -march=$(KBUILD_MARCH)$(KBUILD_ARCH_A)$(KBUILD_ARCH_C)
  44. KBUILD_CFLAGS += -mno-save-restore
  45. KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET)
  46. ifeq ($(CONFIG_CMODEL_MEDLOW),y)
  47. KBUILD_CFLAGS += -mcmodel=medlow
  48. endif
  49. ifeq ($(CONFIG_CMODEL_MEDANY),y)
  50. KBUILD_CFLAGS += -mcmodel=medany
  51. endif
  52. ifeq ($(CONFIG_MODULE_SECTIONS),y)
  53. KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/riscv/kernel/module.lds
  54. endif
  55. KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
  56. # GCC versions that support the "-mstrict-align" option default to allowing
  57. # unaligned accesses. While unaligned accesses are explicitly allowed in the
  58. # RISC-V ISA, they're emulated by machine mode traps on all extant
  59. # architectures. It's faster to have GCC emit only aligned accesses.
  60. KBUILD_CFLAGS += $(call cc-option,-mstrict-align)
  61. # arch specific predefines for sparse
  62. CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
  63. head-y := arch/riscv/kernel/head.o
  64. core-y += arch/riscv/kernel/ arch/riscv/mm/
  65. libs-y += arch/riscv/lib/
  66. PHONY += vdso_install
  67. vdso_install:
  68. $(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@
  69. all: vmlinux