blob: 92506918da633ebe9026ecde26fcb9cfb403d6c1 [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
28KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float
29KBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
Masahiro Yamada685969e2020-06-27 03:59:13 +090030KBUILD_CFLAGS_DECOMPRESSOR += -ffreestanding
Fabrice Fontaine7b18f26d2021-05-10 07:31:33 +020031KBUILD_CFLAGS_DECOMPRESSOR += -fno-stack-protector
Heiko Carstensf9364df2019-06-04 13:10:51 +020032KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member)
Vasily Gorbikee6d7772018-06-28 19:22:21 +020033KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
34KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
Linus Torvalds1da177e2005-04-16 15:20:36 -070035UTS_MACHINE := s390x
Vasily Gorbik9fed9202018-10-26 15:29:59 +020036STACK_SIZE := $(if $(CONFIG_KASAN),65536,16384)
Luc Van Oostenryck145167652018-05-28 20:27:35 +020037CHECKFLAGS += -D__s390__ -D__s390x__
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010039export LD_BFD
40
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020041mflags-$(CONFIG_MARCH_Z900) := -march=z900
42mflags-$(CONFIG_MARCH_Z990) := -march=z990
43mflags-$(CONFIG_MARCH_Z9_109) := -march=z9-109
44mflags-$(CONFIG_MARCH_Z10) := -march=z10
45mflags-$(CONFIG_MARCH_Z196) := -march=z196
46mflags-$(CONFIG_MARCH_ZEC12) := -march=zEC12
Martin Schwidefsky6997c322017-04-12 14:17:25 +020047mflags-$(CONFIG_MARCH_Z13) := -march=z13
48mflags-$(CONFIG_MARCH_Z14) := -march=z14
Martin Schwidefskya0e22512019-02-06 08:22:11 +010049mflags-$(CONFIG_MARCH_Z15) := -march=z15
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020050
Martin Schwidefsky22362a02015-07-08 10:20:04 +020051export CC_FLAGS_MARCH := $(mflags-y)
52
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020053aflags-y += $(mflags-y)
54cflags-y += $(mflags-y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Heiko Carstens1db9e052013-10-30 12:12:50 +010056cflags-$(CONFIG_MARCH_Z900_TUNE) += -mtune=z900
57cflags-$(CONFIG_MARCH_Z990_TUNE) += -mtune=z990
58cflags-$(CONFIG_MARCH_Z9_109_TUNE) += -mtune=z9-109
59cflags-$(CONFIG_MARCH_Z10_TUNE) += -mtune=z10
60cflags-$(CONFIG_MARCH_Z196_TUNE) += -mtune=z196
61cflags-$(CONFIG_MARCH_ZEC12_TUNE) += -mtune=zEC12
Martin Schwidefsky6997c322017-04-12 14:17:25 +020062cflags-$(CONFIG_MARCH_Z13_TUNE) += -mtune=z13
63cflags-$(CONFIG_MARCH_Z14_TUNE) += -mtune=z14
Martin Schwidefskya0e22512019-02-06 08:22:11 +010064cflags-$(CONFIG_MARCH_Z15_TUNE) += -mtune=z15
Heiko Carstens1db9e052013-10-30 12:12:50 +010065
Martin Schwidefskyc783b91e2016-09-06 10:46:36 +020066cflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
67
Heiko Carstenscbbd1fa2006-07-03 00:24:38 -070068#
69# Prevent tail-call optimizations, to get clearer backtraces:
70#
71cflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
72
Vasily Gorbik253b3c42020-01-08 14:46:00 +010073ifeq ($(call cc-option-yn,-mpacked-stack -mbackchain -msoft-float),y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070074cflags-$(CONFIG_PACK_STACK) += -mpacked-stack -D__PACK_STACK
75aflags-$(CONFIG_PACK_STACK) += -D__PACK_STACK
Linus Torvalds1da177e2005-04-16 15:20:36 -070076endif
77
Vasily Gorbik76bf9d62018-06-15 12:28:05 +020078KBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
79KBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081ifeq ($(call cc-option-yn,-mstack-size=8192 -mstack-guard=128),y)
82cflags-$(CONFIG_CHECK_STACK) += -mstack-size=$(STACK_SIZE)
Martin Schwidefskybe796282007-04-27 16:01:46 +020083ifneq ($(call cc-option-yn,-mstack-size=8192),y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070084cflags-$(CONFIG_CHECK_STACK) += -mstack-guard=$(CONFIG_STACK_GUARD)
85endif
Martin Schwidefskybe796282007-04-27 16:01:46 +020086endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
Vasily Gorbik76bf9d62018-06-15 12:28:05 +020088ifdef CONFIG_WARN_DYNAMIC_STACK
89 ifeq ($(call cc-option-yn,-mwarn-dynamicstack),y)
90 KBUILD_CFLAGS += -mwarn-dynamicstack
91 KBUILD_CFLAGS_DECOMPRESSOR += -mwarn-dynamicstack
92 endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070093endif
94
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +010095ifdef CONFIG_EXPOLINE
96 ifeq ($(call cc-option-yn,$(CC_FLAGS_MARCH) -mindirect-branch=thunk),y)
97 CC_FLAGS_EXPOLINE := -mindirect-branch=thunk
98 CC_FLAGS_EXPOLINE += -mfunction-return=thunk
99 CC_FLAGS_EXPOLINE += -mindirect-branch-table
100 export CC_FLAGS_EXPOLINE
Martin Schwidefsky6e179d62018-03-23 13:04:49 +0100101 cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
Vasily Gorbik157484a2018-06-15 10:22:18 +0200102 aflags-y += -DCC_USING_EXPOLINE
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +0100103 endif
104endif
105
Heiko Carstense6d60b32015-01-09 13:08:28 +0100106ifdef CONFIG_FUNCTION_TRACER
Vasily Gorbikd983c892018-08-06 15:17:47 +0200107 ifeq ($(call cc-option-yn,-mfentry -mnop-mcount),n)
108 # make use of hotpatch feature if the compiler supports it
109 cc_hotpatch := -mhotpatch=0,3
110 ifeq ($(call cc-option-yn,$(cc_hotpatch)),y)
111 CC_FLAGS_FTRACE := $(cc_hotpatch)
112 KBUILD_AFLAGS += -DCC_USING_HOTPATCH
113 KBUILD_CFLAGS += -DCC_USING_HOTPATCH
114 endif
115 endif
Heiko Carstense6d60b32015-01-09 13:08:28 +0100116endif
117
Hendrik Brueckner7bceec42017-11-20 11:46:13 +0100118# Test CFI features of binutils
119cfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1)
120
Sam Ravnborga0f97e02007-10-14 22:21:35 +0200121KBUILD_CFLAGS += -mbackchain -msoft-float $(cflags-y)
Arnd Bergmannc1afcae2019-04-08 23:26:14 +0200122KBUILD_CFLAGS += -pipe -Wno-sign-compare
Hendrik Brueckner7bceec42017-11-20 11:46:13 +0100123KBUILD_CFLAGS += -fno-asynchronous-unwind-tables $(cfi)
124KBUILD_AFLAGS += $(aflags-y) $(cfi)
Vasily Gorbik76bf9d62018-06-15 12:28:05 +0200125export KBUILD_AFLAGS_DECOMPRESSOR
126export KBUILD_CFLAGS_DECOMPRESSOR
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128OBJCOPYFLAGS := -O binary
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
Vasily Gorbik8282cd62018-06-12 15:11:40 +0200130head-y := arch/s390/kernel/head64.o
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
Heiko Carstens01485942010-10-25 16:10:09 +0200132# See arch/s390/Kbuild for content of core part of the kernel
133core-y += arch/s390/
Hans-Joachim Picht155af2f2009-06-16 10:30:52 +0200134
Michael Holzheu4562c9f2007-02-21 10:55:46 +0100135libs-y += arch/s390/lib/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136drivers-y += drivers/s390/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
138# must be linked after kernel
139drivers-$(CONFIG_OPROFILE) += arch/s390/oprofile/
140
Michael Holzheu4562c9f2007-02-21 10:55:46 +0100141boot := arch/s390/boot
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100142syscalls := arch/s390/kernel/syscalls
Heiko Carstensc30f6822015-02-02 07:08:44 +0100143tools := arch/s390/tools
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
Vasily Gorbik00f2fb52018-06-11 14:35:01 +0200145all: bzImage
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Vasily Gorbike0aa0992018-02-20 11:31:34 +0100147#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
148KBUILD_IMAGE := $(boot)/bzImage
149
Masahiro Yamada94e90f72020-02-16 23:48:29 +0900150install:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 $(Q)$(MAKE) $(build)=$(boot) $@
152
Vasily Gorbik00f2fb52018-06-11 14:35:01 +0200153bzImage: vmlinux
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
155
Michael Holzheu411ed322007-04-27 16:01:49 +0200156zfcpdump:
157 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
158
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200159vdso_install:
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200160 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200161
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162archclean:
163 $(Q)$(MAKE) $(clean)=$(boot)
Heiko Carstensc30f6822015-02-02 07:08:44 +0100164 $(Q)$(MAKE) $(clean)=$(tools)
165
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100166archheaders:
167 $(Q)$(MAKE) $(build)=$(syscalls) uapi
168
Heiko Carstensc30f6822015-02-02 07:08:44 +0100169archprepare:
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100170 $(Q)$(MAKE) $(build)=$(syscalls) kapi
Hendrik Brueckner7fbf8312018-01-11 12:13:18 +0100171 $(Q)$(MAKE) $(build)=$(tools) kapi
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173# Don't use tabs in echo arguments
174define archhelp
Vasily Gorbik00f2fb52018-06-11 14:35:01 +0200175 echo '* bzImage - Kernel image for IPL ($(boot)/bzImage)'
Michael Holzheub8eecf32015-11-25 11:54:36 +0100176 echo ' install - Install kernel using'
177 echo ' (your) ~/bin/$(INSTALLKERNEL) or'
178 echo ' (distribution) /sbin/$(INSTALLKERNEL) or'
179 echo ' install to $$(INSTALL_PATH)'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180endef