📄 makefile
字号:
## (C) Copyright 2000-2007# Wolfgang Denk, DENX Software Engineering, wd@denx.de.## See file CREDITS for list of people who contributed to this# project.## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License as# published by the Free Software Foundatio; either version 2 of# the License, or (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place, Suite 330, Boston,# MA 02111-1307 USA#VERSION = 1PATCHLEVEL = 3SUBLEVEL = 1EXTRAVERSION = -rc1U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)VERSION_FILE = $(obj)include/version_autogenerated.hHOSTARCH := $(shell uname -m | \ sed -e s/i.86/i386/ \ -e s/sun4u/sparc64/ \ -e s/arm.*/arm/ \ -e s/sa110/arm/ \ -e s/powerpc/ppc/ \ -e s/ppc64/ppc/ \ -e s/macppc/ppc/)HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \ sed -e 's/\(cygwin\).*/cygwin/')export HOSTARCH HOSTOS# Deal with colliding definitions from tcsh etc.VENDOR=########################################################################### 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.#ifdef Oifeq ("$(origin O)", "command line")BUILD_DIR := $(O)endifendififneq ($(BUILD_DIR),)saved-output := $(BUILD_DIR)# Attempt to create a output directory.$(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR})# Verify if it was successful.BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd)$(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist))endif # ifneq ($(BUILD_DIR),)OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))SRCTREE := $(CURDIR)TOPDIR := $(SRCTREE)LNDIR := $(OBJTREE)export TOPDIR SRCTREE OBJTREEMKCONFIG := $(SRCTREE)/mkconfigexport MKCONFIGifneq ($(OBJTREE),$(SRCTREE))REMOTE_BUILD := 1export REMOTE_BUILDendif# $(obj) and (src) are defined in config.mk but here in main Makefile# we also need them before config.mk is included which is the case for# some targets like unconfig, clean, clobber, distclean, etc.ifneq ($(OBJTREE),$(SRCTREE))obj := $(OBJTREE)/src := $(SRCTREE)/elseobj :=src :=endifexport obj src#########################################################################ifeq ($(OBJTREE)/include/config.mk,$(wildcard $(OBJTREE)/include/config.mk))# load ARCH, BOARD, and CPU configurationinclude $(OBJTREE)/include/config.mkexport ARCH CPU BOARD VENDOR SOCifndef CROSS_COMPILEifeq ($(HOSTARCH),$(ARCH))CROSS_COMPILE =elseifeq ($(ARCH),ppc)CROSS_COMPILE = ppc_8xx-endififeq ($(ARCH),arm)CROSS_COMPILE = arm-linux-endififeq ($(ARCH),i386)CROSS_COMPILE = i386-linux-endififeq ($(ARCH),mips)CROSS_COMPILE = mips_4KC-endififeq ($(ARCH),nios)CROSS_COMPILE = nios-elf-endififeq ($(ARCH),nios2)CROSS_COMPILE = nios2-elf-endififeq ($(ARCH),m68k)CROSS_COMPILE = m68k-elf-endififeq ($(ARCH),microblaze)CROSS_COMPILE = mb-endififeq ($(ARCH),blackfin)CROSS_COMPILE = bfin-uclinux-endififeq ($(ARCH),avr32)CROSS_COMPILE = avr32-linux-endifendifendifexport CROSS_COMPILE# load other configurationinclude $(TOPDIR)/config.mk########################################################################## U-Boot objects....order is important (i.e. start must be first)OBJS = cpu/$(CPU)/start.oifeq ($(CPU),i386)OBJS += cpu/$(CPU)/start16.oOBJS += cpu/$(CPU)/reset.oendififeq ($(CPU),ppc4xx)OBJS += cpu/$(CPU)/resetvec.oendififeq ($(CPU),mpc85xx)OBJS += cpu/$(CPU)/resetvec.oendififeq ($(CPU),bf533)OBJS += cpu/$(CPU)/start1.o cpu/$(CPU)/interrupt.o cpu/$(CPU)/cache.oOBJS += cpu/$(CPU)/flush.o cpu/$(CPU)/init_sdram.oendififeq ($(CPU),bf537)OBJS += cpu/$(CPU)/start1.o cpu/$(CPU)/interrupt.o cpu/$(CPU)/cache.oOBJS += cpu/$(CPU)/flush.o cpu/$(CPU)/init_sdram.oendififeq ($(CPU),bf561)OBJS += cpu/$(CPU)/start1.o cpu/$(CPU)/interrupt.o cpu/$(CPU)/cache.oOBJS += cpu/$(CPU)/flush.o cpu/$(CPU)/init_sdram.oendifOBJS := $(addprefix $(obj),$(OBJS))LIBS = lib_generic/libgeneric.aLIBS += $(shell if [ -f board/$(VENDOR)/common/Makefile ]; then echo \ "board/$(VENDOR)/common/lib$(VENDOR).a"; fi)LIBS += board/$(BOARDDIR)/lib$(BOARD).aLIBS += cpu/$(CPU)/lib$(CPU).aifdef SOCLIBS += cpu/$(CPU)/$(SOC)/lib$(SOC).aendififeq ($(CPU),ixp)LIBS += cpu/ixp/npe/libnpe.aendifLIBS += lib_$(ARCH)/lib$(ARCH).aLIBS += fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a \ fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.aLIBS += net/libnet.aLIBS += disk/libdisk.aLIBS += drivers/bios_emulator/libatibiosemu.aLIBS += drivers/block/libblock.aLIBS += drivers/hwmon/libhwmon.aLIBS += drivers/i2c/libi2c.aLIBS += drivers/input/libinput.aLIBS += drivers/misc/libmisc.aLIBS += drivers/mtd/libmtd.aLIBS += drivers/mtd/nand/libnand.aLIBS += drivers/mtd/nand_legacy/libnand_legacy.aLIBS += drivers/mtd/onenand/libonenand.aLIBS += drivers/net/libnet.aLIBS += drivers/net/sk98lin/libsk98lin.aLIBS += drivers/pci/libpci.aLIBS += drivers/pcmcia/libpcmcia.aifeq ($(CPU),mpc83xx)LIBS += drivers/qe/qe.aendififeq ($(CPU),mpc85xx)LIBS += drivers/qe/qe.aendifLIBS += drivers/rtc/librtc.aLIBS += drivers/serial/libserial.aLIBS += drivers/usb/libusb.aLIBS += drivers/video/libvideo.aLIBS += post/libpost.a post/drivers/libpostdrivers.aLIBS += $(shell if [ -d post/lib_$(ARCH) ]; then echo \ "post/lib_$(ARCH)/libpost$(ARCH).a"; fi)LIBS += $(shell if [ -d post/lib_$(ARCH)/fpu ]; then echo \ "post/lib_$(ARCH)/fpu/libpost$(ARCH)fpu.a"; fi)LIBS += $(shell if [ -d post/cpu/$(CPU) ]; then echo \ "post/cpu/$(CPU)/libpost$(CPU).a"; fi)LIBS += $(shell if [ -d post/board/$(BOARDDIR) ]; then echo \ "post/board/$(BOARDDIR)/libpost$(BOARD).a"; fi)LIBS += common/libcommon.aLIBS += libfdt/libfdt.aLIBS := $(addprefix $(obj),$(LIBS)).PHONY : $(LIBS)# Add GCC libPLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc# The "tools" are needed early, so put this first# Don't include stuff already done in $(LIBS)SUBDIRS = tools \ examples.PHONY : $(SUBDIRS)ifeq ($(CONFIG_NAND_U_BOOT),y)NAND_SPL = nand_splU_BOOT_NAND = $(obj)u-boot-nand.binendif__OBJS := $(subst $(obj),,$(OBJS))__LIBS := $(subst $(obj),,$(LIBS))##################################################################################################################################################ALL += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND)all: $(ALL)$(obj)u-boot.hex: $(obj)u-boot $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@$(obj)u-boot.srec: $(obj)u-boot $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@$(obj)u-boot.bin: $(obj)u-boot $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@$(obj)u-boot.img: $(obj)u-boot.bin ./tools/mkimage -A $(ARCH) -T firmware -C none \ -a $(TEXT_BASE) -e 0 \ -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \ sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \ -d $< $@$(obj)u-boot.sha1: $(obj)u-boot.bin $(obj)tools/ubsha1 $(obj)u-boot.bin$(obj)u-boot.dis: $(obj)u-boot $(OBJDUMP) -d $< > $@$(obj)u-boot: depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT) UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\ cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \ --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \ -Map u-boot.map -o u-boot$(OBJS): $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))$(LIBS): $(MAKE) -C $(dir $(subst $(obj),,$@))$(SUBDIRS): $(MAKE) -C $@ all$(NAND_SPL): version $(MAKE) -C nand_spl/board/$(BOARDDIR) all$(U_BOOT_NAND): $(NAND_SPL) $(obj)u-boot.bin cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.binversion: @echo -n "#define U_BOOT_VERSION \"U-Boot " > $(VERSION_FILE); \ echo -n "$(U_BOOT_VERSION)" >> $(VERSION_FILE); \ echo -n $(shell $(CONFIG_SHELL) $(TOPDIR)/tools/setlocalversion \ $(TOPDIR)) >> $(VERSION_FILE); \ echo "\"" >> $(VERSION_FILE)gdbtools: $(MAKE) -C tools/gdb all || exit 1updater: $(MAKE) -C tools/updater all || exit 1env: $(MAKE) -C tools/env all || exit 1depend dep: version for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir _depend ; doneTAG_SUBDIRS += includeTAG_SUBDIRS += lib_generic board/$(BOARDDIR)TAG_SUBDIRS += cpu/$(CPU)TAG_SUBDIRS += lib_$(ARCH)TAG_SUBDIRS += fs/cramfsTAG_SUBDIRS += fs/fatTAG_SUBDIRS += fs/fdosTAG_SUBDIRS += fs/jffs2TAG_SUBDIRS += netTAG_SUBDIRS += diskTAG_SUBDIRS += commonTAG_SUBDIRS += drivers/bios_emulatorTAG_SUBDIRS += drivers/blockTAG_SUBDIRS += drivers/hwmonTAG_SUBDIRS += drivers/i2cTAG_SUBDIRS += drivers/inputTAG_SUBDIRS += drivers/miscTAG_SUBDIRS += drivers/mtdTAG_SUBDIRS += drivers/mtd/nandTAG_SUBDIRS += drivers/mtd/nand_legacyTAG_SUBDIRS += drivers/mtd/onenandTAG_SUBDIRS += drivers/netTAG_SUBDIRS += drivers/net/sk98linTAG_SUBDIRS += drivers/pciTAG_SUBDIRS += drivers/pcmciaTAG_SUBDIRS += drivers/qeTAG_SUBDIRS += drivers/rtcTAG_SUBDIRS += drivers/serialTAG_SUBDIRS += drivers/usbTAG_SUBDIRS += drivers/videotags ctags: ctags -w -o $(OBJTREE)/ctags `find $(SUBDIRS) $(TAG_SUBDIRS) \ -name '*.[ch]' -print`etags: etags -a -o $(OBJTREE)/etags `find $(SUBDIRS) $(TAG_SUBDIRS) \ -name '*.[ch]' -print`$(obj)System.map: $(obj)u-boot @$(NM) $< | \ grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ sort > $(obj)System.map## Auto-generate the autoconf.mk file (which is included by all makefiles)## This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.# the dep file is only include in this top level makefile to determine when# to regenerate the autoconf.mk file.$(OBJTREE)/include/autoconf.mk: $(obj)include/config.h @echo Generating include/autoconf.mk @# Generate the dependancies @$(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) -MQ $@ include/common.h > $@.dep @# Extract the config macros @$(CPP) $(CFLAGS) -dM include/common.h | sed -n -f tools/scripts/define2mk.sed >> $@sinclude $(OBJTREE)/include/autoconf.mk.dep#########################################################################elseall $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \$(obj)u-boot.img $(obj)u-boot.dis $(obj)u-boot \$(SUBDIRS) version gdbtools updater env depend \dep tags ctags etags $(obj)System.map: @echo "System not configured - see README" >&2 @ exit 1endif.PHONY : CHANGELOGCHANGELOG: git log --no-merges U-Boot-1_1_5.. | \ unexpand -a | sed -e 's/\s\s*$$//' > $@#########################################################################unconfig: @rm -f $(obj)include/config.h $(obj)include/config.mk \ $(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \ $(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep#========================================================================# PowerPC#========================================================================########################################################################### MPC5xx Systems#########################################################################canmb_config: unconfig @$(MKCONFIG) -a canmb ppc mpc5xxx canmbcmi_mpc5xx_config: unconfig @$(MKCONFIG) $(@:_config=) ppc mpc5xx cmiPATI_config: unconfig
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -