blob: efc54f3e35e07407777aab00356f52f873bf335f [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001# SPDX-License-Identifier: GPL-2.0-only
Vineet Guptacfdbc2e2013-01-18 15:12:20 +05302#
3# Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
4#
Vineet Guptacfdbc2e2013-01-18 15:12:20 +05305
Eugeniy Paltsev1681baa2019-10-23 15:44:15 +03006KBUILD_DEFCONFIG := haps_hs_smp_defconfig
Vineet Guptacfdbc2e2013-01-18 15:12:20 +05307
Alexey Brodkin2bc42bf2019-06-03 09:31:19 +03008ifeq ($(CROSS_COMPILE),)
9CROSS_COMPILE := $(call cc-cross-prefix, arc-linux- arceb-linux-)
10endif
11
Alexey Brodkin74c11e32018-06-01 14:34:33 +030012cflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
Eugeniy Paltsev0bdd6e72020-06-04 20:39:24 +030013
Vineet Gupta040ece22020-06-16 15:14:50 -070014tune-mcpu-def-$(CONFIG_ISA_ARCOMPACT) := -mcpu=arc700
Eugeniy Paltsev0bdd6e72020-06-04 20:39:24 +030015tune-mcpu-def-$(CONFIG_ISA_ARCV2) := -mcpu=hs38
16
Masahiro Yamada129ab0d2021-12-14 11:53:53 +090017ifeq ($(CONFIG_ARC_TUNE_MCPU),)
Eugeniy Paltsev0bdd6e72020-06-04 20:39:24 +030018cflags-y += $(tune-mcpu-def-y)
19else
Masahiro Yamada129ab0d2021-12-14 11:53:53 +090020tune-mcpu := $(CONFIG_ARC_TUNE_MCPU)
Nick Desaulniers43e6b582021-08-16 17:21:06 -070021ifneq ($(call cc-option,$(tune-mcpu)),)
Eugeniy Paltsev0bdd6e72020-06-04 20:39:24 +030022cflags-y += $(tune-mcpu)
23else
24# The flag provided by 'CONFIG_ARC_TUNE_MCPU' option isn't known by this compiler
25# (probably the compiler is too old). Use ISA default mcpu flag instead as a safe option.
26$(warning ** WARNING ** CONFIG_ARC_TUNE_MCPU flag '$(tune-mcpu)' is unknown, fallback to '$(tune-mcpu-def-y)')
27cflags-y += $(tune-mcpu-def-y)
28endif
29endif
30
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053031
Vineet Gupta080c3742013-02-11 19:52:57 +053032ifdef CONFIG_ARC_CURR_IN_REG
Bhaskar Chowdhuryf79f7a22021-03-22 17:58:19 +053033# For a global register definition, make sure it gets passed to every file
Vineet Gupta080c3742013-02-11 19:52:57 +053034# We had a customer reported bug where some code built in kernel was NOT using
35# any kernel headers, and missing the r25 global register
Vineet Gupta82357032013-06-01 12:55:42 +053036# Can't do unconditionally because of recursive include issues
Vineet Gupta080c3742013-02-11 19:52:57 +053037# due to <linux/thread_info.h>
Masahiro Yamada75dd4742019-07-06 12:07:11 +090038LINUXINCLUDE += -include $(srctree)/arch/arc/include/asm/current.h
Vineet Gupta080c3742013-02-11 19:52:57 +053039endif
40
Masahiro Yamada2b52e2a2018-08-27 12:07:37 +090041cflags-y += -fsection-anchors
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053042
Vineet Gupta76a08402016-11-08 08:47:14 -080043cflags-$(CONFIG_ARC_HAS_LLSC) += -mlock
44cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape
45
Alexey Brodkind05a76a2015-07-16 21:45:38 +030046ifdef CONFIG_ISA_ARCV2
47
Eugeniy Paltsev76551462019-01-30 19:32:41 +030048ifdef CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS
49cflags-y += -munaligned-access
50else
51cflags-y += -mno-unaligned-access
52endif
53
Vineet Gupta1f6ccff2013-05-13 18:30:41 +053054ifndef CONFIG_ARC_HAS_LL64
Alexey Brodkind05a76a2015-07-16 21:45:38 +030055cflags-y += -mno-ll64
56endif
57
58ifndef CONFIG_ARC_HAS_DIV_REM
59cflags-y += -mno-div-rem
60endif
61
Vineet Gupta1f6ccff2013-05-13 18:30:41 +053062endif
63
Vineet Gupta5a205a32016-09-16 17:23:26 -070064cfi := $(call as-instr,.cfi_startproc\n.cfi_endproc,-DARC_DW2_UNWIND_AS_CFI)
65cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables $(cfi)
Vineet Gupta6716dbb2013-06-24 21:22:06 +053066
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053067# small data is default for elf32 tool-chain. If not usable, disable it
68# This also allows repurposing GP as scratch reg to gcc reg allocator
69disable_small_data := y
70cflags-$(disable_small_data) += -mno-sdata -fcall-used-gp
71
72cflags-$(CONFIG_CPU_BIG_ENDIAN) += -mbig-endian
73ldflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB
74
Alexey Brodkin40660f12018-09-16 23:47:57 +030075LIBGCC = $(shell $(CC) $(cflags-y) --print-libgcc-file-name)
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053076
77# Modules with short calls might break for calls into builtin-kernel
Vineet Gupta07fd7d42015-12-21 12:38:01 +053078KBUILD_CFLAGS_MODULE += -mlong-calls -mno-millicode
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053079
80# Finally dump eveything into kernel build system
81KBUILD_CFLAGS += $(cflags-y)
82KBUILD_AFLAGS += $(KBUILD_CFLAGS)
Masahiro Yamadad503ac52018-08-24 08:20:39 +090083KBUILD_LDFLAGS += $(ldflags-y)
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053084
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053085head-y := arch/arc/kernel/head.o
86
Vineet Gupta999159a2013-01-22 17:00:52 +053087# w/o this dtb won't embed into kernel binary
88core-y += arch/arc/boot/dts/
89
Vineet Gupta33460f82017-07-28 16:53:50 +053090core-y += arch/arc/plat-sim/
Vineet Guptafd155792015-02-20 19:12:18 +053091core-$(CONFIG_ARC_PLAT_TB10X) += arch/arc/plat-tb10x/
Alexey Brodkin556cc1c2014-01-27 14:51:34 +010092core-$(CONFIG_ARC_PLAT_AXS10X) += arch/arc/plat-axs10x/
Alexey Brodkina518d632017-08-15 21:13:55 +030093core-$(CONFIG_ARC_SOC_HSDK) += arch/arc/plat-hsdk/
Noam Camus966657892015-10-16 16:52:43 +030094
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053095libs-y += arch/arc/lib/ $(LIBGCC)
96
Vineet Guptafb0990b2013-03-22 19:48:01 +053097boot := arch/arc/boot
98
Masahiro Yamadac5e6ae52020-11-22 04:36:55 +090099boot_targets := uImage.bin uImage.gz uImage.lzma
Vineet Gupta104058e2013-03-22 22:04:27 +0530100
Masahiro Yamada0cfccb32020-11-22 04:36:54 +0900101PHONY += $(boot_targets)
Vineet Gupta104058e2013-03-22 22:04:27 +0530102$(boot_targets): vmlinux
Vineet Guptacfdbc2e2013-01-18 15:12:20 +0530103 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
104
Masahiro Yamadac5e6ae52020-11-22 04:36:55 +0900105uimage-default-y := uImage.bin
106uimage-default-$(CONFIG_KERNEL_GZIP) := uImage.gz
107uimage-default-$(CONFIG_KERNEL_LZMA) := uImage.lzma
108
109PHONY += uImage
110uImage: $(uimage-default-y)
111 @ln -sf $< $(boot)/uImage
112 @$(kecho) ' Image $(boot)/uImage is ready'
113
114CLEAN_FILES += $(boot)/uImage