]> git.ipfire.org Git - thirdparty/u-boot.git/blame - scripts/check-config.sh
Merge branch 'master' of git://git.denx.de/u-boot-sh
[thirdparty/u-boot.git] / scripts / check-config.sh
CommitLineData
371244cb
SG
1#!/bin/sh
2# Copyright (c) 2016 Google, Inc
3# Written by Simon Glass <sjg@chromium.org>
4#
5# Check that the u-boot.cfg file provided does not introduce any new
6# ad-hoc CONFIG options
7#
7b76daab
MY
8# Use scripts/build-whitelist.sh to generate the list of current ad-hoc
9# CONFIG options (those which are not in Kconfig).
371244cb
SG
10
11# Usage
12# check-config.sh <path to u-boot.cfg> <path to whitelist file> <source dir>
13#
14# For example:
15# scripts/check-config.sh b/chromebook_link/u-boot.cfg kconfig_whitelist.txt .
16
f69dce50
LC
17set -e
18set -u
19
94ca2690
AS
20PROG_NAME="${0##*/}"
21
22usage() {
23 echo "$PROG_NAME <path to u-boot.cfg> <path to whitelist file> <source dir>"
24 exit 1
25}
26
27[ $# -ge 3 ] || usage
28
371244cb
SG
29path="$1"
30whitelist="$2"
31srctree="$3"
32
33# Temporary files
34configs="${path}.configs"
35suspects="${path}.suspects"
36ok="${path}.ok"
37new_adhoc="${path}.adhoc"
38
39export LC_ALL=C
40export LC_COLLATE=C
41
42cat ${path} |sed -n 's/^#define \(CONFIG_[A-Za-z0-9_]*\).*/\1/p' |sort |uniq \
43 >${configs}
44
45comm -23 ${configs} ${whitelist} > ${suspects}
46
47cat `find ${srctree} -name "Kconfig*"` |sed -n \
1f54a47c
BM
48 -e 's/^\s*config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
49 -e 's/^\s*menuconfig \([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
50 |sort |uniq > ${ok}
371244cb
SG
51comm -23 ${suspects} ${ok} >${new_adhoc}
52if [ -s ${new_adhoc} ]; then
1bdd942b
MY
53 echo >&2 "Error: You must add new CONFIG options using Kconfig"
54 echo >&2 "The following new ad-hoc CONFIG options were detected:"
55 cat >&2 ${new_adhoc}
56 echo >&2
57 echo >&2 "Please add these via Kconfig instead. Find a suitable Kconfig"
58 echo >&2 "file and add a 'config' or 'menuconfig' option."
371244cb
SG
59 # Don't delete the temporary files in case they are useful
60 exit 1
61else
62 rm ${suspects} ${ok} ${new_adhoc}
63fi