u-boot分析
分makefile最好的方法就是從參照make之后的輸出學習
?
100ask24x0_config?? ?:?? ?unconfig
?? ?@$(MKCONFIG) $(@:_config=) arm arm920t 100ask24x0 NULL s3c24x0
$@代表的是target 100ask24x0_config, 那么$(@:_config=)就是將100ask24x0_config中的_config替換為空!得到100ask24x0; 你可以用echo自己打印出來看看就明白了!?
@$(MKCONFIG) ? @表示在執行命令時不輸出命令本身,只輸出結果
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? $(MKCONFIG)表示(MKCONFIG) 這個變量的值mkconfig
$(@:_config=) ? ? ?這里用到了makefile的變量替換規則,$(VAR:A=B)表示替換變量$VAR中的A為B,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 即把$@中的_config替換為空變成smdk2410,$@ 目標文件,$^ 所有的依賴文件,$< 第一個依賴文件。
MKCONFIG?? ?:= $(SRCTREE)/mkconfig
export MKCONFIG
@$(MKCONFIG) $(@:_config=) arm arm920t 100ask24x0 NULL s3c24x0分析為:
mkconfig?? 100ask24x0 ? arm?? arm920t?? 100ask24x0? NULL s3c24x0
以下是:Makefile中生成最終u-boot的原句
$(obj)u-boot: depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \-Map u-boot.map -o u-boot?執行之后輸出的語句是:
make[1]: Leaving directory '/work/svn_linux/u-boot/common' UNDEF_SYM=`arm-linux-objdump -x lib_generic/libgeneric.a board/100ask24x0/lib100ask24x0.a cpu/arm920t/libarm920t.a cpu/arm920t/s3c24x0/libs3c24x0.a lib_arm/libarm.a fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a net/libnet.a disk/libdisk.a rtc/librtc.a dtt/libdtt.a drivers/libdrivers.a drivers/nand/libnand.a drivers/nand_legacy/libnand_legacy.a drivers/usb/libusb.a drivers/sk98lin/libsk98lin.a common/libcommon.a |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\cd /work/svn_linux/u-boot && arm-linux-ld -Bstatic -T /work/svn_linux/u-boot/board/100ask24x0/u-boot.lds -Ttext 0x33F80000 $UNDEF_SYM cpu/arm920t/start.o \--start-group lib_generic/libgeneric.a board/100ask24x0/lib100ask24x0.a cpu/arm920t/libarm920t.a cpu/arm920t/s3c24x0/libs3c24x0.a lib_arm/libarm.a fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a net/libnet.a disk/libdisk.a rtc/librtc.a dtt/libdtt.a drivers/libdrivers.a drivers/nand/libnand.a drivers/nand_legacy/libnand_legacy.a drivers/usb/libusb.a drivers/sk98lin/libsk98lin.a common/libcommon.a --end-group -L /work/tools/gcc-3.4.5-glibc-2.3.6/lib/gcc/arm-linux/3.4.5 -lgcc \-Map u-boot.map -o u-boot arm-linux-objcopy --gap-fill=0xff -O srec u-boot u-boot.srec arm-linux-objcopy --gap-fill=0xff -O binary u-boot u-boot.binmake[1]: Leaving directory '/work/svn_linux/u-boot/common'
UNDEF_SYM=`arm-linux-objdump -x lib_generic/libgeneric.a board/100ask24x0/lib100ask24x0.a cpu/arm920t/libarm920t.a cpu/arm920t/s3c24x0/libs3c24x0.a lib_arm/libarm.a fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a net/libnet.a disk/libdisk.a rtc/librtc.a dtt/libdtt.a drivers/libdrivers.a drivers/nand/libnand.a drivers/nand_legacy/libnand_legacy.a drivers/usb/libusb.a drivers/sk98lin/libsk98lin.a common/libcommon.a |sed ?-n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
? ? ? ? cd /work/svn_linux/u-boot && arm-linux-ld -Bstatic -T /work/svn_linux/u-boot/board/100ask24x0/u-boot.lds -Ttext 0x33F80000 ?$UNDEF_SYM cpu/arm920t/start.o \
? ? ? ? ? ? ? ? --start-group lib_generic/libgeneric.a board/100ask24x0/lib100ask24x0.a cpu/arm920t/libarm920t.a cpu/arm920t/s3c24x0/libs3c24x0.a lib_arm/libarm.a fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a net/libnet.a disk/libdisk.a rtc/librtc.a dtt/libdtt.a drivers/libdrivers.a drivers/nand/libnand.a drivers/nand_legacy/libnand_legacy.a drivers/usb/libusb.a drivers/sk98lin/libsk98lin.a common/libcommon.a --end-group -L /work/tools/gcc-3.4.5-glibc-2.3.6/lib/gcc/arm-linux/3.4.5 -lgcc \
? ? ? ? ? ? ? ? -Map u-boot.map -o u-boot
arm-linux-objcopy --gap-fill=0xff -O srec u-boot u-boot.srec
arm-linux-objcopy --gap-fill=0xff -O binary u-boot u-boot.bin
?
?
?
?
?
?
?
總結
- 上一篇: 作者:李涛(1975-),男,博士,南京
- 下一篇: 作者:陈振冲(1959-),男,博士,香