編譯u-boot的步驟:
#make XX_config XX表示某個cpu體系
#make 生成我們需要的u-boot.bin
具體可參考u-boot文件中的README。
1.設置版本
VERSION = 2010
PATCHLEVEL = 06
SUBLEVEL =
EXTRAVERSION = -rc1
ifneq "$(SUBLEVEL)" ""
U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
else
U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL)$(EXTRAVERSION)
endif
TIMESTAMP_FILE = $(obj)include/timestamp_autogenerated.h
VERSION_FILE = $(obj)include/version_autogenerated.h
以上定義了版本的變量U_BOOT_VERSION。
2.獲取主機類型和主機系統
HOSTARCH := $(shell uname -m | \ 執行shell命令 uname -m 查看主機類型
sed -e s/i.86/i386/ \
-e s/sun4u/sparc64/ \
-e s/arm.*/arm/ \
-e s/sa110/arm/ \
-e s/ppc64/powerpc/ \
-e s/ppc/powerpc/ \
-e s/macppc/powerpc/)
sed -e命令進行替換,比如將i386替換成i.86,並將結果放入變量HOSTARCH 。
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
sed -e 's/\(cygwin\).*/cygwin/')
uname -s 查看主機操作系統,tr '[:upper:]' '[:lower:]'將所有大寫變小寫,然後假如有cygwin,替換成cygwin.*,並將結果放入變量HOSTOS
# Set shell to bash if possible, otherwise fall back to sh
SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi; fi)
選擇/bin/bash
export HOSTARCH HOSTOS SHELL
導出變量HOSTARCH HOSTOS SHELL
LC_ALL=C
export LC_ALL
# Deal with colliding definitions from tcsh etc.
VENDOR=
變量為空
#########################################################################
# Allow for silent builds
ifeq (,$(findstring s,$(MAKEFLAGS)))
XECHO = echo
else
XECHO = :
endif
#########################################################################
#
# U-boot build supports producing a object files to the separate external
# directory. Two use cases are supported:
#
# 1) Add O= to the make command line
# 'make O=/tmp/build all'
#
# 2) Set environement variable BUILD_DIR to point to the desired location
# 'export BUILD_DIR=/tmp/build'
# 'make'
#
# The second approach can also be used with a MAKEALL script
# 'export BUILD_DIR=/tmp/build'
# './MAKEALL'
#
# Command line 'O=' setting overrides BUILD_DIR environent variable.
#
# When none of the above methods is used the local build is performed and
# the object files are placed in the source directory.
#
U-boot 生成一個目標文件來分開外面的文件夾,支持兩種方式:
1)將 0= 加到make命令行如:
make 0=/tmp/build all
2) 通過設置全局環境變量BUILD_DIR如:
export BUILD_DIR=/tmp/build
make
第二種方式也可以用MAKEFILE腳本
export BUILD_DIR=/tmp/build
./MAKEALL
通過第一種方式會覆蓋環境變量 BUILD_DIR
如果沒有顯式指定使用哪種方式,編譯腳本會自動進行本地編譯,目標文件被存放在當前文件夾裡