18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci#
38c2ecf20Sopenharmony_ci# s390/Makefile
48c2ecf20Sopenharmony_ci#
58c2ecf20Sopenharmony_ci# This file is included by the global makefile so that you can add your own
68c2ecf20Sopenharmony_ci# architecture-specific flags and dependencies. Remember to do have actions
78c2ecf20Sopenharmony_ci# for "archclean" and "archdep" for cleaning up and making dependencies for
88c2ecf20Sopenharmony_ci# this architecture
98c2ecf20Sopenharmony_ci#
108c2ecf20Sopenharmony_ci# Copyright (C) 1994 by Linus Torvalds
118c2ecf20Sopenharmony_ci#
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciLD_BFD		:= elf64-s390
148c2ecf20Sopenharmony_ciKBUILD_LDFLAGS	:= -m elf64_s390
158c2ecf20Sopenharmony_ciKBUILD_AFLAGS_MODULE += -fPIC
168c2ecf20Sopenharmony_ciKBUILD_CFLAGS_MODULE += -fPIC
178c2ecf20Sopenharmony_ciKBUILD_AFLAGS	+= -m64
188c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= -m64
198c2ecf20Sopenharmony_ciifeq ($(CONFIG_RELOCATABLE),y)
208c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= -fPIE
218c2ecf20Sopenharmony_ciLDFLAGS_vmlinux	:= -pie
228c2ecf20Sopenharmony_ciendif
238c2ecf20Sopenharmony_ciaflags_dwarf	:= -Wa,-gdwarf-2
248c2ecf20Sopenharmony_ciKBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
258c2ecf20Sopenharmony_ciKBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
268c2ecf20Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2
278c2ecf20Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
288c2ecf20Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float
298c2ecf20Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
308c2ecf20Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += -ffreestanding
318c2ecf20Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += -fno-stack-protector
328c2ecf20Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += -fPIE
338c2ecf20Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member)
348c2ecf20Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
358c2ecf20Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ciifdef CONFIG_CC_IS_GCC
388c2ecf20Sopenharmony_ci	ifeq ($(call cc-ifversion, -ge, 1200, y), y)
398c2ecf20Sopenharmony_ci		ifeq ($(call cc-ifversion, -lt, 1300, y), y)
408c2ecf20Sopenharmony_ci			KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
418c2ecf20Sopenharmony_ci			KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, array-bounds)
428c2ecf20Sopenharmony_ci		endif
438c2ecf20Sopenharmony_ci	endif
448c2ecf20Sopenharmony_ciendif
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ciUTS_MACHINE	:= s390x
478c2ecf20Sopenharmony_ciSTACK_SIZE	:= $(if $(CONFIG_KASAN),65536,16384)
488c2ecf20Sopenharmony_ciCHECKFLAGS	+= -D__s390__ -D__s390x__
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ciexport LD_BFD
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cimflags-$(CONFIG_MARCH_Z900)   := -march=z900
538c2ecf20Sopenharmony_cimflags-$(CONFIG_MARCH_Z990)   := -march=z990
548c2ecf20Sopenharmony_cimflags-$(CONFIG_MARCH_Z9_109) := -march=z9-109
558c2ecf20Sopenharmony_cimflags-$(CONFIG_MARCH_Z10)    := -march=z10
568c2ecf20Sopenharmony_cimflags-$(CONFIG_MARCH_Z196)   := -march=z196
578c2ecf20Sopenharmony_cimflags-$(CONFIG_MARCH_ZEC12)  := -march=zEC12
588c2ecf20Sopenharmony_cimflags-$(CONFIG_MARCH_Z13)    := -march=z13
598c2ecf20Sopenharmony_cimflags-$(CONFIG_MARCH_Z14)    := -march=z14
608c2ecf20Sopenharmony_cimflags-$(CONFIG_MARCH_Z15)    := -march=z15
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ciexport CC_FLAGS_MARCH := $(mflags-y)
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ciaflags-y += $(mflags-y)
658c2ecf20Sopenharmony_cicflags-y += $(mflags-y)
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_cicflags-$(CONFIG_MARCH_Z900_TUNE)	+= -mtune=z900
688c2ecf20Sopenharmony_cicflags-$(CONFIG_MARCH_Z990_TUNE)	+= -mtune=z990
698c2ecf20Sopenharmony_cicflags-$(CONFIG_MARCH_Z9_109_TUNE)	+= -mtune=z9-109
708c2ecf20Sopenharmony_cicflags-$(CONFIG_MARCH_Z10_TUNE)		+= -mtune=z10
718c2ecf20Sopenharmony_cicflags-$(CONFIG_MARCH_Z196_TUNE)	+= -mtune=z196
728c2ecf20Sopenharmony_cicflags-$(CONFIG_MARCH_ZEC12_TUNE)	+= -mtune=zEC12
738c2ecf20Sopenharmony_cicflags-$(CONFIG_MARCH_Z13_TUNE)		+= -mtune=z13
748c2ecf20Sopenharmony_cicflags-$(CONFIG_MARCH_Z14_TUNE)		+= -mtune=z14
758c2ecf20Sopenharmony_cicflags-$(CONFIG_MARCH_Z15_TUNE)		+= -mtune=z15
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_cicflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#
808c2ecf20Sopenharmony_ci# Prevent tail-call optimizations, to get clearer backtraces:
818c2ecf20Sopenharmony_ci#
828c2ecf20Sopenharmony_cicflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ciifeq ($(call cc-option-yn,-mpacked-stack -mbackchain -msoft-float),y)
858c2ecf20Sopenharmony_cicflags-$(CONFIG_PACK_STACK)  += -mpacked-stack -D__PACK_STACK
868c2ecf20Sopenharmony_ciaflags-$(CONFIG_PACK_STACK)  += -D__PACK_STACK
878c2ecf20Sopenharmony_ciendif
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ciKBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
908c2ecf20Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ciifeq ($(call cc-option-yn,-mstack-size=8192 -mstack-guard=128),y)
938c2ecf20Sopenharmony_cicflags-$(CONFIG_CHECK_STACK) += -mstack-size=$(STACK_SIZE)
948c2ecf20Sopenharmony_ciifneq ($(call cc-option-yn,-mstack-size=8192),y)
958c2ecf20Sopenharmony_cicflags-$(CONFIG_CHECK_STACK) += -mstack-guard=$(CONFIG_STACK_GUARD)
968c2ecf20Sopenharmony_ciendif
978c2ecf20Sopenharmony_ciendif
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ciifdef CONFIG_WARN_DYNAMIC_STACK
1008c2ecf20Sopenharmony_ci  ifeq ($(call cc-option-yn,-mwarn-dynamicstack),y)
1018c2ecf20Sopenharmony_ci    KBUILD_CFLAGS += -mwarn-dynamicstack
1028c2ecf20Sopenharmony_ci    KBUILD_CFLAGS_DECOMPRESSOR += -mwarn-dynamicstack
1038c2ecf20Sopenharmony_ci  endif
1048c2ecf20Sopenharmony_ciendif
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ciifdef CONFIG_EXPOLINE
1078c2ecf20Sopenharmony_ci  ifeq ($(call cc-option-yn,$(CC_FLAGS_MARCH) -mindirect-branch=thunk),y)
1088c2ecf20Sopenharmony_ci    CC_FLAGS_EXPOLINE := -mindirect-branch=thunk
1098c2ecf20Sopenharmony_ci    CC_FLAGS_EXPOLINE += -mfunction-return=thunk
1108c2ecf20Sopenharmony_ci    CC_FLAGS_EXPOLINE += -mindirect-branch-table
1118c2ecf20Sopenharmony_ci    export CC_FLAGS_EXPOLINE
1128c2ecf20Sopenharmony_ci    cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
1138c2ecf20Sopenharmony_ci    aflags-y += -DCC_USING_EXPOLINE
1148c2ecf20Sopenharmony_ci  endif
1158c2ecf20Sopenharmony_ciendif
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ciifdef CONFIG_FUNCTION_TRACER
1188c2ecf20Sopenharmony_ci  ifeq ($(call cc-option-yn,-mfentry -mnop-mcount),n)
1198c2ecf20Sopenharmony_ci    # make use of hotpatch feature if the compiler supports it
1208c2ecf20Sopenharmony_ci    cc_hotpatch	:= -mhotpatch=0,3
1218c2ecf20Sopenharmony_ci    ifeq ($(call cc-option-yn,$(cc_hotpatch)),y)
1228c2ecf20Sopenharmony_ci      CC_FLAGS_FTRACE := $(cc_hotpatch)
1238c2ecf20Sopenharmony_ci      KBUILD_AFLAGS	+= -DCC_USING_HOTPATCH
1248c2ecf20Sopenharmony_ci      KBUILD_CFLAGS	+= -DCC_USING_HOTPATCH
1258c2ecf20Sopenharmony_ci    endif
1268c2ecf20Sopenharmony_ci  endif
1278c2ecf20Sopenharmony_ciendif
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci# Test CFI features of binutils
1308c2ecf20Sopenharmony_cicfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1)
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= -mbackchain -msoft-float $(cflags-y)
1338c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= -pipe -Wno-sign-compare
1348c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables $(cfi)
1358c2ecf20Sopenharmony_ciKBUILD_AFLAGS	+= $(aflags-y) $(cfi)
1368c2ecf20Sopenharmony_ciexport KBUILD_AFLAGS_DECOMPRESSOR
1378c2ecf20Sopenharmony_ciexport KBUILD_CFLAGS_DECOMPRESSOR
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ciOBJCOPYFLAGS	:= -O binary
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_cihead-y		:= arch/s390/kernel/head64.o
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci# See arch/s390/Kbuild for content of core part of the kernel
1448c2ecf20Sopenharmony_cicore-y		+= arch/s390/
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_cilibs-y		+= arch/s390/lib/
1478c2ecf20Sopenharmony_cidrivers-y	+= drivers/s390/
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci# must be linked after kernel
1508c2ecf20Sopenharmony_cidrivers-$(CONFIG_OPROFILE)	+= arch/s390/oprofile/
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ciboot		:= arch/s390/boot
1538c2ecf20Sopenharmony_cisyscalls	:= arch/s390/kernel/syscalls
1548c2ecf20Sopenharmony_citools		:= arch/s390/tools
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ciall: bzImage
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
1598c2ecf20Sopenharmony_ciKBUILD_IMAGE	:= $(boot)/bzImage
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ciinstall:
1628c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(boot) $@
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_cibzImage: vmlinux
1658c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_cizfcpdump:
1688c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_civdso_install:
1718c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ciarchclean:
1748c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(clean)=$(boot)
1758c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(clean)=$(tools)
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ciarchheaders:
1788c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(syscalls) uapi
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ciarchprepare:
1818c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(syscalls) kapi
1828c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(tools) kapi
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci# Don't use tabs in echo arguments
1858c2ecf20Sopenharmony_cidefine archhelp
1868c2ecf20Sopenharmony_ci  echo	'* bzImage         - Kernel image for IPL ($(boot)/bzImage)'
1878c2ecf20Sopenharmony_ci  echo	'  install         - Install kernel using'
1888c2ecf20Sopenharmony_ci  echo	'                    (your) ~/bin/$(INSTALLKERNEL) or'
1898c2ecf20Sopenharmony_ci  echo	'                    (distribution) /sbin/$(INSTALLKERNEL) or'
1908c2ecf20Sopenharmony_ci  echo	'                    install to $$(INSTALL_PATH)'
1918c2ecf20Sopenharmony_ciendef
192