Makefile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #
  2. # arch/arm64/Makefile
  3. #
  4. # This file is included by the global makefile so that you can add your own
  5. # architecture-specific flags and dependencies.
  6. #
  7. # This file is subject to the terms and conditions of the GNU General Public
  8. # License. See the file "COPYING" in the main directory of this archive
  9. # for more details.
  10. #
  11. # Copyright (C) 1995-2001 by Russell King
  12. LDFLAGS_vmlinux :=-p --no-undefined -X
  13. CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
  14. GZFLAGS :=-9
  15. ifneq ($(CONFIG_RELOCATABLE),)
  16. LDFLAGS_vmlinux += -pie -shared -Bsymbolic
  17. endif
  18. ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
  19. ifeq ($(call ld-option, --fix-cortex-a53-843419),)
  20. $(warning ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum)
  21. else
  22. LDFLAGS_vmlinux += --fix-cortex-a53-843419
  23. endif
  24. endif
  25. KBUILD_DEFCONFIG := defconfig
  26. # Check for binutils support for specific extensions
  27. lseinstr := $(call as-instr,.arch_extension lse,-DCONFIG_AS_LSE=1)
  28. ifeq ($(CONFIG_ARM64_LSE_ATOMICS), y)
  29. ifeq ($(lseinstr),)
  30. $(warning LSE atomics not supported by binutils)
  31. endif
  32. endif
  33. KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr)
  34. KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
  35. KBUILD_CFLAGS += $(call cc-option, -mpc-relative-literal-loads)
  36. KBUILD_AFLAGS += $(lseinstr)
  37. ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
  38. KBUILD_CPPFLAGS += -mbig-endian
  39. AS += -EB
  40. LD += -EB
  41. UTS_MACHINE := aarch64_be
  42. else
  43. KBUILD_CPPFLAGS += -mlittle-endian
  44. AS += -EL
  45. LD += -EL
  46. UTS_MACHINE := aarch64
  47. endif
  48. CHECKFLAGS += -D__aarch64__
  49. ifeq ($(CONFIG_ARM64_MODULE_CMODEL_LARGE), y)
  50. KBUILD_CFLAGS_MODULE += -mcmodel=large
  51. endif
  52. ifeq ($(CONFIG_ARM64_MODULE_PLTS),y)
  53. KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm64/kernel/module.lds
  54. endif
  55. # Default value
  56. head-y := arch/arm64/kernel/head.o
  57. # The byte offset of the kernel image in RAM from the start of RAM.
  58. ifeq ($(CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET), y)
  59. TEXT_OFFSET := $(shell awk "BEGIN {srand(); printf \"0x%06x\n\", \
  60. int(2 * 1024 * 1024 / (2 ^ $(CONFIG_ARM64_PAGE_SHIFT)) * \
  61. rand()) * (2 ^ $(CONFIG_ARM64_PAGE_SHIFT))}")
  62. else
  63. TEXT_OFFSET := 0x00080000
  64. endif
  65. # KASAN_SHADOW_OFFSET = VA_START + (1 << (VA_BITS - 3)) - (1 << 61)
  66. # in 32-bit arithmetic
  67. KASAN_SHADOW_OFFSET := $(shell printf "0x%08x00000000\n" $$(( \
  68. (0xffffffff & (-1 << ($(CONFIG_ARM64_VA_BITS) - 32))) \
  69. + (1 << ($(CONFIG_ARM64_VA_BITS) - 32 - 3)) \
  70. - (1 << (64 - 32 - 3)) )) )
  71. export TEXT_OFFSET GZFLAGS
  72. core-y += arch/arm64/kernel/ arch/arm64/mm/
  73. core-$(CONFIG_NET) += arch/arm64/net/
  74. core-$(CONFIG_KVM) += arch/arm64/kvm/
  75. core-$(CONFIG_XEN) += arch/arm64/xen/
  76. core-$(CONFIG_CRYPTO) += arch/arm64/crypto/
  77. libs-y := arch/arm64/lib/ $(libs-y)
  78. core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
  79. # Default target when executing plain make
  80. KBUILD_IMAGE := Image.gz
  81. KBUILD_DTBS := dtbs
  82. all: $(KBUILD_IMAGE) $(KBUILD_DTBS)
  83. boot := arch/arm64/boot
  84. Image: vmlinux
  85. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  86. Image.%: Image
  87. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  88. zinstall install:
  89. $(Q)$(MAKE) $(build)=$(boot) $@
  90. %.dtb: scripts
  91. $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@
  92. PHONY += dtbs dtbs_install
  93. dtbs: prepare scripts
  94. $(Q)$(MAKE) $(build)=$(boot)/dts
  95. dtbs_install:
  96. $(Q)$(MAKE) $(dtbinst)=$(boot)/dts
  97. PHONY += vdso_install
  98. vdso_install:
  99. $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
  100. # We use MRPROPER_FILES and CLEAN_FILES now
  101. archclean:
  102. $(Q)$(MAKE) $(clean)=$(boot)
  103. $(Q)$(MAKE) $(clean)=$(boot)/dts
  104. # We need to generate vdso-offsets.h before compiling certain files in kernel/.
  105. # In order to do that, we should use the archprepare target, but we can't since
  106. # asm-offsets.h is included in some files used to generate vdso-offsets.h, and
  107. # asm-offsets.h is built in prepare0, for which archprepare is a dependency.
  108. # Therefore we need to generate the header after prepare0 has been made, hence
  109. # this hack.
  110. prepare: vdso_prepare
  111. vdso_prepare: prepare0
  112. $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso include/generated/vdso-offsets.h
  113. define archhelp
  114. echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
  115. echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
  116. echo '* dtbs - Build device tree blobs for enabled boards'
  117. echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'
  118. echo ' install - Install uncompressed kernel'
  119. echo ' zinstall - Install compressed kernel'
  120. echo ' Install using (your) ~/bin/installkernel or'
  121. echo ' (distribution) /sbin/installkernel or'
  122. echo ' install to $$(INSTALL_PATH) and run lilo'
  123. endef