17ebf7443Swdenk# 2eca3aeb3SWolfgang Denk# (C) Copyright 2000-2013 37ebf7443Swdenk# Wolfgang Denk, DENX Software Engineering, wd@denx.de. 47ebf7443Swdenk# 5eca3aeb3SWolfgang Denk# SPDX-License-Identifier: GPL-2.0+ 67ebf7443Swdenk# 77ebf7443Swdenk 8d19ad726STom RiniVERSION = 2014 9d19ad726STom RiniPATCHLEVEL = 01 10211e4754SWolfgang DenkSUBLEVEL = 11b44bd2c7STom RiniEXTRAVERSION = 125f30f3beSMasahiro YamadaNAME = 13ae6d1056SWolfgang Denk 146825a95bSMasahiro Yamada# *DOCUMENTATION* 156825a95bSMasahiro Yamada# To see a list of typical targets execute "make help" 166825a95bSMasahiro Yamada# More info can be located in ./README 176825a95bSMasahiro Yamada# Comments in this file are targeted only to the developer, do not 186825a95bSMasahiro Yamada# expect to learn how to build the kernel reading this file. 196825a95bSMasahiro Yamada 206825a95bSMasahiro Yamada# Do not: 216825a95bSMasahiro Yamada# o use make's built-in rules and variables 226825a95bSMasahiro Yamada# (this increases performance and avoids hard-to-debug behaviour); 236825a95bSMasahiro Yamada# o print "Entering directory ..."; 246825a95bSMasahiro YamadaMAKEFLAGS += -rR --no-print-directory 256825a95bSMasahiro Yamada 266825a95bSMasahiro Yamada# Avoid funny character set dependencies 276825a95bSMasahiro Yamadaunexport LC_ALL 286825a95bSMasahiro YamadaLC_COLLATE=C 296825a95bSMasahiro YamadaLC_NUMERIC=C 306825a95bSMasahiro Yamadaexport LC_COLLATE LC_NUMERIC 316825a95bSMasahiro Yamada 326825a95bSMasahiro Yamada# We are using a recursive build, so we need to do a little thinking 336825a95bSMasahiro Yamada# to get the ordering right. 346825a95bSMasahiro Yamada# 356825a95bSMasahiro Yamada# Most importantly: sub-Makefiles should only ever modify files in 366825a95bSMasahiro Yamada# their own directory. If in some directory we have a dependency on 376825a95bSMasahiro Yamada# a file in another dir (which doesn't happen often, but it's often 386825a95bSMasahiro Yamada# unavoidable when linking the built-in.o targets which finally 396825a95bSMasahiro Yamada# turn into vmlinux), we will call a sub make in that other dir, and 406825a95bSMasahiro Yamada# after that we are sure that everything which is in that other dir 416825a95bSMasahiro Yamada# is now up to date. 426825a95bSMasahiro Yamada# 436825a95bSMasahiro Yamada# The only cases where we need to modify files which have global 446825a95bSMasahiro Yamada# effects are thus separated out and done before the recursive 456825a95bSMasahiro Yamada# descending is started. They are now explicitly listed as the 466825a95bSMasahiro Yamada# prepare rule. 476825a95bSMasahiro Yamada 486825a95bSMasahiro Yamada# To put more focus on warnings, be less verbose as default 496825a95bSMasahiro Yamada# Use 'make V=1' to see the full commands 506825a95bSMasahiro Yamada 516825a95bSMasahiro Yamadaifeq ("$(origin V)", "command line") 526825a95bSMasahiro Yamada KBUILD_VERBOSE = $(V) 536825a95bSMasahiro Yamadaendif 546825a95bSMasahiro Yamadaifndef KBUILD_VERBOSE 556825a95bSMasahiro Yamada KBUILD_VERBOSE = 0 566825a95bSMasahiro Yamadaendif 576825a95bSMasahiro Yamada 586825a95bSMasahiro Yamada# Call a source code checker (by default, "sparse") as part of the 596825a95bSMasahiro Yamada# C compilation. 606825a95bSMasahiro Yamada# 616825a95bSMasahiro Yamada# Use 'make C=1' to enable checking of only re-compiled files. 626825a95bSMasahiro Yamada# Use 'make C=2' to enable checking of *all* source files, regardless 636825a95bSMasahiro Yamada# of whether they are re-compiled or not. 646825a95bSMasahiro Yamada# 656825a95bSMasahiro Yamada# See the file "Documentation/sparse.txt" for more details, including 666825a95bSMasahiro Yamada# where to get the "sparse" utility. 676825a95bSMasahiro Yamada 686825a95bSMasahiro Yamadaifeq ("$(origin C)", "command line") 696825a95bSMasahiro Yamada KBUILD_CHECKSRC = $(C) 706825a95bSMasahiro Yamadaendif 716825a95bSMasahiro Yamadaifndef KBUILD_CHECKSRC 726825a95bSMasahiro Yamada KBUILD_CHECKSRC = 0 736825a95bSMasahiro Yamadaendif 746825a95bSMasahiro Yamada 756825a95bSMasahiro Yamada# Use make M=dir to specify directory of external module to build 766825a95bSMasahiro Yamada# Old syntax make ... SUBDIRS=$PWD is still supported 776825a95bSMasahiro Yamada# Setting the environment variable KBUILD_EXTMOD take precedence 786825a95bSMasahiro Yamadaifdef SUBDIRS 796825a95bSMasahiro Yamada KBUILD_EXTMOD ?= $(SUBDIRS) 806825a95bSMasahiro Yamadaendif 816825a95bSMasahiro Yamada 826825a95bSMasahiro Yamadaifeq ("$(origin M)", "command line") 836825a95bSMasahiro Yamada KBUILD_EXTMOD := $(M) 846825a95bSMasahiro Yamadaendif 856825a95bSMasahiro Yamada 869e414032SMasahiro Yamada# kbuild supports saving output files in a separate directory. 879e414032SMasahiro Yamada# To locate output files in a separate directory two syntaxes are supported. 889e414032SMasahiro Yamada# In both cases the working directory must be the root of the kernel src. 899e414032SMasahiro Yamada# 1) O= 909e414032SMasahiro Yamada# Use "make O=dir/to/store/output/files/" 91f9328639SMarian Balakowicz# 929e414032SMasahiro Yamada# 2) Set KBUILD_OUTPUT 939e414032SMasahiro Yamada# Set the environment variable KBUILD_OUTPUT to point to the directory 949e414032SMasahiro Yamada# where the output files shall be placed. 959e414032SMasahiro Yamada# export KBUILD_OUTPUT=dir/to/store/output/files/ 969e414032SMasahiro Yamada# make 97f9328639SMarian Balakowicz# 989e414032SMasahiro Yamada# The O= assignment takes precedence over the KBUILD_OUTPUT environment 999e414032SMasahiro Yamada# variable. 1007ebf7443Swdenk 1019e414032SMasahiro Yamada 1029e414032SMasahiro Yamada# KBUILD_SRC is set on invocation of make in OBJ directory 1039e414032SMasahiro Yamada# KBUILD_SRC is not intended to be used by the regular user (for now) 1049e414032SMasahiro Yamadaifeq ($(KBUILD_SRC),) 1059e414032SMasahiro Yamada 1069e414032SMasahiro Yamada# OK, Make called in directory where kernel src resides 1079e414032SMasahiro Yamada# Do we want to locate output files in a separate directory? 108f9328639SMarian Balakowiczifeq ("$(origin O)", "command line") 1099e414032SMasahiro Yamada KBUILD_OUTPUT := $(O) 110f9328639SMarian Balakowiczendif 1117ebf7443Swdenk 1129e414032SMasahiro Yamadaifeq ("$(origin W)", "command line") 1139e414032SMasahiro Yamada export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W) 1149e414032SMasahiro Yamadaendif 1159e414032SMasahiro Yamada 1169e414032SMasahiro Yamada# That's our default target when none is given on the command line 1179e414032SMasahiro YamadaPHONY := _all 1189e414032SMasahiro Yamada_all: 1199e414032SMasahiro Yamada 1209e414032SMasahiro Yamada# Cancel implicit rules on top Makefile 1219e414032SMasahiro Yamada$(CURDIR)/Makefile Makefile: ; 1229e414032SMasahiro Yamada 1239e414032SMasahiro Yamadaifneq ($(KBUILD_OUTPUT),) 1249e414032SMasahiro Yamada# Invoke a second make in the output directory, passing relevant variables 1259e414032SMasahiro Yamada# check that the output directory actually exists 1269e414032SMasahiro Yamadasaved-output := $(KBUILD_OUTPUT) 1279e414032SMasahiro YamadaKBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd) 1289e414032SMasahiro Yamada$(if $(KBUILD_OUTPUT),, \ 1299e414032SMasahiro Yamada $(error output directory "$(saved-output)" does not exist)) 1309e414032SMasahiro Yamada 1319e414032SMasahiro YamadaPHONY += $(MAKECMDGOALS) sub-make 1329e414032SMasahiro Yamada 1339e414032SMasahiro Yamada$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make 1349e414032SMasahiro Yamada @: 1359e414032SMasahiro Yamada 1369e414032SMasahiro Yamadasub-make: FORCE 1379e414032SMasahiro Yamada $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ 1389e414032SMasahiro Yamada KBUILD_SRC=$(CURDIR) \ 1399e414032SMasahiro Yamada KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \ 1409e414032SMasahiro Yamada $(filter-out _all sub-make,$(MAKECMDGOALS)) 1419e414032SMasahiro Yamada 1429e414032SMasahiro Yamada# Leave processing to above invocation of make 1439e414032SMasahiro Yamadaskip-makefile := 1 1449e414032SMasahiro Yamadaendif # ifneq ($(KBUILD_OUTPUT),) 1459e414032SMasahiro Yamadaendif # ifeq ($(KBUILD_SRC),) 1469e414032SMasahiro Yamada 1479e414032SMasahiro Yamada# We process the rest of the Makefile if this is the final invocation of make 1489e414032SMasahiro Yamadaifeq ($(skip-makefile),) 1499e414032SMasahiro Yamada 1506825a95bSMasahiro Yamada# If building an external module we do not care about the all: rule 1516825a95bSMasahiro Yamada# but instead _all depend on modules 1529e414032SMasahiro YamadaPHONY += all 1536825a95bSMasahiro Yamadaifeq ($(KBUILD_EXTMOD),) 1549e414032SMasahiro Yamada_all: all 1556825a95bSMasahiro Yamadaelse 1566825a95bSMasahiro Yamada_all: modules 1576825a95bSMasahiro Yamadaendif 1589e414032SMasahiro Yamada 1599e414032SMasahiro Yamadasrctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)) 1609e414032SMasahiro Yamadaobjtree := $(CURDIR) 1619e414032SMasahiro Yamadasrc := $(srctree) 1629e414032SMasahiro Yamadaobj := $(objtree) 1639e414032SMasahiro Yamada 1649e414032SMasahiro YamadaVPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) 1659e414032SMasahiro Yamada 1669e414032SMasahiro Yamadaexport srctree objtree VPATH 1679e414032SMasahiro Yamada 1689e414032SMasahiro YamadaOBJTREE := $(objtree) 169c8f9c302SDaniel SchwierzeckSPLTREE := $(OBJTREE)/spl 1703aa29de0SYing ZhangTPLTREE := $(OBJTREE)/tpl 1719e414032SMasahiro YamadaSRCTREE := $(srctree) 172f9328639SMarian BalakowiczTOPDIR := $(SRCTREE) 1739e414032SMasahiro Yamadaexport TOPDIR SRCTREE OBJTREE SPLTREE TPLTREE 174f9328639SMarian Balakowicz 175f9328639SMarian BalakowiczMKCONFIG := $(SRCTREE)/mkconfig 176f9328639SMarian Balakowiczexport MKCONFIG 177f9328639SMarian Balakowicz 1785013c09fSWolfgang Denk# Make sure CDPATH settings don't interfere 1795013c09fSWolfgang Denkunexport CDPATH 1805013c09fSWolfgang Denk 181f9328639SMarian Balakowicz######################################################################### 182f9328639SMarian Balakowicz 1835f30f3beSMasahiro YamadaTIMESTAMP_FILE = include/generated/timestamp_autogenerated.h 1845f30f3beSMasahiro YamadaVERSION_FILE = include/generated/version_autogenerated.h 1855f30f3beSMasahiro Yamada 1865f30f3beSMasahiro YamadaHOSTARCH := $(shell uname -m | \ 1875f30f3beSMasahiro Yamada sed -e s/i.86/x86/ \ 1885f30f3beSMasahiro Yamada -e s/sun4u/sparc64/ \ 1895f30f3beSMasahiro Yamada -e s/arm.*/arm/ \ 1905f30f3beSMasahiro Yamada -e s/sa110/arm/ \ 1915f30f3beSMasahiro Yamada -e s/ppc64/powerpc/ \ 1925f30f3beSMasahiro Yamada -e s/ppc/powerpc/ \ 1935f30f3beSMasahiro Yamada -e s/macppc/powerpc/\ 1945f30f3beSMasahiro Yamada -e s/sh.*/sh/) 1955f30f3beSMasahiro Yamada 1965f30f3beSMasahiro YamadaHOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \ 1975f30f3beSMasahiro Yamada sed -e 's/\(cygwin\).*/cygwin/') 1985f30f3beSMasahiro Yamada 1995f30f3beSMasahiro Yamadaexport HOSTARCH HOSTOS 2005f30f3beSMasahiro Yamada 2015f30f3beSMasahiro Yamada# Deal with colliding definitions from tcsh etc. 2025f30f3beSMasahiro YamadaVENDOR= 2035f30f3beSMasahiro Yamada 2045f30f3beSMasahiro Yamada######################################################################### 2055f30f3beSMasahiro Yamada 2066d1ce387SMike Frysinger# The "tools" are needed early, so put this first 2076d1ce387SMike Frysinger# Don't include stuff already done in $(LIBS) 208349e83f0SChe-liang Chiou# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC 209349e83f0SChe-liang Chiou# is "yes"), so compile examples after U-Boot is compiled. 210349e83f0SChe-liang ChiouSUBDIR_TOOLS = tools 211349e83f0SChe-liang ChiouSUBDIRS = $(SUBDIR_TOOLS) 2126d1ce387SMike Frysinger 213249b53a6SLoïc Minier.PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE) 2146d1ce387SMike Frysinger 2159e414032SMasahiro Yamadaifeq (include/config.mk,$(wildcard include/config.mk)) 216f9328639SMarian Balakowicz 2172632c008SMike Frysinger# Include autoconf.mk before config.mk so that the config options are available 2182632c008SMike Frysinger# to all top level build files. We need the dummy all: target to prevent the 2192632c008SMike Frysinger# dependency target in autoconf.mk.dep from being the default. 2202632c008SMike Frysingerall: 2219e414032SMasahiro Yamadasinclude include/autoconf.mk.dep 2229e414032SMasahiro Yamadasinclude include/autoconf.mk 2232632c008SMike Frysinger 2248a7e7d56SMasahiro YamadaSUBDIR_EXAMPLES-y := examples/standalone 2258a7e7d56SMasahiro YamadaSUBDIR_EXAMPLES-$(CONFIG_API) += examples/api 226b5728756SSimon Glassifndef CONFIG_SANDBOX 2278a7e7d56SMasahiro YamadaSUBDIRS += $(SUBDIR_EXAMPLES-y) 228b5728756SSimon Glassendif 229b5728756SSimon Glass 2307ebf7443Swdenk# load ARCH, BOARD, and CPU configuration 2319e414032SMasahiro Yamadainclude include/config.mk 2321d9f4105Swdenkexport ARCH CPU BOARD VENDOR SOC 233f9328639SMarian Balakowicz 2341ea6bcd8SMike Frysinger# set default to nothing for native builds 235a5284efdSWolfgang Denkifeq ($(HOSTARCH),$(ARCH)) 2361ea6bcd8SMike FrysingerCROSS_COMPILE ?= 2377ebf7443Swdenkendif 2387ebf7443Swdenk 239f6322eb7SMasahiro Yamada# SHELL used by kbuild 240f6322eb7SMasahiro YamadaCONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ 241f6322eb7SMasahiro Yamada else if [ -x /bin/bash ]; then echo /bin/bash; \ 242f6322eb7SMasahiro Yamada else echo sh; fi ; fi) 243f6322eb7SMasahiro Yamada 244f6322eb7SMasahiro YamadaHOSTCC = gcc 245f6322eb7SMasahiro YamadaHOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer 246f6322eb7SMasahiro Yamada 247f6322eb7SMasahiro Yamadaifeq ($(HOSTOS),cygwin) 248f6322eb7SMasahiro YamadaHOSTCFLAGS += -ansi 249f6322eb7SMasahiro Yamadaendif 250f6322eb7SMasahiro Yamada 251f6322eb7SMasahiro Yamada# Mac OS X / Darwin's C preprocessor is Apple specific. It 252f6322eb7SMasahiro Yamada# generates numerous errors and warnings. We want to bypass it 253f6322eb7SMasahiro Yamada# and use GNU C's cpp. To do this we pass the -traditional-cpp 254f6322eb7SMasahiro Yamada# option to the compiler. Note that the -traditional-cpp flag 255f6322eb7SMasahiro Yamada# DOES NOT have the same semantics as GNU C's flag, all it does 256f6322eb7SMasahiro Yamada# is invoke the GNU preprocessor in stock ANSI/ISO C fashion. 257f6322eb7SMasahiro Yamada# 258f6322eb7SMasahiro Yamada# Apple's linker is similar, thanks to the new 2 stage linking 259f6322eb7SMasahiro Yamada# multiple symbol definitions are treated as errors, hence the 260f6322eb7SMasahiro Yamada# -multiply_defined suppress option to turn off this error. 261f6322eb7SMasahiro Yamada# 262f6322eb7SMasahiro Yamadaifeq ($(HOSTOS),darwin) 263f6322eb7SMasahiro Yamada# get major and minor product version (e.g. '10' and '6' for Snow Leopard) 264f6322eb7SMasahiro YamadaDARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.') 265f6322eb7SMasahiro YamadaDARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.') 266f6322eb7SMasahiro Yamada 267f6322eb7SMasahiro Yamadaos_x_before = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \ 268f6322eb7SMasahiro Yamada $(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;) 269f6322eb7SMasahiro Yamada 270f6322eb7SMasahiro Yamada# Snow Leopards build environment has no longer restrictions as described above 271f6322eb7SMasahiro YamadaHOSTCC = $(call os_x_before, 10, 5, "cc", "gcc") 272f6322eb7SMasahiro YamadaHOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp") 273f6322eb7SMasahiro YamadaHOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress") 274f6322eb7SMasahiro Yamadaendif 275f6322eb7SMasahiro Yamada 2766825a95bSMasahiro Yamada# Decide whether to build built-in, modular, or both. 2776825a95bSMasahiro Yamada# Normally, just do built-in. 2786825a95bSMasahiro Yamada 2796825a95bSMasahiro YamadaKBUILD_MODULES := 2806825a95bSMasahiro YamadaKBUILD_BUILTIN := 1 2816825a95bSMasahiro Yamada 2826825a95bSMasahiro Yamada# If we have only "make modules", don't compile built-in objects. 2836825a95bSMasahiro Yamada# When we're building modules with modversions, we need to consider 2846825a95bSMasahiro Yamada# the built-in objects during the descend as well, in order to 2856825a95bSMasahiro Yamada# make sure the checksums are up to date before we record them. 2866825a95bSMasahiro Yamada 2876825a95bSMasahiro Yamadaifeq ($(MAKECMDGOALS),modules) 2886825a95bSMasahiro Yamada KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) 2896825a95bSMasahiro Yamadaendif 2906825a95bSMasahiro Yamada 2916825a95bSMasahiro Yamada# If we have "make <whatever> modules", compile modules 2926825a95bSMasahiro Yamada# in addition to whatever we do anyway. 2936825a95bSMasahiro Yamada# Just "make" or "make all" shall build modules as well 2946825a95bSMasahiro Yamada 2956825a95bSMasahiro Yamada# U-Boot does not need modules 2966825a95bSMasahiro Yamada#ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) 2976825a95bSMasahiro Yamada# KBUILD_MODULES := 1 2986825a95bSMasahiro Yamada#endif 2996825a95bSMasahiro Yamada 3006825a95bSMasahiro Yamada#ifeq ($(MAKECMDGOALS),) 3016825a95bSMasahiro Yamada# KBUILD_MODULES := 1 3026825a95bSMasahiro Yamada#endif 3036825a95bSMasahiro Yamada 3046825a95bSMasahiro Yamadaexport KBUILD_MODULES KBUILD_BUILTIN 3056825a95bSMasahiro Yamadaexport KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD 3066825a95bSMasahiro Yamada 3076825a95bSMasahiro Yamada# Beautify output 3086825a95bSMasahiro Yamada# --------------------------------------------------------------------------- 3096825a95bSMasahiro Yamada# 3106825a95bSMasahiro Yamada# Normally, we echo the whole command before executing it. By making 3116825a95bSMasahiro Yamada# that echo $($(quiet)$(cmd)), we now have the possibility to set 3126825a95bSMasahiro Yamada# $(quiet) to choose other forms of output instead, e.g. 3136825a95bSMasahiro Yamada# 3146825a95bSMasahiro Yamada# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ 3156825a95bSMasahiro Yamada# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< 3166825a95bSMasahiro Yamada# 3176825a95bSMasahiro Yamada# If $(quiet) is empty, the whole command will be printed. 3186825a95bSMasahiro Yamada# If it is set to "quiet_", only the short version will be printed. 3196825a95bSMasahiro Yamada# If it is set to "silent_", nothing will be printed at all, since 3206825a95bSMasahiro Yamada# the variable $(silent_cmd_cc_o_c) doesn't exist. 3216825a95bSMasahiro Yamada# 3226825a95bSMasahiro Yamada# A simple variant is to prefix commands with $(Q) - that's useful 3236825a95bSMasahiro Yamada# for commands that shall be hidden in non-verbose mode. 3246825a95bSMasahiro Yamada# 3256825a95bSMasahiro Yamada# $(Q)ln $@ :< 3266825a95bSMasahiro Yamada# 3276825a95bSMasahiro Yamada# If KBUILD_VERBOSE equals 0 then the above command will be hidden. 3286825a95bSMasahiro Yamada# If KBUILD_VERBOSE equals 1 then the above command is displayed. 3296825a95bSMasahiro Yamada 3306825a95bSMasahiro Yamadaifeq ($(KBUILD_VERBOSE),1) 3316825a95bSMasahiro Yamada quiet = 3326825a95bSMasahiro Yamada Q = 3336825a95bSMasahiro Yamadaelse 3346825a95bSMasahiro Yamada quiet=quiet_ 3356825a95bSMasahiro Yamada Q = @ 3366825a95bSMasahiro Yamadaendif 3376825a95bSMasahiro Yamada 3386825a95bSMasahiro Yamada# If the user is running make -s (silent mode), suppress echoing of 3396825a95bSMasahiro Yamada# commands 3406825a95bSMasahiro Yamada 3416825a95bSMasahiro Yamadaifneq ($(filter s% -s%,$(MAKEFLAGS)),) 3426825a95bSMasahiro Yamada quiet=silent_ 3436825a95bSMasahiro Yamadaendif 3446825a95bSMasahiro Yamada 3456825a95bSMasahiro Yamadaexport quiet Q KBUILD_VERBOSE 3466825a95bSMasahiro Yamada 3476825a95bSMasahiro Yamada 3489e414032SMasahiro Yamada# Look for make include files relative to root of kernel src 3499e414032SMasahiro YamadaMAKEFLAGS += --include-dir=$(srctree) 3509e414032SMasahiro Yamada 351bf4b3de1SMasahiro Yamada# We need some generic definitions (do not try to remake the file). 352bf4b3de1SMasahiro Yamada$(srctree)/scripts/Kbuild.include: ; 353bf4b3de1SMasahiro Yamadainclude $(srctree)/scripts/Kbuild.include 354bf4b3de1SMasahiro Yamada 355f6322eb7SMasahiro Yamada# Make variables (CC, etc...) 356f6322eb7SMasahiro Yamada 357f6322eb7SMasahiro YamadaAS = $(CROSS_COMPILE)as 358f6322eb7SMasahiro Yamada# Always use GNU ld 359f6322eb7SMasahiro Yamadaifneq ($(shell $(CROSS_COMPILE)ld.bfd -v 2> /dev/null),) 360f6322eb7SMasahiro YamadaLD = $(CROSS_COMPILE)ld.bfd 361f6322eb7SMasahiro Yamadaelse 362f6322eb7SMasahiro YamadaLD = $(CROSS_COMPILE)ld 363f6322eb7SMasahiro Yamadaendif 364f6322eb7SMasahiro YamadaCC = $(CROSS_COMPILE)gcc 365f6322eb7SMasahiro YamadaCPP = $(CC) -E 366f6322eb7SMasahiro YamadaAR = $(CROSS_COMPILE)ar 367f6322eb7SMasahiro YamadaNM = $(CROSS_COMPILE)nm 368f6322eb7SMasahiro YamadaLDR = $(CROSS_COMPILE)ldr 369f6322eb7SMasahiro YamadaSTRIP = $(CROSS_COMPILE)strip 370f6322eb7SMasahiro YamadaOBJCOPY = $(CROSS_COMPILE)objcopy 371f6322eb7SMasahiro YamadaOBJDUMP = $(CROSS_COMPILE)objdump 372f6322eb7SMasahiro YamadaAWK = awk 373f6322eb7SMasahiro YamadaRANLIB = $(CROSS_COMPILE)RANLIB 374f6322eb7SMasahiro YamadaDTC = dtc 375f6322eb7SMasahiro YamadaCHECK = sparse 376f6322eb7SMasahiro Yamada 377f6322eb7SMasahiro YamadaCHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ 378f6322eb7SMasahiro Yamada -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF) 379f6322eb7SMasahiro Yamada 380fea1ca8eSMasahiro Yamada# Use UBOOTINCLUDE when you must reference the include/ directory. 381fea1ca8eSMasahiro Yamada# Needed to be compatible with the O= option 382fea1ca8eSMasahiro YamadaUBOOTINCLUDE := 383fea1ca8eSMasahiro Yamadaifneq ($(OBJTREE),$(SRCTREE)) 384fea1ca8eSMasahiro YamadaUBOOTINCLUDE += -I$(OBJTREE)/include 385fea1ca8eSMasahiro Yamadaendif 386fea1ca8eSMasahiro YamadaUBOOTINCLUDE += -I$(srctree)/include \ 387fea1ca8eSMasahiro Yamada -I$(srctree)/arch/$(ARCH)/include 388fea1ca8eSMasahiro Yamada 3892b3c9d3dSMasahiro YamadaKBUILD_CPPFLAGS := -D__KERNEL__ 3902b3c9d3dSMasahiro Yamada 3912b3c9d3dSMasahiro YamadaKBUILD_CFLAGS := -Wall -Wstrict-prototypes \ 3922b3c9d3dSMasahiro Yamada -Wno-format-security \ 3932b3c9d3dSMasahiro Yamada -fno-builtin -ffreestanding 3942b3c9d3dSMasahiro YamadaKBUILD_AFLAGS := -D__ASSEMBLY__ 3952b3c9d3dSMasahiro Yamada 3965f30f3beSMasahiro YamadaU_BOOT_VERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) 3975f30f3beSMasahiro Yamada 3985f30f3beSMasahiro Yamadaexport VERSION PATCHLEVEL SUBLEVEL U_BOOT_VERSION 399f6322eb7SMasahiro Yamadaexport CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC 400f6322eb7SMasahiro Yamadaexport CPP AR NM LDR STRIP OBJCOPY OBJDUMP 401f6322eb7SMasahiro Yamadaexport MAKE AWK 402f6322eb7SMasahiro Yamadaexport DTC CHECK CHECKFLAGS 403f6322eb7SMasahiro Yamada 404fea1ca8eSMasahiro Yamadaexport KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE 4052b3c9d3dSMasahiro Yamadaexport KBUILD_CFLAGS KBUILD_AFLAGS 4062b3c9d3dSMasahiro Yamada 4076825a95bSMasahiro Yamada# When compiling out-of-tree modules, put MODVERDIR in the module 4086825a95bSMasahiro Yamada# tree rather than in the kernel tree. The kernel tree might 4096825a95bSMasahiro Yamada# even be read-only. 4106825a95bSMasahiro Yamadaexport MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions 4116825a95bSMasahiro Yamada 4126825a95bSMasahiro Yamada# Files to ignore in find ... statements 4136825a95bSMasahiro Yamada 4146825a95bSMasahiro YamadaRCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \ 4156825a95bSMasahiro Yamada -o -name .pc -o -name .hg -o -name .git \) -prune -o 4166825a95bSMasahiro Yamadaexport RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ 4176825a95bSMasahiro Yamada --exclude CVS --exclude .pc --exclude .hg --exclude .git 4186825a95bSMasahiro Yamada 4196825a95bSMasahiro Yamada# =========================================================================== 4206825a95bSMasahiro Yamada# Rules shared between *config targets and build targets 4216825a95bSMasahiro Yamada 4226825a95bSMasahiro Yamada# Basic helpers built in scripts/ 4236825a95bSMasahiro YamadaPHONY += scripts_basic 4246825a95bSMasahiro Yamadascripts_basic: 4256825a95bSMasahiro Yamada $(Q)$(MAKE) $(build)=scripts/basic 4266825a95bSMasahiro Yamada $(Q)rm -f .tmp_quiet_recordmcount 4276825a95bSMasahiro Yamada 4286825a95bSMasahiro Yamada# To avoid any implicit rule to kick in, define an empty command. 4296825a95bSMasahiro Yamadascripts/basic/%: scripts_basic ; 4306825a95bSMasahiro Yamada 4316825a95bSMasahiro Yamada 4322b3c9d3dSMasahiro YamadaKBUILD_CFLAGS += -Os #-fomit-frame-pointer 4332b3c9d3dSMasahiro Yamada 4342b3c9d3dSMasahiro Yamadaifdef BUILD_TAG 4352b3c9d3dSMasahiro YamadaKBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"' 4362b3c9d3dSMasahiro Yamadaendif 4372b3c9d3dSMasahiro Yamada 4382b3c9d3dSMasahiro YamadaKBUILD_CFLAGS += $(call cc-option,-fno-stack-protector) 4392b3c9d3dSMasahiro Yamada 4402b3c9d3dSMasahiro YamadaKBUILD_CFLAGS += -g 4412b3c9d3dSMasahiro Yamada# $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format> 4422b3c9d3dSMasahiro Yamada# option to the assembler. 4432b3c9d3dSMasahiro YamadaKBUILD_AFLAGS += -g 4442b3c9d3dSMasahiro Yamada 445fea1ca8eSMasahiro YamadaNOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) 446fea1ca8eSMasahiro YamadaCHECKFLAGS += $(NOSTDINC_FLAGS) 447fea1ca8eSMasahiro Yamada 4482b3c9d3dSMasahiro Yamada# Report stack usage if supported 4492b3c9d3dSMasahiro YamadaKBUILD_CFLAGS += $(call cc-option,-fstack-usage) 4502b3c9d3dSMasahiro Yamada 4512b3c9d3dSMasahiro YamadaKBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral) 4522b3c9d3dSMasahiro Yamada 4532b3c9d3dSMasahiro Yamada# turn jbsr into jsr for m68k 4542b3c9d3dSMasahiro Yamadaifeq ($(ARCH),m68k) 4552b3c9d3dSMasahiro Yamadaifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4) 4562b3c9d3dSMasahiro YamadaKBUILD_AFLAGS += -Wa,-gstabs,-S 4572b3c9d3dSMasahiro Yamadaendif 4582b3c9d3dSMasahiro Yamadaendif 4592b3c9d3dSMasahiro Yamada 46092b197f0SWolfgang Denk# load other configuration 46192b197f0SWolfgang Denkinclude $(TOPDIR)/config.mk 46292b197f0SWolfgang Denk 463ced0715dSMasahiro Yamadaifneq ($(CONFIG_SYS_TEXT_BASE),) 464ced0715dSMasahiro YamadaKBUILD_CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) 465ced0715dSMasahiro Yamadaendif 466ced0715dSMasahiro Yamada 467ced0715dSMasahiro Yamadaexport CONFIG_SYS_TEXT_BASE 468ced0715dSMasahiro Yamada 4699e414032SMasahiro YamadaLDFLAGS_u-boot += -T u-boot.lds $(LDFLAGS_FINAL) 470ced0715dSMasahiro Yamadaifneq ($(CONFIG_SYS_TEXT_BASE),) 471ced0715dSMasahiro YamadaLDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE) 472ced0715dSMasahiro Yamadaendif 473ced0715dSMasahiro Yamada 474fada9e20SSimon Glass# Targets which don't build the source code 475ced0715dSMasahiro YamadaNON_BUILD_TARGETS = backup clean clobber distclean mrproper tidy unconfig %_config 476fada9e20SSimon Glass 477fada9e20SSimon Glass# Only do the generic board check when actually building, not configuring 478fada9e20SSimon Glassifeq ($(filter $(NON_BUILD_TARGETS),$(MAKECMDGOALS)),) 479ced0715dSMasahiro Yamadaifeq ($(__HAVE_ARCH_GENERIC_BOARD),) 480ced0715dSMasahiro Yamadaifneq ($(CONFIG_SYS_GENERIC_BOARD),) 481ced0715dSMasahiro YamadaCHECK_GENERIC_BOARD = $(error Your architecture does not support generic board. \ 482ced0715dSMasahiro YamadaPlease undefined CONFIG_SYS_GENERIC_BOARD in your board config file) 483ced0715dSMasahiro Yamadaendif 484fada9e20SSimon Glassendif 485fada9e20SSimon Glassendif 486fada9e20SSimon Glass 4876825a95bSMasahiro Yamada# FIX ME 4886825a95bSMasahiro Yamadacpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS) 4896825a95bSMasahiro Yamadac_flags := $(KBUILD_CFLAGS) $(cpp_flags) 4906825a95bSMasahiro Yamada 491d51dfff7SIlya Yanok# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use 492d51dfff7SIlya Yanok# that (or fail if absent). Otherwise, search for a linker script in a 493d51dfff7SIlya Yanok# standard location. 494d51dfff7SIlya Yanok 495ee60197eSSimon GlassLDSCRIPT_MAKEFILE_DIR = $(dir $(LDSCRIPT)) 496ee60197eSSimon Glass 497d51dfff7SIlya Yanokifndef LDSCRIPT 498d51dfff7SIlya Yanok #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug 499d51dfff7SIlya Yanok ifdef CONFIG_SYS_LDSCRIPT 500d51dfff7SIlya Yanok # need to strip off double quotes 501a8c07541SMasahiro Yamada LDSCRIPT := $(CONFIG_SYS_LDSCRIPT:"%"=%) 502d51dfff7SIlya Yanok endif 503d51dfff7SIlya Yanokendif 504d51dfff7SIlya Yanok 505ee60197eSSimon Glass# If there is no specified link script, we look in a number of places for it 506d51dfff7SIlya Yanokifndef LDSCRIPT 507d51dfff7SIlya Yanok ifeq ($(CONFIG_NAND_U_BOOT),y) 508d51dfff7SIlya Yanok LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds 509d51dfff7SIlya Yanok ifeq ($(wildcard $(LDSCRIPT)),) 510d51dfff7SIlya Yanok LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds 511d51dfff7SIlya Yanok endif 512d51dfff7SIlya Yanok endif 513d51dfff7SIlya Yanok ifeq ($(wildcard $(LDSCRIPT)),) 514d51dfff7SIlya Yanok LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds 515d51dfff7SIlya Yanok endif 516d51dfff7SIlya Yanok ifeq ($(wildcard $(LDSCRIPT)),) 517d51dfff7SIlya Yanok LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds 518d51dfff7SIlya Yanok endif 519d51dfff7SIlya Yanok ifeq ($(wildcard $(LDSCRIPT)),) 520ee60197eSSimon Glass LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot.lds 521ee60197eSSimon Glass # We don't expect a Makefile here 522ee60197eSSimon Glass LDSCRIPT_MAKEFILE_DIR = 523ee60197eSSimon Glass endif 524ee60197eSSimon Glass ifeq ($(wildcard $(LDSCRIPT)),) 525d51dfff7SIlya Yanok$(error could not find linker script) 526d51dfff7SIlya Yanok endif 527d51dfff7SIlya Yanokendif 528d51dfff7SIlya Yanok 5297ebf7443Swdenk######################################################################### 5307ebf7443Swdenk# U-Boot objects....order is important (i.e. start must be first) 5317ebf7443Swdenk 532e8a8b824SMasahiro Yamadahead-y := $(CPUDIR)/start.o 533e8a8b824SMasahiro Yamadahead-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o 534e8a8b824SMasahiro Yamadahead-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o 5357ebf7443Swdenk 5369e414032SMasahiro YamadaOBJS := $(head-y) 537f9328639SMarian Balakowicz 5389e414032SMasahiro YamadaHAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n) 5398b5a0264SDaniel Schwierzeck 540e2906a59SMasahiro YamadaLIBS-y += lib/ 541e2906a59SMasahiro YamadaLIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ 542e2906a59SMasahiro YamadaLIBS-y += $(CPUDIR)/ 5431d9f4105Swdenkifdef SOC 544e2906a59SMasahiro YamadaLIBS-y += $(CPUDIR)/$(SOC)/ 5451d9f4105Swdenkendif 546e2906a59SMasahiro YamadaLIBS-$(CONFIG_IXP4XX_NPE) += drivers/net/npe/ 547e2906a59SMasahiro YamadaLIBS-$(CONFIG_OF_EMBED) += dts/ 548e2906a59SMasahiro YamadaLIBS-y += arch/$(ARCH)/lib/ 54957c3e5fcSMasahiro YamadaLIBS-y += fs/ 550e2906a59SMasahiro YamadaLIBS-y += net/ 551e2906a59SMasahiro YamadaLIBS-y += disk/ 552e2906a59SMasahiro YamadaLIBS-y += drivers/ 553e2906a59SMasahiro YamadaLIBS-y += drivers/dma/ 554e2906a59SMasahiro YamadaLIBS-y += drivers/gpio/ 555e2906a59SMasahiro YamadaLIBS-y += drivers/i2c/ 556e2906a59SMasahiro YamadaLIBS-y += drivers/input/ 557e2906a59SMasahiro YamadaLIBS-y += drivers/mmc/ 558e2906a59SMasahiro YamadaLIBS-y += drivers/mtd/ 559392ba525SMasahiro YamadaLIBS-$(CONFIG_CMD_NAND) += drivers/mtd/nand/ 560e2906a59SMasahiro YamadaLIBS-y += drivers/mtd/onenand/ 561392ba525SMasahiro YamadaLIBS-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/ 562e2906a59SMasahiro YamadaLIBS-y += drivers/mtd/spi/ 563e2906a59SMasahiro YamadaLIBS-y += drivers/net/ 564e2906a59SMasahiro YamadaLIBS-y += drivers/net/phy/ 565e2906a59SMasahiro YamadaLIBS-y += drivers/pci/ 566e2906a59SMasahiro YamadaLIBS-y += drivers/power/ \ 567e2906a59SMasahiro Yamada drivers/power/fuel_gauge/ \ 568e2906a59SMasahiro Yamada drivers/power/mfd/ \ 569e2906a59SMasahiro Yamada drivers/power/pmic/ \ 570e2906a59SMasahiro Yamada drivers/power/battery/ 571e2906a59SMasahiro YamadaLIBS-y += drivers/spi/ 572e2906a59SMasahiro YamadaLIBS-$(CONFIG_FMAN_ENET) += drivers/net/fm/ 5735614e71bSYork SunLIBS-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/ 574e2906a59SMasahiro YamadaLIBS-y += drivers/serial/ 575e2906a59SMasahiro YamadaLIBS-y += drivers/usb/eth/ 576e2906a59SMasahiro YamadaLIBS-y += drivers/usb/gadget/ 577e2906a59SMasahiro YamadaLIBS-y += drivers/usb/host/ 578e2906a59SMasahiro YamadaLIBS-y += drivers/usb/musb/ 579e2906a59SMasahiro YamadaLIBS-y += drivers/usb/musb-new/ 580e2906a59SMasahiro YamadaLIBS-y += drivers/usb/phy/ 581e2906a59SMasahiro YamadaLIBS-y += drivers/usb/ulpi/ 582e2906a59SMasahiro YamadaLIBS-y += common/ 583e2906a59SMasahiro YamadaLIBS-y += lib/libfdt/ 5848a7e7d56SMasahiro YamadaLIBS-$(CONFIG_API) += api/ 585755e08f0SMasahiro YamadaLIBS-$(CONFIG_HAS_POST) += post/ 586e2906a59SMasahiro YamadaLIBS-y += test/ 587f9328639SMarian Balakowicz 58824e8bee5SAlison Wangifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610)) 589e2906a59SMasahiro YamadaLIBS-y += arch/$(ARCH)/imx-common/ 59018936ee2SJason Liuendif 59118936ee2SJason Liu 592e2906a59SMasahiro YamadaLIBS-$(CONFIG_ARM) += arch/arm/cpu/ 593e2906a59SMasahiro YamadaLIBS-$(CONFIG_PPC) += arch/powerpc/cpu/ 594852bd07cSMinkyu Kang 595e2906a59SMasahiro YamadaLIBS-y += board/$(BOARDDIR)/ 59608e39a84SMasahiro Yamada 597e2906a59SMasahiro YamadaLIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y)) 5989e414032SMasahiro YamadaLIBS := $(sort $(LIBS-y)) 599249b53a6SLoïc Minier.PHONY : $(LIBS) 600a8c7c708Swdenk 6014f7cb08eSwdenk# Add GCC lib 60252b1bf2cSWolfgang Denkifdef USE_PRIVATE_LIBGCC 60352b1bf2cSWolfgang Denkifeq ("$(USE_PRIVATE_LIBGCC)", "yes") 6046825a95bSMasahiro YamadaPLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/lib.a 60552b1bf2cSWolfgang Denkelse 60652b1bf2cSWolfgang DenkPLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc 60752b1bf2cSWolfgang Denkendif 60852b1bf2cSWolfgang Denkelse 6096825a95bSMasahiro YamadaPLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc 61052b1bf2cSWolfgang Denkendif 61152b1bf2cSWolfgang DenkPLATFORM_LIBS += $(PLATFORM_LIBGCC) 61252b1bf2cSWolfgang Denkexport PLATFORM_LIBS 6133d3befa7Swdenk 6146ac9f479SMike Frysinger# Special flags for CPP when processing the linker script. 6156ac9f479SMike Frysinger# Pass the version down so we can handle backwards compatibility 6166ac9f479SMike Frysinger# on the fly. 6176ac9f479SMike FrysingerLDPPFLAGS += \ 6186ac9f479SMike Frysinger -include $(TOPDIR)/include/u-boot/u-boot.lds.h \ 6197e6403a6SSimon Glass -DCPUDIR=$(CPUDIR) \ 6206ac9f479SMike Frysinger $(shell $(LD) --version | \ 6216ac9f479SMike Frysinger sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p') 6226ac9f479SMike Frysinger 6237ebf7443Swdenk######################################################################### 624bdccc4feSwdenk######################################################################### 6257ebf7443Swdenk 626f3a14d37SMike Frysingerifneq ($(CONFIG_BOARD_SIZE_LIMIT),) 627f3a14d37SMike FrysingerBOARD_SIZE_CHECK = \ 628f3a14d37SMike Frysinger @actual=`wc -c $@ | awk '{print $$1}'`; \ 629d060e6f4SJoe Hershberger limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \ 630f3a14d37SMike Frysinger if test $$actual -gt $$limit; then \ 631d060e6f4SJoe Hershberger echo "$@ exceeds file size limit:" >&2 ; \ 632d060e6f4SJoe Hershberger echo " limit: $$limit bytes" >&2 ; \ 633d060e6f4SJoe Hershberger echo " actual: $$actual bytes" >&2 ; \ 634d060e6f4SJoe Hershberger echo " excess: $$((actual - limit)) bytes" >&2; \ 635f3a14d37SMike Frysinger exit 1; \ 636f3a14d37SMike Frysinger fi 637f3a14d37SMike Frysingerelse 638f3a14d37SMike FrysingerBOARD_SIZE_CHECK = 639f3a14d37SMike Frysingerendif 640f3a14d37SMike Frysinger 6418137af19SScott Wood# Statically apply RELA-style relocations (currently arm64 only) 6428137af19SScott Woodifneq ($(CONFIG_STATIC_RELA),) 6438137af19SScott Wood# $(1) is u-boot ELF, $(2) is u-boot bin, $(3) is text base 6448137af19SScott WoodDO_STATIC_RELA = \ 6458137af19SScott Wood start=$$($(NM) $(1) | grep __rel_dyn_start | cut -f 1 -d ' '); \ 6468137af19SScott Wood end=$$($(NM) $(1) | grep __rel_dyn_end | cut -f 1 -d ' '); \ 6479e414032SMasahiro Yamada tools/relocate-rela $(2) $(3) $$start $$end 6488137af19SScott Woodelse 6498137af19SScott WoodDO_STATIC_RELA = 6508137af19SScott Woodendif 6518137af19SScott Wood 6523e88337bSMike Frysinger# Always append ALL so that arch config.mk's can add custom ones 6539e414032SMasahiro YamadaALL-y += u-boot.srec u-boot.bin System.map 654e935a374SHaiying Wang 6559e414032SMasahiro YamadaALL-$(CONFIG_NAND_U_BOOT) += u-boot-nand.bin 6569e414032SMasahiro YamadaALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin 6579e414032SMasahiro YamadaALL-$(CONFIG_RAMBOOT_PBL) += u-boot.pbl 6589e414032SMasahiro YamadaALL-$(CONFIG_SPL) += spl/u-boot-spl.bin 6599e414032SMasahiro YamadaALL-$(CONFIG_SPL_FRAMEWORK) += u-boot.img 6609e414032SMasahiro YamadaALL-$(CONFIG_TPL) += tpl/u-boot-tpl.bin 6619e414032SMasahiro YamadaALL-$(CONFIG_OF_SEPARATE) += u-boot.dtb u-boot-dtb.bin 662b343bbb5SVadim Bendeburyifneq ($(CONFIG_SPL_TARGET),) 6639e414032SMasahiro YamadaALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%) 664b343bbb5SVadim Bendeburyendif 6659e414032SMasahiro YamadaALL-$(CONFIG_REMAKE_ELF) += u-boot.elf 6667ebf7443Swdenk 66712b7b70cSAllen Martin# enable combined SPL/u-boot/dtb rules for tegra 6686d6c0baeSTom Warrenifneq ($(CONFIG_TEGRA),) 6697dcd3a21SVidya Sagarifeq ($(CONFIG_SPL),y) 67012b7b70cSAllen Martinifeq ($(CONFIG_OF_SEPARATE),y) 6719e414032SMasahiro YamadaALL-y += u-boot-dtb-tegra.bin 67212b7b70cSAllen Martinelse 6739e414032SMasahiro YamadaALL-y += u-boot-nodtb-tegra.bin 67412b7b70cSAllen Martinendif 67512b7b70cSAllen Martinendif 6767dcd3a21SVidya Sagarendif 67712b7b70cSAllen Martin 6788a7e7d56SMasahiro Yamadaall: $(ALL-y) $(SUBDIR_EXAMPLES-y) 6797ebf7443Swdenk 6809e414032SMasahiro Yamadau-boot.dtb: checkdtc u-boot 6819e414032SMasahiro Yamada $(MAKE) $(build)=dts binary 6829e414032SMasahiro Yamada mv dts/dt.dtb $@ 6832c0f79e4SSimon Glass 6849e414032SMasahiro Yamadau-boot-dtb.bin: u-boot.bin u-boot.dtb 6852c0f79e4SSimon Glass cat $^ >$@ 6862c0f79e4SSimon Glass 6879e414032SMasahiro Yamadau-boot.hex: u-boot 6886310eb9dSwdenk $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ 6896310eb9dSwdenk 6909e414032SMasahiro Yamadau-boot.srec: u-boot 69147ed5dd0SAlbert ARIBAUD $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ 6927ebf7443Swdenk 6939e414032SMasahiro Yamadau-boot.bin: u-boot 6947ebf7443Swdenk $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ 6958137af19SScott Wood $(call DO_STATIC_RELA,$<,$@,$(CONFIG_SYS_TEXT_BASE)) 696f3a14d37SMike Frysinger $(BOARD_SIZE_CHECK) 6977ebf7443Swdenk 6989e414032SMasahiro Yamadau-boot.ldr: u-boot 69976d82187SMike Frysinger $(CREATE_LDR_ENV) 70068e56324SMike Frysinger $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS) 701f3a14d37SMike Frysinger $(BOARD_SIZE_CHECK) 70294a91e24SMike Frysinger 7039e414032SMasahiro Yamadau-boot.ldr.hex: u-boot.ldr 70494a91e24SMike Frysinger $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary 70594a91e24SMike Frysinger 7069e414032SMasahiro Yamadau-boot.ldr.srec: u-boot.ldr 70794a91e24SMike Frysinger $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary 70894a91e24SMike Frysinger 709b40bda6bSStefan Roese# 710b40bda6bSStefan Roese# U-Boot entry point, needed for booting of full-blown U-Boot 711b40bda6bSStefan Roese# from the SPL U-Boot version. 712b40bda6bSStefan Roese# 713b40bda6bSStefan Roeseifndef CONFIG_SYS_UBOOT_START 714b40bda6bSStefan RoeseCONFIG_SYS_UBOOT_START := 0 715b40bda6bSStefan Roeseendif 716b40bda6bSStefan Roese 7179e414032SMasahiro Yamadau-boot.img: u-boot.bin 7189e414032SMasahiro Yamada tools/mkimage -A $(ARCH) -T firmware -C none \ 719b40bda6bSStefan Roese -O u-boot -a $(CONFIG_SYS_TEXT_BASE) \ 720b40bda6bSStefan Roese -e $(CONFIG_SYS_UBOOT_START) \ 721881a87ecSWolfgang Denk -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \ 722bdccc4feSwdenk sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \ 723bdccc4feSwdenk -d $< $@ 724bdccc4feSwdenk 7259e414032SMasahiro Yamadau-boot.imx: u-boot.bin depend 7269e414032SMasahiro Yamada $(MAKE) $(build)=arch/arm/imx-common $(objtree)/u-boot.imx 7278edcde5eSStefano Babic 7289e414032SMasahiro Yamadau-boot.kwb: u-boot.bin 7299e414032SMasahiro Yamada tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \ 7302ea88b06SEric Cooper -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -d $< $@ 731aa0c7a86SPrafulla Wadaskar 7329e414032SMasahiro Yamadau-boot.pbl: u-boot.bin 7339e414032SMasahiro Yamada tools/mkimage -n $(CONFIG_SYS_FSL_PBL_RCW) \ 734690e4258SPrabhakar Kushwaha -R $(CONFIG_SYS_FSL_PBL_PBI) -T pblimage \ 7355d898a00SShaohui Xie -d $< $@ 7365d898a00SShaohui Xie 7379e414032SMasahiro Yamadau-boot.sha1: u-boot.bin 7389e414032SMasahiro Yamada tools/ubsha1 u-boot.bin 739566a494fSHeiko Schocher 7409e414032SMasahiro Yamadau-boot.dis: u-boot 7417ebf7443Swdenk $(OBJDUMP) -d $< > $@ 7427ebf7443Swdenk 7433aa29de0SYing Zhang# $@ is output, $(1) and $(2) are inputs, $(3) is padded intermediate, 7443aa29de0SYing Zhang# $(4) is pad-to 7453aa29de0SYing ZhangSPL_PAD_APPEND = \ 7463aa29de0SYing Zhang $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(4) -I binary -O binary \ 7479e414032SMasahiro Yamada $(1) $(3); \ 7489e414032SMasahiro Yamada cat $(3) $(2) > $@; \ 7499e414032SMasahiro Yamada rm $(3) 75074752baaSScott Wood 7513aa29de0SYing Zhangifdef CONFIG_TPL 7529e414032SMasahiro YamadaSPL_PAYLOAD := tpl/u-boot-with-tpl.bin 7533aa29de0SYing Zhangelse 7549e414032SMasahiro YamadaSPL_PAYLOAD := u-boot.bin 7553aa29de0SYing Zhangendif 75674752baaSScott Wood 7579e414032SMasahiro Yamadau-boot-with-spl.bin: spl/u-boot-spl.bin $(SPL_PAYLOAD) 7583aa29de0SYing Zhang $(call SPL_PAD_APPEND,$<,$(SPL_PAYLOAD),spl/u-boot-spl-pad.bin,$(CONFIG_SPL_PAD_TO)) 7593aa29de0SYing Zhang 7609e414032SMasahiro Yamadatpl/u-boot-with-tpl.bin: tpl/u-boot-tpl.bin u-boot.bin 7619e414032SMasahiro Yamada $(call SPL_PAD_APPEND,$<,u-boot.bin,tpl/u-boot-tpl-pad.bin,$(CONFIG_TPL_PAD_TO)) 7627816f2cfSHeiko Schocher 7639e414032SMasahiro Yamadau-boot-with-spl.imx: spl/u-boot-spl.bin u-boot.bin 7649e414032SMasahiro Yamada $(MAKE) $(build)=arch/arm/imx-common \ 765ba597609SBenoît Thébaudeau $(OBJTREE)/u-boot-with-spl.imx 766ba597609SBenoît Thébaudeau 7679e414032SMasahiro Yamadau-boot-with-nand-spl.imx: spl/u-boot-spl.bin u-boot.bin 7689e414032SMasahiro Yamada $(MAKE) $(build)=arch/arm/imx-common \ 7697d5a5c79SBenoît Thébaudeau $(OBJTREE)/u-boot-with-nand-spl.imx 7707d5a5c79SBenoît Thébaudeau 7719e414032SMasahiro Yamadau-boot.ubl: u-boot-with-spl.bin 7729e414032SMasahiro Yamada tools/mkimage -n $(UBL_CONFIG) -T ublimage \ 7739e414032SMasahiro Yamada -e $(CONFIG_SYS_TEXT_BASE) -d $< u-boot.ubl 774277f00f5SJosé Miguel Gonçalves 7759e414032SMasahiro Yamadau-boot.ais: spl/u-boot-spl.bin u-boot.img 7769e414032SMasahiro Yamada tools/mkimage -s -n $(if $(CONFIG_AIS_CONFIG_FILE),$(srctree)/$(CONFIG_AIS_CONFIG_FILE:"%"=%),"/dev/null") \ 7776d660e77SSughosh Ganu -T aisimage \ 778d36d8859SChristian Riesch -e $(CONFIG_SPL_TEXT_BASE) \ 7799e414032SMasahiro Yamada -d spl/u-boot-spl.bin \ 7809e414032SMasahiro Yamada spl/u-boot-spl.ais 781d36d8859SChristian Riesch $(OBJCOPY) ${OBJCFLAGS} -I binary \ 782d36d8859SChristian Riesch --pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \ 7839e414032SMasahiro Yamada spl/u-boot-spl.ais spl/u-boot-spl-pad.ais 7849e414032SMasahiro Yamada cat spl/u-boot-spl-pad.ais u-boot.img > u-boot.ais 785d36d8859SChristian Riesch 786a5453555SOtavio Salvador 7879e414032SMasahiro Yamadau-boot.sb: u-boot.bin spl/u-boot-spl.bin 7889e414032SMasahiro Yamada $(MAKE) $(build)=$(CPUDIR)/$(SOC)/ $(OBJTREE)/u-boot.sb 78930b9b932SMarek Vasut 79094aebe6cSStefan Roese# On x600 (SPEAr600) U-Boot is appended to U-Boot SPL. 79194aebe6cSStefan Roese# Both images are created using mkimage (crc etc), so that the ROM 79294aebe6cSStefan Roese# bootloader can check its integrity. Padding needs to be done to the 79394aebe6cSStefan Roese# SPL image (with mkimage header) and not the binary. Otherwise the resulting image 79494aebe6cSStefan Roese# which is loaded/copied by the ROM bootloader to SRAM doesn't fit. 79594aebe6cSStefan Roese# The resulting image containing both U-Boot images is called u-boot.spr 7969e414032SMasahiro Yamadau-boot.spr: u-boot.img spl/u-boot-spl.bin 7979e414032SMasahiro Yamada tools/mkimage -A $(ARCH) -T firmware -C none \ 79894aebe6cSStefan Roese -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER \ 7999e414032SMasahiro Yamada -d spl/u-boot-spl.bin $@ 80057270260SMasahiro Yamada $(OBJCOPY) -I binary -O binary \ 80157270260SMasahiro Yamada --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff $@ 8029e414032SMasahiro Yamada cat u-boot.img >> $@ 80394aebe6cSStefan Roese 8046d6c0baeSTom Warrenifneq ($(CONFIG_TEGRA),) 8059e414032SMasahiro Yamadau-boot-nodtb-tegra.bin: spl/u-boot-spl.bin u-boot.bin 8069e414032SMasahiro Yamada $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary spl/u-boot-spl spl/u-boot-spl-pad.bin 8079e414032SMasahiro Yamada cat spl/u-boot-spl-pad.bin u-boot.bin > $@ 8089e414032SMasahiro Yamada rm spl/u-boot-spl-pad.bin 8099972db5cSStephen Warren 8109972db5cSStephen Warrenifeq ($(CONFIG_OF_SEPARATE),y) 8119e414032SMasahiro Yamadau-boot-dtb-tegra.bin: u-boot-nodtb-tegra.bin u-boot.dtb 8129e414032SMasahiro Yamada cat u-boot-nodtb-tegra.bin u-boot.dtb > $@ 8139972db5cSStephen Warrenendif 814984df4ecSAllen Martinendif 815984df4ecSAllen Martin 8169e414032SMasahiro Yamadau-boot-img.bin: spl/u-boot-spl.bin u-boot.img 8179e414032SMasahiro Yamada cat spl/u-boot-spl.bin u-boot.img > $@ 818fb3d2b8aSStefan Roese 819ecddccd0SStefan Roese# PPC4xx needs the SPL at the end of the image, since the reset vector 820ecddccd0SStefan Roese# is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target 821ecddccd0SStefan Roese# and need to introduce a new build target with the full blown U-Boot 822ecddccd0SStefan Roese# at the start padded up to the start of the SPL image. And then concat 823ecddccd0SStefan Roese# the SPL image to the end. 8249e414032SMasahiro Yamadau-boot-img-spl-at-end.bin: spl/u-boot-spl.bin u-boot.img 82557270260SMasahiro Yamada $(OBJCOPY) -I binary -O binary --pad-to=$(CONFIG_UBOOT_PAD_TO) \ 8269e414032SMasahiro Yamada --gap-fill=0xff u-boot.img $@ 8279e414032SMasahiro Yamada cat spl/u-boot-spl.bin >> $@ 828ecddccd0SStefan Roese 829f4dc714aSScott Wood# Create a new ELF from a raw binary file. This is useful for arm64 830f4dc714aSScott Wood# where static relocation needs to be performed on the raw binary, 831f4dc714aSScott Wood# but certain simulators only accept an ELF file (but don't do the 832f4dc714aSScott Wood# relocation). 833f4dc714aSScott Wood# FIXME refactor dts/Makefile to share target/arch detection 8349e414032SMasahiro Yamadau-boot.elf: u-boot.bin 835f4dc714aSScott Wood @$(OBJCOPY) -B aarch64 -I binary -O elf64-littleaarch64 \ 8369e414032SMasahiro Yamada $< u-boot-elf.o 8379e414032SMasahiro Yamada @$(LD) u-boot-elf.o -o $@ \ 838f4dc714aSScott Wood --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \ 839f4dc714aSScott Wood -Ttext=$(CONFIG_SYS_TEXT_BASE) 840f4dc714aSScott Wood 84186eb49b3SSimon Glassifeq ($(CONFIG_SANDBOX),y) 84286eb49b3SSimon GlassGEN_UBOOT = \ 8439e414032SMasahiro Yamada $(CC) $(SYMS) -T u-boot.lds \ 8449e414032SMasahiro Yamada -Wl,--start-group $(LIBS) -Wl,--end-group \ 84586eb49b3SSimon Glass $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot 84686eb49b3SSimon Glasselse 847ecb1dc89SMike FrysingerGEN_UBOOT = \ 8489e414032SMasahiro Yamada $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \ 8499e414032SMasahiro Yamada $(OBJS) \ 8509e414032SMasahiro Yamada --start-group $(LIBS) --end-group $(PLATFORM_LIBS) \ 851b2184c31Swdenk -Map u-boot.map -o u-boot 85286eb49b3SSimon Glassendif 85386eb49b3SSimon Glass 8549e414032SMasahiro Yamadau-boot: depend $(SUBDIR_TOOLS) $(OBJS) $(LIBS) u-boot.lds 855ecb1dc89SMike Frysinger $(GEN_UBOOT) 856ecb1dc89SMike Frysingerifeq ($(CONFIG_KALLSYMS),y) 8579e414032SMasahiro Yamada smap=`$(call SYSTEM_MAP,u-boot) | \ 8581aada9cdSWolfgang Denk awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \ 8596825a95bSMasahiro Yamada $(CC) $(c_flags) -DSYSTEM_MAP="\"$${smap}\"" \ 8609e414032SMasahiro Yamada -c $(srctree)/common/system_map.c -o common/system_map.o 8619e414032SMasahiro Yamada $(GEN_UBOOT) common/system_map.o 862ecb1dc89SMike Frysingerendif 8637ebf7443Swdenk 8643bddafaaSMasahiro Yamada$(OBJS): 8653bddafaaSMasahiro Yamada @: 866f9328639SMarian Balakowicz 8676825a95bSMasahiro Yamada$(LIBS): depend $(SUBDIR_TOOLS) scripts_basic 8686825a95bSMasahiro Yamada $(Q)$(MAKE) $(build)=$(patsubst %/,%,$(dir $@)) 869a8c7c708Swdenk 8706825a95bSMasahiro Yamada$(SUBDIRS): depend scripts_basic 8716825a95bSMasahiro Yamada $(Q)$(MAKE) $(build)=$@ 872940db16dSMasahiro Yamada 8739e414032SMasahiro Yamada$(SUBDIR_EXAMPLES-y): u-boot 874349e83f0SChe-liang Chiou 8759e414032SMasahiro Yamadau-boot.lds: $(LDSCRIPT) depend 8766825a95bSMasahiro Yamada $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@ 8771aada9cdSWolfgang Denk 8786825a95bSMasahiro Yamadanand_spl: $(TIMESTAMP_FILE) $(VERSION_FILE) depend scripts_basic 8799e414032SMasahiro Yamada $(MAKE) $(build)=nand_spl/board/$(BOARDDIR) all 880887e2ec9SStefan Roese 8819e414032SMasahiro Yamadau-boot-nand.bin: nand_spl u-boot.bin 8829e414032SMasahiro Yamada cat nand_spl/u-boot-spl-16k.bin u-boot.bin > u-boot-nand.bin 883887e2ec9SStefan Roese 8846825a95bSMasahiro Yamadaspl/u-boot-spl.bin: $(SUBDIR_TOOLS) depend scripts_basic 8859e414032SMasahiro Yamada $(MAKE) obj=spl -f $(srctree)/spl/Makefile all 8865df2ee27SDaniel Schwierzeck 8876825a95bSMasahiro Yamadatpl/u-boot-tpl.bin: $(SUBDIR_TOOLS) depend scripts_basic 8889e414032SMasahiro Yamada $(MAKE) obj=tpl -f $(srctree)/spl/Makefile all CONFIG_TPL_BUILD=y 8893aa29de0SYing Zhang 8902a998793SDaniel Hobi# Explicitly make _depend in subdirs containing multiple targets to prevent 8912a998793SDaniel Hobi# parallel sub-makes creating .depend files simultaneously. 89216a354f9SWolfgang Denkdepend dep: $(TIMESTAMP_FILE) $(VERSION_FILE) \ 8939e414032SMasahiro Yamada include/spl-autoconf.mk \ 8949e414032SMasahiro Yamada include/tpl-autoconf.mk \ 8959e414032SMasahiro Yamada include/autoconf.mk \ 8969e414032SMasahiro Yamada include/generated/generic-asm-offsets.h \ 8979e414032SMasahiro Yamada include/generated/asm-offsets.h 8987ebf7443Swdenk 899e5e4e705SLi YangTAG_SUBDIRS = $(SUBDIRS) 9009e414032SMasahiro YamadaTAG_SUBDIRS += $(dir $(LIBS)) 901a340c325SJean-Christophe PLAGNIOL-VILLARDTAG_SUBDIRS += include 902a340c325SJean-Christophe PLAGNIOL-VILLARD 903857d9ea6SHorst KronstorferFIND := find 904857d9ea6SHorst KronstorferFINDFLAGS := -L 905857d9ea6SHorst Kronstorfer 906*47f15711SMasahiro YamadaPHONY += checkstack 907*47f15711SMasahiro Yamada 9081064d980STom Rinicheckstack: 909*47f15711SMasahiro Yamada $(OBJDUMP) -d u-boot $$(find . -name u-boot-spl) | \ 910*47f15711SMasahiro Yamada $(PERL) $(src)/scripts/checkstack.pl $(ARCH) 9111064d980STom Rini 912f9328639SMarian Balakowicztags ctags: 9139e414032SMasahiro Yamada ctags -w -o ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ 914e5e4e705SLi Yang -name '*.[chS]' -print` 9157ebf7443Swdenk 9167ebf7443Swdenketags: 917857d9ea6SHorst Kronstorfer etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ 918e5e4e705SLi Yang -name '*.[chS]' -print` 919ffda586fSLi Yangcscope: 920857d9ea6SHorst Kronstorfer $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \ 921857d9ea6SHorst Kronstorfer cscope.files 922ffda586fSLi Yang cscope -b -q -k 9237ebf7443Swdenk 924ecb1dc89SMike FrysingerSYSTEM_MAP = \ 925ecb1dc89SMike Frysinger $(NM) $1 | \ 9267ebf7443Swdenk grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ 927ecb1dc89SMike Frysinger LC_ALL=C sort 9289e414032SMasahiro YamadaSystem.map: u-boot 929bc8bb6ecSMasahiro Yamada @$(call SYSTEM_MAP,$<) > $@ 9307ebf7443Swdenk 93106a119a0STom Rinicheckthumb: 93206a119a0STom Rini @if test $(call cc-version) -lt 0404; then \ 93306a119a0STom Rini echo -n '*** Your GCC does not produce working '; \ 93406a119a0STom Rini echo 'binaries in THUMB mode.'; \ 93506a119a0STom Rini echo '*** Your board is configured for THUMB mode.'; \ 93606a119a0STom Rini false; \ 93706a119a0STom Rini fi 9386ec63f41SScott Wood 9396ec63f41SScott Wood# GCC 3.x is reported to have problems generating the type of relocation 9406ec63f41SScott Wood# that U-Boot wants. 9416ec63f41SScott Wood# See http://lists.denx.de/pipermail/u-boot/2012-September/135156.html 9426ec63f41SScott Woodcheckgcc4: 9436ec63f41SScott Wood @if test $(call cc-version) -lt 0400; then \ 9446ec63f41SScott Wood echo -n '*** Your GCC is too old, please upgrade to GCC 4.x or newer'; \ 9456ec63f41SScott Wood false; \ 9466ec63f41SScott Wood fi 9476ec63f41SScott Wood 948501ebdf2SStephen Warrencheckdtc: 949501ebdf2SStephen Warren @if test $(call dtc-version) -lt 0104; then \ 950501ebdf2SStephen Warren echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \ 951501ebdf2SStephen Warren false; \ 952501ebdf2SStephen Warren fi 953501ebdf2SStephen Warren 9542f155f6cSGrant Likely# 9552f155f6cSGrant Likely# Auto-generate the autoconf.mk file (which is included by all makefiles) 9562f155f6cSGrant Likely# 9572f155f6cSGrant Likely# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep. 9582f155f6cSGrant Likely# the dep file is only include in this top level makefile to determine when 9592f155f6cSGrant Likely# to regenerate the autoconf.mk file. 9601510b82dSWolfgang Denk 961*47f15711SMasahiro Yamadaquiet_cmd_autoconf_dep = GEN $@ 962*47f15711SMasahiro Yamada cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \ 963*47f15711SMasahiro Yamada -MQ include/autoconf.mk $(srctree)/include/common.h > $@ || rm $@ 964*47f15711SMasahiro Yamada 965*47f15711SMasahiro Yamadainclude/autoconf.mk.dep: include/config.h include/common.h 966*47f15711SMasahiro Yamada $(call cmd,autoconf_dep) 967*47f15711SMasahiro Yamada 968*47f15711SMasahiro Yamadaquiet_cmd_autoconf = GEN $@ 969*47f15711SMasahiro Yamada cmd_autoconf = \ 9706825a95bSMasahiro Yamada $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ 9719e414032SMasahiro Yamada sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ 97265947ab4SMasahiro Yamada rm $@.tmp 9732f155f6cSGrant Likely 974*47f15711SMasahiro Yamadainclude/autoconf.mk: include/config.h 975*47f15711SMasahiro Yamada $(call cmd,autoconf) 976*47f15711SMasahiro Yamada 97739bc12ddSJoel Fernandes# Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL) 978*47f15711SMasahiro Yamadaquiet_cmd_tpl-autoconf = GEN $@ 979*47f15711SMasahiro Yamada cmd_tpl-autoconf = \ 9806825a95bSMasahiro Yamada $(CPP) $(c_flags) -DCONFIG_TPL_BUILD -DCONFIG_SPL_BUILD\ 9819e414032SMasahiro Yamada -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ 9829e414032SMasahiro Yamada sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ 98365947ab4SMasahiro Yamada rm $@.tmp 9843aa29de0SYing Zhang 985*47f15711SMasahiro Yamadainclude/tpl-autoconf.mk: include/config.h 986*47f15711SMasahiro Yamada $(call cmd,tpl-autoconf) 987*47f15711SMasahiro Yamada 988*47f15711SMasahiro Yamadaquiet_cmd_spl-autoconf = GEN $@ 989*47f15711SMasahiro Yamada cmd_spl-autoconf = \ 9906825a95bSMasahiro Yamada $(CPP) $(c_flags) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ 9919e414032SMasahiro Yamada sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ 99265947ab4SMasahiro Yamada rm $@.tmp 99339bc12ddSJoel Fernandes 994*47f15711SMasahiro Yamadainclude/spl-autoconf.mk: include/config.h 995*47f15711SMasahiro Yamada $(call cmd,spl-autoconf) 99616a354f9SWolfgang Denk 997*47f15711SMasahiro Yamadaquiet_cmd_offsets = GEN $@ 998*47f15711SMasahiro Yamada cmd_offsets = $(srctree)/tools/scripts/make-asm-offsets $< $@ 999*47f15711SMasahiro Yamada 1000*47f15711SMasahiro Yamadainclude/generated/generic-asm-offsets.h: lib/asm-offsets.s 1001*47f15711SMasahiro Yamada $(call cmd,offsets) 1002*47f15711SMasahiro Yamada 1003*47f15711SMasahiro Yamadaquiet_cmd_asm-offsets.s = CC $@ 1004*47f15711SMasahiro Yamada cmd_asm-offsets.s = mkdir -p lib; \ 100516a354f9SWolfgang Denk $(CC) -DDO_DEPS_ONLY \ 10066825a95bSMasahiro Yamada $(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \ 1007*47f15711SMasahiro Yamada -o $@ $< -c -S 1008*47f15711SMasahiro Yamada 1009*47f15711SMasahiro Yamadalib/asm-offsets.s: $(srctree)/lib/asm-offsets.c include/config.h 1010*47f15711SMasahiro Yamada $(call cmd,asm-offsets.s) 101116a354f9SWolfgang Denk 10129e414032SMasahiro Yamadainclude/generated/asm-offsets.h: $(CPUDIR)/$(SOC)/asm-offsets.s 1013*47f15711SMasahiro Yamada $(call cmd,offsets) 1014a4814a69SStefano Babic 1015*47f15711SMasahiro Yamadaquiet_cmd_soc_asm-offsets.s = CC $@ 1016*47f15711SMasahiro Yamada cmd_soc_asm-offsets.s = mkdir -p $(CPUDIR)/$(SOC); \ 10179e414032SMasahiro Yamada if [ -f $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c ];then \ 1018a4814a69SStefano Babic $(CC) -DDO_DEPS_ONLY \ 10196825a95bSMasahiro Yamada $(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \ 10209e414032SMasahiro Yamada -o $@ $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \ 1021a4814a69SStefano Babic else \ 1022a4814a69SStefano Babic touch $@; \ 1023a4814a69SStefano Babic fi 1024a4814a69SStefano Babic 1025*47f15711SMasahiro Yamada$(CPUDIR)/$(SOC)/asm-offsets.s: include/config.h 1026*47f15711SMasahiro Yamada $(call cmd,soc_asm-offsets.s) 1027*47f15711SMasahiro Yamada 10287ebf7443Swdenk######################################################################### 1029ae6d1056SWolfgang Denkelse # !config.mk 10309e414032SMasahiro Yamadaall u-boot.hex u-boot.srec u-boot.bin \ 10319e414032SMasahiro Yamadau-boot.img u-boot.dis u-boot \ 1032249b53a6SLoïc Minier$(filter-out tools,$(SUBDIRS)) \ 10339e414032SMasahiro Yamadadepend dep tags ctags etags cscope System.map: 10347ebf7443Swdenk @echo "System not configured - see README" >&2 10357ebf7443Swdenk @ exit 1 1036c7c0d542SMike Frysinger 1037249b53a6SLoïc Miniertools: $(VERSION_FILE) $(TIMESTAMP_FILE) 10389e414032SMasahiro Yamada $(MAKE) $(build)=$@ all 1039ae6d1056SWolfgang Denkendif # config.mk 10407ebf7443Swdenk 104154799e45SScott Wood# ARM relocations should all be R_ARM_RELATIVE (32-bit) or 104254799e45SScott Wood# R_AARCH64_RELATIVE (64-bit). 10439e414032SMasahiro Yamadacheckarmreloc: u-boot 104454799e45SScott Wood @RELOC="`$(CROSS_COMPILE)readelf -r -W $< | cut -d ' ' -f 4 | \ 104554799e45SScott Wood grep R_A | sort -u`"; \ 104654799e45SScott Wood if test "$$RELOC" != "R_ARM_RELATIVE" -a \ 104754799e45SScott Wood "$$RELOC" != "R_AARCH64_RELATIVE"; then \ 104854799e45SScott Wood echo "$< contains unexpected relocations: $$RELOC"; \ 104954799e45SScott Wood false; \ 105054799e45SScott Wood fi 1051c37980c3SAlbert ARIBAUD 105228abd48fSIlya Yanok$(VERSION_FILE): 105314ce91b1SMike Frysinger @mkdir -p $(dir $(VERSION_FILE)) 1054dd88ab32SMasahiro Yamada @( localvers='$(shell $(TOPDIR)/scripts/setlocalversion $(TOPDIR))' ; \ 105528abd48fSIlya Yanok printf '#define PLAIN_VERSION "%s%s"\n' \ 105628abd48fSIlya Yanok "$(U_BOOT_VERSION)" "$${localvers}" ; \ 105728abd48fSIlya Yanok printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \ 105828abd48fSIlya Yanok "$(U_BOOT_VERSION)" "$${localvers}" ; \ 105928abd48fSIlya Yanok ) > $@.tmp 106028abd48fSIlya Yanok @( printf '#define CC_VERSION_STRING "%s"\n' \ 106128abd48fSIlya Yanok '$(shell $(CC) --version | head -n 1)' )>> $@.tmp 106228abd48fSIlya Yanok @( printf '#define LD_VERSION_STRING "%s"\n' \ 106328abd48fSIlya Yanok '$(shell $(LD) -v | head -n 1)' )>> $@.tmp 106428abd48fSIlya Yanok @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@ 106528abd48fSIlya Yanok 1066249b53a6SLoïc Minier$(TIMESTAMP_FILE): 1067249b53a6SLoïc Minier @mkdir -p $(dir $(TIMESTAMP_FILE)) 1068a76406fbSLoïc Minier @LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@.tmp 1069a76406fbSLoïc Minier @LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp 1070a76406fbSLoïc Minier @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@ 1071249b53a6SLoïc Minier 10720358df42SMike Frysingereasylogo env gdb: 10736825a95bSMasahiro Yamada $(Q)$(MAKE) $(build)=tools/$@ MTD_VERSION=${MTD_VERSION} 1074940db16dSMasahiro Yamada 10750358df42SMike Frysingergdbtools: gdb 10760358df42SMike Frysinger 107730ff8918SMarek Vasutxmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc 10786825a95bSMasahiro Yamada $(Q)$(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) $(build)=doc/DocBook $@ 107930ff8918SMarek Vasut 1080249b53a6SLoïc Miniertools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE) 10816825a95bSMasahiro Yamada $(Q)$(MAKE) $(build)=tools HOST_TOOLS_ALL=y 10820358df42SMike Frysinger 10834e53a258SWolfgang Denk.PHONY : CHANGELOG 10844e53a258SWolfgang DenkCHANGELOG: 1085b985b5d6SBen Warren git log --no-merges U-Boot-1_1_5.. | \ 1086b985b5d6SBen Warren unexpand -a | sed -e 's/\s\s*$$//' > $@ 10874e53a258SWolfgang Denk 10880a823aa2SHarald Welteinclude/license.h: tools/bin2header COPYING 10890a823aa2SHarald Welte cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h 10907ebf7443Swdenk######################################################################### 10917ebf7443Swdenk 10927ebf7443Swdenkunconfig: 10939e414032SMasahiro Yamada @rm -f include/config.h include/config.mk \ 10949e414032SMasahiro Yamada board/*/config.tmp board/*/*/config.tmp \ 10959e414032SMasahiro Yamada include/autoconf.mk include/autoconf.mk.dep \ 10969e414032SMasahiro Yamada include/spl-autoconf.mk \ 10979e414032SMasahiro Yamada include/tpl-autoconf.mk 10987ebf7443Swdenk 1099a6862bc1SWolfgang Denk%_config:: unconfig 1100a6862bc1SWolfgang Denk @$(MKCONFIG) -A $(@:_config=) 1101a6862bc1SWolfgang Denk 11023e38691eSwdenk######################################################################### 11037ebf7443Swdenk 11047ebf7443Swdenkclean: 11059e414032SMasahiro Yamada @rm -f examples/standalone/atmel_df_pow2 \ 11069e414032SMasahiro Yamada examples/standalone/hello_world \ 11079e414032SMasahiro Yamada examples/standalone/interrupt \ 11089e414032SMasahiro Yamada examples/standalone/mem_to_mem_idma2intr \ 11099e414032SMasahiro Yamada examples/standalone/sched \ 11109e414032SMasahiro Yamada $(addprefix examples/standalone/, smc91111_eeprom smc911x_eeprom) \ 11119e414032SMasahiro Yamada examples/standalone/test_burst \ 11129e414032SMasahiro Yamada examples/standalone/timer 11139e414032SMasahiro Yamada @rm -f $(addprefix examples/api/, demo demo.bin) 11149e414032SMasahiro Yamada @rm -f tools/bmp_logo tools/easylogo/easylogo \ 11159e414032SMasahiro Yamada tools/env/fw_printenv \ 11169e414032SMasahiro Yamada tools/envcrc \ 11179e414032SMasahiro Yamada $(addprefix tools/gdb/, gdbcont gdbsend) \ 11189e414032SMasahiro Yamada tools/gen_eth_addr tools/img2srec \ 11199e414032SMasahiro Yamada tools/dumpimage \ 11209e414032SMasahiro Yamada $(addprefix tools/, mkenvimage mkimage) \ 11219e414032SMasahiro Yamada tools/mpc86x_clk \ 11229e414032SMasahiro Yamada $(addprefix tools/, mk$(BOARD)spl mkexynosspl) \ 11239e414032SMasahiro Yamada tools/mxsboot \ 11249e414032SMasahiro Yamada tools/ncb tools/ubsha1 \ 11259e414032SMasahiro Yamada tools/kernel-doc/docproc \ 11269e414032SMasahiro Yamada tools/proftool 11279e414032SMasahiro Yamada @rm -f $(addprefix board/cray/L1/, bootscript.c bootscript.image) \ 11289e414032SMasahiro Yamada board/matrix_vision/*/bootscript.img \ 11299e414032SMasahiro Yamada spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl \ 11309e414032SMasahiro Yamada u-boot.lds \ 11319e414032SMasahiro Yamada $(addprefix arch/blackfin/cpu/, init.lds init.elf) 11329e414032SMasahiro Yamada @rm -f include/bmp_logo.h 11339e414032SMasahiro Yamada @rm -f include/bmp_logo_data.h 11349e414032SMasahiro Yamada @rm -f lib/asm-offsets.s 11359e414032SMasahiro Yamada @rm -f include/generated/asm-offsets.h 11369e414032SMasahiro Yamada @rm -f $(CPUDIR)/$(SOC)/asm-offsets.s 1137d4abc757SPeter Tyser @rm -f $(TIMESTAMP_FILE) $(VERSION_FILE) 11389e414032SMasahiro Yamada @$(MAKE) -f $(srctree)/doc/DocBook/Makefile cleandocs 1139ae6d1056SWolfgang Denk @find $(OBJTREE) -type f \ 11404a30f1e8STom Rini \( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \ 11416825a95bSMasahiro Yamada -o -name '*.o' -o -name '*.a' -o -name '*.exe' -o -name '*.cmd' \ 114271a988aaSTroy Kisky -o -name '*.cfgtmp' \) -print \ 11437ebf7443Swdenk | xargs rm -f 11447ebf7443Swdenk 1145734329f9SAndy Fleming# Removes everything not needed for testing u-boot 1146734329f9SAndy Flemingtidy: clean 1147734329f9SAndy Fleming @find $(OBJTREE) -type f \( -name '*.depend*' \) -print | xargs rm -f 1148734329f9SAndy Fleming 1149734329f9SAndy Flemingclobber: tidy 1150734329f9SAndy Fleming @find $(OBJTREE) -type f \( -name '*.srec' \ 1151734329f9SAndy Fleming -o -name '*.bin' -o -name u-boot.img \) \ 1152734329f9SAndy Fleming -print0 | xargs -0 rm -f 11539e414032SMasahiro Yamada @rm -f $(OBJS) *.bak ctags etags TAGS \ 11549e414032SMasahiro Yamada cscope.* *.*~ 11559e414032SMasahiro Yamada @rm -f u-boot u-boot.map u-boot.hex $(ALL-y) 11569e414032SMasahiro Yamada @rm -f u-boot.kwb 11579e414032SMasahiro Yamada @rm -f u-boot.pbl 11589e414032SMasahiro Yamada @rm -f u-boot.imx 11599e414032SMasahiro Yamada @rm -f u-boot-with-spl.imx 11609e414032SMasahiro Yamada @rm -f u-boot-with-nand-spl.imx 11619e414032SMasahiro Yamada @rm -f u-boot.ubl 11629e414032SMasahiro Yamada @rm -f u-boot.ais 11639e414032SMasahiro Yamada @rm -f u-boot.dtb 11649e414032SMasahiro Yamada @rm -f u-boot.sb 11659e414032SMasahiro Yamada @rm -f u-boot.spr 11669e414032SMasahiro Yamada @rm -f $(addprefix nand_spl/, u-boot.lds u-boot.lst System.map) 11679e414032SMasahiro Yamada @rm -f $(addprefix nand_spl/, u-boot-nand_spl.lds u-boot-spl u-boot-spl.map) 11689e414032SMasahiro Yamada @rm -f $(addprefix spl/, u-boot-spl u-boot-spl.bin u-boot-spl.map) 11699e414032SMasahiro Yamada @rm -f spl/u-boot-spl.lds 11709e414032SMasahiro Yamada @rm -f $(addprefix tpl/, u-boot-tpl u-boot-tpl.bin u-boot-tpl.map) 11719e414032SMasahiro Yamada @rm -f tpl/u-boot-spl.lds 11729e414032SMasahiro Yamada @rm -f MLO MLO.byteswap 11739e414032SMasahiro Yamada @rm -f SPL 11749e414032SMasahiro Yamada @rm -f tools/xway-swap-bytes 11759e414032SMasahiro Yamada @rm -fr include/asm/proc include/asm/arch include/asm 11769e414032SMasahiro Yamada @rm -fr include/generated 11779e414032SMasahiro Yamada @[ ! -d nand_spl ] || find nand_spl -name "*" -type l -print | xargs rm -f 11789e414032SMasahiro Yamada @rm -f dts/*.tmp 11799e414032SMasahiro Yamada @rm -f $(addprefix spl/, u-boot-spl.ais, u-boot-spl-pad.ais) 11807ebf7443Swdenk 11817ebf7443Swdenkmrproper \ 11827ebf7443Swdenkdistclean: clobber unconfig 1183afd077bdSMike Frysingerifneq ($(OBJTREE),$(SRCTREE)) 11849e414032SMasahiro Yamada rm -rf * 1185f9328639SMarian Balakowiczendif 11867ebf7443Swdenk 11877ebf7443Swdenkbackup: 11887ebf7443Swdenk F=`basename $(TOPDIR)` ; cd .. ; \ 1189d6b93714SIlya Yanok gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F 11907ebf7443Swdenk 11917ebf7443Swdenk######################################################################### 11929e414032SMasahiro Yamada 11939e414032SMasahiro Yamadaendif # skip-makefile 11949e414032SMasahiro Yamada 11959e414032SMasahiro YamadaPHONY += FORCE 11969e414032SMasahiro YamadaFORCE: 11979e414032SMasahiro Yamada 11989e414032SMasahiro Yamada# Declare the contents of the .PHONY variable as phony. We keep that 11999e414032SMasahiro Yamada# information in a variable so we can use it in if_changed and friends. 12009e414032SMasahiro Yamada.PHONY: $(PHONY) 1201