Makefile 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_LDFLAGS += -melf64lriscv
  25. else
  26. BITS := 32
  27. UTS_MACHINE := riscv32
  28. KBUILD_CFLAGS += -mabi=ilp32
  29. KBUILD_AFLAGS += -mabi=ilp32
  30. KBUILD_LDFLAGS += -melf32lriscv
  31. endif
  32. KBUILD_CFLAGS += -Wall
  33. # ISA string setting
  34. riscv-march-$(CONFIG_ARCH_RV32I) := rv32im
  35. riscv-march-$(CONFIG_ARCH_RV64I) := rv64im
  36. riscv-march-$(CONFIG_RISCV_ISA_A) := $(riscv-march-y)a
  37. riscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd
  38. riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c
  39. KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
  40. KBUILD_AFLAGS += -march=$(riscv-march-y)
  41. KBUILD_CFLAGS += -mno-save-restore
  42. KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET)
  43. ifeq ($(CONFIG_CMODEL_MEDLOW),y)
  44. KBUILD_CFLAGS += -mcmodel=medlow
  45. endif
  46. ifeq ($(CONFIG_CMODEL_MEDANY),y)
  47. KBUILD_CFLAGS += -mcmodel=medany
  48. endif
  49. ifeq ($(CONFIG_MODULE_SECTIONS),y)
  50. KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/riscv/kernel/module.lds
  51. endif
  52. KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
  53. # GCC versions that support the "-mstrict-align" option default to allowing
  54. # unaligned accesses. While unaligned accesses are explicitly allowed in the
  55. # RISC-V ISA, they're emulated by machine mode traps on all extant
  56. # architectures. It's faster to have GCC emit only aligned accesses.
  57. KBUILD_CFLAGS += $(call cc-option,-mstrict-align)
  58. # arch specific predefines for sparse
  59. CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
  60. # Default target when executing plain make
  61. boot := arch/riscv/boot
  62. KBUILD_IMAGE := $(boot)/Image.gz
  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: Image.gz
  70. Image: vmlinux
  71. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  72. Image.%: Image
  73. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  74. zinstall install:
  75. $(Q)$(MAKE) $(build)=$(boot) $@