blob: eee31e261bf7de01c8c368745cf006daeaba2623 [file] [log] [blame]
Pranith Kumar1a5e31f2014-07-11 17:31:27 -04001#!/bin/bash
Pranith Kumar3327d922014-07-11 19:47:35 -04002# Usage: configcheck.sh .config .config-template
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -07003#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
Paul E. McKenney0e342a82013-12-03 09:54:18 -080015# along with this program; if not, you can access it online at
16# http://www.gnu.org/licenses/gpl-2.0.html.
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070017#
18# Copyright (C) IBM Corporation, 2011
19#
20# Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
21
22T=/tmp/abat-chk-config.sh.$$
23trap 'rm -rf $T' 0
24mkdir $T
25
26cat $1 > $T/.config
27
28cat $2 | sed -e 's/\(.*\)=n/# \1 is not set/' -e 's/^#CHECK#//' |
29awk '
30BEGIN {
31 print "if grep -q \"" $0 "\" < '"$T/.config"'";
32 print "then";
33 print "\t:";
34 print "else";
35 if ($1 == "#") {
36 print "\tif grep -q \"" $2 "\" < '"$T/.config"'";
37 print "\tthen";
38 print "\t\tif test \"$firsttime\" = \"\""
39 print "\t\tthen"
40 print "\t\t\tfirsttime=1"
41 print "\t\tfi"
42 print "\t\techo \":" $2 ": improperly set\"";
43 print "\telse";
44 print "\t\t:";
45 print "\tfi";
46 } else {
47 print "\tif test \"$firsttime\" = \"\""
48 print "\tthen"
49 print "\t\tfirsttime=1"
50 print "\tfi"
51 print "\techo \":" $0 ": improperly set\"";
52 }
53 print "fi";
54 }' | sh