blob: 354d75402aceaa771adc63c04ecd51538edcbb0b [file] [log] [blame]
Catalin Marinas8c2c3df2012-04-20 14:45:54 +01001#
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
13LDFLAGS_vmlinux :=-p --no-undefined -X
14CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
15OBJCOPYFLAGS :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
16GZFLAGS :=-9
17
Ard Biesheuvel1e48ef72016-01-26 09:13:44 +010018ifneq ($(CONFIG_RELOCATABLE),)
19LDFLAGS_vmlinux += -pie
20endif
21
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010022KBUILD_DEFCONFIG := defconfig
23
Will Deaconc09d6a02015-02-03 16:14:13 +000024# Check for binutils support for specific extensions
25lseinstr := $(call as-instr,.arch_extension lse,-DCONFIG_AS_LSE=1)
26
27ifeq ($(CONFIG_ARM64_LSE_ATOMICS), y)
28 ifeq ($(lseinstr),)
29$(warning LSE atomics not supported by binutils)
30 endif
31endif
32
33KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr)
William Cohen728dabd2016-01-21 22:56:26 -050034KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
dann frazier67dfa172016-01-25 16:52:16 -070035KBUILD_CFLAGS += $(call cc-option, -mpc-relative-literal-loads)
Will Deaconc09d6a02015-02-03 16:14:13 +000036KBUILD_AFLAGS += $(lseinstr)
37
Will Deacona0974e62013-10-11 14:52:08 +010038ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
39KBUILD_CPPFLAGS += -mbig-endian
40AS += -EB
41LD += -EB
42else
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010043KBUILD_CPPFLAGS += -mlittle-endian
44AS += -EL
45LD += -EL
Will Deacona0974e62013-10-11 14:52:08 +010046endif
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010047
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010048CHECKFLAGS += -D__aarch64__
49
Ard Biesheuvelfd045f62015-11-24 12:37:35 +010050ifeq ($(CONFIG_ARM64_MODULE_CMODEL_LARGE), y)
Will Deaconb6dd8e02015-10-08 11:11:17 +010051KBUILD_CFLAGS_MODULE += -mcmodel=large
Will Deacondf057cc2015-03-17 12:15:02 +000052endif
53
Ard Biesheuvelfd045f62015-11-24 12:37:35 +010054ifeq ($(CONFIG_ARM64_MODULE_PLTS),y)
55KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm64/kernel/module.lds
56endif
57
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010058# Default value
59head-y := arch/arm64/kernel/head.o
60
61# The byte offset of the kernel image in RAM from the start of RAM.
Mark Rutlandda57a362014-06-24 16:51:37 +010062ifeq ($(CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET), y)
Ard Biesheuvel41903122014-08-13 18:53:03 +010063TEXT_OFFSET := $(shell awk 'BEGIN {srand(); printf "0x%03x000\n", int(512 * rand())}')
Mark Rutlandda57a362014-06-24 16:51:37 +010064else
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010065TEXT_OFFSET := 0x00080000
Mark Rutlandda57a362014-06-24 16:51:37 +010066endif
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010067
Andrey Ryabinin39d114d2015-10-12 18:52:58 +030068# KASAN_SHADOW_OFFSET = VA_START + (1 << (VA_BITS - 3)) - (1 << 61)
69# in 32-bit arithmetic
70KASAN_SHADOW_OFFSET := $(shell printf "0x%08x00000000\n" $$(( \
71 (0xffffffff & (-1 << ($(CONFIG_ARM64_VA_BITS) - 32))) \
72 + (1 << ($(CONFIG_ARM64_VA_BITS) - 32 - 3)) \
73 - (1 << (64 - 32 - 3)) )) )
74
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010075export TEXT_OFFSET GZFLAGS
76
77core-y += arch/arm64/kernel/ arch/arm64/mm/
Zi Shen Lime54bcde2014-08-26 21:15:30 -070078core-$(CONFIG_NET) += arch/arm64/net/
Marc Zyngier62117532012-12-10 16:41:44 +000079core-$(CONFIG_KVM) += arch/arm64/kvm/
Catalin Marinas63917f02013-06-12 16:48:38 +010080core-$(CONFIG_XEN) += arch/arm64/xen/
Ard Biesheuvel2c988332014-03-06 16:23:33 +080081core-$(CONFIG_CRYPTO) += arch/arm64/crypto/
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010082libs-y := arch/arm64/lib/ $(libs-y)
Steve Capperad08fd42015-03-16 09:30:39 +000083core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010084
85# Default target when executing plain make
Rob Herring70f915a2012-12-03 17:17:21 -060086KBUILD_IMAGE := Image.gz
87KBUILD_DTBS := dtbs
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010088
Rob Herring70f915a2012-12-03 17:17:21 -060089all: $(KBUILD_IMAGE) $(KBUILD_DTBS)
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010090
91boot := arch/arm64/boot
92
Olof Johansson0723c052015-07-16 21:26:16 +010093Image: vmlinux
94 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
95
96Image.%: vmlinux
Rob Herring70f915a2012-12-03 17:17:21 -060097 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010098
Masahiro Yamada8684fa32016-02-19 15:05:50 +090099zinstall install:
Rob Herring70f915a2012-12-03 17:17:21 -0600100 $(Q)$(MAKE) $(build)=$(boot) $@
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100101
Rob Herring70f915a2012-12-03 17:17:21 -0600102%.dtb: scripts
103 $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@
104
Robert Richter862f4642014-08-29 14:17:02 +0200105PHONY += dtbs dtbs_install
Robert Richter9fb5e532014-09-03 15:29:24 +0200106
107dtbs: prepare scripts
Robert Richterd38726c2014-09-03 15:54:55 +0200108 $(Q)$(MAKE) $(build)=$(boot)/dts
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100109
Robert Richter9fb5e532014-09-03 15:29:24 +0200110dtbs_install:
111 $(Q)$(MAKE) $(dtbinst)=$(boot)/dts
112
Kyle McMartin3c017422013-06-16 20:32:44 +0100113PHONY += vdso_install
114vdso_install:
115 $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
116
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100117# We use MRPROPER_FILES and CLEAN_FILES now
118archclean:
119 $(Q)$(MAKE) $(clean)=$(boot)
Jungseok Leec7c52e42015-01-19 14:57:00 +0000120 $(Q)$(MAKE) $(clean)=$(boot)/dts
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100121
122define archhelp
123 echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
124 echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
Rob Herring70f915a2012-12-03 17:17:21 -0600125 echo '* dtbs - Build device tree blobs for enabled boards'
Robert Richter862f4642014-08-29 14:17:02 +0200126 echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100127 echo ' install - Install uncompressed kernel'
128 echo ' zinstall - Install compressed kernel'
129 echo ' Install using (your) ~/bin/installkernel or'
130 echo ' (distribution) /sbin/installkernel or'
131 echo ' install to $$(INSTALL_PATH) and run lilo'
132endef