blob: d67e30faff9c83b519702e15e1ea4ad70eed52d8 [file] [log] [blame]
Chris Zankel8e1a6dd2005-06-23 22:01:10 -07001#
2# This file is subject to the terms and conditions of the GNU General Public
3# License. See the file "COPYING" in the main directory of this archive
4# for more details.
5#
6# Copyright (C) 2001 - 2005 Tensilica Inc.
Max Filippov420ae952014-06-16 07:25:06 +04007# Copyright (C) 2014 Cadence Design Systems Inc.
Chris Zankel8e1a6dd2005-06-23 22:01:10 -07008#
9# This file is included by the global makefile so that you can add your own
10# architecture-specific flags and dependencies. Remember to do have actions
11# for "archclean" and "archdep" for cleaning up and making dependencies for
12# this architecture
13
14# Core configuration.
Chris Zankel173d6682006-12-10 02:18:48 -080015# (Use VAR=<xtensa_config> to use another default compiler.)
Chris Zankel8e1a6dd2005-06-23 22:01:10 -070016
Max Filippov420ae952014-06-16 07:25:06 +040017variant-y := $(patsubst "%",%,$(CONFIG_XTENSA_VARIANT_NAME))
Chris Zankel8e1a6dd2005-06-23 22:01:10 -070018
Chris Zankel173d6682006-12-10 02:18:48 -080019VARIANT = $(variant-y)
20export VARIANT
Chris Zankel8e1a6dd2005-06-23 22:01:10 -070021
Geert Uytterhoeven70cefe72012-05-12 22:39:08 +020022# Test for cross compiling
23
24ifneq ($(VARIANT),)
25 COMPILE_ARCH = $(shell uname -m)
26
27 ifneq ($(COMPILE_ARCH), xtensa)
28 ifndef CROSS_COMPILE
29 CROSS_COMPILE = xtensa_$(VARIANT)-
30 endif
31 endif
32endif
33
Chris Zankel8e1a6dd2005-06-23 22:01:10 -070034# Platform configuration
35
Chris Zankel8e1a6dd2005-06-23 22:01:10 -070036platform-$(CONFIG_XTENSA_PLATFORM_XT2000) := xt2000
37platform-$(CONFIG_XTENSA_PLATFORM_ISS) := iss
Max Filippov0d456ba2012-11-05 07:37:14 +040038platform-$(CONFIG_XTENSA_PLATFORM_XTFPGA) := xtfpga
Chris Zankel8e1a6dd2005-06-23 22:01:10 -070039
40PLATFORM = $(platform-y)
41export PLATFORM
42
Chris Zankelb2444d32007-08-04 09:23:54 -070043# temporarily until string.h is fixed
Max Filippova753cd92012-09-17 05:44:51 +040044KBUILD_CFLAGS += -ffreestanding -D__linux__
Max Filippovf8f02ca2017-12-03 20:55:35 -080045KBUILD_CFLAGS += -pipe -mlongcalls -mtext-section-literals
Chris Zankelcf1c0aa2010-05-02 01:00:22 -070046KBUILD_CFLAGS += $(call cc-option,-mforce-no-pic,)
Max Filippov7bf52342017-04-28 09:40:00 -070047KBUILD_CFLAGS += $(call cc-option,-mno-serialize-volatile,)
Chris Zankelcf1c0aa2010-05-02 01:00:22 -070048
Max Filippovf8f02ca2017-12-03 20:55:35 -080049KBUILD_AFLAGS += -mlongcalls -mtext-section-literals
50
Chris Zankel65501622012-11-13 15:16:36 -080051ifneq ($(CONFIG_LD_NO_RELAX),)
Masahiro Yamadad503ac52018-08-24 08:20:39 +090052KBUILD_LDFLAGS := --no-relax
Chris Zankel65501622012-11-13 15:16:36 -080053endif
54
Max Filippov123f15e2013-08-22 18:09:47 +040055ifeq ($(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#"),1)
Max Filippov72100ed2012-12-11 01:26:25 +040056CHECKFLAGS += -D__XTENSA_EB__
Max Filippov4611bf72016-03-01 02:00:59 +030057KBUILD_CPPFLAGS += -DCONFIG_CPU_BIG_ENDIAN
Max Filippov72100ed2012-12-11 01:26:25 +040058endif
Max Filippov123f15e2013-08-22 18:09:47 +040059ifeq ($(shell echo __XTENSA_EL__ | $(CC) -E - | grep -v "\#"),1)
Max Filippov72100ed2012-12-11 01:26:25 +040060CHECKFLAGS += -D__XTENSA_EL__
Max Filippov4611bf72016-03-01 02:00:59 +030061KBUILD_CPPFLAGS += -DCONFIG_CPU_LITTLE_ENDIAN
Max Filippov72100ed2012-12-11 01:26:25 +040062endif
63
Chris Zankel367b8112008-11-06 06:40:46 -080064vardirs := $(patsubst %,arch/xtensa/variants/%/,$(variant-y))
65plfdirs := $(patsubst %,arch/xtensa/platforms/%/,$(platform-y))
66
Chris Zankel367b8112008-11-06 06:40:46 -080067KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(vardirs) $(plfdirs))
Chris Zankel367b8112008-11-06 06:40:46 -080068
Chris Zankele7d163f2005-06-30 02:58:59 -070069KBUILD_DEFCONFIG := iss_defconfig
Chris Zankel8e1a6dd2005-06-23 22:01:10 -070070
Chris Zankelf1933182009-04-02 16:58:53 -070071# Only build variant and/or platform if it includes a Makefile
72
Geert Uytterhoeven0eff08b2012-06-20 12:52:59 -070073buildvar := $(shell test -e $(srctree)/arch/xtensa/variants/$(VARIANT)/Makefile && echo arch/xtensa/variants/$(VARIANT)/)
74buildplf := $(shell test -e $(srctree)/arch/xtensa/platforms/$(PLATFORM)/Makefile && echo arch/xtensa/platforms/$(PLATFORM)/)
Chris Zankelf1933182009-04-02 16:58:53 -070075
76# Find libgcc.a
Chris Zankel8e1a6dd2005-06-23 22:01:10 -070077
Sam Ravnborga0f97e02007-10-14 22:21:35 +020078LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
Chris Zankel8e1a6dd2005-06-23 22:01:10 -070079
80head-y := arch/xtensa/kernel/head.o
Chris Zankele7d163f2005-06-30 02:58:59 -070081core-y += arch/xtensa/kernel/ arch/xtensa/mm/
Chris Zankelf1933182009-04-02 16:58:53 -070082core-y += $(buildvar) $(buildplf)
83
Chris Zankel8e1a6dd2005-06-23 22:01:10 -070084libs-y += arch/xtensa/lib/ $(LIBGCC)
danne6ffe172008-05-21 17:43:50 -070085drivers-$(CONFIG_OPROFILE) += arch/xtensa/oprofile/
Chris Zankel8e1a6dd2005-06-23 22:01:10 -070086
Max Filippovda844a82012-11-04 00:30:13 +040087ifneq ($(CONFIG_BUILTIN_DTB),"")
Stephen Warren2a02bc12013-01-02 11:27:14 -070088core-$(CONFIG_OF) += arch/xtensa/boot/dts/
Max Filippovda844a82012-11-04 00:30:13 +040089endif
90
Chris Zankele7d163f2005-06-30 02:58:59 -070091boot := arch/xtensa/boot
92
Max Filippov9a736fc2016-12-25 04:58:57 -080093all Image zImage uImage: vmlinux
Chris Zankel8e1a6dd2005-06-23 22:01:10 -070094 $(Q)$(MAKE) $(build)=$(boot) $@
95
Max Filippovda844a82012-11-04 00:30:13 +040096%.dtb:
Stephen Warren2a02bc12013-01-02 11:27:14 -070097 $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@
Max Filippovda844a82012-11-04 00:30:13 +040098
Rob Herring99085702015-10-06 17:51:21 -050099dtbs: scripts
100 $(Q)$(MAKE) $(build)=$(boot)/dts
101
Chris Zankel8e1a6dd2005-06-23 22:01:10 -0700102define archhelp
Max Filippov9a736fc2016-12-25 04:58:57 -0800103 @echo '* Image - Kernel ELF image with reset vector'
Chris Zankel8e1a6dd2005-06-23 22:01:10 -0700104 @echo '* zImage - Compressed kernel image (arch/xtensa/boot/images/zImage.*)'
Max Filippov9a736fc2016-12-25 04:58:57 -0800105 @echo '* uImage - U-Boot wrapped image'
Rob Herring99085702015-10-06 17:51:21 -0500106 @echo ' dtbs - Build device tree blobs for enabled boards'
Chris Zankel8e1a6dd2005-06-23 22:01:10 -0700107endef