1*371244cbSSimon Glass#!/bin/sh 2*371244cbSSimon Glass# Copyright (c) 2016 Google, Inc 3*371244cbSSimon Glass# Written by Simon Glass <sjg@chromium.org> 4*371244cbSSimon Glass# 5*371244cbSSimon Glass# Check that the u-boot.cfg file provided does not introduce any new 6*371244cbSSimon Glass# ad-hoc CONFIG options 7*371244cbSSimon Glass# 8*371244cbSSimon Glass# You can generate the list of current ad-hoc CONFIG options (those which are 9*371244cbSSimon Glass# not in Kconfig) with this command: 10*371244cbSSimon Glass# 11*371244cbSSimon Glass# export LC_ALL=C LC_COLLATE=C 12*371244cbSSimon Glass# git grep CONFIG_ |tr ' \t' '\n\n' |sed -n 's/^\(CONFIG_[A-Z0-9_]*\).*/\1/p' \ 13*371244cbSSimon Glass# |sort |uniq >scripts/config_whitelist.txt; 14*371244cbSSimon Glass# unset LC_ALL LC_COLLATE 15*371244cbSSimon Glass 16*371244cbSSimon Glass# Usage 17*371244cbSSimon Glass# check-config.sh <path to u-boot.cfg> <path to whitelist file> <source dir> 18*371244cbSSimon Glass# 19*371244cbSSimon Glass# For example: 20*371244cbSSimon Glass# scripts/check-config.sh b/chromebook_link/u-boot.cfg kconfig_whitelist.txt . 21*371244cbSSimon Glass 22*371244cbSSimon Glasspath="$1" 23*371244cbSSimon Glasswhitelist="$2" 24*371244cbSSimon Glasssrctree="$3" 25*371244cbSSimon Glass 26*371244cbSSimon Glass# Temporary files 27*371244cbSSimon Glassconfigs="${path}.configs" 28*371244cbSSimon Glasssuspects="${path}.suspects" 29*371244cbSSimon Glassok="${path}.ok" 30*371244cbSSimon Glassnew_adhoc="${path}.adhoc" 31*371244cbSSimon Glass 32*371244cbSSimon Glassexport LC_ALL=C 33*371244cbSSimon Glassexport LC_COLLATE=C 34*371244cbSSimon Glass 35*371244cbSSimon Glasscat ${path} |sed -n 's/^#define \(CONFIG_[A-Za-z0-9_]*\).*/\1/p' |sort |uniq \ 36*371244cbSSimon Glass >${configs} 37*371244cbSSimon Glass 38*371244cbSSimon Glasscomm -23 ${configs} ${whitelist} > ${suspects} 39*371244cbSSimon Glass 40*371244cbSSimon Glasscat `find ${srctree} -name "Kconfig*"` |sed -n \ 41*371244cbSSimon Glass -e 's/^config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ 42*371244cbSSimon Glass -e 's/^menuconfig \([A-Za-z0-9_]*\).*$/CONFIG_\1/p' |sort |uniq > ${ok} 43*371244cbSSimon Glasscomm -23 ${suspects} ${ok} >${new_adhoc} 44*371244cbSSimon Glassif [ -s ${new_adhoc} ]; then 45*371244cbSSimon Glass echo "Error: You must add new CONFIG options using Kconfig" 46*371244cbSSimon Glass echo "The following new ad-hoc CONFIG options were detected:" 47*371244cbSSimon Glass cat ${new_adhoc} 48*371244cbSSimon Glass echo 49*371244cbSSimon Glass echo "Please add these via Kconfig instead. Find a suitable Kconfig" 50*371244cbSSimon Glass echo "file and add a 'config' or 'menuconfig' option." 51*371244cbSSimon Glass # Don't delete the temporary files in case they are useful 52*371244cbSSimon Glass exit 1 53*371244cbSSimon Glasselse 54*371244cbSSimon Glass rm ${suspects} ${ok} ${new_adhoc} 55*371244cbSSimon Glassfi 56