blob: fd79faab789269ca73bed95f8117dca03b44487d [file] [log] [blame]
Vineet Guptacfdbc2e2013-01-18 15:12:20 +05301#
2# Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License version 2 as
6# published by the Free Software Foundation.
7#
8
9UTS_MACHINE := arc
10
Kevin Hilmanabbeacc02018-11-30 15:51:56 +030011KBUILD_DEFCONFIG := nsim_hs_defconfig
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053012
Alexey Brodkine7a03932018-06-01 14:34:33 +030013cflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
Vineet Gupta40b8ad82015-06-28 20:22:01 +053014cflags-$(CONFIG_ISA_ARCOMPACT) += -mA7
15cflags-$(CONFIG_ISA_ARCV2) += -mcpu=archs
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053016
Vineet Gupta080c3742013-02-11 19:52:57 +053017ifdef CONFIG_ARC_CURR_IN_REG
18# For a global register defintion, make sure it gets passed to every file
19# We had a customer reported bug where some code built in kernel was NOT using
20# any kernel headers, and missing the r25 global register
Vineet Gupta82357032013-06-01 12:55:42 +053021# Can't do unconditionally because of recursive include issues
Vineet Gupta080c3742013-02-11 19:52:57 +053022# due to <linux/thread_info.h>
23LINUXINCLUDE += -include ${src}/arch/arc/include/asm/current.h
24endif
25
Vineet Gupta5a45da02013-05-25 14:03:25 +053026upto_gcc44 := $(call cc-ifversion, -le, 0404, y)
27atleast_gcc44 := $(call cc-ifversion, -ge, 0404, y)
Vineet Gupta5a45da02013-05-25 14:03:25 +053028
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053029cflags-$(atleast_gcc44) += -fsection-anchors
30
Vineet Gupta76a08402016-11-08 08:47:14 -080031cflags-$(CONFIG_ARC_HAS_LLSC) += -mlock
32cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape
33
Alexey Brodkind05a76a2015-07-16 21:45:38 +030034ifdef CONFIG_ISA_ARCV2
35
Vineet Gupta1f6ccff2013-05-13 18:30:41 +053036ifndef CONFIG_ARC_HAS_LL64
Alexey Brodkind05a76a2015-07-16 21:45:38 +030037cflags-y += -mno-ll64
38endif
39
40ifndef CONFIG_ARC_HAS_DIV_REM
41cflags-y += -mno-div-rem
42endif
43
Vineet Gupta1f6ccff2013-05-13 18:30:41 +053044endif
45
Vineet Gupta5a205a32016-09-16 17:23:26 -070046cfi := $(call as-instr,.cfi_startproc\n.cfi_endproc,-DARC_DW2_UNWIND_AS_CFI)
47cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables $(cfi)
Vineet Gupta6716dbb2013-06-24 21:22:06 +053048
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053049ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
50# Generic build system uses -O2, we want -O3
Vineet Gupta97709062015-06-18 13:54:01 +053051# Note: No need to add to cflags-y as that happens anyways
Arnd Bergmanna76bcf52016-11-10 17:44:44 +010052#
53# Disable the false maybe-uninitialized warings gcc spits out at -O3
54ARCH_CFLAGS += -O3 $(call cc-disable-warning,maybe-uninitialized,)
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053055endif
56
57# small data is default for elf32 tool-chain. If not usable, disable it
58# This also allows repurposing GP as scratch reg to gcc reg allocator
59disable_small_data := y
60cflags-$(disable_small_data) += -mno-sdata -fcall-used-gp
61
62cflags-$(CONFIG_CPU_BIG_ENDIAN) += -mbig-endian
63ldflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB
64
Vineet Gupta5a45da02013-05-25 14:03:25 +053065# STAR 9000518362: (fixed with binutils shipping with gcc 4.8)
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053066# arc-linux-uclibc-ld (buildroot) or arceb-elf32-ld (EZChip) don't accept
Vineet Gupta5a45da02013-05-25 14:03:25 +053067# --build-id w/o "-marclinux". Default arc-elf32-ld is OK
68ldflags-$(upto_gcc44) += -marclinux
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053069
Alexey Brodkin5d4c6662018-09-16 23:47:57 +030070LIBGCC = $(shell $(CC) $(cflags-y) --print-libgcc-file-name)
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053071
72# Modules with short calls might break for calls into builtin-kernel
Vineet Gupta07fd7d42015-12-21 12:38:01 +053073KBUILD_CFLAGS_MODULE += -mlong-calls -mno-millicode
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053074
75# Finally dump eveything into kernel build system
76KBUILD_CFLAGS += $(cflags-y)
77KBUILD_AFLAGS += $(KBUILD_CFLAGS)
78LDFLAGS += $(ldflags-y)
79
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053080head-y := arch/arc/kernel/head.o
81
82# See arch/arc/Kbuild for content of core part of the kernel
83core-y += arch/arc/
84
Vineet Gupta999159a2013-01-22 17:00:52 +053085# w/o this dtb won't embed into kernel binary
86core-y += arch/arc/boot/dts/
87
Vineet Guptafd155792015-02-20 19:12:18 +053088core-$(CONFIG_ARC_PLAT_SIM) += arch/arc/plat-sim/
89core-$(CONFIG_ARC_PLAT_TB10X) += arch/arc/plat-tb10x/
Alexey Brodkin556cc1c2014-01-27 14:51:34 +010090core-$(CONFIG_ARC_PLAT_AXS10X) += arch/arc/plat-axs10x/
Noam Camus966657892015-10-16 16:52:43 +030091core-$(CONFIG_ARC_PLAT_EZNPS) += arch/arc/plat-eznps/
92
93ifdef CONFIG_ARC_PLAT_EZNPS
94KBUILD_CPPFLAGS += -I$(srctree)/arch/arc/plat-eznps/include
95endif
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053096
Vineet Gupta769bc1f2013-01-22 17:02:38 +053097drivers-$(CONFIG_OPROFILE) += arch/arc/oprofile/
98
Vineet Guptacfdbc2e2013-01-18 15:12:20 +053099libs-y += arch/arc/lib/ $(LIBGCC)
100
Vineet Guptafb0990b2013-03-22 19:48:01 +0530101boot := arch/arc/boot
102
Andrea Gelmini25474762016-05-21 13:45:35 +0200103#default target for make without any arguments.
Vineet Guptafb0990b2013-03-22 19:48:01 +0530104KBUILD_IMAGE := bootpImage
Vineet Guptacfdbc2e2013-01-18 15:12:20 +0530105
106all: $(KBUILD_IMAGE)
Vineet Guptacfdbc2e2013-01-18 15:12:20 +0530107bootpImage: vmlinux
108
Vineet Gupta104058e2013-03-22 22:04:27 +0530109boot_targets += uImage uImage.bin uImage.gz
110
111$(boot_targets): vmlinux
Vineet Guptacfdbc2e2013-01-18 15:12:20 +0530112 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
113
Vineet Gupta999159a2013-01-22 17:00:52 +0530114%.dtb %.dtb.S %.dtb.o: scripts
115 $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@
116
117dtbs: scripts
Rob Herring10375cc2015-10-08 10:10:53 -0500118 $(Q)$(MAKE) $(build)=$(boot)/dts
Vineet Gupta999159a2013-01-22 17:00:52 +0530119
Vineet Guptacfdbc2e2013-01-18 15:12:20 +0530120archclean:
121 $(Q)$(MAKE) $(clean)=$(boot)