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

uboot Makefile解析(三)

作者: QUIZ_JS | 来源:发表于2018-10-07 22:55 被阅读0次

make参数传递


设置输出目录

参数-O

# kbuild supports saving output files in a separate directory.

# To locate output files in a separate directory two syntaxes are supported.
# In both cases the working directory must be the root of the kernel src.
# 1) O=
# Use "make O=dir/to/store/output/files/"
#
# 2) Set KBUILD_OUTPUT
# Set the environment variable KBUILD_OUTPUT to point to the directory
# where the output files shall be placed.
# export KBUILD_OUTPUT=dir/to/store/output/files/
# make
#
# The O= assignment takes precedence over the KBUILD_OUTPUT environment
# variable.

Kbuild支持将输出文件保存在单独的目录中,由两种方式可以实现:
1、在命令行中设置变量O,例如:make O=dir/to/store/output/files/
2、设置变量KBUILD_OUTPUT的值,例如export KBUILD_OUTPUT=dir/to/store/output/files/ 变量O的优先级高于变量KBUILD_OUTPUT。

# KBUILD_SRC is set on invocation of make in OBJ directory
# KBUILD_SRC is not intended to be used by the regular user (for now)
ifeq ($(KBUILD_SRC),)

# OK, Make called in directory where kernel src resides
# Do we want to locate output files in a separate directory?
ifeq ("$(origin O)", "command line")
  KBUILD_OUTPUT := $(O)
endif

# That's our default target when none is given on the command line
PHONY := _all
_all:

# Cancel implicit rules on top Makefile
$(CURDIR)/Makefile Makefile: ;

ifneq ($(KBUILD_OUTPUT),)
# Invoke a second make in the output directory, passing relevant variables
# check that the output directory actually exists
saved-output := $(KBUILD_OUTPUT)
KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \
                                && /bin/pwd)
$(if $(KBUILD_OUTPUT),, \
     $(error failed to create output directory "$(saved-output)"))

PHONY += $(MAKECMDGOALS) sub-make

$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
    @:

sub-make: FORCE
    $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \
    -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))

# Leave processing to above invocation of make
skip-makefile := 1
endif # ifneq ($(KBUILD_OUTPUT),)
endif # ifeq ($(KBUILD_SRC),)

首先系统会检查变量KBUILD_SRC是否为空,它代表代码的顶层目录。如果它是空的,将会设置变量KBUILD_OUTPUT为传递给选项O的值。
然后检查变量KBUILD_OUTPUT,如果已经设置好,那么接下来会做以下几件事:
将变量KBUILD_OUTPUT的值保存到临时变量saved-output;
尝试创建给定的输出目录;
检查创建的输出目录,如果失败了就打印错误;
如果成功创建了输出目录,那么就在新目录重新执行make命令。

相关文章

  • uboot Makefile解析(三)

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

  • uboot Makefile解析(二)

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

  • uboot Makefile解析(一)

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

  • uboot Makefile解析(四)

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

  • 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/qgiraftx.html