1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0+
3#
4# Usage: configcheck.sh .config .config-template
5#
6# Copyright (C) IBM Corporation, 2011
7#
8# Authors: Paul E. McKenney <paulmck@linux.ibm.com>
9
10T="`mktemp -d ${TMPDIR-/tmp}/configcheck.sh.XXXXXX`"
11trap 'rm -rf $T' 0
12
13sed -e 's/"//g' < $1 > $T/.config
14
15sed -e 's/"//g' -e 's/\(.*\)=n/# \1 is not set/' -e 's/^#CHECK#//' < $2 |
16awk	'
17{
18		print "if grep -q \"" $0 "\" < '"$T/.config"'";
19		print "then";
20		print "\t:";
21		print "else";
22		if ($1 == "#") {
23			print "\tif grep -q \"" $2 "\" < '"$T/.config"'";
24			print "\tthen";
25			print "\t\tif test \"$firsttime\" = \"\""
26			print "\t\tthen"
27			print "\t\t\tfirsttime=1"
28			print "\t\tfi"
29			print "\t\techo \":" $2 ": improperly set\"";
30			print "\telse";
31			print "\t\t:";
32			print "\tfi";
33		} else {
34			print "\tif test \"$firsttime\" = \"\""
35			print "\tthen"
36			print "\t\tfirsttime=1"
37			print "\tfi"
38			print "\techo \":" $0 ": improperly set\"";
39		}
40		print "fi";
41	}' | sh
42