Linux移植之make uImage编译过程分析中分析了uImage文件产生的过程,在uImage产生的过程中,顺带还产生了其它的一些中间文件。这里主要介绍几个比较关键的文件

1、linux-2.6.22.6\include\config\auto.conf、inux-2.6.22.6\include\linux\autoconf.h文件的生成过程

2、include\asm-arm\Mach-types.h文件的生成过程

1、inux-2.6.22.6\include\config\auto.conf、inux-2.6.22.6\include\linux\autoconf.h文件的生成过程

在顶层Makefile中尝试寻找auto.conf,找到如下信息:可以看到顶层Makefile中需要包含-include include/config/auto.conf、-include include/config/auto.conf.cmd。-include表示即使文件不存在也不会报错。

    # Read in config
-include include/config/auto.conf ifeq ($(KBUILD_EXTMOD),)
# Read in dependencies to all Kconfig* files, make sure to run
# oldconfig if changes are detected.
-include include/config/auto.conf.cmd # To avoid any implicit rule to kick in, define an empty command
$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; # If .config is newer than include/config/auto.conf, someone tinkered
# with it and forgot to run make oldconfig.
# if auto.conf.cmd is missing then we are probably in a cleaned tree so
# we execute the config step to be sure to catch updated Kconfig files
include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
$(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig

继续分析生成include/config/auto.conf目标的语句

    include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
$(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig

可以看到依赖KCONFIG_CONFIG其实就是.config

    KCONFIG_CONFIG    ?= .config
依赖include/config/auto.conf.cmd,这条语句知道,该语句中的目标没有依赖,也没有生成它的规则命令,所以可想GNU Make本身无法生成auto.conf.cmd 的。
    $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
然后该条语句后面的一个分号表明,这两个目标被强制是最新的,所以下面这条命令得以执行:
        $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig

继续往下分析发现这条命令是执行顶层的Makefile生成silentoldconfig目标。找到生成这个目标的规则:

    config %config: scripts_basic outputmakefile FORCE
$(Q)mkdir -p include/linux include/config
$(Q)$(MAKE) $(build)=scripts/kconfig $@

这个规则在Linux移植之配置过程分析已经分析过。所以直接去到scripts/kconfig/Makefile找到silentoldconfig目标的规则:

    silentoldconfig: $(obj)/conf
$< -s arch/$(ARCH)/Kconfig

可以看到它依赖于scripts/kconfig/conf这个程序,这个程序的编译过程就不分析了,继续看到规则,将规则展开得到

        conf -s arch/arm/Kconfig

所以需要知道conf的功能,那么就去要看它的源码。在这里简单说明一下它的功能:其实就是调用.config文件,保证了 .config 已经最新后,那么调用 conf_write_autoconf() 生成 auto.conf,auto.conf.cmd 以及 autoconf.h 这 3 个文件。详情分析参考https://blog.csdn.net/lcw_202/article/details/6661364

2、include\asm-arm\Mach-types.h文件的生成过程,在分析内核源码时发现这个文件如果没有编译的话是不存在的,它存放着单板机器编码,这个编码就是与uboot传入的编码比较的。比如#define MACH_TYPE_S3C2440              362。

来到arch/arm/Makefile文件中,看到如下几条命令:

    maketools: include/linux/version.h include/asm-arm/.arch FORCE
$(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h

这个分析过程类似于第一点产生文件的过程,来到arch/arm/tools/Makefile中,可以看到nclude/asm-arm/mach-types.h是由

    include/asm-arm/mach-types.h: $(src)/gen-mach-types $(src)/mach-types
@echo ' Generating $@'
$(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }

将第9行命令展开得到,它的意思是利用arch/arm/tools/mach-types程序产生include/asm-arm/mach-types.h文件,如果不成功,则删除。其中arch/arm/tools/mach-types是内核一开始就做好的工具。

awk -f arch/arm/tools/gen-mach-types arch/arm/tools/mach-types > include/asm-arm/mach-types.h || { rm -f include/asm-arm/mach-types.h; /bin/false; }
 

Linux移植之auto.conf、autoconf.h、Mach-types.h的生成过程简析的更多相关文章

  1. [C++]Linux之头文件sys/types.h[/usr/include/sys]

    1.查找<sys/types.h>文件 一般地,Linux的C头文件<sys/types.h>路径在如题的途径:/usr/include/sys下,然而博主[Linux For ...

  2. 《Linux内核Makefile分析》之 auto.conf, auto.conf.cmd, autoconf.h【转】

    转自:http://blog.sina.com.cn/s/blog_87c063060101l25y.html 转载:http://blog.csdn.net/lcw_202/article/deta ...

  3. Linux移植之make uImage编译过程分析

    编译出uboot可以运行的linux内核代码的命令是make uImage,下面详细介绍下生成linux-2.6.22.6/arch/arm/boot/uImage的过程: 1.vmlinux.Ima ...

  4. Linux移植之tag参数列表解析过程分析

    在Linux移植之内核启动过程start_kernel函数简析中已经指出了start_kernel函数的调用层次,这篇主要是对具体的tag参数列表进行解析. 1.内存参数ATAG_MEM参数解析 2. ...

  5. linux移植问题汇总(一)

    linux移植问题汇总(一) 在此记录移植linux过程中出现的问题以及解决方法. 项目GitHub地址 linux3.0.80:https://github.com/numbqq/linux-3.0 ...

  6. 三种嵌入式web服务器(Boa / lighttpd / shttpd)的 linux移植笔记

    一:移植Boa(web服务器)到嵌入式Linux系统 一.Boa程序的移植 1.下载Boa源码    下载地址: http://www.boa.org/    目前最新发行版本: 0.94.13   ...

  7. Linux移植之内核启动过程引导阶段分析

    在Linux移植之make uImage编译过程分析中已经提到了uImage是一个压缩的包并且内含压缩程序,可以进行自解压.自解压完成之后内核代码从物理地址为0x30008000处开始运行.下面分析在 ...

  8. Linux移植随笔:对tslib库的ts_test测试程序代码的一点分析【转】

    转自:http://www.latelee.org/embedded-linux/porting-linux-tstest-code.html 本文是作者对tslib库的ts_test.c文件进行分析 ...

  9. freescale-sdk linux移植一搭建编译环境脚本host-prepare.sh分析

    接下来使用自己的课外歇息时间,对基于PowerPC架构freescale-sdk,进行linux移植和分析.主要參考官方文档freescale linux sdk START_HERE.html,首先 ...

随机推荐

  1. linux console 显示颜色【转】

    http://blog.csdn.net/hejinjing_tom_com/article/details/12162491 引言: 由于在c代码中看到过打印彩色字, 又对PS1 想进一步了解,才有 ...

  2. Nginx深度优化

    简介 1.隐藏版本号2.修改Nginx用户与组3.配置Nginx网页缓存时间4.实现Nginx的日志切割5.配置Nginx实现连接超时6.更改进程数7.配置Nginx实现网页压缩功能8.配置Nginx ...

  3. 使用qt creator4.XXX,b编辑和调试caffe,太好用了

    一直想看caffe的源代码,网上看了一个qt的例子,但是自己也有qt creator,怎么就不行 后面发现是自己的版本太低所以不好用(可能是自己能力有限) 可以参考下面这个链接: 使用qt creat ...

  4. base64 压缩图片

    //图片处理 afterimg(err, photos) { var _this = this; if(err && err != null && err != '') ...

  5. Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test)

    这是因为测试代码时遇到错误,它会停止编译.只需要在pom.xml的<project>里添加以下配置,使得测试出错不影响项目的编译.<build> <plugins> ...

  6. python文件操作之二进制

    列表项 三元运算符号: a=3 b=7 val=a if a>b else val=b print(val) 文件处理 首先给你一个文件,或者自己建立一个文件,那如何查看文件的内容呢? 1.安装 ...

  7. 材料订单不在IN_MO或者IN_SCFHEADER中

    select * from in_sfcheader where MO_ID IN('001600044481'); SELECT * FROM in_sfcheader_temp where MO_ ...

  8. cdh 安装系列3--cdh manager 安装 cdh 6.01 版本

    安装前提是cdh manager 已经可以通过admin登录,管理台安装在192.168.20.163 一.安装自动TLS Setup Auto-TLS 1.ssh 192.168.20.163 2. ...

  9. 解题6(OutputNMin)

    题目描述 输入n个整数,输出其中最小的k个. 详细描述: 接口说明 原型: bool GetMinK(unsignedint uiInputNum, int * pInputArray, unsign ...

  10. 【MongoDB】关于无法连接mongo的问题

    今天使用MongoDB的时候发现直接输入mongo提示连接失败 首先想到的可能是服务还没启动 当我随便打开一个cmd输入net start MongoDB 提示:net start mongodb 发 ...