3 # sh configinit.sh config-spec-file [ build output dir ]
5 # Create a .config file from the spec file. Run from the kernel source tree.
6 # Exits with 0 if all went well, with 1 if all went well but the config
7 # did not match, and some other number for other failures.
9 # The first argument is the .config specification file, which contains
10 # desired settings, for example, "CONFIG_NO_HZ=y". For best results,
11 # this should be a full pathname.
13 # The second argument is a optional path to a build output directory,
14 # for example, "O=/tmp/foo". If this argument is omitted, the .config
15 # file will be generated directly in the current directory.
19 T=/tmp/configinit.sh.$$
23 # Capture config spec file.
30 if echo $buildloc | grep -q '^O='
32 builddir=`echo $buildloc | sed -e 's/^O=//'`
33 if test ! -d $builddir
38 echo Bad build directory: \"$builddir\"
43 sed -e 's/^\(CONFIG[0-9A-Z_]*\)=.*$/grep -v "^# \1" |/' < $c > $T/u.sh
44 sed -e 's/^\(CONFIG[0-9A-Z_]*=\).*$/grep -v \1 |/' < $c >> $T/u.sh
45 grep '^grep' < $T/u.sh > $T/upd.sh
46 echo "cat - $c" >> $T/upd.sh
48 make $buildloc distclean > $builddir/Make.distclean 2>&1
49 make $buildloc defconfig > $builddir/Make.defconfig.out 2>&1
50 mv $builddir/.config $builddir/.config.sav
51 sh $T/upd.sh < $builddir/.config.sav > $builddir/.config
52 cp $builddir/.config $builddir/.config.new
53 yes '' | make $buildloc oldconfig > $builddir/Make.modconfig.out 2>&1
55 # verify new config matches specification.
57 sed -e 's/"//g' < $c > $T/c
58 sed -e 's/"//g' < $builddir/.config > $T/.config
59 sed -e 's/\(.*\)=n/# \1 is not set/' -e 's/^#CHECK#//' < $c |
62 print "if grep -q \"" $0 "\" < '"$T/.config"'";
67 print "\tif grep -q \"" $2 "\" < '"$T/.config"'";
69 print "\t\techo \":" $2 ": improperly set\"";
74 print "\techo \":" $0 ": improperly set\"";
77 }' | sh > $T/diagnostics
78 if test -s $T/diagnostics