Linux移植之auto.conf、autoconf.h、Mach-types.h的生成过程简析

发布者:science56最新更新时间:2024-08-26 来源: cnblogs关键字:Linux移植  auto  conf 手机看文章 扫描二维码
随时随地手机看文章

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


1、linux-2.6.22.6includeconfigauto.conf、inux-2.6.22.6includelinuxautoconf.h文件的生成过程


2、includeasm-armMach-types.h文件的生成过程


1、inux-2.6.22.6includeconfigauto.conf、inux-2.6.22.6includelinuxautoconf.h文件的生成过程


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


442    # Read in config

443    -include include/config/auto.conf

444

445    ifeq ($(KBUILD_EXTMOD),)

446    # Read in dependencies to all Kconfig* files, make sure to run

447    # oldconfig if changes are detected.

448    -include include/config/auto.conf.cmd

449

450    # To avoid any implicit rule to kick in, define an empty command

451    $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;

452

453    # If .config is newer than include/config/auto.conf, someone tinkered

454    # with it and forgot to run make oldconfig.

455    # if auto.conf.cmd is missing then we are probably in a cleaned tree so

456    # we execute the config step to be sure to catch updated Kconfig files

457    include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd

458        $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig


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


457    include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd

458        $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig

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


192    KCONFIG_CONFIG    ?= .config

依赖include/config/auto.conf.cmd,这条语句知道,该语句中的目标没有依赖,也没有生成它的规则命令,所以可想GNU Make本身无法生成auto.conf.cmd 的。

451    $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;

然后该条语句后面的一个分号表明,这两个目标被强制是最新的,所以下面这条命令得以执行:

458        $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig

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


416    config %config: scripts_basic outputmakefile FORCE

417        $(Q)mkdir -p include/linux include/config

418        $(Q)$(MAKE) $(build)=scripts/kconfig $@

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


22    silentoldconfig: $(obj)/conf

23        $< -s arch/$(ARCH)/Kconfig

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


23        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、includeasm-armMach-types.h文件的生成过程,在分析内核源码时发现这个文件如果没有编译的话是不存在的,它存放着单板机器编码,这个编码就是与uboot传入的编码比较的。比如#define MACH_TYPE_S3C2440              362。


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


221    maketools: include/linux/version.h include/asm-arm/.arch FORCE

222        $(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h

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


7    include/asm-arm/mach-types.h: $(src)/gen-mach-types $(src)/mach-types

8    @echo '  Generating $@'

9    $(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 引用地址:Linux移植之auto.conf、autoconf.h、Mach-types.h的生成过程简析

上一篇:Linux移植之子目录下的built-in.o生成过程分析
下一篇:Linux移植之make uImage编译过程分析

推荐阅读最新更新时间:2026-03-20 12:06

关于STM32F103 V3.5.0固件库stm32f10x_conf.h文件
最近项目使用STM32,又重新熟悉了一下STM32的工程建立与程序设计,总结了一下,发现了之前没有发现的技巧与设置。 关于STM32F103 的V3.5.0固件库,使用起来,挺方便,移植性也不错,当然,如果使用Keil uVesion4开始的话,首先需要设置好工作环境,才可以正常的编译。 为什么会有:main.c里面怎么来的stm32f10x_conf.h文件? 我搜索了一下代码,发现来自:主头文件 #include stm32f10x.h 若是使用ST公司为STM32开发的固件库,就会包括头文件:stm32f10x_conf.h。 打开stm32f10x_conf.h文件一看,原来,只有:#include st
[单片机]
关于STM32F103 V3.5.0固件库stm32f10x_<font color='red'>conf</font>.<font color='red'>h</font>文件
【IMX6ULL学习笔记】九、Linux内核移植
一、在 Linux 中添加自己的开发板 1、添加开发板默认配置文件 将 arch/arm/configs 目 录 下 的 imx_v7_mfg_defconfig 重新复制一份,命名为 imx_kodo_emmc_defconfig,命令如下: cd arch/arm/configs cp imx_v7_mfg_defconfig imx_kodo_emmc_defconfig 以后就可以使用如下命令来配置正点原子 EMMC 版开发板对应的 Linux 内核了: make imx_kodo_emmc_defconfig 2、添加开发板对应的设备树文件 添加适合 EMMC 版开发板的设备树文件,进入目录 arch/arm/b
[单片机]
【IMX6ULL学习笔记】九、<font color='red'>Linux</font>内核<font color='red'>移植</font>
imx6ull之linux内核移植
开发板:飞凌 OKMX6ULL-S + 7寸电阻屏 交叉编译工具链:gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf linux内核:linux-imx-rel_imx_4.1.15_2.1.0_ga.tar.bz2 一、内核编译   1、将内核通过ftp上传至linux虚拟机,解压:tar -jxvf linux-imx-rel_imx_4.1.15_2.1.0_ga.tar.bz2   2、修改Makefile     cd linux-imx-rel_imx_4.1.15_2.1.0_ga/     vi Makefile     跳至252行(252G),复制2行(
[单片机]
imx6ull之<font color='red'>linux</font>内核<font color='red'>移植</font>
S5PV210之beep驱动从linux2.6.35.7移植linux3.0.8
beep驱动从linux2.6.35.7内核移植到linux3.0.8,修改的部分为:   '='后面的为修改后的   .ioctl  =  .unlocked_ioctl   static int beep_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)   = static int beep_ioctl(struct file *file, unsigned int cmd, unsigned long arg)   beep_ioctl函数中struct inode *inode去掉,原因是b
[单片机]
u-boot 移植 --->6、引导Linux启动测试
在引导Linux开机之前需要先清楚Linux启动的必要或者说是先决条件,这里就是提到了u-boot的作用了引用百度云---主要用于嵌入式系统的引导加载,其实在我调试下来总结一下就是初始化硬件这里的硬件包括必要部分和不必要的部分,比如SOC的时钟,外部RAM(DDR内存),栈等。因为linux的内核相对于SOC内部的RAM而言还是比较庞大的,并且运行Linux的SOC的主频普遍是比较高的,受限于flash的访问速度,Linux肯定是不能像单片机的程序一样放在片上flash运行的,毕竟在48M以上的时候常见的单片机都是需要加wait以匹配CPU和flash的速度差距了。所以u-boot一定的需要先初始化好RAM(DDR)然后将linu
[单片机]
linux内核移植到S5pv210
make s5pv210_defconfig 1.System Type --- (0) S3C UART to use for low-level messages 2.Kernel hacking --- Kernel low-level debugging functions (0) S3C UART to use for low-level debug 3.移植nand驱动 4.Device Drivers --- * Memory Technology Device (MTD) support ---    * Direct char device access to MTD devices   -*- C
[单片机]
Linux 蓝牙系列 -- ARM-Linux蓝牙工具的移植
一 内核修改 ------------------------------------------------------------ 将内核的蓝牙做成模块形式。 并配置如下, Bluetooth subsystem support --- L2CAP protocol support SCO links support RFCOMM protocol support RFCOMM TTY support BNEP protocol support HIDP protocol support (NEW) Bluetooth d
[单片机]
S3C6410移植u-boot-2010.3(5)Dnw for linux
  现在开始记录在linux上安装dnw功能   想要源代码,可以到这里fork https://github.com/Qunero/dnw4linux   详细的使用,README里面讲得很清楚了,不加赘述了。   这里只讲一下怎么使用。   1、加载模块.ko文件 $ cd secbulk_driver/ $ insmod secbulk.ko   然后确认一下已经加载 $ lsmod | grep secbulk //若正确加载了,应该有回显 secbulk 12728 0   2、插入USB to miniUSB线   然后查看一下系统信息 $ dmesg //正常情况下应
[单片机]
小广播
最新单片机文章
何立民专栏 单片机及嵌入式宝典

北京航空航天大学教授,20余年来致力于单片机与嵌入式系统推广工作。

厂商技术中心

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

 
机器人开发圈

电子工程世界版权所有 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2026 EEWORLD.com.cn, Inc. All rights reserved