2 # SPDX-License-Identifier: GPL-2.0+
4 # Usage: configinit.sh config-spec-file build-output-dir results-dir
6 # Create a .config file from the spec file. Run from the kernel source tree.
7 # Exits with 0 if all went well, with 1 if all went well but the config
8 # did not match, and some other number for other failures.
10 # The first argument is the .config specification file, which contains
11 # desired settings, for example, "CONFIG_NO_HZ=y". For best results,
12 # this should be a full pathname.
14 # The second argument is a optional path to a build output directory,
15 # for example, "O=/tmp/foo". If this argument is omitted, the .config
16 # file will be generated directly in the current directory.
18 # Copyright (C) IBM Corporation, 2013
20 # Authors: Paul E. McKenney <paulmck@linux.ibm.com>
22 T=${TMPDIR-/tmp}/configinit.sh.$$
26 # Capture config spec file.
32 if echo $buildloc | grep -q '^O='
34 builddir=`echo $buildloc | sed -e 's/^O=//'`
35 if test ! -d $builddir
40 echo Bad build directory: \"$buildloc\"
44 sed -e 's/^\(CONFIG[0-9A-Z_]*\)=.*$/grep -v "^# \1" |/' < $c > $T/u.sh
45 sed -e 's/^\(CONFIG[0-9A-Z_]*=\).*$/grep -v \1 |/' < $c >> $T/u.sh
46 grep '^grep' < $T/u.sh > $T/upd.sh
47 echo "cat - $c" >> $T/upd.sh
49 make $buildloc distclean > $resdir/Make.distclean 2>&1
50 make $buildloc $TORTURE_DEFCONFIG > $resdir/Make.defconfig.out 2>&1
51 mv $builddir/.config $builddir/.config.sav
52 sh $T/upd.sh < $builddir/.config.sav > $builddir/.config
53 cp $builddir/.config $builddir/.config.new
54 yes '' | make $buildloc oldconfig > $resdir/Make.oldconfig.out 2> $resdir/Make.oldconfig.err
56 # verify new config matches specification.
57 configcheck.sh $builddir/.config $c