xref: /linux/arch/s390/Makefile (revision f9364df30420987e77599c4789ec0065c609a507)
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
13f3e20ad6SMasahiro YamadaKBUILD_DEFCONFIG := defconfig
14f3e20ad6SMasahiro Yamada
151844c9bcSMartin SchwidefskyLD_BFD		:= elf64-s390
16d503ac53SMasahiro YamadaKBUILD_LDFLAGS	:= -m elf64_s390
177bdc229fSMartin SchwidefskyKBUILD_AFLAGS_MODULE += -fPIC
187bdc229fSMartin SchwidefskyKBUILD_CFLAGS_MODULE += -fPIC
19222d394dSSam RavnborgKBUILD_AFLAGS	+= -m64
2076bf9d6cSVasily GorbikKBUILD_CFLAGS	+= -m64
21805bc0bcSGerald Schaeferifeq ($(CONFIG_RELOCATABLE),y)
22805bc0bcSGerald SchaeferKBUILD_CFLAGS	+= -fPIE
23805bc0bcSGerald SchaeferLDFLAGS_vmlinux	:= -pie
24805bc0bcSGerald Schaeferendif
25ee6d777dSVasily Gorbikaflags_dwarf	:= -Wa,-gdwarf-2
2696fb54a1SArnd BergmannKBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
27ee6d777dSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
2896fb54a1SArnd BergmannKBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2
2976bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
3076bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float
3176bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
3276bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(call cc-option,-ffreestanding)
33*f9364df3SHeiko CarstensKBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member)
34ee6d777dSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
35ee6d777dSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
361da177e4SLinus TorvaldsUTS_MACHINE	:= s390x
379fed920eSVasily GorbikSTACK_SIZE	:= $(if $(CONFIG_KASAN),65536,16384)
3814516765SLuc Van OostenryckCHECKFLAGS	+= -D__s390__ -D__s390x__
391da177e4SLinus Torvalds
401844c9bcSMartin Schwidefskyexport LD_BFD
411844c9bcSMartin Schwidefsky
420f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z900)   := -march=z900
430f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z990)   := -march=z990
440f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z9_109) := -march=z9-109
450f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z10)    := -march=z10
460f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z196)   := -march=z196
470f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_ZEC12)  := -march=zEC12
48f8b2dcbdSMartin Schwidefskymflags-$(CONFIG_MARCH_Z13)    := -march=z13
496997c323SMartin Schwidefskymflags-$(CONFIG_MARCH_Z14)    := -march=z14
500f1b1ff5SHeiko Carstens
5122362a0eSMartin Schwidefskyexport CC_FLAGS_MARCH := $(mflags-y)
5222362a0eSMartin Schwidefsky
530f1b1ff5SHeiko Carstensaflags-y += $(mflags-y)
540f1b1ff5SHeiko Carstenscflags-y += $(mflags-y)
551da177e4SLinus Torvalds
561db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z900_TUNE)	+= -mtune=z900
571db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z990_TUNE)	+= -mtune=z990
581db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z9_109_TUNE)	+= -mtune=z9-109
591db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z10_TUNE)		+= -mtune=z10
601db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z196_TUNE)	+= -mtune=z196
611db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_ZEC12_TUNE)	+= -mtune=zEC12
62f8b2dcbdSMartin Schwidefskycflags-$(CONFIG_MARCH_Z13_TUNE)		+= -mtune=z13
636997c323SMartin Schwidefskycflags-$(CONFIG_MARCH_Z14_TUNE)		+= -mtune=z14
641db9e051SHeiko Carstens
65c783b91eSMartin Schwidefskycflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
66c783b91eSMartin Schwidefsky
67cbbd1fa7SHeiko Carstens#
68cbbd1fa7SHeiko Carstens# Prevent tail-call optimizations, to get clearer backtraces:
69cbbd1fa7SHeiko Carstens#
70cbbd1fa7SHeiko Carstenscflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
71cbbd1fa7SHeiko Carstens
721da177e4SLinus Torvaldsifeq ($(call cc-option-yn,-mpacked-stack),y)
731da177e4SLinus Torvaldscflags-$(CONFIG_PACK_STACK)  += -mpacked-stack -D__PACK_STACK
741da177e4SLinus Torvaldsaflags-$(CONFIG_PACK_STACK)  += -D__PACK_STACK
751da177e4SLinus Torvaldsendif
761da177e4SLinus Torvalds
7776bf9d6cSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
7876bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)
7976bf9d6cSVasily Gorbik
801da177e4SLinus Torvaldsifeq ($(call cc-option-yn,-mstack-size=8192 -mstack-guard=128),y)
811da177e4SLinus Torvaldscflags-$(CONFIG_CHECK_STACK) += -mstack-size=$(STACK_SIZE)
82be796285SMartin Schwidefskyifneq ($(call cc-option-yn,-mstack-size=8192),y)
831da177e4SLinus Torvaldscflags-$(CONFIG_CHECK_STACK) += -mstack-guard=$(CONFIG_STACK_GUARD)
841da177e4SLinus Torvaldsendif
85be796285SMartin Schwidefskyendif
861da177e4SLinus Torvalds
8776bf9d6cSVasily Gorbikifdef CONFIG_WARN_DYNAMIC_STACK
881da177e4SLinus Torvalds  ifeq ($(call cc-option-yn,-mwarn-dynamicstack),y)
8976bf9d6cSVasily Gorbik    KBUILD_CFLAGS += -mwarn-dynamicstack
9076bf9d6cSVasily Gorbik    KBUILD_CFLAGS_DECOMPRESSOR += -mwarn-dynamicstack
9176bf9d6cSVasily Gorbik  endif
921da177e4SLinus Torvaldsendif
931da177e4SLinus Torvalds
94f19fbd5eSMartin Schwidefskyifdef CONFIG_EXPOLINE
95f19fbd5eSMartin Schwidefsky  ifeq ($(call cc-option-yn,$(CC_FLAGS_MARCH) -mindirect-branch=thunk),y)
96f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE := -mindirect-branch=thunk
97f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE += -mfunction-return=thunk
98f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE += -mindirect-branch-table
99f19fbd5eSMartin Schwidefsky    export CC_FLAGS_EXPOLINE
1006e179d64SMartin Schwidefsky    cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
101157484abSVasily Gorbik    aflags-y += -DCC_USING_EXPOLINE
102f19fbd5eSMartin Schwidefsky  endif
103f19fbd5eSMartin Schwidefskyendif
104f19fbd5eSMartin Schwidefsky
105e6d60b36SHeiko Carstensifdef CONFIG_FUNCTION_TRACER
106d983c89cSVasily Gorbik  ifeq ($(call cc-option-yn,-mfentry -mnop-mcount),n)
107e6d60b36SHeiko Carstens    # make use of hotpatch feature if the compiler supports it
108e6d60b36SHeiko Carstens    cc_hotpatch	:= -mhotpatch=0,3
109e6d60b36SHeiko Carstens    ifeq ($(call cc-option-yn,$(cc_hotpatch)),y)
110e6d60b36SHeiko Carstens      CC_FLAGS_FTRACE := $(cc_hotpatch)
111e6d60b36SHeiko Carstens      KBUILD_AFLAGS	+= -DCC_USING_HOTPATCH
112e6d60b36SHeiko Carstens      KBUILD_CFLAGS	+= -DCC_USING_HOTPATCH
113e6d60b36SHeiko Carstens    endif
114e6d60b36SHeiko Carstens  endif
115d983c89cSVasily Gorbikendif
116e6d60b36SHeiko Carstens
1177bceec4eSHendrik Brueckner# Test CFI features of binutils
1187bceec4eSHendrik Bruecknercfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1)
1197bceec4eSHendrik Brueckner
120a0f97e06SSam RavnborgKBUILD_CFLAGS	+= -mbackchain -msoft-float $(cflags-y)
121c1afcaecSArnd BergmannKBUILD_CFLAGS	+= -pipe -Wno-sign-compare
1227bceec4eSHendrik BruecknerKBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables $(cfi)
1237bceec4eSHendrik BruecknerKBUILD_AFLAGS	+= $(aflags-y) $(cfi)
12476bf9d6cSVasily Gorbikexport KBUILD_AFLAGS_DECOMPRESSOR
12576bf9d6cSVasily Gorbikexport KBUILD_CFLAGS_DECOMPRESSOR
1261da177e4SLinus Torvalds
1271da177e4SLinus TorvaldsOBJCOPYFLAGS	:= -O binary
1281da177e4SLinus Torvalds
1298282cd64SVasily Gorbikhead-y		:= arch/s390/kernel/head64.o
1301da177e4SLinus Torvalds
13101485943SHeiko Carstens# See arch/s390/Kbuild for content of core part of the kernel
13201485943SHeiko Carstenscore-y		+= arch/s390/
133155af2f9SHans-Joachim Picht
1344562c9ffSMichael Holzheulibs-y		+= arch/s390/lib/
1351da177e4SLinus Torvaldsdrivers-y	+= drivers/s390/
1361da177e4SLinus Torvalds
1371da177e4SLinus Torvalds# must be linked after kernel
1381da177e4SLinus Torvaldsdrivers-$(CONFIG_OPROFILE)	+= arch/s390/oprofile/
1391da177e4SLinus Torvalds
1404562c9ffSMichael Holzheuboot		:= arch/s390/boot
1415c75824dSHendrik Bruecknersyscalls	:= arch/s390/kernel/syscalls
142c30f6828SHeiko Carstenstools		:= arch/s390/tools
1431da177e4SLinus Torvalds
14400f2fb57SVasily Gorbikall: bzImage
1451da177e4SLinus Torvalds
146e0aa099cSVasily Gorbik#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
147e0aa099cSVasily GorbikKBUILD_IMAGE	:= $(boot)/bzImage
148e0aa099cSVasily Gorbik
1491da177e4SLinus Torvaldsinstall: vmlinux
1501da177e4SLinus Torvalds	$(Q)$(MAKE) $(build)=$(boot) $@
1511da177e4SLinus Torvalds
15200f2fb57SVasily GorbikbzImage: vmlinux
1531da177e4SLinus Torvalds	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
1541da177e4SLinus Torvalds
155411ed322SMichael Holzheuzfcpdump:
156411ed322SMichael Holzheu	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
157411ed322SMichael Holzheu
158f3cb31e4SHendrik Bruecknervdso_install:
159f3cb31e4SHendrik Brueckner	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
160f3cb31e4SHendrik Brueckner	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
161f3cb31e4SHendrik Brueckner
1621da177e4SLinus Torvaldsarchclean:
1631da177e4SLinus Torvalds	$(Q)$(MAKE) $(clean)=$(boot)
164c30f6828SHeiko Carstens	$(Q)$(MAKE) $(clean)=$(tools)
165c30f6828SHeiko Carstens
1665c75824dSHendrik Bruecknerarchheaders:
1675c75824dSHendrik Brueckner	$(Q)$(MAKE) $(build)=$(syscalls) uapi
1685c75824dSHendrik Brueckner
169c30f6828SHeiko Carstensarchprepare:
1705c75824dSHendrik Brueckner	$(Q)$(MAKE) $(build)=$(syscalls) kapi
1717fbf8315SHendrik Brueckner	$(Q)$(MAKE) $(build)=$(tools) kapi
1721da177e4SLinus Torvalds
1731da177e4SLinus Torvalds# Don't use tabs in echo arguments
1741da177e4SLinus Torvaldsdefine archhelp
17500f2fb57SVasily Gorbik  echo	'* bzImage         - Kernel image for IPL ($(boot)/bzImage)'
176b8eecf36SMichael Holzheu  echo	'  install         - Install kernel using'
177b8eecf36SMichael Holzheu  echo	'                    (your) ~/bin/$(INSTALLKERNEL) or'
178b8eecf36SMichael Holzheu  echo	'                    (distribution) /sbin/$(INSTALLKERNEL) or'
179b8eecf36SMichael Holzheu  echo	'                    install to $$(INSTALL_PATH)'
1801da177e4SLinus Torvaldsendef
181