美文网首页
uboot Makefile解析(四)

uboot Makefile解析(四)

作者: QUIZ_JS | 来源:发表于2018-10-12 08:14 被阅读0次

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和其他变量为这个目录,并且将这些变量导出

相关文章

  • uboot Makefile解析(四)

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

  • uboot Makefile解析(二)

    make参数传递 Uboot的编译需要找到并配置所需的配置文件,make命令要使用到的参数都需要从这些配置文件获取...

  • uboot Makefile解析(三)

    make参数传递 设置输出目录 参数-O Kbuild支持将输出文件保存在单独的目录中,由两种方式可以实现:1、在...

  • uboot Makefile解析(一)

    版本信息 uboot版本信息在makefile显示为: VERSION:主板本号PATCHLEVEL:次版本号SU...

  • uboot Makefile解析(五)

    获取系统架构 HOSTARCH 的值代表当前系统CPU的架构$(shell xxxx)相当于在linux中输入xx...

  • 小白视角看uboot makefile

    要了解uboot的结构,最好的办法就是看uboot根目录下的Makefile。作为小白,第一次看Makefile时...

  • uboot完全详细讲解(二)

    一、uboot主Makefile分析 内容源于朱有鹏物联网大讲堂的笔记 (1)uboot的版本号分3个级别: VE...

  • Makefile 进阶笔记

    1. 项目结构 1. Makefile概览 整体的一个Makefile 如下 2. Makefile头部解析 OP...

  • Makefile 解析

    最简约的 Makefile 文件如下 只要列出详细的源文件路径, OBJ 直接从 SRC 替换 .c 得来, 然后...

  • makefile | makefile语法基础

    makefile是为make指令提供信息的文件。make指令直接解析makefile。因此我们从make指令的起源...

网友评论

      本文标题:uboot Makefile解析(四)

      本文链接:https://www.haomeiwen.com/subject/viiiaftx.html