blob: 7cf7a668c16ae7b84a078956bd453df0735d699a [file] [log] [blame]
Simon Glass428975e2016-09-13 21:44:06 -06001#!/bin/sh
2# Copyright (c) 2016 Google, Inc
3# Written by Simon Glass <sjg@chromium.org>
4#
5
6# This script creates the configuration whitelist file. This file contains
7# all the config options which are allowed to be used outside Kconfig.
8# Please do not add things to the whitelist. Instead, add your new option
9# to Kconfig.
10#
11export LC_ALL=C LC_COLLATE=C
12
13# There are two independent greps. The first pulls out the component parts
14# of CONFIG_SYS_EXTRA_OPTIONS. An example is:
15#
16# SUNXI_GMAC,AHCI,SATAPWR=SUNXI_GPB(8)
17#
18# We want this to produce:
19# CONFIG_SUNXI_GMAC
20# CONFIG_AHCI
21# CONFIG_SATAPWR
22#
23# The second looks for the rest of the CONFIG options, but excludes those in
24# Kconfig and defconfig files.
25#
26(
27git grep CONFIG_SYS_EXTRA_OPTIONS |sed -n \
28 's/.*CONFIG_SYS_EXTRA_OPTIONS="\(.*\)"/\1/ p' \
29 | tr , '\n' \
30 | sed 's/ *\([A-Za-z0-9_]*\).*/CONFIG_\1/'
31
32git grep CONFIG_ | \
33 egrep -vi "(Kconfig:|defconfig:|README|\.py|\.pl:)" \
34 | tr ' \t' '\n\n' \
35 | sed -n 's/^\(CONFIG_[A-Za-z0-9_]*\).*/\1/p'
36) \
37 |sort |uniq >scripts/config_whitelist.txt.tmp1;
38
39# Finally, we need a list of the valid Kconfig options to exclude these from
40# the whitelist.
41cat `find . -name "Kconfig*"` |sed -n \
42 -e 's/^config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
43 -e 's/^menuconfig *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
44 |sort |uniq >scripts/config_whitelist.txt.tmp2
45
46# Use only the options that are present in the first file but not the second.
47comm -23 scripts/config_whitelist.txt.tmp1 scripts/config_whitelist.txt.tmp2 \
48 |sort |uniq >scripts/config_whitelist.txt
49rm scripts/config_whitelist.txt.tmp1 scripts/config_whitelist.txt.tmp2
50
51unset LC_ALL LC_COLLATE