wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 1 | # |
Wolfgang Denk | 1234ce7 | 2013-06-21 10:22:36 +0200 | [diff] [blame] | 2 | # (C) Copyright 2000-2013 |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 3 | # Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | # |
Wolfgang Denk | 1234ce7 | 2013-06-21 10:22:36 +0200 | [diff] [blame] | 5 | # SPDX-License-Identifier: GPL-2.0+ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 6 | # |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 7 | ######################################################################### |
| 8 | |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 9 | ifeq ($(CURDIR),$(SRCTREE)) |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 10 | dir := |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 11 | else |
| 12 | dir := $(subst $(SRCTREE)/,,$(CURDIR)) |
| 13 | endif |
| 14 | |
Daniel Schwierzeck | a180922a | 2011-07-18 06:09:15 +0000 | [diff] [blame] | 15 | ifneq ($(OBJTREE),$(SRCTREE)) |
| 16 | # Create object files for SPL in a separate directory |
| 17 | ifeq ($(CONFIG_SPL_BUILD),y) |
Ying Zhang | 2d2e3b6 | 2013-08-16 15:16:15 +0800 | [diff] [blame] | 18 | ifeq ($(CONFIG_TPL_BUILD),y) |
| 19 | obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/) |
| 20 | else |
Daniel Schwierzeck | a180922a | 2011-07-18 06:09:15 +0000 | [diff] [blame] | 21 | obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/) |
Ying Zhang | 2d2e3b6 | 2013-08-16 15:16:15 +0800 | [diff] [blame] | 22 | endif |
Daniel Schwierzeck | a180922a | 2011-07-18 06:09:15 +0000 | [diff] [blame] | 23 | else |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 24 | obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/) |
Daniel Schwierzeck | a180922a | 2011-07-18 06:09:15 +0000 | [diff] [blame] | 25 | endif |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 26 | src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/) |
| 27 | |
| 28 | $(shell mkdir -p $(obj)) |
| 29 | else |
Daniel Schwierzeck | a180922a | 2011-07-18 06:09:15 +0000 | [diff] [blame] | 30 | # Create object files for SPL in a separate directory |
| 31 | ifeq ($(CONFIG_SPL_BUILD),y) |
Ying Zhang | 2d2e3b6 | 2013-08-16 15:16:15 +0800 | [diff] [blame] | 32 | ifeq ($(CONFIG_TPL_BUILD),y) |
| 33 | obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/) |
| 34 | else |
Daniel Schwierzeck | a180922a | 2011-07-18 06:09:15 +0000 | [diff] [blame] | 35 | obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/) |
| 36 | |
Ying Zhang | 2d2e3b6 | 2013-08-16 15:16:15 +0800 | [diff] [blame] | 37 | endif |
Daniel Schwierzeck | a180922a | 2011-07-18 06:09:15 +0000 | [diff] [blame] | 38 | $(shell mkdir -p $(obj)) |
| 39 | else |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 40 | obj := |
Daniel Schwierzeck | a180922a | 2011-07-18 06:09:15 +0000 | [diff] [blame] | 41 | endif |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 42 | src := |
| 43 | endif |
| 44 | |
wdenk | dbae504 | 2003-06-21 00:17:24 +0000 | [diff] [blame] | 45 | # clean the slate ... |
| 46 | PLATFORM_RELFLAGS = |
| 47 | PLATFORM_CPPFLAGS = |
| 48 | PLATFORM_LDFLAGS = |
| 49 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 50 | ######################################################################### |
Wolfgang Denk | 979b4bd | 2008-05-03 22:25:00 +0200 | [diff] [blame] | 51 | |
| 52 | # Load generated board configuration |
Ying Zhang | 2d2e3b6 | 2013-08-16 15:16:15 +0800 | [diff] [blame] | 53 | ifeq ($(CONFIG_TPL_BUILD),y) |
| 54 | # Include TPL autoconf |
| 55 | sinclude $(OBJTREE)/include/tpl-autoconf.mk |
| 56 | else |
Joel Fernandes | 2c8c3c2 | 2013-08-19 16:14:14 +0800 | [diff] [blame] | 57 | ifeq ($(CONFIG_SPL_BUILD),y) |
| 58 | # Include SPL autoconf |
| 59 | sinclude $(OBJTREE)/include/spl-autoconf.mk |
| 60 | else |
| 61 | # Include normal autoconf |
Wolfgang Denk | 979b4bd | 2008-05-03 22:25:00 +0200 | [diff] [blame] | 62 | sinclude $(OBJTREE)/include/autoconf.mk |
Joel Fernandes | 2c8c3c2 | 2013-08-19 16:14:14 +0800 | [diff] [blame] | 63 | endif |
Ying Zhang | 2d2e3b6 | 2013-08-16 15:16:15 +0800 | [diff] [blame] | 64 | endif |
Joakim Tjernlund | 31162e1 | 2011-01-17 23:39:26 +0100 | [diff] [blame] | 65 | sinclude $(OBJTREE)/include/config.mk |
Wolfgang Denk | 979b4bd | 2008-05-03 22:25:00 +0200 | [diff] [blame] | 66 | |
Peter Tyser | d53e8fd | 2010-04-12 22:28:02 -0500 | [diff] [blame] | 67 | # Some architecture config.mk files need to know what CPUDIR is set to, |
| 68 | # so calculate CPUDIR before including ARCH/SOC/CPU config.mk files. |
Peter Tyser | 29514c7 | 2010-04-12 22:28:09 -0500 | [diff] [blame] | 69 | # Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains |
| 70 | # CPU-specific code. |
| 71 | CPUDIR=arch/$(ARCH)/cpu/$(CPU) |
| 72 | ifneq ($(SRCTREE)/$(CPUDIR),$(wildcard $(SRCTREE)/$(CPUDIR))) |
| 73 | CPUDIR=arch/$(ARCH)/cpu |
| 74 | endif |
Peter Tyser | d53e8fd | 2010-04-12 22:28:02 -0500 | [diff] [blame] | 75 | |
Peter Tyser | cede5d8 | 2010-04-12 22:28:04 -0500 | [diff] [blame] | 76 | sinclude $(TOPDIR)/arch/$(ARCH)/config.mk # include architecture dependend rules |
Peter Tyser | d53e8fd | 2010-04-12 22:28:02 -0500 | [diff] [blame] | 77 | sinclude $(TOPDIR)/$(CPUDIR)/config.mk # include CPU specific rules |
| 78 | |
Wolfgang Denk | 979b4bd | 2008-05-03 22:25:00 +0200 | [diff] [blame] | 79 | ifdef SOC |
Peter Tyser | d53e8fd | 2010-04-12 22:28:02 -0500 | [diff] [blame] | 80 | sinclude $(TOPDIR)/$(CPUDIR)/$(SOC)/config.mk # include SoC specific rules |
Wolfgang Denk | 979b4bd | 2008-05-03 22:25:00 +0200 | [diff] [blame] | 81 | endif |
| 82 | ifdef VENDOR |
| 83 | BOARDDIR = $(VENDOR)/$(BOARD) |
| 84 | else |
| 85 | BOARDDIR = $(BOARD) |
| 86 | endif |
| 87 | ifdef BOARD |
| 88 | sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk # include board specific rules |
| 89 | endif |
| 90 | |
| 91 | ######################################################################### |
| 92 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 93 | RELFLAGS= $(PLATFORM_RELFLAGS) |
Scott Wood | 34c6dd2 | 2011-04-06 13:31:37 +0000 | [diff] [blame] | 94 | |
wdenk | b00ec16 | 2003-06-19 23:40:20 +0000 | [diff] [blame] | 95 | OBJCFLAGS += --gap-fill=0xff |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 96 | |
Masahiro Yamada | 700dd89 | 2014-02-04 17:24:19 +0900 | [diff] [blame] | 97 | CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS) |
Daniel Schwierzeck | a180922a | 2011-07-18 06:09:15 +0000 | [diff] [blame] | 98 | |
| 99 | # Enable garbage collection of un-used sections for SPL |
| 100 | ifeq ($(CONFIG_SPL_BUILD),y) |
| 101 | CPPFLAGS += -ffunction-sections -fdata-sections |
| 102 | LDFLAGS_FINAL += --gc-sections |
| 103 | endif |
| 104 | |
Wolfgang Denk | 0708bc6 | 2010-10-07 21:51:12 +0200 | [diff] [blame] | 105 | ifneq ($(CONFIG_SYS_TEXT_BASE),) |
| 106 | CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) |
Mike Frysinger | 1280555 | 2008-01-28 05:28:50 -0500 | [diff] [blame] | 107 | endif |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 108 | |
Daniel Schwierzeck | a180922a | 2011-07-18 06:09:15 +0000 | [diff] [blame] | 109 | ifeq ($(CONFIG_SPL_BUILD),y) |
| 110 | CPPFLAGS += -DCONFIG_SPL_BUILD |
Ying Zhang | 2d2e3b6 | 2013-08-16 15:16:15 +0800 | [diff] [blame] | 111 | ifeq ($(CONFIG_TPL_BUILD),y) |
| 112 | CPPFLAGS += -DCONFIG_TPL_BUILD |
| 113 | endif |
Daniel Schwierzeck | a180922a | 2011-07-18 06:09:15 +0000 | [diff] [blame] | 114 | endif |
| 115 | |
Simon Glass | 6682832 | 2013-03-08 13:45:27 +0000 | [diff] [blame] | 116 | # Does this architecture support generic board init? |
| 117 | ifeq ($(__HAVE_ARCH_GENERIC_BOARD),) |
| 118 | ifneq ($(CONFIG_SYS_GENERIC_BOARD),) |
Simon Glass | 07253bb | 2013-04-20 08:42:36 +0000 | [diff] [blame] | 119 | CHECK_GENERIC_BOARD = $(error Your architecture does not support generic board. \ |
| 120 | Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file) |
Simon Glass | 6682832 | 2013-03-08 13:45:27 +0000 | [diff] [blame] | 121 | endif |
| 122 | endif |
| 123 | |
Masahiro Yamada | 0302445 | 2014-02-04 17:24:20 +0900 | [diff] [blame^] | 124 | CPPFLAGS += $(UBOOTINCLUDE) |
| 125 | CPPFLAGS += $(NOSTDINC_FLAGS) -pipe $(PLATFORM_CPPFLAGS) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 126 | |
Masahiro Yamada | 700dd89 | 2014-02-04 17:24:19 +0900 | [diff] [blame] | 127 | CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS) |
Tom Rini | b7f3413 | 2012-02-20 13:50:10 +0000 | [diff] [blame] | 128 | |
Simon Glass | 831aa54 | 2013-06-11 11:14:41 -0700 | [diff] [blame] | 129 | BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%)) |
| 130 | |
| 131 | ifeq ($(findstring examples/,$(BCURDIR)),) |
| 132 | ifeq ($(CONFIG_SPL_BUILD),) |
| 133 | ifdef FTRACE |
| 134 | CFLAGS += -finstrument-functions -DFTRACE |
| 135 | endif |
| 136 | endif |
| 137 | endif |
| 138 | |
Masahiro Yamada | 700dd89 | 2014-02-04 17:24:19 +0900 | [diff] [blame] | 139 | AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 140 | |
Nobuhiro Iwamatsu | b859b8c | 2011-01-06 10:23:54 +0900 | [diff] [blame] | 141 | LDFLAGS += $(PLATFORM_LDFLAGS) |
Haiying Wang | 3935873 | 2011-02-22 16:38:05 -0500 | [diff] [blame] | 142 | LDFLAGS_FINAL += -Bstatic |
Nobuhiro Iwamatsu | b859b8c | 2011-01-06 10:23:54 +0900 | [diff] [blame] | 143 | |
Haiying Wang | 3935873 | 2011-02-22 16:38:05 -0500 | [diff] [blame] | 144 | LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL) |
Wolfgang Denk | 0708bc6 | 2010-10-07 21:51:12 +0200 | [diff] [blame] | 145 | ifneq ($(CONFIG_SYS_TEXT_BASE),) |
Nobuhiro Iwamatsu | b859b8c | 2011-01-06 10:23:54 +0900 | [diff] [blame] | 146 | LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE) |
Mike Frysinger | 1280555 | 2008-01-28 05:28:50 -0500 | [diff] [blame] | 147 | endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 148 | |
Ying Zhang | 2d2e3b6 | 2013-08-16 15:16:15 +0800 | [diff] [blame] | 149 | LDFLAGS_$(SPL_BIN) += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL) |
Daniel Schwierzeck | a180922a | 2011-07-18 06:09:15 +0000 | [diff] [blame] | 150 | ifneq ($(CONFIG_SPL_TEXT_BASE),) |
Ying Zhang | 2d2e3b6 | 2013-08-16 15:16:15 +0800 | [diff] [blame] | 151 | LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE) |
Daniel Schwierzeck | a180922a | 2011-07-18 06:09:15 +0000 | [diff] [blame] | 152 | endif |
| 153 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 154 | ######################################################################### |
| 155 | |
Wolfgang Denk | 0708bc6 | 2010-10-07 21:51:12 +0200 | [diff] [blame] | 156 | export CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS |