xref: /linux/arch/s390/Makefile (revision 9fed920e6817218ad786c3f28e14b4c877cc2aed)
10b73214fSGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds#
31da177e4SLinus Torvalds# s390/Makefile
41da177e4SLinus Torvalds#
51da177e4SLinus Torvalds# This file is included by the global makefile so that you can add your own
61da177e4SLinus Torvalds# architecture-specific flags and dependencies. Remember to do have actions
71da177e4SLinus Torvalds# for "archclean" and "archdep" for cleaning up and making dependencies for
81da177e4SLinus Torvalds# this architecture
91da177e4SLinus Torvalds#
101da177e4SLinus Torvalds# Copyright (C) 1994 by Linus Torvalds
111da177e4SLinus Torvalds#
121da177e4SLinus Torvalds
131844c9bcSMartin SchwidefskyLD_BFD		:= elf64-s390
14d503ac53SMasahiro YamadaKBUILD_LDFLAGS	:= -m elf64_s390
157bdc229fSMartin SchwidefskyKBUILD_AFLAGS_MODULE += -fPIC
167bdc229fSMartin SchwidefskyKBUILD_CFLAGS_MODULE += -fPIC
17222d394dSSam RavnborgKBUILD_AFLAGS	+= -m64
1876bf9d6cSVasily GorbikKBUILD_CFLAGS	+= -m64
19ee6d777dSVasily Gorbikaflags_dwarf	:= -Wa,-gdwarf-2
2076bf9d6cSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR := -m64 -D__ASSEMBLY__
21ee6d777dSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
2276bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR := -m64 -O2
2376bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
2476bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float
2576bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
2676bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(call cc-option,-ffreestanding)
27ee6d777dSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
28ee6d777dSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
291da177e4SLinus TorvaldsUTS_MACHINE	:= s390x
30*9fed920eSVasily GorbikSTACK_SIZE	:= $(if $(CONFIG_KASAN),65536,16384)
3114516765SLuc Van OostenryckCHECKFLAGS	+= -D__s390__ -D__s390x__
321da177e4SLinus Torvalds
331844c9bcSMartin Schwidefskyexport LD_BFD
341844c9bcSMartin Schwidefsky
350f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z900)   := -march=z900
360f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z990)   := -march=z990
370f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z9_109) := -march=z9-109
380f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z10)    := -march=z10
390f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z196)   := -march=z196
400f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_ZEC12)  := -march=zEC12
41f8b2dcbdSMartin Schwidefskymflags-$(CONFIG_MARCH_Z13)    := -march=z13
426997c323SMartin Schwidefskymflags-$(CONFIG_MARCH_Z14)    := -march=z14
430f1b1ff5SHeiko Carstens
4422362a0eSMartin Schwidefskyexport CC_FLAGS_MARCH := $(mflags-y)
4522362a0eSMartin Schwidefsky
460f1b1ff5SHeiko Carstensaflags-y += $(mflags-y)
470f1b1ff5SHeiko Carstenscflags-y += $(mflags-y)
481da177e4SLinus Torvalds
491db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z900_TUNE)	+= -mtune=z900
501db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z990_TUNE)	+= -mtune=z990
511db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z9_109_TUNE)	+= -mtune=z9-109
521db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z10_TUNE)		+= -mtune=z10
531db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z196_TUNE)	+= -mtune=z196
541db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_ZEC12_TUNE)	+= -mtune=zEC12
55f8b2dcbdSMartin Schwidefskycflags-$(CONFIG_MARCH_Z13_TUNE)		+= -mtune=z13
566997c323SMartin Schwidefskycflags-$(CONFIG_MARCH_Z14_TUNE)		+= -mtune=z14
571db9e051SHeiko Carstens
58c783b91eSMartin Schwidefskycflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
59c783b91eSMartin Schwidefsky
60cbbd1fa7SHeiko Carstens#
61cbbd1fa7SHeiko Carstens# Prevent tail-call optimizations, to get clearer backtraces:
62cbbd1fa7SHeiko Carstens#
63cbbd1fa7SHeiko Carstenscflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
64cbbd1fa7SHeiko Carstens
651da177e4SLinus Torvaldsifeq ($(call cc-option-yn,-mpacked-stack),y)
661da177e4SLinus Torvaldscflags-$(CONFIG_PACK_STACK)  += -mpacked-stack -D__PACK_STACK
671da177e4SLinus Torvaldsaflags-$(CONFIG_PACK_STACK)  += -D__PACK_STACK
681da177e4SLinus Torvaldsendif
691da177e4SLinus Torvalds
7076bf9d6cSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
7176bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)
7276bf9d6cSVasily Gorbik
731da177e4SLinus Torvaldsifeq ($(call cc-option-yn,-mstack-size=8192 -mstack-guard=128),y)
741da177e4SLinus Torvaldscflags-$(CONFIG_CHECK_STACK) += -mstack-size=$(STACK_SIZE)
75be796285SMartin Schwidefskyifneq ($(call cc-option-yn,-mstack-size=8192),y)
761da177e4SLinus Torvaldscflags-$(CONFIG_CHECK_STACK) += -mstack-guard=$(CONFIG_STACK_GUARD)
771da177e4SLinus Torvaldsendif
78be796285SMartin Schwidefskyendif
791da177e4SLinus Torvalds
8076bf9d6cSVasily Gorbikifdef CONFIG_WARN_DYNAMIC_STACK
811da177e4SLinus Torvalds  ifeq ($(call cc-option-yn,-mwarn-dynamicstack),y)
8276bf9d6cSVasily Gorbik    KBUILD_CFLAGS += -mwarn-dynamicstack
8376bf9d6cSVasily Gorbik    KBUILD_CFLAGS_DECOMPRESSOR += -mwarn-dynamicstack
8476bf9d6cSVasily Gorbik  endif
851da177e4SLinus Torvaldsendif
861da177e4SLinus Torvalds
87f19fbd5eSMartin Schwidefskyifdef CONFIG_EXPOLINE
88f19fbd5eSMartin Schwidefsky  ifeq ($(call cc-option-yn,$(CC_FLAGS_MARCH) -mindirect-branch=thunk),y)
89f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE := -mindirect-branch=thunk
90f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE += -mfunction-return=thunk
91f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE += -mindirect-branch-table
92f19fbd5eSMartin Schwidefsky    export CC_FLAGS_EXPOLINE
936e179d64SMartin Schwidefsky    cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
94157484abSVasily Gorbik    aflags-y += -DCC_USING_EXPOLINE
95f19fbd5eSMartin Schwidefsky  endif
96f19fbd5eSMartin Schwidefskyendif
97f19fbd5eSMartin Schwidefsky
98e6d60b36SHeiko Carstensifdef CONFIG_FUNCTION_TRACER
99d983c89cSVasily Gorbik  ifeq ($(call cc-option-yn,-mfentry -mnop-mcount),n)
100e6d60b36SHeiko Carstens    # make use of hotpatch feature if the compiler supports it
101e6d60b36SHeiko Carstens    cc_hotpatch	:= -mhotpatch=0,3
102e6d60b36SHeiko Carstens    ifeq ($(call cc-option-yn,$(cc_hotpatch)),y)
103e6d60b36SHeiko Carstens      CC_FLAGS_FTRACE := $(cc_hotpatch)
104e6d60b36SHeiko Carstens      KBUILD_AFLAGS	+= -DCC_USING_HOTPATCH
105e6d60b36SHeiko Carstens      KBUILD_CFLAGS	+= -DCC_USING_HOTPATCH
106e6d60b36SHeiko Carstens    endif
107e6d60b36SHeiko Carstens  endif
108d983c89cSVasily Gorbikendif
109e6d60b36SHeiko Carstens
1107bceec4eSHendrik Brueckner# Test CFI features of binutils
1117bceec4eSHendrik Bruecknercfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1)
1127bceec4eSHendrik Brueckner
113a0f97e06SSam RavnborgKBUILD_CFLAGS	+= -mbackchain -msoft-float $(cflags-y)
114a0f97e06SSam RavnborgKBUILD_CFLAGS	+= -pipe -fno-strength-reduce -Wno-sign-compare
1157bceec4eSHendrik BruecknerKBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables $(cfi)
1167bceec4eSHendrik BruecknerKBUILD_AFLAGS	+= $(aflags-y) $(cfi)
11776bf9d6cSVasily Gorbikexport KBUILD_AFLAGS_DECOMPRESSOR
11876bf9d6cSVasily Gorbikexport KBUILD_CFLAGS_DECOMPRESSOR
1191da177e4SLinus Torvalds
1201da177e4SLinus TorvaldsOBJCOPYFLAGS	:= -O binary
1211da177e4SLinus Torvalds
1228282cd64SVasily Gorbikhead-y		:= arch/s390/kernel/head64.o
1231da177e4SLinus Torvalds
12401485943SHeiko Carstens# See arch/s390/Kbuild for content of core part of the kernel
12501485943SHeiko Carstenscore-y		+= arch/s390/
126155af2f9SHans-Joachim Picht
1274562c9ffSMichael Holzheulibs-y		+= arch/s390/lib/
1281da177e4SLinus Torvaldsdrivers-y	+= drivers/s390/
1291da177e4SLinus Torvalds
1301da177e4SLinus Torvalds# must be linked after kernel
1311da177e4SLinus Torvaldsdrivers-$(CONFIG_OPROFILE)	+= arch/s390/oprofile/
1321da177e4SLinus Torvalds
1334562c9ffSMichael Holzheuboot		:= arch/s390/boot
1345c75824dSHendrik Bruecknersyscalls	:= arch/s390/kernel/syscalls
135c30f6828SHeiko Carstenstools		:= arch/s390/tools
1361da177e4SLinus Torvalds
13700f2fb57SVasily Gorbikall: bzImage
1381da177e4SLinus Torvalds
139e0aa099cSVasily Gorbik#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
140e0aa099cSVasily GorbikKBUILD_IMAGE	:= $(boot)/bzImage
141e0aa099cSVasily Gorbik
1421da177e4SLinus Torvaldsinstall: vmlinux
1431da177e4SLinus Torvalds	$(Q)$(MAKE) $(build)=$(boot) $@
1441da177e4SLinus Torvalds
14500f2fb57SVasily GorbikbzImage: vmlinux
1461da177e4SLinus Torvalds	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
1471da177e4SLinus Torvalds
148411ed322SMichael Holzheuzfcpdump:
149411ed322SMichael Holzheu	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
150411ed322SMichael Holzheu
151f3cb31e4SHendrik Bruecknervdso_install:
152f3cb31e4SHendrik Brueckner	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
153f3cb31e4SHendrik Brueckner	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
154f3cb31e4SHendrik Brueckner
1551da177e4SLinus Torvaldsarchclean:
1561da177e4SLinus Torvalds	$(Q)$(MAKE) $(clean)=$(boot)
157c30f6828SHeiko Carstens	$(Q)$(MAKE) $(clean)=$(tools)
158c30f6828SHeiko Carstens
1595c75824dSHendrik Bruecknerarchheaders:
1605c75824dSHendrik Brueckner	$(Q)$(MAKE) $(build)=$(syscalls) uapi
1615c75824dSHendrik Brueckner
162c30f6828SHeiko Carstensarchprepare:
1635c75824dSHendrik Brueckner	$(Q)$(MAKE) $(build)=$(syscalls) kapi
1647fbf8315SHendrik Brueckner	$(Q)$(MAKE) $(build)=$(tools) kapi
1651da177e4SLinus Torvalds
1661da177e4SLinus Torvalds# Don't use tabs in echo arguments
1671da177e4SLinus Torvaldsdefine archhelp
16800f2fb57SVasily Gorbik  echo	'* bzImage         - Kernel image for IPL ($(boot)/bzImage)'
169b8eecf36SMichael Holzheu  echo	'  install         - Install kernel using'
170b8eecf36SMichael Holzheu  echo	'                    (your) ~/bin/$(INSTALLKERNEL) or'
171b8eecf36SMichael Holzheu  echo	'                    (distribution) /sbin/$(INSTALLKERNEL) or'
172b8eecf36SMichael Holzheu  echo	'                    install to $$(INSTALL_PATH)'
1731da177e4SLinus Torvaldsendef
174