1# SPDX-License-Identifier: GPL-2.0 2# 3# s390/Makefile 4# 5# This file is included by the global makefile so that you can add your own 6# architecture-specific flags and dependencies. Remember to do have actions 7# for "archclean" and "archdep" for cleaning up and making dependencies for 8# this architecture 9# 10# Copyright (C) 1994 by Linus Torvalds 11# 12 13LD_BFD := elf64-s390 14KBUILD_LDFLAGS := -m elf64_s390 15KBUILD_AFLAGS_MODULE += -fPIC 16KBUILD_CFLAGS_MODULE += -fPIC 17KBUILD_AFLAGS += -m64 18KBUILD_CFLAGS += -m64 19aflags_dwarf := -Wa,-gdwarf-2 20KBUILD_AFLAGS_DECOMPRESSOR := -m64 -D__ASSEMBLY__ 21KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf)) 22KBUILD_CFLAGS_DECOMPRESSOR := -m64 -O2 23KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY 24KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float 25KBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables 26KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-option,-ffreestanding) 27KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g) 28KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,)) 29UTS_MACHINE := s390x 30STACK_SIZE := 16384 31CHECKFLAGS += -D__s390__ -D__s390x__ 32 33export LD_BFD 34 35mflags-$(CONFIG_MARCH_Z900) := -march=z900 36mflags-$(CONFIG_MARCH_Z990) := -march=z990 37mflags-$(CONFIG_MARCH_Z9_109) := -march=z9-109 38mflags-$(CONFIG_MARCH_Z10) := -march=z10 39mflags-$(CONFIG_MARCH_Z196) := -march=z196 40mflags-$(CONFIG_MARCH_ZEC12) := -march=zEC12 41mflags-$(CONFIG_MARCH_Z13) := -march=z13 42mflags-$(CONFIG_MARCH_Z14) := -march=z14 43 44export CC_FLAGS_MARCH := $(mflags-y) 45 46aflags-y += $(mflags-y) 47cflags-y += $(mflags-y) 48 49cflags-$(CONFIG_MARCH_Z900_TUNE) += -mtune=z900 50cflags-$(CONFIG_MARCH_Z990_TUNE) += -mtune=z990 51cflags-$(CONFIG_MARCH_Z9_109_TUNE) += -mtune=z9-109 52cflags-$(CONFIG_MARCH_Z10_TUNE) += -mtune=z10 53cflags-$(CONFIG_MARCH_Z196_TUNE) += -mtune=z196 54cflags-$(CONFIG_MARCH_ZEC12_TUNE) += -mtune=zEC12 55cflags-$(CONFIG_MARCH_Z13_TUNE) += -mtune=z13 56cflags-$(CONFIG_MARCH_Z14_TUNE) += -mtune=z14 57 58cflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include 59 60# 61# Prevent tail-call optimizations, to get clearer backtraces: 62# 63cflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls 64 65ifeq ($(call cc-option-yn,-mpacked-stack),y) 66cflags-$(CONFIG_PACK_STACK) += -mpacked-stack -D__PACK_STACK 67aflags-$(CONFIG_PACK_STACK) += -D__PACK_STACK 68endif 69 70KBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y) 71KBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y) 72 73ifeq ($(call cc-option-yn,-mstack-size=8192 -mstack-guard=128),y) 74cflags-$(CONFIG_CHECK_STACK) += -mstack-size=$(STACK_SIZE) 75ifneq ($(call cc-option-yn,-mstack-size=8192),y) 76cflags-$(CONFIG_CHECK_STACK) += -mstack-guard=$(CONFIG_STACK_GUARD) 77endif 78endif 79 80ifdef CONFIG_WARN_DYNAMIC_STACK 81 ifeq ($(call cc-option-yn,-mwarn-dynamicstack),y) 82 KBUILD_CFLAGS += -mwarn-dynamicstack 83 KBUILD_CFLAGS_DECOMPRESSOR += -mwarn-dynamicstack 84 endif 85endif 86 87ifdef CONFIG_EXPOLINE 88 ifeq ($(call cc-option-yn,$(CC_FLAGS_MARCH) -mindirect-branch=thunk),y) 89 CC_FLAGS_EXPOLINE := -mindirect-branch=thunk 90 CC_FLAGS_EXPOLINE += -mfunction-return=thunk 91 CC_FLAGS_EXPOLINE += -mindirect-branch-table 92 export CC_FLAGS_EXPOLINE 93 cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE 94 aflags-y += -DCC_USING_EXPOLINE 95 endif 96endif 97 98ifdef CONFIG_FUNCTION_TRACER 99 ifeq ($(call cc-option-yn,-mfentry -mnop-mcount),n) 100 # make use of hotpatch feature if the compiler supports it 101 cc_hotpatch := -mhotpatch=0,3 102 ifeq ($(call cc-option-yn,$(cc_hotpatch)),y) 103 CC_FLAGS_FTRACE := $(cc_hotpatch) 104 KBUILD_AFLAGS += -DCC_USING_HOTPATCH 105 KBUILD_CFLAGS += -DCC_USING_HOTPATCH 106 endif 107 endif 108endif 109 110# Test CFI features of binutils 111cfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1) 112 113KBUILD_CFLAGS += -mbackchain -msoft-float $(cflags-y) 114KBUILD_CFLAGS += -pipe -fno-strength-reduce -Wno-sign-compare 115KBUILD_CFLAGS += -fno-asynchronous-unwind-tables $(cfi) 116KBUILD_AFLAGS += $(aflags-y) $(cfi) 117export KBUILD_AFLAGS_DECOMPRESSOR 118export KBUILD_CFLAGS_DECOMPRESSOR 119 120OBJCOPYFLAGS := -O binary 121 122head-y := arch/s390/kernel/head64.o 123 124# See arch/s390/Kbuild for content of core part of the kernel 125core-y += arch/s390/ 126 127libs-y += arch/s390/lib/ 128drivers-y += drivers/s390/ 129 130# must be linked after kernel 131drivers-$(CONFIG_OPROFILE) += arch/s390/oprofile/ 132 133boot := arch/s390/boot 134syscalls := arch/s390/kernel/syscalls 135tools := arch/s390/tools 136 137all: bzImage 138 139#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg... 140KBUILD_IMAGE := $(boot)/bzImage 141 142install: vmlinux 143 $(Q)$(MAKE) $(build)=$(boot) $@ 144 145bzImage: vmlinux 146 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 147 148zfcpdump: 149 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 150 151vdso_install: 152 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@ 153 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@ 154 155archclean: 156 $(Q)$(MAKE) $(clean)=$(boot) 157 $(Q)$(MAKE) $(clean)=$(tools) 158 159archheaders: 160 $(Q)$(MAKE) $(build)=$(syscalls) uapi 161 162archprepare: 163 $(Q)$(MAKE) $(build)=$(syscalls) kapi 164 $(Q)$(MAKE) $(build)=$(tools) kapi 165 166# Don't use tabs in echo arguments 167define archhelp 168 echo '* bzImage - Kernel image for IPL ($(boot)/bzImage)' 169 echo ' install - Install kernel using' 170 echo ' (your) ~/bin/$(INSTALLKERNEL) or' 171 echo ' (distribution) /sbin/$(INSTALLKERNEL) or' 172 echo ' install to $$(INSTALL_PATH)' 173endef 174