1# 2# (C) Copyright 2000-2013 3# Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4# 5# SPDX-License-Identifier: GPL-2.0+ 6# 7 8VERSION = 2013 9PATCHLEVEL = 10 10SUBLEVEL = 11EXTRAVERSION = 12ifneq "$(SUBLEVEL)" "" 13U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) 14else 15U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL)$(EXTRAVERSION) 16endif 17TIMESTAMP_FILE = $(obj)include/generated/timestamp_autogenerated.h 18VERSION_FILE = $(obj)include/generated/version_autogenerated.h 19 20HOSTARCH := $(shell uname -m | \ 21 sed -e s/i.86/x86/ \ 22 -e s/sun4u/sparc64/ \ 23 -e s/arm.*/arm/ \ 24 -e s/sa110/arm/ \ 25 -e s/ppc64/powerpc/ \ 26 -e s/ppc/powerpc/ \ 27 -e s/macppc/powerpc/\ 28 -e s/sh.*/sh/) 29 30HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \ 31 sed -e 's/\(cygwin\).*/cygwin/') 32 33export HOSTARCH HOSTOS 34 35# Deal with colliding definitions from tcsh etc. 36VENDOR= 37 38######################################################################### 39# Allow for silent builds 40ifeq (,$(findstring s,$(MAKEFLAGS))) 41XECHO = echo 42else 43XECHO = : 44endif 45 46######################################################################### 47# 48# U-boot build supports generating object files in a separate external 49# directory. Two use cases are supported: 50# 51# 1) Add O= to the make command line 52# 'make O=/tmp/build all' 53# 54# 2) Set environment variable BUILD_DIR to point to the desired location 55# 'export BUILD_DIR=/tmp/build' 56# 'make' 57# 58# The second approach can also be used with a MAKEALL script 59# 'export BUILD_DIR=/tmp/build' 60# './MAKEALL' 61# 62# Command line 'O=' setting overrides BUILD_DIR environment variable. 63# 64# When none of the above methods is used the local build is performed and 65# the object files are placed in the source directory. 66# 67 68ifdef O 69ifeq ("$(origin O)", "command line") 70BUILD_DIR := $(O) 71endif 72endif 73 74# Call a source code checker (by default, "sparse") as part of the 75# C compilation. 76# 77# Use 'make C=1' to enable checking of re-compiled files. 78# 79# See the linux kernel file "Documentation/sparse.txt" for more details, 80# including where to get the "sparse" utility. 81 82ifdef C 83ifeq ("$(origin C)", "command line") 84CHECKSRC := $(C) 85endif 86endif 87ifndef CHECKSRC 88 CHECKSRC = 0 89endif 90export CHECKSRC 91 92ifneq ($(BUILD_DIR),) 93saved-output := $(BUILD_DIR) 94 95# Attempt to create a output directory. 96$(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}) 97 98# Verify if it was successful. 99BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd) 100$(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist)) 101endif # ifneq ($(BUILD_DIR),) 102 103OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR)) 104SPLTREE := $(OBJTREE)/spl 105TPLTREE := $(OBJTREE)/tpl 106SRCTREE := $(CURDIR) 107TOPDIR := $(SRCTREE) 108LNDIR := $(OBJTREE) 109export TOPDIR SRCTREE OBJTREE SPLTREE TPLTREE 110 111MKCONFIG := $(SRCTREE)/mkconfig 112export MKCONFIG 113 114ifneq ($(OBJTREE),$(SRCTREE)) 115REMOTE_BUILD := 1 116export REMOTE_BUILD 117endif 118 119# $(obj) and (src) are defined in config.mk but here in main Makefile 120# we also need them before config.mk is included which is the case for 121# some targets like unconfig, clean, clobber, distclean, etc. 122ifneq ($(OBJTREE),$(SRCTREE)) 123obj := $(OBJTREE)/ 124src := $(SRCTREE)/ 125else 126obj := 127src := 128endif 129export obj src 130 131# Make sure CDPATH settings don't interfere 132unexport CDPATH 133 134######################################################################### 135 136# The "tools" are needed early, so put this first 137# Don't include stuff already done in $(LIBS) 138# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC 139# is "yes"), so compile examples after U-Boot is compiled. 140SUBDIR_TOOLS = tools 141SUBDIR_EXAMPLES = examples/standalone examples/api 142SUBDIRS = $(SUBDIR_TOOLS) 143 144.PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE) 145 146ifeq ($(obj)include/config.mk,$(wildcard $(obj)include/config.mk)) 147 148# Include autoconf.mk before config.mk so that the config options are available 149# to all top level build files. We need the dummy all: target to prevent the 150# dependency target in autoconf.mk.dep from being the default. 151all: 152sinclude $(obj)include/autoconf.mk.dep 153sinclude $(obj)include/autoconf.mk 154 155ifndef CONFIG_SANDBOX 156SUBDIRS += $(SUBDIR_EXAMPLES) 157endif 158 159# load ARCH, BOARD, and CPU configuration 160include $(obj)include/config.mk 161export ARCH CPU BOARD VENDOR SOC 162 163# set default to nothing for native builds 164ifeq ($(HOSTARCH),$(ARCH)) 165CROSS_COMPILE ?= 166endif 167 168# load other configuration 169include $(TOPDIR)/config.mk 170 171# Targets which don't build the source code 172NON_BUILD_TARGETS = backup clean clobber distclean mkproper tidy unconfig 173 174# Only do the generic board check when actually building, not configuring 175ifeq ($(filter $(NON_BUILD_TARGETS),$(MAKECMDGOALS)),) 176ifeq ($(findstring _config,$(MAKECMDGOALS)),) 177$(CHECK_GENERIC_BOARD) 178endif 179endif 180 181# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use 182# that (or fail if absent). Otherwise, search for a linker script in a 183# standard location. 184 185LDSCRIPT_MAKEFILE_DIR = $(dir $(LDSCRIPT)) 186 187ifndef LDSCRIPT 188 #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug 189 ifdef CONFIG_SYS_LDSCRIPT 190 # need to strip off double quotes 191 LDSCRIPT := $(subst ",,$(CONFIG_SYS_LDSCRIPT)) 192 endif 193endif 194 195# If there is no specified link script, we look in a number of places for it 196ifndef LDSCRIPT 197 ifeq ($(CONFIG_NAND_U_BOOT),y) 198 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds 199 ifeq ($(wildcard $(LDSCRIPT)),) 200 LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds 201 endif 202 endif 203 ifeq ($(wildcard $(LDSCRIPT)),) 204 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds 205 endif 206 ifeq ($(wildcard $(LDSCRIPT)),) 207 LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds 208 endif 209 ifeq ($(wildcard $(LDSCRIPT)),) 210 LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot.lds 211 # We don't expect a Makefile here 212 LDSCRIPT_MAKEFILE_DIR = 213 endif 214 ifeq ($(wildcard $(LDSCRIPT)),) 215$(error could not find linker script) 216 endif 217endif 218 219######################################################################### 220# U-Boot objects....order is important (i.e. start must be first) 221 222OBJS = $(CPUDIR)/start.o 223ifeq ($(CPU),ppc4xx) 224OBJS += $(CPUDIR)/resetvec.o 225endif 226ifeq ($(CPU),mpc85xx) 227OBJS += $(CPUDIR)/resetvec.o 228endif 229 230OBJS := $(addprefix $(obj),$(OBJS)) 231 232HAVE_VENDOR_COMMON_LIB = $(if $(wildcard board/$(VENDOR)/common/Makefile),y,n) 233 234LIBS-y += lib/libgeneric.o 235LIBS-y += lib/rsa/librsa.o 236LIBS-y += lib/lzma/liblzma.o 237LIBS-y += lib/lzo/liblzo.o 238LIBS-y += lib/zlib/libz.o 239LIBS-$(CONFIG_TIZEN) += lib/tizen/libtizen.o 240LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/lib$(VENDOR).o 241LIBS-y += $(CPUDIR)/lib$(CPU).o 242ifdef SOC 243LIBS-y += $(CPUDIR)/$(SOC)/lib$(SOC).o 244endif 245ifeq ($(CPU),ixp) 246LIBS-y += drivers/net/npe/libnpe.o 247endif 248LIBS-$(CONFIG_OF_EMBED) += dts/libdts.o 249LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o 250LIBS-y += fs/libfs.o \ 251 fs/cbfs/libcbfs.o \ 252 fs/cramfs/libcramfs.o \ 253 fs/ext4/libext4fs.o \ 254 fs/fat/libfat.o \ 255 fs/fdos/libfdos.o \ 256 fs/jffs2/libjffs2.o \ 257 fs/reiserfs/libreiserfs.o \ 258 fs/sandbox/libsandboxfs.o \ 259 fs/ubifs/libubifs.o \ 260 fs/yaffs2/libyaffs2.o \ 261 fs/zfs/libzfs.o 262LIBS-y += net/libnet.o 263LIBS-y += disk/libdisk.o 264LIBS-y += drivers/libdrivers.o 265LIBS-y += drivers/dma/libdma.o 266LIBS-y += drivers/gpio/libgpio.o 267LIBS-y += drivers/i2c/libi2c.o 268LIBS-y += drivers/input/libinput.o 269LIBS-y += drivers/mmc/libmmc.o 270LIBS-y += drivers/mtd/libmtd.o 271LIBS-y += drivers/mtd/nand/libnand.o 272LIBS-y += drivers/mtd/onenand/libonenand.o 273LIBS-y += drivers/mtd/ubi/libubi.o 274LIBS-y += drivers/mtd/spi/libspi_flash.o 275LIBS-y += drivers/net/libnet.o 276LIBS-y += drivers/net/phy/libphy.o 277LIBS-y += drivers/pci/libpci.o 278LIBS-y += drivers/power/libpower.o \ 279 drivers/power/fuel_gauge/libfuel_gauge.o \ 280 drivers/power/mfd/libmfd.o \ 281 drivers/power/pmic/libpmic.o \ 282 drivers/power/battery/libbattery.o 283LIBS-y += drivers/spi/libspi.o 284ifeq ($(CPU),mpc83xx) 285LIBS-y += drivers/qe/libqe.o 286LIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o 287LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o 288endif 289ifeq ($(CPU),mpc85xx) 290LIBS-y += drivers/qe/libqe.o 291LIBS-y += drivers/net/fm/libfm.o 292LIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o 293LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o 294endif 295ifeq ($(CPU),mpc86xx) 296LIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o 297LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o 298endif 299LIBS-y += drivers/serial/libserial.o 300LIBS-y += drivers/usb/eth/libusb_eth.o 301LIBS-y += drivers/usb/gadget/libusb_gadget.o 302LIBS-y += drivers/usb/host/libusb_host.o 303LIBS-y += drivers/usb/musb/libusb_musb.o 304LIBS-y += drivers/usb/musb-new/libusb_musb-new.o 305LIBS-y += drivers/usb/phy/libusb_phy.o 306LIBS-y += drivers/usb/ulpi/libusb_ulpi.o 307LIBS-y += common/libcommon.o 308LIBS-y += lib/libfdt/libfdt.o 309LIBS-y += api/libapi.o 310LIBS-y += post/libpost.o 311LIBS-y += test/libtest.o 312 313ifneq ($(CONFIG_OMAP_COMMON),) 314LIBS-y += $(CPUDIR)/omap-common/libomap-common.o 315endif 316 317ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610)) 318LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o 319endif 320 321ifeq ($(SOC),s5pc1xx) 322LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o 323endif 324ifeq ($(SOC),exynos) 325LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o 326endif 327ifneq ($(CONFIG_TEGRA),) 328LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o 329LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o 330LIBS-y += $(CPUDIR)/tegra-common/libtegra-common.o 331endif 332 333LIBS := $(addprefix $(obj),$(sort $(LIBS-y))) 334.PHONY : $(LIBS) 335 336LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).o 337LIBBOARD := $(addprefix $(obj),$(LIBBOARD)) 338 339# Add GCC lib 340ifdef USE_PRIVATE_LIBGCC 341ifeq ("$(USE_PRIVATE_LIBGCC)", "yes") 342PLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/libgcc.o 343else 344PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc 345endif 346else 347PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc 348endif 349PLATFORM_LIBS += $(PLATFORM_LIBGCC) 350export PLATFORM_LIBS 351 352# Special flags for CPP when processing the linker script. 353# Pass the version down so we can handle backwards compatibility 354# on the fly. 355LDPPFLAGS += \ 356 -include $(TOPDIR)/include/u-boot/u-boot.lds.h \ 357 -DCPUDIR=$(CPUDIR) \ 358 $(shell $(LD) --version | \ 359 sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p') 360 361__OBJS := $(subst $(obj),,$(OBJS)) 362__LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD)) 363 364######################################################################### 365######################################################################### 366 367ifneq ($(CONFIG_BOARD_SIZE_LIMIT),) 368BOARD_SIZE_CHECK = \ 369 @actual=`wc -c $@ | awk '{print $$1}'`; \ 370 limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \ 371 if test $$actual -gt $$limit; then \ 372 echo "$@ exceeds file size limit:" >&2 ; \ 373 echo " limit: $$limit bytes" >&2 ; \ 374 echo " actual: $$actual bytes" >&2 ; \ 375 echo " excess: $$((actual - limit)) bytes" >&2; \ 376 exit 1; \ 377 fi 378else 379BOARD_SIZE_CHECK = 380endif 381 382# Always append ALL so that arch config.mk's can add custom ones 383ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map 384 385ALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin 386ALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin 387ALL-$(CONFIG_RAMBOOT_PBL) += $(obj)u-boot.pbl 388ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin 389ALL-$(CONFIG_SPL_FRAMEWORK) += $(obj)u-boot.img 390ALL-$(CONFIG_TPL) += $(obj)tpl/u-boot-tpl.bin 391ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin 392ifneq ($(CONFIG_SPL_TARGET),) 393ALL-$(CONFIG_SPL) += $(obj)$(subst ",,$(CONFIG_SPL_TARGET)) 394endif 395 396# enable combined SPL/u-boot/dtb rules for tegra 397ifneq ($(CONFIG_TEGRA),) 398ifeq ($(CONFIG_OF_SEPARATE),y) 399ALL-y += $(obj)u-boot-dtb-tegra.bin 400else 401ALL-y += $(obj)u-boot-nodtb-tegra.bin 402endif 403endif 404 405build := -f $(TOPDIR)/scripts/Makefile.build -C 406 407all: $(ALL-y) $(SUBDIR_EXAMPLES) 408 409$(obj)u-boot.dtb: checkdtc $(obj)u-boot 410 $(MAKE) -C dts binary 411 mv $(obj)dts/dt.dtb $@ 412 413$(obj)u-boot-dtb.bin: $(obj)u-boot.bin $(obj)u-boot.dtb 414 cat $^ >$@ 415 416$(obj)u-boot.hex: $(obj)u-boot 417 $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ 418 419$(obj)u-boot.srec: $(obj)u-boot 420 $(OBJCOPY) -O srec $< $@ 421 422$(obj)u-boot.bin: $(obj)u-boot 423 $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ 424 $(BOARD_SIZE_CHECK) 425 426$(obj)u-boot.ldr: $(obj)u-boot 427 $(CREATE_LDR_ENV) 428 $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS) 429 $(BOARD_SIZE_CHECK) 430 431$(obj)u-boot.ldr.hex: $(obj)u-boot.ldr 432 $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary 433 434$(obj)u-boot.ldr.srec: $(obj)u-boot.ldr 435 $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary 436 437# 438# U-Boot entry point, needed for booting of full-blown U-Boot 439# from the SPL U-Boot version. 440# 441ifndef CONFIG_SYS_UBOOT_START 442CONFIG_SYS_UBOOT_START := 0 443endif 444 445$(obj)u-boot.img: $(obj)u-boot.bin 446 $(obj)tools/mkimage -A $(ARCH) -T firmware -C none \ 447 -O u-boot -a $(CONFIG_SYS_TEXT_BASE) \ 448 -e $(CONFIG_SYS_UBOOT_START) \ 449 -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \ 450 sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \ 451 -d $< $@ 452 453$(obj)u-boot.imx: $(obj)u-boot.bin depend 454 $(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common $(OBJTREE)/u-boot.imx 455 456$(obj)u-boot.kwb: $(obj)u-boot.bin 457 $(obj)tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \ 458 -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -d $< $@ 459 460$(obj)u-boot.pbl: $(obj)u-boot.bin 461 $(obj)tools/mkimage -n $(CONFIG_PBLRCW_CONFIG) \ 462 -R $(CONFIG_PBLPBI_CONFIG) -T pblimage \ 463 -d $< $@ 464 465$(obj)u-boot.sha1: $(obj)u-boot.bin 466 $(obj)tools/ubsha1 $(obj)u-boot.bin 467 468$(obj)u-boot.dis: $(obj)u-boot 469 $(OBJDUMP) -d $< > $@ 470 471# $@ is output, $(1) and $(2) are inputs, $(3) is padded intermediate, 472# $(4) is pad-to 473SPL_PAD_APPEND = \ 474 $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(4) -I binary -O binary \ 475 $(1) $(obj)$(3); \ 476 cat $(obj)$(3) $(2) > $@; \ 477 rm $(obj)$(3) 478 479ifdef CONFIG_TPL 480SPL_PAYLOAD := $(obj)tpl/u-boot-with-tpl.bin 481else 482SPL_PAYLOAD := $(obj)u-boot.bin 483endif 484 485$(obj)u-boot-with-spl.bin: $(obj)spl/u-boot-spl.bin $(SPL_PAYLOAD) 486 $(call SPL_PAD_APPEND,$<,$(SPL_PAYLOAD),spl/u-boot-spl-pad.bin,$(CONFIG_SPL_PAD_TO)) 487 488$(obj)tpl/u-boot-with-tpl.bin: $(obj)tpl/u-boot-tpl.bin $(obj)u-boot.bin 489 $(call SPL_PAD_APPEND,$<,$(obj)u-boot.bin,tpl/u-boot-tpl-pad.bin,$(CONFIG_TPL_PAD_TO)) 490 491$(obj)u-boot-with-spl.imx: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin 492 $(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common \ 493 $(OBJTREE)/u-boot-with-spl.imx 494 495$(obj)u-boot-with-nand-spl.imx: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin 496 $(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common \ 497 $(OBJTREE)/u-boot-with-nand-spl.imx 498 499$(obj)u-boot.ubl: $(obj)u-boot-with-spl.bin 500 $(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \ 501 -e $(CONFIG_SYS_TEXT_BASE) -d $< $(obj)u-boot.ubl 502 503$(obj)u-boot.ais: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img 504 $(obj)tools/mkimage -s -n $(if $(CONFIG_AIS_CONFIG_FILE),$(CONFIG_AIS_CONFIG_FILE),"/dev/null") \ 505 -T aisimage \ 506 -e $(CONFIG_SPL_TEXT_BASE) \ 507 -d $(obj)spl/u-boot-spl.bin \ 508 $(obj)spl/u-boot-spl.ais 509 $(OBJCOPY) ${OBJCFLAGS} -I binary \ 510 --pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \ 511 $(obj)spl/u-boot-spl.ais $(obj)spl/u-boot-spl-pad.ais 512 cat $(obj)spl/u-boot-spl-pad.ais $(obj)u-boot.img > \ 513 $(obj)u-boot.ais 514 515 516$(obj)u-boot.sb: $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin 517 $(MAKE) -C $(SRCTREE)/$(CPUDIR)/$(SOC)/ $(OBJTREE)/u-boot.sb 518 519# On x600 (SPEAr600) U-Boot is appended to U-Boot SPL. 520# Both images are created using mkimage (crc etc), so that the ROM 521# bootloader can check its integrity. Padding needs to be done to the 522# SPL image (with mkimage header) and not the binary. Otherwise the resulting image 523# which is loaded/copied by the ROM bootloader to SRAM doesn't fit. 524# The resulting image containing both U-Boot images is called u-boot.spr 525$(obj)u-boot.spr: $(obj)u-boot.img $(obj)spl/u-boot-spl.bin 526 $(obj)tools/mkimage -A $(ARCH) -T firmware -C none \ 527 -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER \ 528 -d $(obj)spl/u-boot-spl.bin $(obj)spl/u-boot-spl.img 529 tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_SPL_PAD_TO) \ 530 of=$(obj)spl/u-boot-spl-pad.img 2>/dev/null 531 dd if=$(obj)spl/u-boot-spl.img of=$(obj)spl/u-boot-spl-pad.img \ 532 conv=notrunc 2>/dev/null 533 cat $(obj)spl/u-boot-spl-pad.img $(obj)u-boot.img > $@ 534 535ifneq ($(CONFIG_TEGRA),) 536$(obj)u-boot-nodtb-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin 537 $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin 538 cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $@ 539 rm $(obj)spl/u-boot-spl-pad.bin 540 541ifeq ($(CONFIG_OF_SEPARATE),y) 542$(obj)u-boot-dtb-tegra.bin: $(obj)u-boot-nodtb-tegra.bin $(obj)u-boot.dtb 543 cat $(obj)u-boot-nodtb-tegra.bin $(obj)u-boot.dtb > $@ 544endif 545endif 546 547$(obj)u-boot-img.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img 548 cat $(obj)spl/u-boot-spl.bin $(obj)u-boot.img > $@ 549 550# PPC4xx needs the SPL at the end of the image, since the reset vector 551# is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target 552# and need to introduce a new build target with the full blown U-Boot 553# at the start padded up to the start of the SPL image. And then concat 554# the SPL image to the end. 555$(obj)u-boot-img-spl-at-end.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img 556 tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_UBOOT_PAD_TO) \ 557 of=$(obj)u-boot-pad.img 2>/dev/null 558 dd if=$(obj)u-boot.img of=$(obj)u-boot-pad.img \ 559 conv=notrunc 2>/dev/null 560 cat $(obj)u-boot-pad.img $(obj)spl/u-boot-spl.bin > $@ 561 562ifeq ($(CONFIG_SANDBOX),y) 563GEN_UBOOT = \ 564 cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \ 565 -Wl,--start-group $(__LIBS) -Wl,--end-group \ 566 $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot 567else 568GEN_UBOOT = \ 569 cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \ 570 $(__OBJS) \ 571 --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \ 572 -Map u-boot.map -o u-boot 573endif 574 575$(obj)u-boot: depend \ 576 $(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds 577 $(GEN_UBOOT) 578ifeq ($(CONFIG_KALLSYMS),y) 579 smap=`$(call SYSTEM_MAP,$(obj)u-boot) | \ 580 awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \ 581 $(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" \ 582 -c common/system_map.c -o $(obj)common/system_map.o 583 $(GEN_UBOOT) $(obj)common/system_map.o 584endif 585 586# Tentative step for Kbuild-style makefiles coexist with conventional U-Boot style makefiles 587# U-Boot conventional sub makefiles always include some other makefiles. 588# So, the build system searches a line beginning with "include" before entering into the sub makefile 589# in order to distinguish which style it is. 590# If the Makefile include a "include" line, we assume it is an U-Boot style makefile. 591# Otherwise, it is treated as a Kbuild-style makefile. 592select_makefile = \ 593 +if grep -q "^include" $1/Makefile; then \ 594 $(MAKE) -C $1; \ 595 else \ 596 $(MAKE) -C $1 -f $(TOPDIR)/scripts/Makefile.build; \ 597 mv $(dir $@)built-in.o $@; \ 598 fi 599 600# We do not need to build $(OBJS) explicitly. 601# It is built while we are at $(CPUDIR)/lib$(CPU).o build. 602$(OBJS): depend 603 if grep -q "^include" $(CPUDIR)/Makefile; then \ 604 $(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@)); \ 605 fi 606 607$(LIBS): depend $(SUBDIR_TOOLS) 608 +$(call select_makefile, $(dir $(subst $(obj),,$@))) 609 610$(LIBBOARD): depend $(LIBS) 611 +$(call select_makefile, $(dir $(subst $(obj),,$@))) 612 613$(SUBDIRS): depend 614 $(MAKE) -C $@ all 615 616$(SUBDIR_EXAMPLES): $(obj)u-boot 617 618$(LDSCRIPT): depend 619 $(MAKE) -C $(dir $@) $(notdir $@) 620 621$(obj)u-boot.lds: $(LDSCRIPT) 622 $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@ 623 624nand_spl: $(TIMESTAMP_FILE) $(VERSION_FILE) depend 625 $(MAKE) -C nand_spl/board/$(BOARDDIR) all 626 627$(obj)u-boot-nand.bin: nand_spl $(obj)u-boot.bin 628 cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin 629 630$(obj)spl/u-boot-spl.bin: $(SUBDIR_TOOLS) depend 631 $(MAKE) -C spl all 632 633$(obj)tpl/u-boot-tpl.bin: $(SUBDIR_TOOLS) depend 634 $(MAKE) -C spl all CONFIG_TPL_BUILD=y 635 636updater: 637 $(MAKE) -C tools/updater all 638 639select_makefile2 = \ 640 if grep -q "^include" $1/Makefile; then \ 641 $(MAKE) -C $1 _depend; \ 642 else \ 643 $(MAKE) -C $1 -f $(TOPDIR)/scripts/Makefile.build _depend; \ 644 fi 645 646# Explicitly make _depend in subdirs containing multiple targets to prevent 647# parallel sub-makes creating .depend files simultaneously. 648depend dep: $(TIMESTAMP_FILE) $(VERSION_FILE) \ 649 $(obj)include/spl-autoconf.mk \ 650 $(obj)include/tpl-autoconf.mk \ 651 $(obj)include/autoconf.mk \ 652 $(obj)include/generated/generic-asm-offsets.h \ 653 $(obj)include/generated/asm-offsets.h 654 +for dir in $(SUBDIRS) $(CPUDIR) $(LDSCRIPT_MAKEFILE_DIR) ; do \ 655 $(call select_makefile2, $$dir); \ 656 done 657 658TAG_SUBDIRS = $(SUBDIRS) 659TAG_SUBDIRS += $(dir $(__LIBS)) 660TAG_SUBDIRS += include 661 662FIND := find 663FINDFLAGS := -L 664 665checkstack: 666 $(CROSS_COMPILE)objdump -d $(obj)u-boot \ 667 `$(FIND) $(obj) -name u-boot-spl -print` | \ 668 perl $(src)tools/checkstack.pl $(ARCH) 669 670tags ctags: 671 ctags -w -o $(obj)ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ 672 -name '*.[chS]' -print` 673 674etags: 675 etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ 676 -name '*.[chS]' -print` 677cscope: 678 $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \ 679 cscope.files 680 cscope -b -q -k 681 682SYSTEM_MAP = \ 683 $(NM) $1 | \ 684 grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ 685 LC_ALL=C sort 686$(obj)System.map: $(obj)u-boot 687 @$(call SYSTEM_MAP,$<) > $(obj)System.map 688 689checkthumb: 690 @if test $(call cc-version) -lt 0404; then \ 691 echo -n '*** Your GCC does not produce working '; \ 692 echo 'binaries in THUMB mode.'; \ 693 echo '*** Your board is configured for THUMB mode.'; \ 694 false; \ 695 fi 696 697# GCC 3.x is reported to have problems generating the type of relocation 698# that U-Boot wants. 699# See http://lists.denx.de/pipermail/u-boot/2012-September/135156.html 700checkgcc4: 701 @if test $(call cc-version) -lt 0400; then \ 702 echo -n '*** Your GCC is too old, please upgrade to GCC 4.x or newer'; \ 703 false; \ 704 fi 705 706checkdtc: 707 @if test $(call dtc-version) -lt 0104; then \ 708 echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \ 709 false; \ 710 fi 711 712# 713# Auto-generate the autoconf.mk file (which is included by all makefiles) 714# 715# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep. 716# the dep file is only include in this top level makefile to determine when 717# to regenerate the autoconf.mk file. 718$(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h 719 @$(XECHO) Generating $@ ; \ 720 set -e ; \ 721 : Generate the dependancies ; \ 722 $(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \ 723 -MQ $(obj)include/autoconf.mk include/common.h > $@ 724 725$(obj)include/autoconf.mk: $(obj)include/config.h 726 @$(XECHO) Generating $@ ; \ 727 set -e ; \ 728 : Extract the config macros ; \ 729 $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \ 730 sed -n -f tools/scripts/define2mk.sed > $@.tmp && \ 731 mv $@.tmp $@ 732 733# Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL) 734$(obj)include/tpl-autoconf.mk: $(obj)include/config.h 735 @$(XECHO) Generating $@ ; \ 736 set -e ; \ 737 : Extract the config macros ; \ 738 $(CPP) $(CFLAGS) -DCONFIG_TPL_BUILD -DCONFIG_SPL_BUILD\ 739 -DDO_DEPS_ONLY -dM include/common.h | \ 740 sed -n -f tools/scripts/define2mk.sed > $@.tmp && \ 741 mv $@.tmp $@ 742 743$(obj)include/spl-autoconf.mk: $(obj)include/config.h 744 @$(XECHO) Generating $@ ; \ 745 set -e ; \ 746 : Extract the config macros ; \ 747 $(CPP) $(CFLAGS) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM include/common.h | \ 748 sed -n -f tools/scripts/define2mk.sed > $@.tmp && \ 749 mv $@.tmp $@ 750 751$(obj)include/generated/generic-asm-offsets.h: $(obj)include/autoconf.mk.dep \ 752 $(obj)include/spl-autoconf.mk \ 753 $(obj)include/tpl-autoconf.mk \ 754 $(obj)lib/asm-offsets.s 755 @$(XECHO) Generating $@ 756 tools/scripts/make-asm-offsets $(obj)lib/asm-offsets.s $@ 757 758$(obj)lib/asm-offsets.s: $(obj)include/autoconf.mk.dep \ 759 $(obj)include/spl-autoconf.mk \ 760 $(obj)include/tpl-autoconf.mk \ 761 $(src)lib/asm-offsets.c 762 @mkdir -p $(obj)lib 763 $(CC) -DDO_DEPS_ONLY \ 764 $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \ 765 -o $@ $(src)lib/asm-offsets.c -c -S 766 767$(obj)include/generated/asm-offsets.h: $(obj)include/autoconf.mk.dep \ 768 $(obj)include/spl-autoconf.mk \ 769 $(obj)include/tpl-autoconf.mk \ 770 $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s 771 @$(XECHO) Generating $@ 772 tools/scripts/make-asm-offsets $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s $@ 773 774$(obj)$(CPUDIR)/$(SOC)/asm-offsets.s: $(obj)include/autoconf.mk.dep \ 775 $(obj)include/spl-autoconf.mk \ 776 $(obj)include/tpl-autoconf.mk 777 @mkdir -p $(obj)$(CPUDIR)/$(SOC) 778 if [ -f $(src)$(CPUDIR)/$(SOC)/asm-offsets.c ];then \ 779 $(CC) -DDO_DEPS_ONLY \ 780 $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \ 781 -o $@ $(src)$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \ 782 else \ 783 touch $@; \ 784 fi 785 786######################################################################### 787else # !config.mk 788all $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \ 789$(obj)u-boot.img $(obj)u-boot.dis $(obj)u-boot \ 790$(filter-out tools,$(SUBDIRS)) \ 791updater depend dep tags ctags etags cscope $(obj)System.map: 792 @echo "System not configured - see README" >&2 793 @ exit 1 794 795tools: $(VERSION_FILE) $(TIMESTAMP_FILE) 796 $(MAKE) -C $@ all 797endif # config.mk 798 799# ARM relocations should all be R_ARM_RELATIVE. 800checkarmreloc: $(obj)u-boot 801 @if test "R_ARM_RELATIVE" != \ 802 "`$(CROSS_COMPILE)readelf -r $< | cut -d ' ' -f 4 | grep R_ARM | sort -u`"; \ 803 then echo "$< contains relocations other than \ 804 R_ARM_RELATIVE"; false; fi 805 806$(VERSION_FILE): 807 @mkdir -p $(dir $(VERSION_FILE)) 808 @( localvers='$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' ; \ 809 printf '#define PLAIN_VERSION "%s%s"\n' \ 810 "$(U_BOOT_VERSION)" "$${localvers}" ; \ 811 printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \ 812 "$(U_BOOT_VERSION)" "$${localvers}" ; \ 813 ) > $@.tmp 814 @( printf '#define CC_VERSION_STRING "%s"\n' \ 815 '$(shell $(CC) --version | head -n 1)' )>> $@.tmp 816 @( printf '#define LD_VERSION_STRING "%s"\n' \ 817 '$(shell $(LD) -v | head -n 1)' )>> $@.tmp 818 @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@ 819 820$(TIMESTAMP_FILE): 821 @mkdir -p $(dir $(TIMESTAMP_FILE)) 822 @LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@.tmp 823 @LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp 824 @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@ 825 826easylogo env gdb: 827 $(MAKE) -C tools/$@ all MTD_VERSION=${MTD_VERSION} 828gdbtools: gdb 829 830xmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc 831 $(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) -C doc/DocBook/ $@ 832 833tools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE) 834 $(MAKE) -C tools HOST_TOOLS_ALL=y 835 836.PHONY : CHANGELOG 837CHANGELOG: 838 git log --no-merges U-Boot-1_1_5.. | \ 839 unexpand -a | sed -e 's/\s\s*$$//' > $@ 840 841include/license.h: tools/bin2header COPYING 842 cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h 843######################################################################### 844 845unconfig: 846 @rm -f $(obj)include/config.h $(obj)include/config.mk \ 847 $(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \ 848 $(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep \ 849 $(obj)include/spl-autoconf.mk \ 850 $(obj)include/tpl-autoconf.mk 851 852%_config:: unconfig 853 @$(MKCONFIG) -A $(@:_config=) 854 855sinclude $(obj).boards.depend 856$(obj).boards.depend: boards.cfg 857 @awk '(NF && $$1 !~ /^#/) { print $$7 ": " $$7 "_config; $$(MAKE)" }' $< > $@ 858 859# 860# Functions to generate common board directory names 861# 862lcname = $(shell echo $(1) | sed -e 's/\(.*\)_config/\L\1/') 863ucname = $(shell echo $(1) | sed -e 's/\(.*\)_config/\U\1/') 864 865######################################################################### 866######################################################################### 867 868clean: 869 @rm -f $(obj)examples/standalone/82559_eeprom \ 870 $(obj)examples/standalone/atmel_df_pow2 \ 871 $(obj)examples/standalone/eepro100_eeprom \ 872 $(obj)examples/standalone/hello_world \ 873 $(obj)examples/standalone/interrupt \ 874 $(obj)examples/standalone/mem_to_mem_idma2intr \ 875 $(obj)examples/standalone/sched \ 876 $(obj)examples/standalone/smc911{11,x}_eeprom \ 877 $(obj)examples/standalone/test_burst \ 878 $(obj)examples/standalone/timer 879 @rm -f $(obj)examples/api/demo{,.bin} 880 @rm -f $(obj)tools/bmp_logo $(obj)tools/easylogo/easylogo \ 881 $(obj)tools/env/{fw_printenv,fw_setenv} \ 882 $(obj)tools/envcrc \ 883 $(obj)tools/gdb/{astest,gdbcont,gdbsend} \ 884 $(obj)tools/gen_eth_addr $(obj)tools/img2srec \ 885 $(obj)tools/mk{env,}image $(obj)tools/mpc86x_clk \ 886 $(obj)tools/mk{$(BOARD),}spl \ 887 $(obj)tools/mxsboot \ 888 $(obj)tools/ncb $(obj)tools/ubsha1 \ 889 $(obj)tools/kernel-doc/docproc \ 890 $(obj)tools/proftool 891 @rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image} \ 892 $(obj)board/matrix_vision/*/bootscript.img \ 893 $(obj)board/voiceblue/eeprom \ 894 $(obj)u-boot.lds \ 895 $(obj)arch/blackfin/cpu/bootrom-asm-offsets.[chs] \ 896 $(obj)arch/blackfin/cpu/init.{lds,elf} 897 @rm -f $(obj)include/bmp_logo.h 898 @rm -f $(obj)include/bmp_logo_data.h 899 @rm -f $(obj)lib/asm-offsets.s 900 @rm -f $(obj)include/generated/asm-offsets.h 901 @rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s 902 @rm -f $(TIMESTAMP_FILE) $(VERSION_FILE) 903 @$(MAKE) -s -C doc/DocBook/ cleandocs 904 @find $(OBJTREE) -type f \ 905 \( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \ 906 -o -name '*.o' -o -name '*.a' -o -name '*.exe' \ 907 -o -name '*.cfgtmp' \) -print \ 908 | xargs rm -f 909 910# Removes everything not needed for testing u-boot 911tidy: clean 912 @find $(OBJTREE) -type f \( -name '*.depend*' \) -print | xargs rm -f 913 914clobber: tidy 915 @find $(OBJTREE) -type f \( -name '*.srec' \ 916 -o -name '*.bin' -o -name u-boot.img \) \ 917 -print0 | xargs -0 rm -f 918 @rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \ 919 $(obj)cscope.* $(obj)*.*~ 920 @rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL-y) 921 @rm -f $(obj)u-boot.kwb 922 @rm -f $(obj)u-boot.pbl 923 @rm -f $(obj)u-boot.imx 924 @rm -f $(obj)u-boot-with-spl.imx 925 @rm -f $(obj)u-boot-with-nand-spl.imx 926 @rm -f $(obj)u-boot.ubl 927 @rm -f $(obj)u-boot.ais 928 @rm -f $(obj)u-boot.dtb 929 @rm -f $(obj)u-boot.sb 930 @rm -f $(obj)u-boot.bd 931 @rm -f $(obj)u-boot.spr 932 @rm -f $(obj)nand_spl/{u-boot.{lds,lst},System.map} 933 @rm -f $(obj)nand_spl/{u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map} 934 @rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.map} 935 @rm -f $(obj)spl/u-boot-spl.lds 936 @rm -f $(obj)tpl/{u-boot-tpl,u-boot-tpl.bin,u-boot-tpl.map} 937 @rm -f $(obj)tpl/u-boot-spl.lds 938 @rm -f $(obj)MLO MLO.byteswap 939 @rm -f $(obj)SPL 940 @rm -f $(obj)tools/xway-swap-bytes 941 @rm -f $(obj)arch/powerpc/cpu/mpc824x/bedbug_603e.c 942 @rm -f $(obj)arch/powerpc/cpu/mpc83xx/ddr-gen?.c 943 @rm -fr $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm 944 @rm -fr $(obj)include/generated 945 @[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f 946 @rm -f $(obj)dts/*.tmp 947 @rm -f $(obj)spl/u-boot-spl{,-pad}.ais 948 949mrproper \ 950distclean: clobber unconfig 951ifneq ($(OBJTREE),$(SRCTREE)) 952 rm -rf $(obj)* 953endif 954 955backup: 956 F=`basename $(TOPDIR)` ; cd .. ; \ 957 gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F 958 959######################################################################### 960