makefile源码分析

# (C) Copyright(版权) 2000-2006

# Wolfgang Denk(人名), DENX Software Engineering(denx软件工程师), wd@denx.de.(邮箱)

# See file CREDITS for list of people who contributed to thisproject.

#在文件中查看对项目有贡献的人人的名单

# 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. (merchantability(商业性的) or fitness for a particular(特别) poupose) 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 = 1 PATCHLEVEL = 1 SUBLEVEL = 6 EXTRAVERSION =

U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) // VERSION_FILE = $(obj)include/version_autogenerated.h

HOSTARCH := $(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/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 O

ifeq (\BUILD_DIR := $(O) endif endif

ifneq ($(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 \endif # ifneq ($(BUILD_DIR),)

OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR)) SRCTREE := $(CURDIR) TOPDIR := $(SRCTREE) LNDIR := $(OBJTREE)

export TOPDIR SRCTREE OBJTREE

MKCONFIG := $(SRCTREE)/mkconfig export MKCONFIG

ifneq ($(OBJTREE),$(SRCTREE)) REMOTE_BUILD := 1 export REMOTE_BUILD endif

# $(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)/ else obj := src := endif

export obj src

#########################################################################

ifeq ($(OBJTREE)/include/config.mk,$(wildcard $(OBJTREE)/include/config.mk))

# load ARCH, BOARD, and CPU configuration include $(OBJTREE)/include/config.mk export ARCH CPU BOARD VENDOR SOC

ifndef CROSS_COMPILE ifeq ($(HOSTARCH),ppc) CROSS_COMPILE = else

ifeq ($(ARCH),ppc)

CROSS_COMPILE = powerpc-linux- endif

ifeq ($(ARCH),arm)

CROSS_COMPILE = arm-linux- endif

ifeq ($(ARCH),i386)

ifeq ($(HOSTARCH),i386) CROSS_COMPILE = else

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4