xref: /linux/arch/arc/Makefile (revision c17ee635fd3a482b2ad2bf5e269755c2eae5f25e)
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),)
9824927e8SLeon RomanovskyCROSS_COMPILE := $(call cc-cross-prefix, arc-linux- arceb-linux- arc-linux-gnu-)
102bc42bfbSAlexey Brodkinendif
112bc42bfbSAlexey Brodkin
12*b4171fd0SThomas Weißschuhcflags-y	+= -fno-common -pipe -fno-builtin -mmedium-calls -mswape -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 Gupta
45d05a76abSAlexey Brodkinifdef CONFIG_ISA_ARCV2
46d05a76abSAlexey Brodkin
4776551468SEugeniy Paltsevifdef CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS
4876551468SEugeniy Paltsevcflags-y				+= -munaligned-access
4976551468SEugeniy Paltsevelse
5076551468SEugeniy Paltsevcflags-y				+= -mno-unaligned-access
5176551468SEugeniy Paltsevendif
5276551468SEugeniy Paltsev
531f6ccfffSVineet Guptaifndef CONFIG_ARC_HAS_LL64
54d05a76abSAlexey Brodkincflags-y				+= -mno-ll64
55d05a76abSAlexey Brodkinendif
56d05a76abSAlexey Brodkin
57d05a76abSAlexey Brodkinifndef CONFIG_ARC_HAS_DIV_REM
58d05a76abSAlexey Brodkincflags-y				+= -mno-div-rem
59d05a76abSAlexey Brodkinendif
60d05a76abSAlexey Brodkin
611f6ccfffSVineet Guptaendif
621f6ccfffSVineet Gupta
635a205a32SVineet Guptacfi := $(call as-instr,.cfi_startproc\n.cfi_endproc,-DARC_DW2_UNWIND_AS_CFI)
645a205a32SVineet Guptacflags-$(CONFIG_ARC_DW2_UNWIND)		+= -fasynchronous-unwind-tables $(cfi)
656716dbbdSVineet Gupta
66cfdbc2e1SVineet Gupta# small data is default for elf32 tool-chain. If not usable, disable it
67cfdbc2e1SVineet Gupta# This also allows repurposing GP as scratch reg to gcc reg allocator
68cfdbc2e1SVineet Guptadisable_small_data := y
69cfca4b5aSVineet Guptacflags-$(disable_small_data)		+= -mno-sdata
70cfdbc2e1SVineet Gupta
71cfdbc2e1SVineet Guptacflags-$(CONFIG_CPU_BIG_ENDIAN)		+= -mbig-endian
72cfdbc2e1SVineet Guptaldflags-$(CONFIG_CPU_BIG_ENDIAN)	+= -EB
73cfdbc2e1SVineet Gupta
7440660f1fSAlexey BrodkinLIBGCC	= $(shell $(CC) $(cflags-y) --print-libgcc-file-name)
75cfdbc2e1SVineet Gupta
76cfdbc2e1SVineet Gupta# Modules with short calls might break for calls into builtin-kernel
7707fd7d4bSVineet GuptaKBUILD_CFLAGS_MODULE	+= -mlong-calls -mno-millicode
78cfdbc2e1SVineet Gupta
79cfdbc2e1SVineet Gupta# Finally dump eveything into kernel build system
80cfdbc2e1SVineet GuptaKBUILD_CFLAGS	+= $(cflags-y)
81cfdbc2e1SVineet GuptaKBUILD_AFLAGS	+= $(KBUILD_CFLAGS)
82d503ac53SMasahiro YamadaKBUILD_LDFLAGS	+= $(ldflags-y)
83cfdbc2e1SVineet Gupta
8433460f86SVineet Guptacore-y				+= arch/arc/plat-sim/
85072eb693SChristian Ruppertcore-$(CONFIG_ARC_PLAT_TB10X)	+= arch/arc/plat-tb10x/
86556cc1c5SAlexey Brodkincore-$(CONFIG_ARC_PLAT_AXS10X)	+= arch/arc/plat-axs10x/
87a518d637SAlexey Brodkincore-$(CONFIG_ARC_SOC_HSDK)	+= arch/arc/plat-hsdk/
8896665789SNoam Camus
89cfdbc2e1SVineet Guptalibs-y		+= arch/arc/lib/ $(LIBGCC)
90cfdbc2e1SVineet Gupta
91fb0990bbSVineet Guptaboot		:= arch/arc/boot
92fb0990bbSVineet Gupta
93c5e6ae56SMasahiro Yamadaboot_targets := uImage.bin uImage.gz uImage.lzma
94104058edSVineet Gupta
950cfccb3cSMasahiro YamadaPHONY += $(boot_targets)
96104058edSVineet Gupta$(boot_targets): vmlinux
97cfdbc2e1SVineet Gupta	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
98cfdbc2e1SVineet Gupta
99c5e6ae56SMasahiro Yamadauimage-default-y			:= uImage.bin
100c5e6ae56SMasahiro Yamadauimage-default-$(CONFIG_KERNEL_GZIP)	:= uImage.gz
101c5e6ae56SMasahiro Yamadauimage-default-$(CONFIG_KERNEL_LZMA)	:= uImage.lzma
102c5e6ae56SMasahiro Yamada
103c5e6ae56SMasahiro YamadaPHONY += uImage
104c5e6ae56SMasahiro YamadauImage: $(uimage-default-y)
105c5e6ae56SMasahiro Yamada	@ln -sf $< $(boot)/uImage
106c5e6ae56SMasahiro Yamada	@$(kecho) '  Image $(boot)/uImage is ready'
107c5e6ae56SMasahiro Yamada
108c5e6ae56SMasahiro YamadaCLEAN_FILES += $(boot)/uImage
109