blob: 8498babb5dad3dd284317aaed31e11a5ffc138a3 [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070014LDFLAGS := -m elf64_s390
Martin Schwidefsky7bdc2292013-01-11 15:26:01 +010015KBUILD_AFLAGS_MODULE += -fPIC
16KBUILD_CFLAGS_MODULE += -fPIC
Sam Ravnborga0f97e02007-10-14 22:21:35 +020017KBUILD_CFLAGS += -m64
Sam Ravnborg222d3942007-10-15 21:59:31 +020018KBUILD_AFLAGS += -m64
Linus Torvalds1da177e2005-04-16 15:20:36 -070019UTS_MACHINE := s390x
20STACK_SIZE := 16384
Luc Van Oostenryck145167652018-05-28 20:27:35 +020021CHECKFLAGS += -D__s390__ -D__s390x__
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010023export LD_BFD
24
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020025mflags-$(CONFIG_MARCH_Z900) := -march=z900
26mflags-$(CONFIG_MARCH_Z990) := -march=z990
27mflags-$(CONFIG_MARCH_Z9_109) := -march=z9-109
28mflags-$(CONFIG_MARCH_Z10) := -march=z10
29mflags-$(CONFIG_MARCH_Z196) := -march=z196
30mflags-$(CONFIG_MARCH_ZEC12) := -march=zEC12
Martin Schwidefsky6997c322017-04-12 14:17:25 +020031mflags-$(CONFIG_MARCH_Z13) := -march=z13
32mflags-$(CONFIG_MARCH_Z14) := -march=z14
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020033
Martin Schwidefsky22362a02015-07-08 10:20:04 +020034export CC_FLAGS_MARCH := $(mflags-y)
35
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020036aflags-y += $(mflags-y)
37cflags-y += $(mflags-y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Heiko Carstens1db9e052013-10-30 12:12:50 +010039cflags-$(CONFIG_MARCH_Z900_TUNE) += -mtune=z900
40cflags-$(CONFIG_MARCH_Z990_TUNE) += -mtune=z990
41cflags-$(CONFIG_MARCH_Z9_109_TUNE) += -mtune=z9-109
42cflags-$(CONFIG_MARCH_Z10_TUNE) += -mtune=z10
43cflags-$(CONFIG_MARCH_Z196_TUNE) += -mtune=z196
44cflags-$(CONFIG_MARCH_ZEC12_TUNE) += -mtune=zEC12
Martin Schwidefsky6997c322017-04-12 14:17:25 +020045cflags-$(CONFIG_MARCH_Z13_TUNE) += -mtune=z13
46cflags-$(CONFIG_MARCH_Z14_TUNE) += -mtune=z14
Heiko Carstens1db9e052013-10-30 12:12:50 +010047
Martin Schwidefskyc783b912016-09-06 10:46:36 +020048cflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
49
Heiko Carstenscbbd1fa2006-07-03 00:24:38 -070050#
51# Prevent tail-call optimizations, to get clearer backtraces:
52#
53cflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055# old style option for packed stacks
56ifeq ($(call cc-option-yn,-mkernel-backchain),y)
57cflags-$(CONFIG_PACK_STACK) += -mkernel-backchain -D__PACK_STACK
58aflags-$(CONFIG_PACK_STACK) += -D__PACK_STACK
Linus Torvalds1da177e2005-04-16 15:20:36 -070059endif
60
61# new style option for packed stacks
62ifeq ($(call cc-option-yn,-mpacked-stack),y)
63cflags-$(CONFIG_PACK_STACK) += -mpacked-stack -D__PACK_STACK
64aflags-$(CONFIG_PACK_STACK) += -D__PACK_STACK
Linus Torvalds1da177e2005-04-16 15:20:36 -070065endif
66
67ifeq ($(call cc-option-yn,-mstack-size=8192 -mstack-guard=128),y)
68cflags-$(CONFIG_CHECK_STACK) += -mstack-size=$(STACK_SIZE)
Martin Schwidefskybe796282007-04-27 16:01:46 +020069ifneq ($(call cc-option-yn,-mstack-size=8192),y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070070cflags-$(CONFIG_CHECK_STACK) += -mstack-guard=$(CONFIG_STACK_GUARD)
71endif
Martin Schwidefskybe796282007-04-27 16:01:46 +020072endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74ifeq ($(call cc-option-yn,-mwarn-dynamicstack),y)
Jan Glauber2c190da2011-03-15 17:08:19 +010075cflags-$(CONFIG_WARN_DYNAMIC_STACK) += -mwarn-dynamicstack
Linus Torvalds1da177e2005-04-16 15:20:36 -070076endif
77
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +010078ifdef CONFIG_EXPOLINE
79 ifeq ($(call cc-option-yn,$(CC_FLAGS_MARCH) -mindirect-branch=thunk),y)
80 CC_FLAGS_EXPOLINE := -mindirect-branch=thunk
81 CC_FLAGS_EXPOLINE += -mfunction-return=thunk
82 CC_FLAGS_EXPOLINE += -mindirect-branch-table
83 export CC_FLAGS_EXPOLINE
Martin Schwidefsky6e179d62018-03-23 13:04:49 +010084 cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +010085 endif
86endif
87
Heiko Carstense6d60b32015-01-09 13:08:28 +010088ifdef CONFIG_FUNCTION_TRACER
Vasily Gorbikd983c892018-08-06 15:17:47 +020089 ifeq ($(call cc-option-yn,-mfentry -mnop-mcount),n)
90 # make use of hotpatch feature if the compiler supports it
91 cc_hotpatch := -mhotpatch=0,3
92 ifeq ($(call cc-option-yn,$(cc_hotpatch)),y)
93 CC_FLAGS_FTRACE := $(cc_hotpatch)
94 KBUILD_AFLAGS += -DCC_USING_HOTPATCH
95 KBUILD_CFLAGS += -DCC_USING_HOTPATCH
96 endif
97 endif
Heiko Carstense6d60b32015-01-09 13:08:28 +010098endif
99
Hendrik Brueckner7bceec42017-11-20 11:46:13 +0100100# Test CFI features of binutils
101cfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1)
102
Sam Ravnborga0f97e02007-10-14 22:21:35 +0200103KBUILD_CFLAGS += -mbackchain -msoft-float $(cflags-y)
104KBUILD_CFLAGS += -pipe -fno-strength-reduce -Wno-sign-compare
Hendrik Brueckner7bceec42017-11-20 11:46:13 +0100105KBUILD_CFLAGS += -fno-asynchronous-unwind-tables $(cfi)
106KBUILD_AFLAGS += $(aflags-y) $(cfi)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
108OBJCOPYFLAGS := -O binary
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +0100110head-y := arch/s390/kernel/head.o
Heiko Carstens5a79859a2015-02-12 13:08:27 +0100111head-y += arch/s390/kernel/head64.o
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Heiko Carstens01485942010-10-25 16:10:09 +0200113# See arch/s390/Kbuild for content of core part of the kernel
114core-y += arch/s390/
Hans-Joachim Picht155af2f2009-06-16 10:30:52 +0200115
Michael Holzheu4562c9f2007-02-21 10:55:46 +0100116libs-y += arch/s390/lib/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117drivers-y += drivers/s390/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
119# must be linked after kernel
120drivers-$(CONFIG_OPROFILE) += arch/s390/oprofile/
121
Michael Holzheu4562c9f2007-02-21 10:55:46 +0100122boot := arch/s390/boot
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100123syscalls := arch/s390/kernel/syscalls
Heiko Carstensc30f6822015-02-02 07:08:44 +0100124tools := arch/s390/tools
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +0100126all: image bzImage
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
Vasily Gorbike0aa0992018-02-20 11:31:34 +0100128#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
129KBUILD_IMAGE := $(boot)/bzImage
130
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131install: vmlinux
132 $(Q)$(MAKE) $(build)=$(boot) $@
133
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +0100134image bzImage: vmlinux
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
136
Michael Holzheu411ed322007-04-27 16:01:49 +0200137zfcpdump:
138 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
139
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200140vdso_install:
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200141 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200142 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
143
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144archclean:
145 $(Q)$(MAKE) $(clean)=$(boot)
Heiko Carstensc30f6822015-02-02 07:08:44 +0100146 $(Q)$(MAKE) $(clean)=$(tools)
147
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100148archheaders:
149 $(Q)$(MAKE) $(build)=$(syscalls) uapi
150
Heiko Carstensc30f6822015-02-02 07:08:44 +0100151archprepare:
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100152 $(Q)$(MAKE) $(build)=$(syscalls) kapi
Hendrik Brueckner7fbf8312018-01-11 12:13:18 +0100153 $(Q)$(MAKE) $(build)=$(tools) kapi
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155# Don't use tabs in echo arguments
156define archhelp
157 echo '* image - Kernel image for IPL ($(boot)/image)'
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +0100158 echo '* bzImage - Compressed kernel image for IPL ($(boot)/bzImage)'
Michael Holzheub8eecf32015-11-25 11:54:36 +0100159 echo ' install - Install kernel using'
160 echo ' (your) ~/bin/$(INSTALLKERNEL) or'
161 echo ' (distribution) /sbin/$(INSTALLKERNEL) or'
162 echo ' install to $$(INSTALL_PATH)'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163endef