162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci#
362306a36Sopenharmony_ci# s390/Makefile
462306a36Sopenharmony_ci#
562306a36Sopenharmony_ci# This file is included by the global makefile so that you can add your own
662306a36Sopenharmony_ci# architecture-specific flags and dependencies.
762306a36Sopenharmony_ci#
862306a36Sopenharmony_ci# Copyright (C) 1994 by Linus Torvalds
962306a36Sopenharmony_ci#
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciLD_BFD		:= elf64-s390
1262306a36Sopenharmony_ciKBUILD_LDFLAGS	:= -m elf64_s390
1362306a36Sopenharmony_ciKBUILD_AFLAGS_MODULE += -fPIC
1462306a36Sopenharmony_ciKBUILD_CFLAGS_MODULE += -fPIC
1562306a36Sopenharmony_ciKBUILD_AFLAGS	+= -m64
1662306a36Sopenharmony_ciKBUILD_CFLAGS	+= -m64
1762306a36Sopenharmony_ciKBUILD_CFLAGS	+= -fPIE
1862306a36Sopenharmony_ciLDFLAGS_vmlinux	:= -pie
1962306a36Sopenharmony_ciaflags_dwarf	:= -Wa,-gdwarf-2
2062306a36Sopenharmony_ciKBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
2162306a36Sopenharmony_ciifndef CONFIG_AS_IS_LLVM
2262306a36Sopenharmony_ciKBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
2362306a36Sopenharmony_ciendif
2462306a36Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack
2562306a36Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
2662306a36Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float -mbackchain
2762306a36Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
2862306a36Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += -ffreestanding
2962306a36Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += -fno-stack-protector
3062306a36Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += -fPIE
3162306a36Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member)
3262306a36Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
3362306a36Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
3462306a36Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_CC_NO_ARRAY_BOUNDS),-Wno-array-bounds)
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ciUTS_MACHINE	:= s390x
3762306a36Sopenharmony_ciSTACK_SIZE	:= $(if $(CONFIG_KASAN),65536,16384)
3862306a36Sopenharmony_ciCHECKFLAGS	+= -D__s390__ -D__s390x__
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ciexport LD_BFD
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_cimflags-$(CONFIG_MARCH_Z10)    := -march=z10
4362306a36Sopenharmony_cimflags-$(CONFIG_MARCH_Z196)   := -march=z196
4462306a36Sopenharmony_cimflags-$(CONFIG_MARCH_ZEC12)  := -march=zEC12
4562306a36Sopenharmony_cimflags-$(CONFIG_MARCH_Z13)    := -march=z13
4662306a36Sopenharmony_cimflags-$(CONFIG_MARCH_Z14)    := -march=z14
4762306a36Sopenharmony_cimflags-$(CONFIG_MARCH_Z15)    := -march=z15
4862306a36Sopenharmony_cimflags-$(CONFIG_MARCH_Z16)    := -march=z16
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ciexport CC_FLAGS_MARCH := $(mflags-y)
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ciaflags-y += $(mflags-y)
5362306a36Sopenharmony_cicflags-y += $(mflags-y)
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_cicflags-$(CONFIG_MARCH_Z10_TUNE)		+= -mtune=z10
5662306a36Sopenharmony_cicflags-$(CONFIG_MARCH_Z196_TUNE)	+= -mtune=z196
5762306a36Sopenharmony_cicflags-$(CONFIG_MARCH_ZEC12_TUNE)	+= -mtune=zEC12
5862306a36Sopenharmony_cicflags-$(CONFIG_MARCH_Z13_TUNE)		+= -mtune=z13
5962306a36Sopenharmony_cicflags-$(CONFIG_MARCH_Z14_TUNE)		+= -mtune=z14
6062306a36Sopenharmony_cicflags-$(CONFIG_MARCH_Z15_TUNE)		+= -mtune=z15
6162306a36Sopenharmony_cicflags-$(CONFIG_MARCH_Z16_TUNE)		+= -mtune=z16
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_cicflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci#
6662306a36Sopenharmony_ci# Prevent tail-call optimizations, to get clearer backtraces:
6762306a36Sopenharmony_ci#
6862306a36Sopenharmony_cicflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ciKBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
7162306a36Sopenharmony_ciKBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ciifneq ($(call cc-option,-mstack-size=8192 -mstack-guard=128),)
7462306a36Sopenharmony_ci  CC_FLAGS_CHECK_STACK := -mstack-size=$(STACK_SIZE)
7562306a36Sopenharmony_ci  ifeq ($(call cc-option,-mstack-size=8192),)
7662306a36Sopenharmony_ci    CC_FLAGS_CHECK_STACK += -mstack-guard=$(CONFIG_STACK_GUARD)
7762306a36Sopenharmony_ci  endif
7862306a36Sopenharmony_ci  export CC_FLAGS_CHECK_STACK
7962306a36Sopenharmony_ci  cflags-$(CONFIG_CHECK_STACK) += $(CC_FLAGS_CHECK_STACK)
8062306a36Sopenharmony_ciendif
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ciifdef CONFIG_EXPOLINE
8362306a36Sopenharmony_ci  ifdef CONFIG_EXPOLINE_EXTERN
8462306a36Sopenharmony_ci    KBUILD_LDFLAGS_MODULE += arch/s390/lib/expoline/expoline.o
8562306a36Sopenharmony_ci    CC_FLAGS_EXPOLINE := -mindirect-branch=thunk-extern
8662306a36Sopenharmony_ci    CC_FLAGS_EXPOLINE += -mfunction-return=thunk-extern
8762306a36Sopenharmony_ci  else
8862306a36Sopenharmony_ci    CC_FLAGS_EXPOLINE := -mindirect-branch=thunk
8962306a36Sopenharmony_ci    CC_FLAGS_EXPOLINE += -mfunction-return=thunk
9062306a36Sopenharmony_ci  endif
9162306a36Sopenharmony_ci  CC_FLAGS_EXPOLINE += -mindirect-branch-table
9262306a36Sopenharmony_ci  export CC_FLAGS_EXPOLINE
9362306a36Sopenharmony_ci  cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
9462306a36Sopenharmony_ci  aflags-y += -DCC_USING_EXPOLINE
9562306a36Sopenharmony_ciendif
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ciifdef CONFIG_FUNCTION_TRACER
9862306a36Sopenharmony_ci  ifeq ($(call cc-option,-mfentry -mnop-mcount),)
9962306a36Sopenharmony_ci    # make use of hotpatch feature if the compiler supports it
10062306a36Sopenharmony_ci    cc_hotpatch	:= -mhotpatch=0,3
10162306a36Sopenharmony_ci    ifneq ($(call cc-option,$(cc_hotpatch)),)
10262306a36Sopenharmony_ci      CC_FLAGS_FTRACE := $(cc_hotpatch)
10362306a36Sopenharmony_ci      KBUILD_AFLAGS	+= -DCC_USING_HOTPATCH
10462306a36Sopenharmony_ci      KBUILD_CFLAGS	+= -DCC_USING_HOTPATCH
10562306a36Sopenharmony_ci    endif
10662306a36Sopenharmony_ci  endif
10762306a36Sopenharmony_ciendif
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci# Test CFI features of binutils
11062306a36Sopenharmony_cicfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1)
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ciKBUILD_CFLAGS	+= -mpacked-stack -mbackchain -msoft-float $(cflags-y)
11362306a36Sopenharmony_ciKBUILD_CFLAGS	+= -pipe -Wno-sign-compare
11462306a36Sopenharmony_ciKBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables $(cfi)
11562306a36Sopenharmony_ciKBUILD_AFLAGS	+= $(aflags-y) $(cfi)
11662306a36Sopenharmony_ciexport KBUILD_AFLAGS_DECOMPRESSOR
11762306a36Sopenharmony_ciexport KBUILD_CFLAGS_DECOMPRESSOR
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ciOBJCOPYFLAGS	:= -O binary
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_cilibs-y		+= arch/s390/lib/
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ciboot		:= arch/s390/boot
12462306a36Sopenharmony_cisyscalls	:= arch/s390/kernel/syscalls
12562306a36Sopenharmony_citools		:= arch/s390/tools
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ciall: bzImage
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
13062306a36Sopenharmony_ciKBUILD_IMAGE	:= $(boot)/bzImage
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ciinstall:
13362306a36Sopenharmony_ci	$(call cmd,install)
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_cibzImage: vmlinux
13662306a36Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_cizfcpdump:
13962306a36Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_civdso_install:
14262306a36Sopenharmony_ci	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ciarchheaders:
14562306a36Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(syscalls) uapi
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_ciarchprepare:
14862306a36Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(syscalls) kapi
14962306a36Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(tools) kapi
15062306a36Sopenharmony_ciifeq ($(KBUILD_EXTMOD),)
15162306a36Sopenharmony_ci# We need to generate vdso-offsets.h before compiling certain files in kernel/.
15262306a36Sopenharmony_ci# In order to do that, we should use the archprepare target, but we can't since
15362306a36Sopenharmony_ci# asm-offsets.h is included in some files used to generate vdso-offsets.h, and
15462306a36Sopenharmony_ci# asm-offsets.h is built in prepare0, for which archprepare is a dependency.
15562306a36Sopenharmony_ci# Therefore we need to generate the header after prepare0 has been made, hence
15662306a36Sopenharmony_ci# this hack.
15762306a36Sopenharmony_ciprepare: vdso_prepare
15862306a36Sopenharmony_civdso_prepare: prepare0
15962306a36Sopenharmony_ci	$(Q)$(MAKE) $(build)=arch/s390/kernel/vdso64 include/generated/vdso64-offsets.h
16062306a36Sopenharmony_ci	$(if $(CONFIG_COMPAT),$(Q)$(MAKE) \
16162306a36Sopenharmony_ci		$(build)=arch/s390/kernel/vdso32 include/generated/vdso32-offsets.h)
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ciifdef CONFIG_EXPOLINE_EXTERN
16462306a36Sopenharmony_cimodules_prepare: expoline_prepare
16562306a36Sopenharmony_ciexpoline_prepare: scripts
16662306a36Sopenharmony_ci	$(Q)$(MAKE) $(build)=arch/s390/lib/expoline arch/s390/lib/expoline/expoline.o
16762306a36Sopenharmony_ciendif
16862306a36Sopenharmony_ciendif
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ci# Don't use tabs in echo arguments
17162306a36Sopenharmony_cidefine archhelp
17262306a36Sopenharmony_ci  echo	'* bzImage         - Kernel image for IPL ($(boot)/bzImage)'
17362306a36Sopenharmony_ci  echo	'  install         - Install kernel using'
17462306a36Sopenharmony_ci  echo	'                    (your) ~/bin/$(INSTALLKERNEL) or'
17562306a36Sopenharmony_ci  echo	'                    (distribution) /sbin/$(INSTALLKERNEL) or'
17662306a36Sopenharmony_ci  echo	'                    install to $$(INSTALL_PATH)'
17762306a36Sopenharmony_ciendef
178