blob: df1d6a150f3007a0cc6cfab410c9637ea0221170 [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
30KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-option,-ffreestanding)
Vasily Gorbikee6d7772018-06-28 19:22:21 +020031KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
32KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
Linus Torvalds1da177e2005-04-16 15:20:36 -070033UTS_MACHINE := s390x
Vasily Gorbik9fed9202018-10-26 15:29:59 +020034STACK_SIZE := $(if $(CONFIG_KASAN),65536,16384)
Luc Van Oostenryck145167652018-05-28 20:27:35 +020035CHECKFLAGS += -D__s390__ -D__s390x__
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010037export LD_BFD
38
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020039mflags-$(CONFIG_MARCH_Z900) := -march=z900
40mflags-$(CONFIG_MARCH_Z990) := -march=z990
41mflags-$(CONFIG_MARCH_Z9_109) := -march=z9-109
42mflags-$(CONFIG_MARCH_Z10) := -march=z10
43mflags-$(CONFIG_MARCH_Z196) := -march=z196
44mflags-$(CONFIG_MARCH_ZEC12) := -march=zEC12
Martin Schwidefsky6997c322017-04-12 14:17:25 +020045mflags-$(CONFIG_MARCH_Z13) := -march=z13
46mflags-$(CONFIG_MARCH_Z14) := -march=z14
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020047
Martin Schwidefsky22362a02015-07-08 10:20:04 +020048export CC_FLAGS_MARCH := $(mflags-y)
49
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020050aflags-y += $(mflags-y)
51cflags-y += $(mflags-y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Heiko Carstens1db9e052013-10-30 12:12:50 +010053cflags-$(CONFIG_MARCH_Z900_TUNE) += -mtune=z900
54cflags-$(CONFIG_MARCH_Z990_TUNE) += -mtune=z990
55cflags-$(CONFIG_MARCH_Z9_109_TUNE) += -mtune=z9-109
56cflags-$(CONFIG_MARCH_Z10_TUNE) += -mtune=z10
57cflags-$(CONFIG_MARCH_Z196_TUNE) += -mtune=z196
58cflags-$(CONFIG_MARCH_ZEC12_TUNE) += -mtune=zEC12
Martin Schwidefsky6997c322017-04-12 14:17:25 +020059cflags-$(CONFIG_MARCH_Z13_TUNE) += -mtune=z13
60cflags-$(CONFIG_MARCH_Z14_TUNE) += -mtune=z14
Heiko Carstens1db9e052013-10-30 12:12:50 +010061
Martin Schwidefskyc783b912016-09-06 10:46:36 +020062cflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
63
Heiko Carstenscbbd1fa2006-07-03 00:24:38 -070064#
65# Prevent tail-call optimizations, to get clearer backtraces:
66#
67cflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
68
Linus Torvalds1da177e2005-04-16 15:20:36 -070069ifeq ($(call cc-option-yn,-mpacked-stack),y)
70cflags-$(CONFIG_PACK_STACK) += -mpacked-stack -D__PACK_STACK
71aflags-$(CONFIG_PACK_STACK) += -D__PACK_STACK
Linus Torvalds1da177e2005-04-16 15:20:36 -070072endif
73
Vasily Gorbik76bf9d62018-06-15 12:28:05 +020074KBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
75KBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)
76
Linus Torvalds1da177e2005-04-16 15:20:36 -070077ifeq ($(call cc-option-yn,-mstack-size=8192 -mstack-guard=128),y)
78cflags-$(CONFIG_CHECK_STACK) += -mstack-size=$(STACK_SIZE)
Martin Schwidefskybe796282007-04-27 16:01:46 +020079ifneq ($(call cc-option-yn,-mstack-size=8192),y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070080cflags-$(CONFIG_CHECK_STACK) += -mstack-guard=$(CONFIG_STACK_GUARD)
81endif
Martin Schwidefskybe796282007-04-27 16:01:46 +020082endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
Vasily Gorbik76bf9d62018-06-15 12:28:05 +020084ifdef CONFIG_WARN_DYNAMIC_STACK
85 ifeq ($(call cc-option-yn,-mwarn-dynamicstack),y)
86 KBUILD_CFLAGS += -mwarn-dynamicstack
87 KBUILD_CFLAGS_DECOMPRESSOR += -mwarn-dynamicstack
88 endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070089endif
90
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +010091ifdef CONFIG_EXPOLINE
92 ifeq ($(call cc-option-yn,$(CC_FLAGS_MARCH) -mindirect-branch=thunk),y)
93 CC_FLAGS_EXPOLINE := -mindirect-branch=thunk
94 CC_FLAGS_EXPOLINE += -mfunction-return=thunk
95 CC_FLAGS_EXPOLINE += -mindirect-branch-table
96 export CC_FLAGS_EXPOLINE
Martin Schwidefsky6e179d62018-03-23 13:04:49 +010097 cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
Vasily Gorbik157484a2018-06-15 10:22:18 +020098 aflags-y += -DCC_USING_EXPOLINE
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +010099 endif
100endif
101
Heiko Carstense6d60b32015-01-09 13:08:28 +0100102ifdef CONFIG_FUNCTION_TRACER
Vasily Gorbikd983c892018-08-06 15:17:47 +0200103 ifeq ($(call cc-option-yn,-mfentry -mnop-mcount),n)
104 # make use of hotpatch feature if the compiler supports it
105 cc_hotpatch := -mhotpatch=0,3
106 ifeq ($(call cc-option-yn,$(cc_hotpatch)),y)
107 CC_FLAGS_FTRACE := $(cc_hotpatch)
108 KBUILD_AFLAGS += -DCC_USING_HOTPATCH
109 KBUILD_CFLAGS += -DCC_USING_HOTPATCH
110 endif
111 endif
Heiko Carstense6d60b32015-01-09 13:08:28 +0100112endif
113
Hendrik Brueckner7bceec42017-11-20 11:46:13 +0100114# Test CFI features of binutils
115cfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1)
116
Sam Ravnborga0f97e02007-10-14 22:21:35 +0200117KBUILD_CFLAGS += -mbackchain -msoft-float $(cflags-y)
Arnd Bergmannc1afcae2019-04-08 23:26:14 +0200118KBUILD_CFLAGS += -pipe -Wno-sign-compare
Hendrik Brueckner7bceec42017-11-20 11:46:13 +0100119KBUILD_CFLAGS += -fno-asynchronous-unwind-tables $(cfi)
120KBUILD_AFLAGS += $(aflags-y) $(cfi)
Vasily Gorbik76bf9d62018-06-15 12:28:05 +0200121export KBUILD_AFLAGS_DECOMPRESSOR
122export KBUILD_CFLAGS_DECOMPRESSOR
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123
124OBJCOPYFLAGS := -O binary
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
Vasily Gorbik8282cd62018-06-12 15:11:40 +0200126head-y := arch/s390/kernel/head64.o
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
Heiko Carstens01485942010-10-25 16:10:09 +0200128# See arch/s390/Kbuild for content of core part of the kernel
129core-y += arch/s390/
Hans-Joachim Picht155af2f2009-06-16 10:30:52 +0200130
Michael Holzheu4562c9f2007-02-21 10:55:46 +0100131libs-y += arch/s390/lib/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132drivers-y += drivers/s390/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
134# must be linked after kernel
135drivers-$(CONFIG_OPROFILE) += arch/s390/oprofile/
136
Michael Holzheu4562c9f2007-02-21 10:55:46 +0100137boot := arch/s390/boot
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100138syscalls := arch/s390/kernel/syscalls
Heiko Carstensc30f6822015-02-02 07:08:44 +0100139tools := arch/s390/tools
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
Vasily Gorbik00f2fb52018-06-11 14:35:01 +0200141all: bzImage
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
Vasily Gorbike0aa0992018-02-20 11:31:34 +0100143#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
144KBUILD_IMAGE := $(boot)/bzImage
145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146install: vmlinux
147 $(Q)$(MAKE) $(build)=$(boot) $@
148
Vasily Gorbik00f2fb52018-06-11 14:35:01 +0200149bzImage: vmlinux
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
151
Michael Holzheu411ed322007-04-27 16:01:49 +0200152zfcpdump:
153 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
154
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200155vdso_install:
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200156 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200157 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159archclean:
160 $(Q)$(MAKE) $(clean)=$(boot)
Heiko Carstensc30f6822015-02-02 07:08:44 +0100161 $(Q)$(MAKE) $(clean)=$(tools)
162
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100163archheaders:
164 $(Q)$(MAKE) $(build)=$(syscalls) uapi
165
Heiko Carstensc30f6822015-02-02 07:08:44 +0100166archprepare:
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100167 $(Q)$(MAKE) $(build)=$(syscalls) kapi
Hendrik Brueckner7fbf8312018-01-11 12:13:18 +0100168 $(Q)$(MAKE) $(build)=$(tools) kapi
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170# Don't use tabs in echo arguments
171define archhelp
Vasily Gorbik00f2fb52018-06-11 14:35:01 +0200172 echo '* bzImage - Kernel image for IPL ($(boot)/bzImage)'
Michael Holzheub8eecf32015-11-25 11:54:36 +0100173 echo ' install - Install kernel using'
174 echo ' (your) ~/bin/$(INSTALLKERNEL) or'
175 echo ' (distribution) /sbin/$(INSTALLKERNEL) or'
176 echo ' install to $$(INSTALL_PATH)'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177endef