Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 1 | # |
| 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 Filippov | 420ae95 | 2014-06-16 07:25:06 +0400 | [diff] [blame] | 7 | # Copyright (C) 2014 Cadence Design Systems Inc. |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 8 | # |
| 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 Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 15 | # (Use VAR=<xtensa_config> to use another default compiler.) |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 16 | |
Max Filippov | 420ae95 | 2014-06-16 07:25:06 +0400 | [diff] [blame] | 17 | variant-y := $(patsubst "%",%,$(CONFIG_XTENSA_VARIANT_NAME)) |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 18 | |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 19 | VARIANT = $(variant-y) |
| 20 | export VARIANT |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 21 | |
Geert Uytterhoeven | 70cefe7 | 2012-05-12 22:39:08 +0200 | [diff] [blame] | 22 | # Test for cross compiling |
| 23 | |
| 24 | ifneq ($(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 |
| 32 | endif |
| 33 | |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 34 | # Platform configuration |
| 35 | |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 36 | platform-$(CONFIG_XTENSA_PLATFORM_XT2000) := xt2000 |
| 37 | platform-$(CONFIG_XTENSA_PLATFORM_ISS) := iss |
Max Filippov | 0d456ba | 2012-11-05 07:37:14 +0400 | [diff] [blame] | 38 | platform-$(CONFIG_XTENSA_PLATFORM_XTFPGA) := xtfpga |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 39 | |
| 40 | PLATFORM = $(platform-y) |
| 41 | export PLATFORM |
| 42 | |
Chris Zankel | b2444d3 | 2007-08-04 09:23:54 -0700 | [diff] [blame] | 43 | # temporarily until string.h is fixed |
Max Filippov | a753cd9 | 2012-09-17 05:44:51 +0400 | [diff] [blame] | 44 | KBUILD_CFLAGS += -ffreestanding -D__linux__ |
Max Filippov | f8f02ca | 2017-12-03 20:55:35 -0800 | [diff] [blame] | 45 | KBUILD_CFLAGS += -pipe -mlongcalls -mtext-section-literals |
Chris Zankel | cf1c0aa | 2010-05-02 01:00:22 -0700 | [diff] [blame] | 46 | KBUILD_CFLAGS += $(call cc-option,-mforce-no-pic,) |
Max Filippov | 7bf5234 | 2017-04-28 09:40:00 -0700 | [diff] [blame] | 47 | KBUILD_CFLAGS += $(call cc-option,-mno-serialize-volatile,) |
Chris Zankel | cf1c0aa | 2010-05-02 01:00:22 -0700 | [diff] [blame] | 48 | |
Max Filippov | f8f02ca | 2017-12-03 20:55:35 -0800 | [diff] [blame] | 49 | KBUILD_AFLAGS += -mlongcalls -mtext-section-literals |
| 50 | |
Chris Zankel | 6550162 | 2012-11-13 15:16:36 -0800 | [diff] [blame] | 51 | ifneq ($(CONFIG_LD_NO_RELAX),) |
Masahiro Yamada | d503ac5 | 2018-08-24 08:20:39 +0900 | [diff] [blame] | 52 | KBUILD_LDFLAGS := --no-relax |
Chris Zankel | 6550162 | 2012-11-13 15:16:36 -0800 | [diff] [blame] | 53 | endif |
| 54 | |
Max Filippov | 123f15e | 2013-08-22 18:09:47 +0400 | [diff] [blame] | 55 | ifeq ($(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#"),1) |
Max Filippov | 72100ed | 2012-12-11 01:26:25 +0400 | [diff] [blame] | 56 | CHECKFLAGS += -D__XTENSA_EB__ |
Max Filippov | 4611bf7 | 2016-03-01 02:00:59 +0300 | [diff] [blame] | 57 | KBUILD_CPPFLAGS += -DCONFIG_CPU_BIG_ENDIAN |
Max Filippov | 72100ed | 2012-12-11 01:26:25 +0400 | [diff] [blame] | 58 | endif |
Max Filippov | 123f15e | 2013-08-22 18:09:47 +0400 | [diff] [blame] | 59 | ifeq ($(shell echo __XTENSA_EL__ | $(CC) -E - | grep -v "\#"),1) |
Max Filippov | 72100ed | 2012-12-11 01:26:25 +0400 | [diff] [blame] | 60 | CHECKFLAGS += -D__XTENSA_EL__ |
Max Filippov | 4611bf7 | 2016-03-01 02:00:59 +0300 | [diff] [blame] | 61 | KBUILD_CPPFLAGS += -DCONFIG_CPU_LITTLE_ENDIAN |
Max Filippov | 72100ed | 2012-12-11 01:26:25 +0400 | [diff] [blame] | 62 | endif |
| 63 | |
Chris Zankel | 367b811 | 2008-11-06 06:40:46 -0800 | [diff] [blame] | 64 | vardirs := $(patsubst %,arch/xtensa/variants/%/,$(variant-y)) |
| 65 | plfdirs := $(patsubst %,arch/xtensa/platforms/%/,$(platform-y)) |
| 66 | |
Chris Zankel | 367b811 | 2008-11-06 06:40:46 -0800 | [diff] [blame] | 67 | KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(vardirs) $(plfdirs)) |
Chris Zankel | 367b811 | 2008-11-06 06:40:46 -0800 | [diff] [blame] | 68 | |
Chris Zankel | e7d163f | 2005-06-30 02:58:59 -0700 | [diff] [blame] | 69 | KBUILD_DEFCONFIG := iss_defconfig |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 70 | |
Chris Zankel | f193318 | 2009-04-02 16:58:53 -0700 | [diff] [blame] | 71 | # Only build variant and/or platform if it includes a Makefile |
| 72 | |
Geert Uytterhoeven | 0eff08b | 2012-06-20 12:52:59 -0700 | [diff] [blame] | 73 | buildvar := $(shell test -e $(srctree)/arch/xtensa/variants/$(VARIANT)/Makefile && echo arch/xtensa/variants/$(VARIANT)/) |
| 74 | buildplf := $(shell test -e $(srctree)/arch/xtensa/platforms/$(PLATFORM)/Makefile && echo arch/xtensa/platforms/$(PLATFORM)/) |
Chris Zankel | f193318 | 2009-04-02 16:58:53 -0700 | [diff] [blame] | 75 | |
| 76 | # Find libgcc.a |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 77 | |
Sam Ravnborg | a0f97e0 | 2007-10-14 22:21:35 +0200 | [diff] [blame] | 78 | LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 79 | |
| 80 | head-y := arch/xtensa/kernel/head.o |
Chris Zankel | e7d163f | 2005-06-30 02:58:59 -0700 | [diff] [blame] | 81 | core-y += arch/xtensa/kernel/ arch/xtensa/mm/ |
Chris Zankel | f193318 | 2009-04-02 16:58:53 -0700 | [diff] [blame] | 82 | core-y += $(buildvar) $(buildplf) |
| 83 | |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 84 | libs-y += arch/xtensa/lib/ $(LIBGCC) |
dann | e6ffe17 | 2008-05-21 17:43:50 -0700 | [diff] [blame] | 85 | drivers-$(CONFIG_OPROFILE) += arch/xtensa/oprofile/ |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 86 | |
Max Filippov | da844a8 | 2012-11-04 00:30:13 +0400 | [diff] [blame] | 87 | ifneq ($(CONFIG_BUILTIN_DTB),"") |
Stephen Warren | 2a02bc1 | 2013-01-02 11:27:14 -0700 | [diff] [blame] | 88 | core-$(CONFIG_OF) += arch/xtensa/boot/dts/ |
Max Filippov | da844a8 | 2012-11-04 00:30:13 +0400 | [diff] [blame] | 89 | endif |
| 90 | |
Chris Zankel | e7d163f | 2005-06-30 02:58:59 -0700 | [diff] [blame] | 91 | boot := arch/xtensa/boot |
| 92 | |
Max Filippov | 9a736fc | 2016-12-25 04:58:57 -0800 | [diff] [blame] | 93 | all Image zImage uImage: vmlinux |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 94 | $(Q)$(MAKE) $(build)=$(boot) $@ |
| 95 | |
Max Filippov | da844a8 | 2012-11-04 00:30:13 +0400 | [diff] [blame] | 96 | %.dtb: |
Stephen Warren | 2a02bc1 | 2013-01-02 11:27:14 -0700 | [diff] [blame] | 97 | $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@ |
Max Filippov | da844a8 | 2012-11-04 00:30:13 +0400 | [diff] [blame] | 98 | |
Rob Herring | 9908570 | 2015-10-06 17:51:21 -0500 | [diff] [blame] | 99 | dtbs: scripts |
| 100 | $(Q)$(MAKE) $(build)=$(boot)/dts |
| 101 | |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 102 | define archhelp |
Max Filippov | 9a736fc | 2016-12-25 04:58:57 -0800 | [diff] [blame] | 103 | @echo '* Image - Kernel ELF image with reset vector' |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 104 | @echo '* zImage - Compressed kernel image (arch/xtensa/boot/images/zImage.*)' |
Max Filippov | 9a736fc | 2016-12-25 04:58:57 -0800 | [diff] [blame] | 105 | @echo '* uImage - U-Boot wrapped image' |
Rob Herring | 9908570 | 2015-10-06 17:51:21 -0500 | [diff] [blame] | 106 | @echo ' dtbs - Build device tree blobs for enabled boards' |
Chris Zankel | 8e1a6dd | 2005-06-23 22:01:10 -0700 | [diff] [blame] | 107 | endef |