blob: 8db267d2a543ab7a66faf3cbf4a481ba17135a28 [file] [log] [blame]
Greg Kroah-Hartman0b732142017-11-24 15:00:38 +01001# SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#
3# s390/Makefile
4#
5# This file is included by the global makefile so that you can add your own
6# architecture-specific flags and dependencies. Remember to do have actions
7# for "archclean" and "archdep" for cleaning up and making dependencies for
8# this architecture
9#
Linus Torvalds1da177e2005-04-16 15:20:36 -070010# Copyright (C) 1994 by Linus Torvalds
11#
12
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010013LD_BFD := elf64-s390
Masahiro Yamadad503ac52018-08-24 08:20:39 +090014KBUILD_LDFLAGS := -m elf64_s390
Martin Schwidefsky7bdc2292013-01-11 15:26:01 +010015KBUILD_AFLAGS_MODULE += -fPIC
16KBUILD_CFLAGS_MODULE += -fPIC
Sam Ravnborg222d3942007-10-15 21:59:31 +020017KBUILD_AFLAGS += -m64
Vasily Gorbik76bf9d62018-06-15 12:28:05 +020018KBUILD_CFLAGS += -m64
Gerald Schaefer805bc0b2019-02-03 21:35:45 +010019ifeq ($(CONFIG_RELOCATABLE),y)
20KBUILD_CFLAGS += -fPIE
21LDFLAGS_vmlinux := -pie
22endif
Vasily Gorbikee6d7772018-06-28 19:22:21 +020023aflags_dwarf := -Wa,-gdwarf-2
Arnd Bergmann96fb54a2019-04-15 10:35:52 +020024KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
Vasily Gorbikee6d7772018-06-28 19:22:21 +020025KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
Arnd Bergmann96fb54a2019-04-15 10:35:52 +020026KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2
Vasily Gorbik76bf9d62018-06-15 12:28:05 +020027KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
Vasily Gorbik8977ab62020-11-10 17:05:35 +010028KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float -mbackchain
Vasily Gorbik76bf9d62018-06-15 12:28:05 +020029KBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
Masahiro Yamada685969e2020-06-27 03:59:13 +090030KBUILD_CFLAGS_DECOMPRESSOR += -ffreestanding
Heiko Carstensf9364df2019-06-04 13:10:51 +020031KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member)
Vasily Gorbikee6d7772018-06-28 19:22:21 +020032KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
33KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
Linus Torvalds1da177e2005-04-16 15:20:36 -070034UTS_MACHINE := s390x
Vasily Gorbik9fed9202018-10-26 15:29:59 +020035STACK_SIZE := $(if $(CONFIG_KASAN),65536,16384)
Luc Van Oostenryck145167652018-05-28 20:27:35 +020036CHECKFLAGS += -D__s390__ -D__s390x__
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010038export LD_BFD
39
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020040mflags-$(CONFIG_MARCH_Z900) := -march=z900
41mflags-$(CONFIG_MARCH_Z990) := -march=z990
42mflags-$(CONFIG_MARCH_Z9_109) := -march=z9-109
43mflags-$(CONFIG_MARCH_Z10) := -march=z10
44mflags-$(CONFIG_MARCH_Z196) := -march=z196
45mflags-$(CONFIG_MARCH_ZEC12) := -march=zEC12
Martin Schwidefsky6997c322017-04-12 14:17:25 +020046mflags-$(CONFIG_MARCH_Z13) := -march=z13
47mflags-$(CONFIG_MARCH_Z14) := -march=z14
Martin Schwidefskya0e22512019-02-06 08:22:11 +010048mflags-$(CONFIG_MARCH_Z15) := -march=z15
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020049
Martin Schwidefsky22362a02015-07-08 10:20:04 +020050export CC_FLAGS_MARCH := $(mflags-y)
51
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020052aflags-y += $(mflags-y)
53cflags-y += $(mflags-y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Heiko Carstens1db9e052013-10-30 12:12:50 +010055cflags-$(CONFIG_MARCH_Z900_TUNE) += -mtune=z900
56cflags-$(CONFIG_MARCH_Z990_TUNE) += -mtune=z990
57cflags-$(CONFIG_MARCH_Z9_109_TUNE) += -mtune=z9-109
58cflags-$(CONFIG_MARCH_Z10_TUNE) += -mtune=z10
59cflags-$(CONFIG_MARCH_Z196_TUNE) += -mtune=z196
60cflags-$(CONFIG_MARCH_ZEC12_TUNE) += -mtune=zEC12
Martin Schwidefsky6997c322017-04-12 14:17:25 +020061cflags-$(CONFIG_MARCH_Z13_TUNE) += -mtune=z13
62cflags-$(CONFIG_MARCH_Z14_TUNE) += -mtune=z14
Martin Schwidefskya0e22512019-02-06 08:22:11 +010063cflags-$(CONFIG_MARCH_Z15_TUNE) += -mtune=z15
Heiko Carstens1db9e052013-10-30 12:12:50 +010064
Martin Schwidefskyc783b912016-09-06 10:46:36 +020065cflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
66
Heiko Carstenscbbd1fa2006-07-03 00:24:38 -070067#
68# Prevent tail-call optimizations, to get clearer backtraces:
69#
70cflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
71
Vasily Gorbik253b3c42020-01-08 14:46:00 +010072ifeq ($(call cc-option-yn,-mpacked-stack -mbackchain -msoft-float),y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073cflags-$(CONFIG_PACK_STACK) += -mpacked-stack -D__PACK_STACK
74aflags-$(CONFIG_PACK_STACK) += -D__PACK_STACK
Linus Torvalds1da177e2005-04-16 15:20:36 -070075endif
76
Vasily Gorbik76bf9d62018-06-15 12:28:05 +020077KBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
78KBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)
79
Linus Torvalds1da177e2005-04-16 15:20:36 -070080ifeq ($(call cc-option-yn,-mstack-size=8192 -mstack-guard=128),y)
81cflags-$(CONFIG_CHECK_STACK) += -mstack-size=$(STACK_SIZE)
Martin Schwidefskybe796282007-04-27 16:01:46 +020082ifneq ($(call cc-option-yn,-mstack-size=8192),y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083cflags-$(CONFIG_CHECK_STACK) += -mstack-guard=$(CONFIG_STACK_GUARD)
84endif
Martin Schwidefskybe796282007-04-27 16:01:46 +020085endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
Vasily Gorbik76bf9d62018-06-15 12:28:05 +020087ifdef CONFIG_WARN_DYNAMIC_STACK
88 ifeq ($(call cc-option-yn,-mwarn-dynamicstack),y)
89 KBUILD_CFLAGS += -mwarn-dynamicstack
90 KBUILD_CFLAGS_DECOMPRESSOR += -mwarn-dynamicstack
91 endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070092endif
93
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +010094ifdef CONFIG_EXPOLINE
95 ifeq ($(call cc-option-yn,$(CC_FLAGS_MARCH) -mindirect-branch=thunk),y)
96 CC_FLAGS_EXPOLINE := -mindirect-branch=thunk
97 CC_FLAGS_EXPOLINE += -mfunction-return=thunk
98 CC_FLAGS_EXPOLINE += -mindirect-branch-table
99 export CC_FLAGS_EXPOLINE
Martin Schwidefsky6e179d62018-03-23 13:04:49 +0100100 cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
Vasily Gorbik157484a2018-06-15 10:22:18 +0200101 aflags-y += -DCC_USING_EXPOLINE
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +0100102 endif
103endif
104
Heiko Carstense6d60b32015-01-09 13:08:28 +0100105ifdef CONFIG_FUNCTION_TRACER
Vasily Gorbikd983c892018-08-06 15:17:47 +0200106 ifeq ($(call cc-option-yn,-mfentry -mnop-mcount),n)
107 # make use of hotpatch feature if the compiler supports it
108 cc_hotpatch := -mhotpatch=0,3
109 ifeq ($(call cc-option-yn,$(cc_hotpatch)),y)
110 CC_FLAGS_FTRACE := $(cc_hotpatch)
111 KBUILD_AFLAGS += -DCC_USING_HOTPATCH
112 KBUILD_CFLAGS += -DCC_USING_HOTPATCH
113 endif
114 endif
Heiko Carstense6d60b32015-01-09 13:08:28 +0100115endif
116
Hendrik Brueckner7bceec42017-11-20 11:46:13 +0100117# Test CFI features of binutils
118cfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1)
119
Sam Ravnborga0f97e02007-10-14 22:21:35 +0200120KBUILD_CFLAGS += -mbackchain -msoft-float $(cflags-y)
Arnd Bergmannc1afcae2019-04-08 23:26:14 +0200121KBUILD_CFLAGS += -pipe -Wno-sign-compare
Hendrik Brueckner7bceec42017-11-20 11:46:13 +0100122KBUILD_CFLAGS += -fno-asynchronous-unwind-tables $(cfi)
123KBUILD_AFLAGS += $(aflags-y) $(cfi)
Vasily Gorbik76bf9d62018-06-15 12:28:05 +0200124export KBUILD_AFLAGS_DECOMPRESSOR
125export KBUILD_CFLAGS_DECOMPRESSOR
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
127OBJCOPYFLAGS := -O binary
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
Vasily Gorbik8282cd62018-06-12 15:11:40 +0200129head-y := arch/s390/kernel/head64.o
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
Heiko Carstens01485942010-10-25 16:10:09 +0200131# See arch/s390/Kbuild for content of core part of the kernel
132core-y += arch/s390/
Hans-Joachim Picht155af2f2009-06-16 10:30:52 +0200133
Michael Holzheu4562c9f2007-02-21 10:55:46 +0100134libs-y += arch/s390/lib/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135drivers-y += drivers/s390/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
137# must be linked after kernel
138drivers-$(CONFIG_OPROFILE) += arch/s390/oprofile/
139
Michael Holzheu4562c9f2007-02-21 10:55:46 +0100140boot := arch/s390/boot
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100141syscalls := arch/s390/kernel/syscalls
Heiko Carstensc30f6822015-02-02 07:08:44 +0100142tools := arch/s390/tools
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
Vasily Gorbik00f2fb52018-06-11 14:35:01 +0200144all: bzImage
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
Vasily Gorbike0aa0992018-02-20 11:31:34 +0100146#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
147KBUILD_IMAGE := $(boot)/bzImage
148
Masahiro Yamada94e90f72020-02-16 23:48:29 +0900149install:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 $(Q)$(MAKE) $(build)=$(boot) $@
151
Vasily Gorbik00f2fb52018-06-11 14:35:01 +0200152bzImage: vmlinux
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
154
Michael Holzheu411ed322007-04-27 16:01:49 +0200155zfcpdump:
156 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
157
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200158vdso_install:
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200159 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200160
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161archclean:
162 $(Q)$(MAKE) $(clean)=$(boot)
Heiko Carstensc30f6822015-02-02 07:08:44 +0100163 $(Q)$(MAKE) $(clean)=$(tools)
164
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100165archheaders:
166 $(Q)$(MAKE) $(build)=$(syscalls) uapi
167
Heiko Carstensc30f6822015-02-02 07:08:44 +0100168archprepare:
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100169 $(Q)$(MAKE) $(build)=$(syscalls) kapi
Hendrik Brueckner7fbf8312018-01-11 12:13:18 +0100170 $(Q)$(MAKE) $(build)=$(tools) kapi
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172# Don't use tabs in echo arguments
173define archhelp
Vasily Gorbik00f2fb52018-06-11 14:35:01 +0200174 echo '* bzImage - Kernel image for IPL ($(boot)/bzImage)'
Michael Holzheub8eecf32015-11-25 11:54:36 +0100175 echo ' install - Install kernel using'
176 echo ' (your) ~/bin/$(INSTALLKERNEL) or'
177 echo ' (distribution) /sbin/$(INSTALLKERNEL) or'
178 echo ' install to $$(INSTALL_PATH)'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179endef