u-boot中的include/autoconf.mk文件是如何生成的

本文介绍了一种使用Makefile自动生成配置宏文件的方法。通过预处理命令和sed脚本配合,从common.h头文件中提取配置宏,并将其转换为autoconf.mk文件中的形式。这一过程涉及gcc预编译、宏提取及格式化。

在Makefile中:

[c-sharp] view plain copy
  1. $(obj)include/autoconf.mk: $(obj)include/config.h  
  2.   @$(XECHO) Generating $@ ; /  
  3.   set -e ; /  
  4.   : Extract the config macros ; /  
  5.   $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | /  
  6.     sed -n -f tools/scripts/define2mk.sed > $@ 

在2011-12中:

#
# Auto-generate the autoconf.mk file (which is included by all makefiles)
#
# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
# the dep file is only include in this top level makefile to determine when
# to regenerate the autoconf.mk file.
$(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h
	@$(XECHO) Generating $@ ; \
	set -e ; \
	: Generate the dependancies ; \
	$(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \
		-MQ $(obj)include/autoconf.mk include/common.h > $@

$(obj)include/autoconf.mk: $(obj)include/config.h
	@$(XECHO) Generating $@ ; \
	set -e ; \
	: Extract the config macros ; \
	$(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \
		sed -n -f tools/scripts/define2mk.sed > $@.tmp && \
	mv $@.tmp $@


实际执行的命令:

[c-sharp] view plain copy
  1. arm-none-linux-gnueabi-gcc -E -g -Os -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DTEXT_BASE=0xc3e00000 -I/home/zkl/svn/compiled/uboot-1.3.4-m9_v4/include -fno-builtin -ffreestanding -nostdinc -isystem /usr/local/arm/arm-2009q3/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -DDO_DEPS_ONLY -dM include/common.h | sed -n -f tools/scripts/define2mk.sed  

 

[c-sharp] view plain copy
  1. /^#define CONFIG_[A-Za-z0-9_][A-Za-z0-9_]*/ {  
  2.   # Strip the #define prefix  
  3.   s/#define *//;                
  4.   # Change to form CONFIG_*=VALUE  
  5.   s/  */=/;  
  6.   # Drop trailing spaces        
  7.   s/ *$//;  
  8.   # drop quotes around string values  
  9.   s/="/(.*/)"$/=/1/;            
  10.   # Concatenate string values   
  11.   s/" *"//g;  
  12.   # Wrap non-numeral values with quotes  
  13.   s/=/(.*/?[^0-9].*/)$/=/"/1/"/;   
  14.   # Change '1' and empty values to "y" (not perfect, but  
  15.   # supports conditional compilation in the makefiles  
  16.   s/=$/=y/;  
  17.   s/=1$/=y/;  
  18.   # print the line              
  19.   p                             


正常编译log Configuring for isvp_t31_sfcnor_ddr128M - Board: isvp_t31, Options: SPL_SFC_SUPPORT,ENV_IS_IN_SPI_FLASH,SPL_SFC_NOR,JZ_MMC_MSC0,DDR2_128M make make[2]: Entering directory '/home/lixueming/00lixueming/zeratul_1.2/os/uboot/u-boot' Generating include/autoconf.mk Generating include/autoconf.mk.dep mips-linux-gnu-gcc -DDO_DEPS_ONLY \ -g -Os -ffunction-sections -fdata-sections -D__KERNEL__ -DCONFIG_SYS_TEXT_BASE=0x80100000 -DCONFIG_SPL_TEXT_BASE=0x80001000 -DCONFIG_SPL_PAD_TO=36864 -I/home/lixueming/00lixueming/zeratul_1.2/os/uboot/u-boot/include -fno-builtin -ffreestanding -nostdinc -isystem /home/lixueming/00lixueming/cameos_BS_1.2/toolchain/zeratul_sdk/mips-gcc472-glibc216-64bit/bin/../lib/gcc/mips-linux-gnu/4.7.2/include -pipe -msoft-float -std=gnu89 -DCONFIG_MIPS -D__MIPS__ -G 0 -EL -msoft-float -fpic -mabicalls -march=mips32 -mabi=32 -DCONFIG_32BIT -mno-branch-likely -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fstack-usage -DCONFIG_TP_SERIAL_FORBIDDEN \ -o lib/asm-offsets.s lib/asm-offsets.c -c -S In file included from /home/lixueming/00lixueming/zeratul_1.2/os/uboot/u-boot/include/config.h:15:0, from /home/lixueming/00lixueming/zeratul_1.2/os/uboot/u-boot/include/common.h:37, from lib/asm-offsets.c:18: 出问题的编译log ls: 无法访问'/home/wuhsulei/share_smbd/Cworkspace/2D230/zeratul/os/uboot/u-boot/tools/charge_logo/*.jpg': 没有那个文件或目录 make[2]: Leaving directory '/home/wuhsulei/share_smbd/Cworkspace/2D230/zeratul/os/uboot/u-boot/tools/ingenic-tools' make[1]: Leaving directory '/home/wuhsulei/share_smbd/Cworkspace/2D230/zeratul/os/uboot/u-boot' make[1]: Entering directory '/home/wuhsulei/share_smbd/Cworkspace/2D230/zeratul/os/uboot/u-boot' Configuring for isvp_t31_sfcnor_ddr128M - Board: isvp_t31, Options: SPL_SFC_SUPPORT,ENV_IS_IN_SPI_FLASH,SPL_SFC_NOR,JZ_MMC_MSC0,DDR2_128M make make[2]: Entering directory '/home/wuhsulei/share_smbd/Cworkspace/2D230/zeratul/os/uboot/u-boot' make[2]: mips-linux-gnu-gcc:命令未找到 /bin/sh: mips-linux-gnu-gcc: 未找到命令 dirname: 缺少操作数 Try 'dirname --help' for more information. Generating include/autoconf.mk /bin/sh: 行 3: mips-linux-gnu-gcc: 未找到命令 Generating include/autoconf.mk.dep /bin/sh: 行 3: mips-linux-gnu-gcc: 未找到命令 make[2]: mips-linux-gnu-gcc:命令未找到 /bin/sh: mips-linux-gnu-gcc: 未找到命令 dirname: 缺少操作数 Try 'dirname --help' for more information. /bin/sh: mips-linux-gnu-gcc: 未找到命令 mips-linux-gnu-gcc -DDO_DEPS_ONLY \ -g -Os -ffunction-sections -fdata-sections -D__KERNEL__ -I/home/wuhsulei/share_smbd/Cworkspace/2D230/zeratul/os/uboot/u-boot/include -fno-builtin -ffreestanding -nostdinc -isystem -pipe -msoft-float -std=gnu89 -DCONFIG_MIPS -D__MIPS__ -G 0 -EB -msoft-float -fpic -mabicalls -march=mips32 -mabi=32 -DCONFIG_32BIT -mno-branch-likely -Wall -Wstrict-prototypes -DCONFIG_TP_SERIAL_FORBIDDEN \ -o lib/asm-offsets.s lib/asm-offsets.c -c -S make[2]: mips-linux-gnu-gcc:命令未找到 Makefile:779: recipe for target 'lib/asm-offsets.s' failed make[2]: *** [lib/asm-offsets.s] Error 127 make[2]: Leaving directory '/home/wuhsulei/share_smbd/Cworkspace/2D230/zeratul/os/uboot/u-boot' .boards.depend:534: recipe for target 'isvp_t31_sfcnor_ddr128M' failed make[1]: *** [isvp_t31_sfcnor_ddr128M] Error 2 请问问题可能出在哪?
最新发布
11-18
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值