分类: LINUX
2008-06-13 19:43:20
512行 CONFIG=.tmpconfig CONFIG_H=.tmpconfig.h #临时文件.tmpconfig用来生成.confg #.tmpconfig.h用来生成autoconfig.h rap "rm -f $CONFIG $CONFIG_H ; exit 1" 1 2 #捕获到信号1和信号2时,删除$CONFIG $CONFIG_H,并退出 # # Make sure we start out with a clean slate. # echo "#" > $CONFIG echo "# Automatically generated make config: don't edit" >> $CONFIG echo "#" >> $CONFIG echo "/*" > $CONFIG_H echo " * Automatically generated C config: don't edit" >> $CONFIG_H echo " */" >> $CONFIG_H echo "#define AUTOCONF_INCLUDED" >> $CONFIG_H #生成CONFIG和CONFIG_H的头 DEFAULT="" if [ "$1" = "-d" ] ; then DEFAULT="-d" shift fi #此时的$1=arch/config.in,因此不会进入if CONFIG_IN=./config.in if [ "$1" != "" ] ; then CONFIG_IN=$1 fi #$1=arch/config.in,因此CONFIG_IN=arch/config.in DEFAULTS=arch/$ARCH/defconfig if [ -f .config ]; then DEFAULTS=.config fi #.config存在,所以DEFAULTS=.config if [ -f $DEFAULTS ]; then #进入 echo "#" echo "# Using defaults found in" $DEFAULTS echo "#" . $DEFAULTS sed -e 's/# \(CONFIG_[^ ]*\) is not.*/\1=n/' <$DEFAULTS >.config-is-not.$$ #将.config中所有符合# \(CONFIG_[^ ]*\) is not.*特征的字符串替换成 #\(CONFIG_[^ ]*\)=n,例如“# CONFIG_DEBUG_LL is not set”替换成 #“CONFIG_DEBUG_LL=n” #生成隐藏文件.config-is-not.$$,$$为sed的进程号 . .config-is-not.$$ #执行.config-is-not.$$,给所有的CONFIG_宏赋值,例如CONFIG_DEBUG_LL=n, #$CONFIG_IN脚本执行时将用这些变量的值作为判断条件 rm .config-is-not.$$ else echo "#" echo "# No defaults found" echo "#" fi . $CONFIG_IN #完成新的.config和autoconf.h的生成,下面将详细解释实现过程 rm -f .config.old if [ -f .config ]; then mv .config .config.old fi mv .tmpconfig .config mv .tmpconfig.h include/autoconf.h #删除中间文件,生成新的.config和autoconf.h echo echo "*** End of Linux kernel configuration." echo "*** Check the top-level Makefile for additional configuration." echo "*** Next, you must run 'make'." echo exit 0 |