s3c6410_U-boot Makefile分析(一)

U-boot Makefile分析(一)

VERSION = 2011

PATCHLEVEL = 09

SUBLEVEL =

EXTRAVERSION =

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版本号变量U_BOOT_VERSION、时间戳头文件TIMESTAMP_FILE及版本信息头文件VERSION_FILE

HOSTARCH := $(shell uname -m | \

         sed -e s/i.86/x86/ \

             -e s/sun4u/sparc64/ \

             -e s/arm.*/arm/ \

             -e s/sa110/arm/ \

             -e s/ppc64/powerpc/ \

             -e s/ppc/powerpc/ \

             -e s/macppc/powerpc/\

             -e s/sh.*/sh/)

 

HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \

             sed -e 's/\(cygwin\).*/cygwin/')

定义利用shell函数初始化主机(Host)架构变量HOSTARCH、主机操作系统变量HOSTOS,可能的话使用sed编辑器替换成标准名字

# 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)

 

export        HOSTARCH HOSTOS SHELL

转化自定义变量 HOSTARCH HOSTOS SHELL成系统环境变量

# Deal with colliding definitions from tcsh etc.

VENDOR=

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

# Allow for silent builds

ifeq (,$(findstring s,$(MAKEFLAGS)))

XECHO = echo

else

XECHO = :

endif

 

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

当make使用–s参数时,不打印一些过程信息

ifdef O

ifeq ("$(origin O)", "command line")

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 "$(saved-output)" does not exist))

endif # ifneq ($(BUILD_DIR),)

 

OBJTREE             := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))

SPLTREE              := $(OBJTREE)/spl

SRCTREE             := $(CURDIR)

TOPDIR                := $(SRCTREE)

LNDIR                  := $(OBJTREE)

export        TOPDIR SRCTREE OBJTREE SPLTREE

 

MKCONFIG          := $(SRCTREE)/mkconfig

export MKCONFIG

 

ifneq ($(OBJTREE),$(SRCTREE))

REMOTE_BUILD  := 1

export REMOTE_BUILD

endif

Makefile支持编译的*.o文件存储在源文件之外的其它路径下,当make 命令行中有定义路径变量O,makefile脚本从命令行中提取出*.o文件路径BUILD_DIR。

OBJTREE             := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))

SPLTREE              := $(OBJTREE)/spl

SRCTREE             := $(CURDIR)

TOPDIR                := $(SRCTREE)

LNDIR                  := $(OBJTREE)

export        TOPDIR SRCTREE OBJTREE SPLTREE

初始化一些路径变量


你可能感兴趣的:(c,shell,bash,Build,makefile,output)