1c87b9c60SPaul E. McKenney#!/bin/sh 2c87b9c60SPaul E. McKenney# 3c87b9c60SPaul E. McKenney# sh configinit.sh config-spec-file [ build output dir ] 4c87b9c60SPaul E. McKenney# 5c87b9c60SPaul E. McKenney# Create a .config file from the spec file. Run from the kernel source tree. 6c87b9c60SPaul E. McKenney# Exits with 0 if all went well, with 1 if all went well but the config 7c87b9c60SPaul E. McKenney# did not match, and some other number for other failures. 8c87b9c60SPaul E. McKenney# 9c87b9c60SPaul E. McKenney# The first argument is the .config specification file, which contains 10c87b9c60SPaul E. McKenney# desired settings, for example, "CONFIG_NO_HZ=y". For best results, 11c87b9c60SPaul E. McKenney# this should be a full pathname. 12c87b9c60SPaul E. McKenney# 13c87b9c60SPaul E. McKenney# The second argument is a optional path to a build output directory, 14c87b9c60SPaul E. McKenney# for example, "O=/tmp/foo". If this argument is omitted, the .config 15c87b9c60SPaul E. McKenney# file will be generated directly in the current directory. 160e342a87SPaul E. McKenney# 170e342a87SPaul E. McKenney# This program is free software; you can redistribute it and/or modify 180e342a87SPaul E. McKenney# it under the terms of the GNU General Public License as published by 190e342a87SPaul E. McKenney# the Free Software Foundation; either version 2 of the License, or 200e342a87SPaul E. McKenney# (at your option) any later version. 210e342a87SPaul E. McKenney# 220e342a87SPaul E. McKenney# This program is distributed in the hope that it will be useful, 230e342a87SPaul E. McKenney# but WITHOUT ANY WARRANTY; without even the implied warranty of 240e342a87SPaul E. McKenney# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 250e342a87SPaul E. McKenney# GNU General Public License for more details. 260e342a87SPaul E. McKenney# 270e342a87SPaul E. McKenney# You should have received a copy of the GNU General Public License 280e342a87SPaul E. McKenney# along with this program; if not, you can access it online at 290e342a87SPaul E. McKenney# http://www.gnu.org/licenses/gpl-2.0.html. 300e342a87SPaul E. McKenney# 310e342a87SPaul E. McKenney# Copyright (C) IBM Corporation, 2013 320e342a87SPaul E. McKenney# 330e342a87SPaul E. McKenney# Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com> 34c87b9c60SPaul E. McKenney 35c87b9c60SPaul E. McKenneyT=/tmp/configinit.sh.$$ 36c87b9c60SPaul E. McKenneytrap 'rm -rf $T' 0 37c87b9c60SPaul E. McKenneymkdir $T 38c87b9c60SPaul E. McKenney 39c87b9c60SPaul E. McKenney# Capture config spec file. 40c87b9c60SPaul E. McKenney 41c87b9c60SPaul E. McKenneyc=$1 42c87b9c60SPaul E. McKenneybuildloc=$2 43c87b9c60SPaul E. McKenneybuilddir= 44c87b9c60SPaul E. McKenneyif test -n $buildloc 45c87b9c60SPaul E. McKenneythen 46c87b9c60SPaul E. McKenney if echo $buildloc | grep -q '^O=' 47c87b9c60SPaul E. McKenney then 48c87b9c60SPaul E. McKenney builddir=`echo $buildloc | sed -e 's/^O=//'` 49c87b9c60SPaul E. McKenney if test ! -d $builddir 50c87b9c60SPaul E. McKenney then 51c87b9c60SPaul E. McKenney mkdir $builddir 52c87b9c60SPaul E. McKenney fi 53c87b9c60SPaul E. McKenney else 54c87b9c60SPaul E. McKenney echo Bad build directory: \"$builddir\" 55c87b9c60SPaul E. McKenney exit 2 56c87b9c60SPaul E. McKenney fi 57c87b9c60SPaul E. McKenneyfi 58c87b9c60SPaul E. McKenney 59c87b9c60SPaul E. McKenneysed -e 's/^\(CONFIG[0-9A-Z_]*\)=.*$/grep -v "^# \1" |/' < $c > $T/u.sh 60c87b9c60SPaul E. McKenneysed -e 's/^\(CONFIG[0-9A-Z_]*=\).*$/grep -v \1 |/' < $c >> $T/u.sh 61c87b9c60SPaul E. McKenneygrep '^grep' < $T/u.sh > $T/upd.sh 62c87b9c60SPaul E. McKenneyecho "cat - $c" >> $T/upd.sh 63c87b9c60SPaul E. McKenneymake mrproper 64c87b9c60SPaul E. McKenneymake $buildloc distclean > $builddir/Make.distclean 2>&1 65c87b9c60SPaul E. McKenneymake $buildloc defconfig > $builddir/Make.defconfig.out 2>&1 66c87b9c60SPaul E. McKenneymv $builddir/.config $builddir/.config.sav 67c87b9c60SPaul E. McKenneysh $T/upd.sh < $builddir/.config.sav > $builddir/.config 68c87b9c60SPaul E. McKenneycp $builddir/.config $builddir/.config.new 69c87b9c60SPaul E. McKenneyyes '' | make $buildloc oldconfig > $builddir/Make.modconfig.out 2>&1 70c87b9c60SPaul E. McKenney 71c87b9c60SPaul E. McKenney# verify new config matches specification. 7250d48a1dSPaul E. McKenneyconfigcheck.sh $builddir/.config $c 73c87b9c60SPaul E. McKenney 74c87b9c60SPaul E. McKenneyexit 0 75