xref: /linux/arch/s390/Makefile (revision 805bc0bc238f7209fca5e39c152b0d3c12046ac9)
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
19*805bc0bcSGerald Schaeferifeq ($(CONFIG_RELOCATABLE),y)
20*805bc0bcSGerald SchaeferKBUILD_CFLAGS	+= -fPIE
21*805bc0bcSGerald SchaeferLDFLAGS_vmlinux	:= -pie
22*805bc0bcSGerald Schaeferendif
23ee6d777dSVasily Gorbikaflags_dwarf	:= -Wa,-gdwarf-2
2476bf9d6cSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR := -m64 -D__ASSEMBLY__
25ee6d777dSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
2676bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR := -m64 -O2
2776bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
2876bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float
2976bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
3076bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(call cc-option,-ffreestanding)
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
470f1b1ff5SHeiko Carstens
4822362a0eSMartin Schwidefskyexport CC_FLAGS_MARCH := $(mflags-y)
4922362a0eSMartin Schwidefsky
500f1b1ff5SHeiko Carstensaflags-y += $(mflags-y)
510f1b1ff5SHeiko Carstenscflags-y += $(mflags-y)
521da177e4SLinus Torvalds
531db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z900_TUNE)	+= -mtune=z900
541db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z990_TUNE)	+= -mtune=z990
551db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z9_109_TUNE)	+= -mtune=z9-109
561db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z10_TUNE)		+= -mtune=z10
571db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z196_TUNE)	+= -mtune=z196
581db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_ZEC12_TUNE)	+= -mtune=zEC12
59f8b2dcbdSMartin Schwidefskycflags-$(CONFIG_MARCH_Z13_TUNE)		+= -mtune=z13
606997c323SMartin Schwidefskycflags-$(CONFIG_MARCH_Z14_TUNE)		+= -mtune=z14
611db9e051SHeiko Carstens
62c783b91eSMartin Schwidefskycflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
63c783b91eSMartin Schwidefsky
64cbbd1fa7SHeiko Carstens#
65cbbd1fa7SHeiko Carstens# Prevent tail-call optimizations, to get clearer backtraces:
66cbbd1fa7SHeiko Carstens#
67cbbd1fa7SHeiko Carstenscflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
68cbbd1fa7SHeiko Carstens
691da177e4SLinus Torvaldsifeq ($(call cc-option-yn,-mpacked-stack),y)
701da177e4SLinus Torvaldscflags-$(CONFIG_PACK_STACK)  += -mpacked-stack -D__PACK_STACK
711da177e4SLinus Torvaldsaflags-$(CONFIG_PACK_STACK)  += -D__PACK_STACK
721da177e4SLinus Torvaldsendif
731da177e4SLinus Torvalds
7476bf9d6cSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
7576bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)
7676bf9d6cSVasily Gorbik
771da177e4SLinus Torvaldsifeq ($(call cc-option-yn,-mstack-size=8192 -mstack-guard=128),y)
781da177e4SLinus Torvaldscflags-$(CONFIG_CHECK_STACK) += -mstack-size=$(STACK_SIZE)
79be796285SMartin Schwidefskyifneq ($(call cc-option-yn,-mstack-size=8192),y)
801da177e4SLinus Torvaldscflags-$(CONFIG_CHECK_STACK) += -mstack-guard=$(CONFIG_STACK_GUARD)
811da177e4SLinus Torvaldsendif
82be796285SMartin Schwidefskyendif
831da177e4SLinus Torvalds
8476bf9d6cSVasily Gorbikifdef CONFIG_WARN_DYNAMIC_STACK
851da177e4SLinus Torvalds  ifeq ($(call cc-option-yn,-mwarn-dynamicstack),y)
8676bf9d6cSVasily Gorbik    KBUILD_CFLAGS += -mwarn-dynamicstack
8776bf9d6cSVasily Gorbik    KBUILD_CFLAGS_DECOMPRESSOR += -mwarn-dynamicstack
8876bf9d6cSVasily Gorbik  endif
891da177e4SLinus Torvaldsendif
901da177e4SLinus Torvalds
91f19fbd5eSMartin Schwidefskyifdef CONFIG_EXPOLINE
92f19fbd5eSMartin Schwidefsky  ifeq ($(call cc-option-yn,$(CC_FLAGS_MARCH) -mindirect-branch=thunk),y)
93f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE := -mindirect-branch=thunk
94f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE += -mfunction-return=thunk
95f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE += -mindirect-branch-table
96f19fbd5eSMartin Schwidefsky    export CC_FLAGS_EXPOLINE
976e179d64SMartin Schwidefsky    cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
98157484abSVasily Gorbik    aflags-y += -DCC_USING_EXPOLINE
99f19fbd5eSMartin Schwidefsky  endif
100f19fbd5eSMartin Schwidefskyendif
101f19fbd5eSMartin Schwidefsky
102e6d60b36SHeiko Carstensifdef CONFIG_FUNCTION_TRACER
103d983c89cSVasily Gorbik  ifeq ($(call cc-option-yn,-mfentry -mnop-mcount),n)
104e6d60b36SHeiko Carstens    # make use of hotpatch feature if the compiler supports it
105e6d60b36SHeiko Carstens    cc_hotpatch	:= -mhotpatch=0,3
106e6d60b36SHeiko Carstens    ifeq ($(call cc-option-yn,$(cc_hotpatch)),y)
107e6d60b36SHeiko Carstens      CC_FLAGS_FTRACE := $(cc_hotpatch)
108e6d60b36SHeiko Carstens      KBUILD_AFLAGS	+= -DCC_USING_HOTPATCH
109e6d60b36SHeiko Carstens      KBUILD_CFLAGS	+= -DCC_USING_HOTPATCH
110e6d60b36SHeiko Carstens    endif
111e6d60b36SHeiko Carstens  endif
112d983c89cSVasily Gorbikendif
113e6d60b36SHeiko Carstens
1147bceec4eSHendrik Brueckner# Test CFI features of binutils
1157bceec4eSHendrik Bruecknercfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1)
1167bceec4eSHendrik Brueckner
117a0f97e06SSam RavnborgKBUILD_CFLAGS	+= -mbackchain -msoft-float $(cflags-y)
118c1afcaecSArnd BergmannKBUILD_CFLAGS	+= -pipe -Wno-sign-compare
1197bceec4eSHendrik BruecknerKBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables $(cfi)
1207bceec4eSHendrik BruecknerKBUILD_AFLAGS	+= $(aflags-y) $(cfi)
12176bf9d6cSVasily Gorbikexport KBUILD_AFLAGS_DECOMPRESSOR
12276bf9d6cSVasily Gorbikexport KBUILD_CFLAGS_DECOMPRESSOR
1231da177e4SLinus Torvalds
1241da177e4SLinus TorvaldsOBJCOPYFLAGS	:= -O binary
1251da177e4SLinus Torvalds
1268282cd64SVasily Gorbikhead-y		:= arch/s390/kernel/head64.o
1271da177e4SLinus Torvalds
12801485943SHeiko Carstens# See arch/s390/Kbuild for content of core part of the kernel
12901485943SHeiko Carstenscore-y		+= arch/s390/
130155af2f9SHans-Joachim Picht
1314562c9ffSMichael Holzheulibs-y		+= arch/s390/lib/
1321da177e4SLinus Torvaldsdrivers-y	+= drivers/s390/
1331da177e4SLinus Torvalds
1341da177e4SLinus Torvalds# must be linked after kernel
1351da177e4SLinus Torvaldsdrivers-$(CONFIG_OPROFILE)	+= arch/s390/oprofile/
1361da177e4SLinus Torvalds
1374562c9ffSMichael Holzheuboot		:= arch/s390/boot
1385c75824dSHendrik Bruecknersyscalls	:= arch/s390/kernel/syscalls
139c30f6828SHeiko Carstenstools		:= arch/s390/tools
1401da177e4SLinus Torvalds
14100f2fb57SVasily Gorbikall: bzImage
1421da177e4SLinus Torvalds
143e0aa099cSVasily Gorbik#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
144e0aa099cSVasily GorbikKBUILD_IMAGE	:= $(boot)/bzImage
145e0aa099cSVasily Gorbik
1461da177e4SLinus Torvaldsinstall: vmlinux
1471da177e4SLinus Torvalds	$(Q)$(MAKE) $(build)=$(boot) $@
1481da177e4SLinus Torvalds
14900f2fb57SVasily GorbikbzImage: vmlinux
1501da177e4SLinus Torvalds	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
1511da177e4SLinus Torvalds
152411ed322SMichael Holzheuzfcpdump:
153411ed322SMichael Holzheu	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
154411ed322SMichael Holzheu
155f3cb31e4SHendrik Bruecknervdso_install:
156f3cb31e4SHendrik Brueckner	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
157f3cb31e4SHendrik Brueckner	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
158f3cb31e4SHendrik Brueckner
1591da177e4SLinus Torvaldsarchclean:
1601da177e4SLinus Torvalds	$(Q)$(MAKE) $(clean)=$(boot)
161c30f6828SHeiko Carstens	$(Q)$(MAKE) $(clean)=$(tools)
162c30f6828SHeiko Carstens
1635c75824dSHendrik Bruecknerarchheaders:
1645c75824dSHendrik Brueckner	$(Q)$(MAKE) $(build)=$(syscalls) uapi
1655c75824dSHendrik Brueckner
166c30f6828SHeiko Carstensarchprepare:
1675c75824dSHendrik Brueckner	$(Q)$(MAKE) $(build)=$(syscalls) kapi
1687fbf8315SHendrik Brueckner	$(Q)$(MAKE) $(build)=$(tools) kapi
1691da177e4SLinus Torvalds
1701da177e4SLinus Torvalds# Don't use tabs in echo arguments
1711da177e4SLinus Torvaldsdefine archhelp
17200f2fb57SVasily Gorbik  echo	'* bzImage         - Kernel image for IPL ($(boot)/bzImage)'
173b8eecf36SMichael Holzheu  echo	'  install         - Install kernel using'
174b8eecf36SMichael Holzheu  echo	'                    (your) ~/bin/$(INSTALLKERNEL) or'
175b8eecf36SMichael Holzheu  echo	'                    (distribution) /sbin/$(INSTALLKERNEL) or'
176b8eecf36SMichael Holzheu  echo	'                    install to $$(INSTALL_PATH)'
1771da177e4SLinus Torvaldsendef
178