uboot Makefile解析(四)

make参数传递


参数-C

# We process the rest of the Makefile if this is the final invocation of make
ifeq ($(skip-makefile),)

# Do not print "Entering directory ...",
# but we want to display it when entering to the output directory
# so that IDEs/editors are able to understand relative filenames.
MAKEFLAGS += --no-print-directory

# Call a source code checker (by default, "sparse") as part of the
# C compilation.
#
# Use 'make C=1' to enable checking of only re-compiled files.
# Use 'make C=2' to enable checking of *all* source files, regardless
# of whether they are re-compiled or not.
#
# See the file "Documentation/sparse.txt" for more details, including
# where to get the "sparse" utility.

ifeq ("$(origin C)", "command line")
  KBUILD_CHECKSRC = $(C)
endif
ifndef KBUILD_CHECKSRC
  KBUILD_CHECKSRC = 0
endif

首先检查了skip-makefile ,这个变量在配置选项O的时候设置为1
然后ifeq语句会检查传递给make的选项C


参数 -M

用来编译外部模块

# Use make M=dir to specify directory of external module to build
# Old syntax make ... SUBDIRS=$PWD is still supported
# Setting the environment variable KBUILD_EXTMOD take precedence
ifdef SUBDIRS
  KBUILD_EXTMOD ?= $(SUBDIRS)
endif

ifeq ("$(origin M)", "command line")
  KBUILD_EXTMOD := $(M)
endif

# If building an external module we do not care about the all: rule
# but instead _all depend on modules
PHONY += all
ifeq ($(KBUILD_EXTMOD),)
_all: all
else
_all: modules
endif

设置objtree

OBJTREE:编译出的.o文件存放的目录的根目录;
在默认编译下,OBJTREE等于当前目录;
在O=xx编译下,OBJTREE就等于我们设置的那个输出目录。
SRCTREE: 源码目录,其实就是源代码的根目录,也就是当前目录。

ifeq ($(KBUILD_SRC),)
        # building in the source tree
        srctree := .
else
        ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
                # building in a subdirectory of the source tree
                srctree := ..
        else
                srctree := $(KBUILD_SRC)
        endif
endif
objtree     := .
src     := $(srctree)
obj     := $(objtree)

VPATH       := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))

export srctree objtree VPATH

系统检查了变量KBUILD_SRC ,如果KBUILD_SRC 未设置,系统会设置变量srctree为当前目录。
设置objtree和其他变量为这个目录,并且将这些变量导出

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 官网 中文版本 好的网站 Content-type: text/htmlBASH Section: User ...
    不排版阅读 4,434评论 0 5
  • 来自陈浩的一片老文,但绝对营养。 示例工程:3 个头文件*.h,和 8 个 C 文件*.c。 初 编译过程,源文件...
    周筱鲁阅读 4,727评论 0 17
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,841评论 18 139
  • 随着就业形势的严峻,越来越多的大学生投入到创业的领域中来,那么对于这样一个特殊的群体,如何才能在创业的大潮中找到适...
    LD丹哥阅读 436评论 0 1
  • 躲在天真花冠之后 苹果蓓蕾恍如待嫁新娘般惊悸又忠诚 要寻找澄蓝的幸福 野蘑菇已娉婷勃发 树熊脱下冬袄 想在天使的酒...
    常梵阅读 174评论 0 0