xref: /linux/arch/s390/Makefile (revision 8212f8986d311ccf6a72305e6bdbd814691701d6)
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
6*8212f898SMasahiro Yamada# architecture-specific flags and dependencies.
71da177e4SLinus Torvalds#
81da177e4SLinus Torvalds# Copyright (C) 1994 by Linus Torvalds
91da177e4SLinus Torvalds#
101da177e4SLinus Torvalds
111844c9bcSMartin SchwidefskyLD_BFD		:= elf64-s390
12d503ac53SMasahiro YamadaKBUILD_LDFLAGS	:= -m elf64_s390
137bdc229fSMartin SchwidefskyKBUILD_AFLAGS_MODULE += -fPIC
147bdc229fSMartin SchwidefskyKBUILD_CFLAGS_MODULE += -fPIC
15222d394dSSam RavnborgKBUILD_AFLAGS	+= -m64
1676bf9d6cSVasily GorbikKBUILD_CFLAGS	+= -m64
17805bc0bcSGerald Schaeferifeq ($(CONFIG_RELOCATABLE),y)
18805bc0bcSGerald SchaeferKBUILD_CFLAGS	+= -fPIE
19805bc0bcSGerald SchaeferLDFLAGS_vmlinux	:= -pie
20805bc0bcSGerald Schaeferendif
21ee6d777dSVasily Gorbikaflags_dwarf	:= -Wa,-gdwarf-2
2296fb54a1SArnd BergmannKBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
23ee6d777dSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
2496fb54a1SArnd BergmannKBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2
2576bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
268977ab65SVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float -mbackchain
2776bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
28685969e0SMasahiro YamadaKBUILD_CFLAGS_DECOMPRESSOR += -ffreestanding
2942e8d652SFabrice FontaineKBUILD_CFLAGS_DECOMPRESSOR += -fno-stack-protector
30f9364df3SHeiko CarstensKBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member)
31ee6d777dSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
32ee6d777dSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
331da177e4SLinus TorvaldsUTS_MACHINE	:= s390x
349fed920eSVasily GorbikSTACK_SIZE	:= $(if $(CONFIG_KASAN),65536,16384)
3514516765SLuc Van OostenryckCHECKFLAGS	+= -D__s390__ -D__s390x__
361da177e4SLinus Torvalds
371844c9bcSMartin Schwidefskyexport LD_BFD
381844c9bcSMartin Schwidefsky
390f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z900)   := -march=z900
400f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z990)   := -march=z990
410f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z9_109) := -march=z9-109
420f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z10)    := -march=z10
430f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z196)   := -march=z196
440f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_ZEC12)  := -march=zEC12
45f8b2dcbdSMartin Schwidefskymflags-$(CONFIG_MARCH_Z13)    := -march=z13
466997c323SMartin Schwidefskymflags-$(CONFIG_MARCH_Z14)    := -march=z14
47a0e22511SMartin Schwidefskymflags-$(CONFIG_MARCH_Z15)    := -march=z15
480f1b1ff5SHeiko Carstens
4922362a0eSMartin Schwidefskyexport CC_FLAGS_MARCH := $(mflags-y)
5022362a0eSMartin Schwidefsky
510f1b1ff5SHeiko Carstensaflags-y += $(mflags-y)
520f1b1ff5SHeiko Carstenscflags-y += $(mflags-y)
531da177e4SLinus Torvalds
541db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z900_TUNE)	+= -mtune=z900
551db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z990_TUNE)	+= -mtune=z990
561db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z9_109_TUNE)	+= -mtune=z9-109
571db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z10_TUNE)		+= -mtune=z10
581db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z196_TUNE)	+= -mtune=z196
591db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_ZEC12_TUNE)	+= -mtune=zEC12
60f8b2dcbdSMartin Schwidefskycflags-$(CONFIG_MARCH_Z13_TUNE)		+= -mtune=z13
616997c323SMartin Schwidefskycflags-$(CONFIG_MARCH_Z14_TUNE)		+= -mtune=z14
62a0e22511SMartin Schwidefskycflags-$(CONFIG_MARCH_Z15_TUNE)		+= -mtune=z15
631db9e051SHeiko Carstens
64c783b91eSMartin Schwidefskycflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
65c783b91eSMartin Schwidefsky
66cbbd1fa7SHeiko Carstens#
67cbbd1fa7SHeiko Carstens# Prevent tail-call optimizations, to get clearer backtraces:
68cbbd1fa7SHeiko Carstens#
69cbbd1fa7SHeiko Carstenscflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
70cbbd1fa7SHeiko Carstens
71ff00f64bSNick Desaulniersifneq ($(call cc-option,-mpacked-stack -mbackchain -msoft-float),)
721da177e4SLinus Torvaldscflags-$(CONFIG_PACK_STACK)  += -mpacked-stack -D__PACK_STACK
731da177e4SLinus Torvaldsaflags-$(CONFIG_PACK_STACK)  += -D__PACK_STACK
741da177e4SLinus Torvaldsendif
751da177e4SLinus Torvalds
7676bf9d6cSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
7776bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)
7876bf9d6cSVasily Gorbik
79ff00f64bSNick Desaulniersifneq ($(call cc-option,-mstack-size=8192 -mstack-guard=128),)
801da177e4SLinus Torvaldscflags-$(CONFIG_CHECK_STACK) += -mstack-size=$(STACK_SIZE)
81ff00f64bSNick Desaulniersifeq ($(call cc-option,-mstack-size=8192),)
821da177e4SLinus Torvaldscflags-$(CONFIG_CHECK_STACK) += -mstack-guard=$(CONFIG_STACK_GUARD)
831da177e4SLinus Torvaldsendif
84be796285SMartin Schwidefskyendif
851da177e4SLinus Torvalds
86f19fbd5eSMartin Schwidefskyifdef CONFIG_EXPOLINE
87ff00f64bSNick Desaulniers  ifneq ($(call cc-option,$(CC_FLAGS_MARCH) -mindirect-branch=thunk),)
88f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE := -mindirect-branch=thunk
89f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE += -mfunction-return=thunk
90f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE += -mindirect-branch-table
91f19fbd5eSMartin Schwidefsky    export CC_FLAGS_EXPOLINE
926e179d64SMartin Schwidefsky    cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
93157484abSVasily Gorbik    aflags-y += -DCC_USING_EXPOLINE
94f19fbd5eSMartin Schwidefsky  endif
95f19fbd5eSMartin Schwidefskyendif
96f19fbd5eSMartin Schwidefsky
97e6d60b36SHeiko Carstensifdef CONFIG_FUNCTION_TRACER
98ff00f64bSNick Desaulniers  ifeq ($(call cc-option,-mfentry -mnop-mcount),)
99e6d60b36SHeiko Carstens    # make use of hotpatch feature if the compiler supports it
100e6d60b36SHeiko Carstens    cc_hotpatch	:= -mhotpatch=0,3
101ff00f64bSNick Desaulniers    ifneq ($(call cc-option,$(cc_hotpatch)),)
102e6d60b36SHeiko Carstens      CC_FLAGS_FTRACE := $(cc_hotpatch)
103e6d60b36SHeiko Carstens      KBUILD_AFLAGS	+= -DCC_USING_HOTPATCH
104e6d60b36SHeiko Carstens      KBUILD_CFLAGS	+= -DCC_USING_HOTPATCH
105e6d60b36SHeiko Carstens    endif
106e6d60b36SHeiko Carstens  endif
107d983c89cSVasily Gorbikendif
108e6d60b36SHeiko Carstens
1097bceec4eSHendrik Brueckner# Test CFI features of binutils
1107bceec4eSHendrik Bruecknercfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1)
1117bceec4eSHendrik Brueckner
112a0f97e06SSam RavnborgKBUILD_CFLAGS	+= -mbackchain -msoft-float $(cflags-y)
113c1afcaecSArnd BergmannKBUILD_CFLAGS	+= -pipe -Wno-sign-compare
1147bceec4eSHendrik BruecknerKBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables $(cfi)
1157bceec4eSHendrik BruecknerKBUILD_AFLAGS	+= $(aflags-y) $(cfi)
11676bf9d6cSVasily Gorbikexport KBUILD_AFLAGS_DECOMPRESSOR
11776bf9d6cSVasily Gorbikexport KBUILD_CFLAGS_DECOMPRESSOR
1181da177e4SLinus Torvalds
1191da177e4SLinus TorvaldsOBJCOPYFLAGS	:= -O binary
1201da177e4SLinus Torvalds
1218282cd64SVasily Gorbikhead-y		:= arch/s390/kernel/head64.o
1221da177e4SLinus Torvalds
1234562c9ffSMichael Holzheulibs-y		+= arch/s390/lib/
1241da177e4SLinus Torvaldsdrivers-y	+= drivers/s390/
1251da177e4SLinus Torvalds
1264562c9ffSMichael Holzheuboot		:= arch/s390/boot
1275c75824dSHendrik Bruecknersyscalls	:= arch/s390/kernel/syscalls
128c30f6828SHeiko Carstenstools		:= arch/s390/tools
1291da177e4SLinus Torvalds
13000f2fb57SVasily Gorbikall: bzImage
1311da177e4SLinus Torvalds
132e0aa099cSVasily Gorbik#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
133e0aa099cSVasily GorbikKBUILD_IMAGE	:= $(boot)/bzImage
134e0aa099cSVasily Gorbik
13594e90f72SMasahiro Yamadainstall:
136d80d3ea6SMasahiro Yamada	sh -x $(srctree)/$(boot)/install.sh $(KERNELRELEASE) $(KBUILD_IMAGE) \
137d80d3ea6SMasahiro Yamada	      System.map "$(INSTALL_PATH)"
1381da177e4SLinus Torvalds
13900f2fb57SVasily GorbikbzImage: vmlinux
1401da177e4SLinus Torvalds	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
1411da177e4SLinus Torvalds
142411ed322SMichael Holzheuzfcpdump:
143411ed322SMichael Holzheu	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
144411ed322SMichael Holzheu
145f3cb31e4SHendrik Bruecknervdso_install:
146f3cb31e4SHendrik Brueckner	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
147f3cb31e4SHendrik Brueckner
1485c75824dSHendrik Bruecknerarchheaders:
1495c75824dSHendrik Brueckner	$(Q)$(MAKE) $(build)=$(syscalls) uapi
1505c75824dSHendrik Brueckner
151c30f6828SHeiko Carstensarchprepare:
1525c75824dSHendrik Brueckner	$(Q)$(MAKE) $(build)=$(syscalls) kapi
1537fbf8315SHendrik Brueckner	$(Q)$(MAKE) $(build)=$(tools) kapi
154779df224SSven Schnelleifeq ($(KBUILD_EXTMOD),)
155779df224SSven Schnelle# We need to generate vdso-offsets.h before compiling certain files in kernel/.
156779df224SSven Schnelle# In order to do that, we should use the archprepare target, but we can't since
157779df224SSven Schnelle# asm-offsets.h is included in some files used to generate vdso-offsets.h, and
158779df224SSven Schnelle# asm-offsets.h is built in prepare0, for which archprepare is a dependency.
159779df224SSven Schnelle# Therefore we need to generate the header after prepare0 has been made, hence
160779df224SSven Schnelle# this hack.
161779df224SSven Schnelleprepare: vdso_prepare
162779df224SSven Schnellevdso_prepare: prepare0
163779df224SSven Schnelle	$(Q)$(MAKE) $(build)=arch/s390/kernel/vdso64 include/generated/vdso64-offsets.h
164779df224SSven Schnelle	$(if $(CONFIG_COMPAT),$(Q)$(MAKE) \
165779df224SSven Schnelle		$(build)=arch/s390/kernel/vdso32 include/generated/vdso32-offsets.h)
166779df224SSven Schnelleendif
1671da177e4SLinus Torvalds
1681da177e4SLinus Torvalds# Don't use tabs in echo arguments
1691da177e4SLinus Torvaldsdefine archhelp
17000f2fb57SVasily Gorbik  echo	'* bzImage         - Kernel image for IPL ($(boot)/bzImage)'
171b8eecf36SMichael Holzheu  echo	'  install         - Install kernel using'
172b8eecf36SMichael Holzheu  echo	'                    (your) ~/bin/$(INSTALLKERNEL) or'
173b8eecf36SMichael Holzheu  echo	'                    (distribution) /sbin/$(INSTALLKERNEL) or'
174b8eecf36SMichael Holzheu  echo	'                    install to $$(INSTALL_PATH)'
1751da177e4SLinus Torvaldsendef
176