18c2ecf20Sopenharmony_ci#!/bin/bash
28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0+
38c2ecf20Sopenharmony_ci#
48c2ecf20Sopenharmony_ci# Usage: configcheck.sh .config .config-template
58c2ecf20Sopenharmony_ci#
68c2ecf20Sopenharmony_ci# Copyright (C) IBM Corporation, 2011
78c2ecf20Sopenharmony_ci#
88c2ecf20Sopenharmony_ci# Authors: Paul E. McKenney <paulmck@linux.ibm.com>
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciT=${TMPDIR-/tmp}/abat-chk-config.sh.$$
118c2ecf20Sopenharmony_citrap 'rm -rf $T' 0
128c2ecf20Sopenharmony_cimkdir $T
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cicat $1 > $T/.config
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_cicat $2 | sed -e 's/\(.*\)=n/# \1 is not set/' -e 's/^#CHECK#//' |
178c2ecf20Sopenharmony_cigrep -v '^CONFIG_INITRAMFS_SOURCE' |
188c2ecf20Sopenharmony_ciawk	'
198c2ecf20Sopenharmony_ci{
208c2ecf20Sopenharmony_ci		print "if grep -q \"" $0 "\" < '"$T/.config"'";
218c2ecf20Sopenharmony_ci		print "then";
228c2ecf20Sopenharmony_ci		print "\t:";
238c2ecf20Sopenharmony_ci		print "else";
248c2ecf20Sopenharmony_ci		if ($1 == "#") {
258c2ecf20Sopenharmony_ci			print "\tif grep -q \"" $2 "\" < '"$T/.config"'";
268c2ecf20Sopenharmony_ci			print "\tthen";
278c2ecf20Sopenharmony_ci			print "\t\tif test \"$firsttime\" = \"\""
288c2ecf20Sopenharmony_ci			print "\t\tthen"
298c2ecf20Sopenharmony_ci			print "\t\t\tfirsttime=1"
308c2ecf20Sopenharmony_ci			print "\t\tfi"
318c2ecf20Sopenharmony_ci			print "\t\techo \":" $2 ": improperly set\"";
328c2ecf20Sopenharmony_ci			print "\telse";
338c2ecf20Sopenharmony_ci			print "\t\t:";
348c2ecf20Sopenharmony_ci			print "\tfi";
358c2ecf20Sopenharmony_ci		} else {
368c2ecf20Sopenharmony_ci			print "\tif test \"$firsttime\" = \"\""
378c2ecf20Sopenharmony_ci			print "\tthen"
388c2ecf20Sopenharmony_ci			print "\t\tfirsttime=1"
398c2ecf20Sopenharmony_ci			print "\tfi"
408c2ecf20Sopenharmony_ci			print "\techo \":" $0 ": improperly set\"";
418c2ecf20Sopenharmony_ci		}
428c2ecf20Sopenharmony_ci		print "fi";
438c2ecf20Sopenharmony_ci	}' | sh
44