1d2912cb1SThomas Gleixner# SPDX-License-Identifier: GPL-2.0-only 2cfdbc2e1SVineet Gupta# 3cfdbc2e1SVineet Gupta# Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) 4cfdbc2e1SVineet Gupta# 5cfdbc2e1SVineet Gupta 61681baa7SEugeniy PaltsevKBUILD_DEFCONFIG := haps_hs_smp_defconfig 7cfdbc2e1SVineet Gupta 82bc42bfbSAlexey Brodkinifeq ($(CROSS_COMPILE),) 9*824927e8SLeon RomanovskyCROSS_COMPILE := $(call cc-cross-prefix, arc-linux- arceb-linux- arc-linux-gnu-) 102bc42bfbSAlexey Brodkinendif 112bc42bfbSAlexey Brodkin 1274c11e30SAlexey Brodkincflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__ 130bdd6e74SEugeniy Paltsev 14040ece2aSVineet Guptatune-mcpu-def-$(CONFIG_ISA_ARCOMPACT) := -mcpu=arc700 150bdd6e74SEugeniy Paltsevtune-mcpu-def-$(CONFIG_ISA_ARCV2) := -mcpu=hs38 160bdd6e74SEugeniy Paltsev 17129ab0d2SMasahiro Yamadaifeq ($(CONFIG_ARC_TUNE_MCPU),) 180bdd6e74SEugeniy Paltsevcflags-y += $(tune-mcpu-def-y) 190bdd6e74SEugeniy Paltsevelse 20129ab0d2SMasahiro Yamadatune-mcpu := $(CONFIG_ARC_TUNE_MCPU) 2143e6b58fSNick Desaulniersifneq ($(call cc-option,$(tune-mcpu)),) 220bdd6e74SEugeniy Paltsevcflags-y += $(tune-mcpu) 230bdd6e74SEugeniy Paltsevelse 240bdd6e74SEugeniy Paltsev# The flag provided by 'CONFIG_ARC_TUNE_MCPU' option isn't known by this compiler 250bdd6e74SEugeniy Paltsev# (probably the compiler is too old). Use ISA default mcpu flag instead as a safe option. 260bdd6e74SEugeniy Paltsev$(warning ** WARNING ** CONFIG_ARC_TUNE_MCPU flag '$(tune-mcpu)' is unknown, fallback to '$(tune-mcpu-def-y)') 270bdd6e74SEugeniy Paltsevcflags-y += $(tune-mcpu-def-y) 280bdd6e74SEugeniy Paltsevendif 290bdd6e74SEugeniy Paltsevendif 300bdd6e74SEugeniy Paltsev 31080c3747SVineet Guptaifdef CONFIG_ARC_CURR_IN_REG 32f79f7a2dSBhaskar Chowdhury# For a global register definition, make sure it gets passed to every file 33080c3747SVineet Gupta# We had a customer reported bug where some code built in kernel was NOT using 34cfca4b5aSVineet Gupta# any kernel headers, and missing the global register 358235703eSVineet Gupta# Can't do unconditionally because of recursive include issues 36080c3747SVineet Gupta# due to <linux/thread_info.h> 3775dd4747SMasahiro YamadaLINUXINCLUDE += -include $(srctree)/arch/arc/include/asm/current.h 38cfca4b5aSVineet Guptacflags-y += -ffixed-gp 39080c3747SVineet Guptaendif 40080c3747SVineet Gupta 412b52e2a6SMasahiro Yamadacflags-y += -fsection-anchors 42cfdbc2e1SVineet Gupta 4376a08404SVineet Guptacflags-$(CONFIG_ARC_HAS_LLSC) += -mlock 4476a08404SVineet Guptacflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape 4576a08404SVineet Gupta 46d05a76abSAlexey Brodkinifdef CONFIG_ISA_ARCV2 47d05a76abSAlexey Brodkin 4876551468SEugeniy Paltsevifdef CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS 4976551468SEugeniy Paltsevcflags-y += -munaligned-access 5076551468SEugeniy Paltsevelse 5176551468SEugeniy Paltsevcflags-y += -mno-unaligned-access 5276551468SEugeniy Paltsevendif 5376551468SEugeniy Paltsev 541f6ccfffSVineet Guptaifndef CONFIG_ARC_HAS_LL64 55d05a76abSAlexey Brodkincflags-y += -mno-ll64 56d05a76abSAlexey Brodkinendif 57d05a76abSAlexey Brodkin 58d05a76abSAlexey Brodkinifndef CONFIG_ARC_HAS_DIV_REM 59d05a76abSAlexey Brodkincflags-y += -mno-div-rem 60d05a76abSAlexey Brodkinendif 61d05a76abSAlexey Brodkin 621f6ccfffSVineet Guptaendif 631f6ccfffSVineet Gupta 645a205a32SVineet Guptacfi := $(call as-instr,.cfi_startproc\n.cfi_endproc,-DARC_DW2_UNWIND_AS_CFI) 655a205a32SVineet Guptacflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables $(cfi) 666716dbbdSVineet Gupta 67cfdbc2e1SVineet Gupta# small data is default for elf32 tool-chain. If not usable, disable it 68cfdbc2e1SVineet Gupta# This also allows repurposing GP as scratch reg to gcc reg allocator 69cfdbc2e1SVineet Guptadisable_small_data := y 70cfca4b5aSVineet Guptacflags-$(disable_small_data) += -mno-sdata 71cfdbc2e1SVineet Gupta 72cfdbc2e1SVineet Guptacflags-$(CONFIG_CPU_BIG_ENDIAN) += -mbig-endian 73cfdbc2e1SVineet Guptaldflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB 74cfdbc2e1SVineet Gupta 7540660f1fSAlexey BrodkinLIBGCC = $(shell $(CC) $(cflags-y) --print-libgcc-file-name) 76cfdbc2e1SVineet Gupta 77cfdbc2e1SVineet Gupta# Modules with short calls might break for calls into builtin-kernel 7807fd7d4bSVineet GuptaKBUILD_CFLAGS_MODULE += -mlong-calls -mno-millicode 79cfdbc2e1SVineet Gupta 80cfdbc2e1SVineet Gupta# Finally dump eveything into kernel build system 81cfdbc2e1SVineet GuptaKBUILD_CFLAGS += $(cflags-y) 82cfdbc2e1SVineet GuptaKBUILD_AFLAGS += $(KBUILD_CFLAGS) 83d503ac53SMasahiro YamadaKBUILD_LDFLAGS += $(ldflags-y) 84cfdbc2e1SVineet Gupta 85999159a5SVineet Guptacore-y += arch/arc/plat-sim/ 86999159a5SVineet Guptacore-$(CONFIG_ARC_PLAT_TB10X) += arch/arc/plat-tb10x/ 87999159a5SVineet Guptacore-$(CONFIG_ARC_PLAT_AXS10X) += arch/arc/plat-axs10x/ 8833460f86SVineet Guptacore-$(CONFIG_ARC_SOC_HSDK) += arch/arc/plat-hsdk/ 89072eb693SChristian Ruppert 90556cc1c5SAlexey Brodkinlibs-y += arch/arc/lib/ $(LIBGCC) 91a518d637SAlexey Brodkin 9296665789SNoam Camusboot := arch/arc/boot 93cfdbc2e1SVineet Gupta 94cfdbc2e1SVineet Guptaboot_targets := uImage.bin uImage.gz uImage.lzma 95fb0990bbSVineet Gupta 96fb0990bbSVineet GuptaPHONY += $(boot_targets) 97c5e6ae56SMasahiro Yamada$(boot_targets): vmlinux 98104058edSVineet Gupta $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 990cfccb3cSMasahiro Yamada 100104058edSVineet Guptauimage-default-y := uImage.bin 101cfdbc2e1SVineet Guptauimage-default-$(CONFIG_KERNEL_GZIP) := uImage.gz 102cfdbc2e1SVineet Guptauimage-default-$(CONFIG_KERNEL_LZMA) := uImage.lzma 103c5e6ae56SMasahiro Yamada 104c5e6ae56SMasahiro YamadaPHONY += uImage 105c5e6ae56SMasahiro YamadauImage: $(uimage-default-y) 106c5e6ae56SMasahiro Yamada @ln -sf $< $(boot)/uImage 107c5e6ae56SMasahiro Yamada @$(kecho) ' Image $(boot)/uImage is ready' 108c5e6ae56SMasahiro Yamada 109c5e6ae56SMasahiro YamadaCLEAN_FILES += $(boot)/uImage 110c5e6ae56SMasahiro Yamada