• builtroot make menuconfig流程


    本文主要介绍一下,buildroot(buildroot-2018.02.1)的make menuconfig。众所周知,在我们执行menuconfig时,会生成一个图形化界面,然后进行相关的配置。同样,kernel 也有同样的配置方式,buildroot应该是借鉴kernel的。

    那么,这个界面到底是怎样生成的呢?接下来,我来详细的介绍。

    1. 顶层Makefile解析

    1 menuconfig: $(BUILD_DIR)/buildroot-config/mconf prepare-kconfig
    2     $(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)

    首先看依赖项,有两个,mconf和prepare-kconfig,ok,一个一个解决。

     1 HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
     2 $(info ${HOSTCFLAGS})
     3 $(info $(origin CFLAGS_FOR_BUILD))
     4 export HOSTCFLAGS
     5 
     6 #mkdir -p /home/frank/test/buildroot/buildroot-2018.02.1/output/build/buildroot-config/lxdialog
     7 #PKG_CONFIG_PATH="" make CC="/usr/bin/gcc" HOSTCC="/usr/bin/gcc" 
     8                 obj=/home/frank/test/buildroot/buildroot-2018.02.1/output/build/buildroot-config -C support/kconfig -f Makefile.br mconf
     9 .PHONY: prepare-kconfig
    10 prepare-kconfig: outputmakefile $(BUILD_DIR)/.br2-external.in
    11     $(Q) echo "1111111111111"
    12 $(BUILD_DIR)/buildroot-config/%onf:--->$(BUILD_DIR)/buildroot-config/mconf
    13     mkdir -p $(@D)/lxdialog
    14     $(info $(HOST_PKG_CONFIG_PATH))
    15     $(info $(origin HOST_PKG_CONFIG_PATH))
    16     $(info $(MAKE))
    17     $(info $(origin MAKE))
    18     $(info $(HOSTCC_NOCCACHE))
    19     $(info $(origin HOSTCC_NOCCACHE))
    20     PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" 
    21         obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
    22 
    23 DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
    24 
    25 # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
    26 # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
    27 # BR2_DEFCONFIG='' KCONFIG_AUTOCONFIG=/home/frank/test/buildroot/buildroot-2018.02.1/output/build/buildroot-config/auto.conf KCONFIG_AUTOHEADER=/home/frank/test/buildroot/buildroot-2018.02.1/output/build/buildroot-config/autoconf.h KCONFIG_TRISTATE=/home/frank/test/buildroot/buildroot-2018.02.1/output/build/buildroot-config/tristate.config BR2_CONFIG=/home/frank/test/buildroot/buildroot-2018.02.1/.config HOST_GCC_VERSION="4 8" BUILD_DIR=/home/frank/test/buildroot/buildroot-2018.02.1/output/build SKIP_LEGACY= /home/frank/test/buildroot/buildroot-2018.02.1/output/build/buildroot-config/mconf Config.in
    31 32 COMMON_CONFIG_ENV = 
    33     BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' 
    34     KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf 
    35     KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h 
    36     KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config 
    37     BR2_CONFIG=$(BR2_CONFIG) 
    38     HOST_GCC_VERSION="$(HOSTCC_VERSION)" 
    39     BUILD_DIR=$(BUILD_DIR) 
    40     SKIP_LEGACY=
    prepare-kconfig又依赖 outputmakefile 和 $(BUILD_DIR)/.br2-external.in
     1 # outputmakefile generates a Makefile in the output directory, if using a
     2 # separate output directory. This allows convenient use of make in the
     3 # output directory.
     4 .PHONY: outputmakefile
     5 outputmakefile:
     6     echo $(origin NEED_WRAPPER)
     7     echo $(origin Q)
     8     echo $(origin TOPDIR)
     9     echo $(origin O)
    10     echo ${NEED_WRAPPER}
    11 ifeq ($(NEED_WRAPPER),y)
    12     $(info "xxxxxxx")
    13     $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
    14 endif
    15 
    16 # Even though the target is a real file, we mark it as PHONY as we
    17 # want it to be re-generated each time make is invoked, in case the
    18 # value of BR2_EXTERNAL is changed.
    19 # support/scripts/br2-external -k -o "/home/frank/test/buildroot/buildroot-2018.02.1/output/build/.br2-external.in"
    20 .PHONY: $(BUILD_DIR)/.br2-external.in
    21 $(BUILD_DIR)/.br2-external.in: $(BUILD_DIR)
    22     $(Q)support/scripts/br2-external -k -o "$(@)" $(BR2_EXTERNAL)

    outputmakefile主要是 看 NEED_WRAPPER的值,由于执行make menuconfig时,NEED_WRAPPER的条件并不满足,所以当前outputmakefile这个目标并没有执行什么实际的动作。

    $(BUILD_DIR)/.br2-external.in的作用是 生成.br2-external.in文件,在上面的#19行 已经指出了具体的执行命令。当前并没有太大作用,所以不做过多说明了。

    接着我们再看$(BUILD_DIR)/buildroot-config/%onf,主要就是

    PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)"
    obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)

    这行命令生成了mconf可执行程序。非常重要的节点。

    接下来再执行$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN),即 mconf Config.ini,那么最开始给出的图形界面就弹出来了。

    备注:上述的Makefile中我自己加了一些调试代码,如$(info ), echo

  • 相关阅读:
    动态规划(决策单调优化):BZOJ 4518 [Sdoi2016]征途
    数据结构(树链剖分,线段树):SDOI 2016 游戏
    图论(费用流):BZOJ 4514 [Sdoi2016]数字配对
    搜索(四分树):BZOJ 4513 [SDOI2016 Round1] 储能表
    数据结构(KD树):HDU 4347 The Closest M Points
    数学(逆元):BZOJ 2186: [Sdoi2008]沙拉公主的困惑
    数学:UVAoj 11174 Stand in a Line
    线性代数(矩阵乘法):POJ 2778 DNA Sequence
    线性代数(矩阵乘法):NOI 2007 生成树计数
    线性代数(矩阵乘法):POJ 3233 Matrix Power Series
  • 原文地址:https://www.cnblogs.com/black-mamba/p/8888539.html
Copyright © 2020-2023  润新知