xref: /OK3568_Linux_fs/kernel/arch/arc/Makefile (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun#
3*4882a593Smuzhiyun# Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
4*4882a593Smuzhiyun#
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunKBUILD_DEFCONFIG := haps_hs_smp_defconfig
7*4882a593Smuzhiyun
8*4882a593Smuzhiyunifeq ($(CROSS_COMPILE),)
9*4882a593SmuzhiyunCROSS_COMPILE := $(call cc-cross-prefix, arc-linux- arceb-linux-)
10*4882a593Smuzhiyunendif
11*4882a593Smuzhiyun
12*4882a593Smuzhiyuncflags-y	+= -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
13*4882a593Smuzhiyun
14*4882a593Smuzhiyuntune-mcpu-def-$(CONFIG_ISA_ARCOMPACT)	:= -mcpu=arc700
15*4882a593Smuzhiyuntune-mcpu-def-$(CONFIG_ISA_ARCV2)	:= -mcpu=hs38
16*4882a593Smuzhiyun
17*4882a593Smuzhiyunifeq ($(CONFIG_ARC_TUNE_MCPU),"")
18*4882a593Smuzhiyuncflags-y				+= $(tune-mcpu-def-y)
19*4882a593Smuzhiyunelse
20*4882a593Smuzhiyuntune-mcpu				:= $(shell echo $(CONFIG_ARC_TUNE_MCPU))
21*4882a593Smuzhiyuntune-mcpu-ok 				:= $(call cc-option-yn, $(tune-mcpu))
22*4882a593Smuzhiyunifeq ($(tune-mcpu-ok),y)
23*4882a593Smuzhiyuncflags-y				+= $(tune-mcpu)
24*4882a593Smuzhiyunelse
25*4882a593Smuzhiyun# The flag provided by 'CONFIG_ARC_TUNE_MCPU' option isn't known by this compiler
26*4882a593Smuzhiyun# (probably the compiler is too old). Use ISA default mcpu flag instead as a safe option.
27*4882a593Smuzhiyun$(warning ** WARNING ** CONFIG_ARC_TUNE_MCPU flag '$(tune-mcpu)' is unknown, fallback to '$(tune-mcpu-def-y)')
28*4882a593Smuzhiyuncflags-y				+= $(tune-mcpu-def-y)
29*4882a593Smuzhiyunendif
30*4882a593Smuzhiyunendif
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun
33*4882a593Smuzhiyunifdef CONFIG_ARC_CURR_IN_REG
34*4882a593Smuzhiyun# For a global register defintion, make sure it gets passed to every file
35*4882a593Smuzhiyun# We had a customer reported bug where some code built in kernel was NOT using
36*4882a593Smuzhiyun# any kernel headers, and missing the r25 global register
37*4882a593Smuzhiyun# Can't do unconditionally because of recursive include issues
38*4882a593Smuzhiyun# due to <linux/thread_info.h>
39*4882a593SmuzhiyunLINUXINCLUDE	+=  -include $(srctree)/arch/arc/include/asm/current.h
40*4882a593Smuzhiyunendif
41*4882a593Smuzhiyun
42*4882a593Smuzhiyuncflags-y				+= -fsection-anchors
43*4882a593Smuzhiyun
44*4882a593Smuzhiyuncflags-$(CONFIG_ARC_HAS_LLSC)		+= -mlock
45*4882a593Smuzhiyuncflags-$(CONFIG_ARC_HAS_SWAPE)		+= -mswape
46*4882a593Smuzhiyun
47*4882a593Smuzhiyunifdef CONFIG_ISA_ARCV2
48*4882a593Smuzhiyun
49*4882a593Smuzhiyunifdef CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS
50*4882a593Smuzhiyuncflags-y				+= -munaligned-access
51*4882a593Smuzhiyunelse
52*4882a593Smuzhiyuncflags-y				+= -mno-unaligned-access
53*4882a593Smuzhiyunendif
54*4882a593Smuzhiyun
55*4882a593Smuzhiyunifndef CONFIG_ARC_HAS_LL64
56*4882a593Smuzhiyuncflags-y				+= -mno-ll64
57*4882a593Smuzhiyunendif
58*4882a593Smuzhiyun
59*4882a593Smuzhiyunifndef CONFIG_ARC_HAS_DIV_REM
60*4882a593Smuzhiyuncflags-y				+= -mno-div-rem
61*4882a593Smuzhiyunendif
62*4882a593Smuzhiyun
63*4882a593Smuzhiyunendif
64*4882a593Smuzhiyun
65*4882a593Smuzhiyuncfi := $(call as-instr,.cfi_startproc\n.cfi_endproc,-DARC_DW2_UNWIND_AS_CFI)
66*4882a593Smuzhiyuncflags-$(CONFIG_ARC_DW2_UNWIND)		+= -fasynchronous-unwind-tables $(cfi)
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun# small data is default for elf32 tool-chain. If not usable, disable it
69*4882a593Smuzhiyun# This also allows repurposing GP as scratch reg to gcc reg allocator
70*4882a593Smuzhiyundisable_small_data := y
71*4882a593Smuzhiyuncflags-$(disable_small_data)		+= -mno-sdata -fcall-used-gp
72*4882a593Smuzhiyun
73*4882a593Smuzhiyuncflags-$(CONFIG_CPU_BIG_ENDIAN)		+= -mbig-endian
74*4882a593Smuzhiyunldflags-$(CONFIG_CPU_BIG_ENDIAN)	+= -EB
75*4882a593Smuzhiyun
76*4882a593SmuzhiyunLIBGCC	= $(shell $(CC) $(cflags-y) --print-libgcc-file-name)
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun# Modules with short calls might break for calls into builtin-kernel
79*4882a593SmuzhiyunKBUILD_CFLAGS_MODULE	+= -mlong-calls -mno-millicode
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun# Finally dump eveything into kernel build system
82*4882a593SmuzhiyunKBUILD_CFLAGS	+= $(cflags-y)
83*4882a593SmuzhiyunKBUILD_AFLAGS	+= $(KBUILD_CFLAGS)
84*4882a593SmuzhiyunKBUILD_LDFLAGS	+= $(ldflags-y)
85*4882a593Smuzhiyun
86*4882a593Smuzhiyunhead-y		:= arch/arc/kernel/head.o
87*4882a593Smuzhiyun
88*4882a593Smuzhiyun# See arch/arc/Kbuild for content of core part of the kernel
89*4882a593Smuzhiyuncore-y		+= arch/arc/
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun# w/o this dtb won't embed into kernel binary
92*4882a593Smuzhiyuncore-y		+= arch/arc/boot/dts/
93*4882a593Smuzhiyun
94*4882a593Smuzhiyuncore-y				+= arch/arc/plat-sim/
95*4882a593Smuzhiyuncore-$(CONFIG_ARC_PLAT_TB10X)	+= arch/arc/plat-tb10x/
96*4882a593Smuzhiyuncore-$(CONFIG_ARC_PLAT_AXS10X)	+= arch/arc/plat-axs10x/
97*4882a593Smuzhiyuncore-$(CONFIG_ARC_SOC_HSDK)	+= arch/arc/plat-hsdk/
98*4882a593Smuzhiyun
99*4882a593Smuzhiyundrivers-$(CONFIG_OPROFILE)	+= arch/arc/oprofile/
100*4882a593Smuzhiyun
101*4882a593Smuzhiyunlibs-y		+= arch/arc/lib/ $(LIBGCC)
102*4882a593Smuzhiyun
103*4882a593Smuzhiyunboot		:= arch/arc/boot
104*4882a593Smuzhiyun
105*4882a593Smuzhiyunboot_targets := uImage.bin uImage.gz uImage.lzma
106*4882a593Smuzhiyun
107*4882a593SmuzhiyunPHONY += $(boot_targets)
108*4882a593Smuzhiyun$(boot_targets): vmlinux
109*4882a593Smuzhiyun	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
110*4882a593Smuzhiyun
111*4882a593Smuzhiyunuimage-default-y			:= uImage.bin
112*4882a593Smuzhiyunuimage-default-$(CONFIG_KERNEL_GZIP)	:= uImage.gz
113*4882a593Smuzhiyunuimage-default-$(CONFIG_KERNEL_LZMA)	:= uImage.lzma
114*4882a593Smuzhiyun
115*4882a593SmuzhiyunPHONY += uImage
116*4882a593SmuzhiyunuImage: $(uimage-default-y)
117*4882a593Smuzhiyun	@ln -sf $< $(boot)/uImage
118*4882a593Smuzhiyun	@$(kecho) '  Image $(boot)/uImage is ready'
119*4882a593Smuzhiyun
120*4882a593SmuzhiyunCLEAN_FILES += $(boot)/uImage
121*4882a593Smuzhiyun
122*4882a593Smuzhiyunarchclean:
123*4882a593Smuzhiyun	$(Q)$(MAKE) $(clean)=$(boot)
124