1371244cbSSimon Glass#!/bin/sh 2371244cbSSimon Glass# Copyright (c) 2016 Google, Inc 3371244cbSSimon Glass# Written by Simon Glass <sjg@chromium.org> 4371244cbSSimon Glass# 5371244cbSSimon Glass# Check that the u-boot.cfg file provided does not introduce any new 6371244cbSSimon Glass# ad-hoc CONFIG options 7371244cbSSimon Glass# 87b76daabSMasahiro Yamada# Use scripts/build-whitelist.sh to generate the list of current ad-hoc 97b76daabSMasahiro Yamada# CONFIG options (those which are not in Kconfig). 10371244cbSSimon Glass 11371244cbSSimon Glass# Usage 12371244cbSSimon Glass# check-config.sh <path to u-boot.cfg> <path to whitelist file> <source dir> 13371244cbSSimon Glass# 14371244cbSSimon Glass# For example: 15371244cbSSimon Glass# scripts/check-config.sh b/chromebook_link/u-boot.cfg kconfig_whitelist.txt . 16371244cbSSimon Glass 17*f69dce50SLuca Ceresoliset -e 18*f69dce50SLuca Ceresoliset -u 19*f69dce50SLuca Ceresoli 20371244cbSSimon Glasspath="$1" 21371244cbSSimon Glasswhitelist="$2" 22371244cbSSimon Glasssrctree="$3" 23371244cbSSimon Glass 24371244cbSSimon Glass# Temporary files 25371244cbSSimon Glassconfigs="${path}.configs" 26371244cbSSimon Glasssuspects="${path}.suspects" 27371244cbSSimon Glassok="${path}.ok" 28371244cbSSimon Glassnew_adhoc="${path}.adhoc" 29371244cbSSimon Glass 30371244cbSSimon Glassexport LC_ALL=C 31371244cbSSimon Glassexport LC_COLLATE=C 32371244cbSSimon Glass 33371244cbSSimon Glasscat ${path} |sed -n 's/^#define \(CONFIG_[A-Za-z0-9_]*\).*/\1/p' |sort |uniq \ 34371244cbSSimon Glass >${configs} 35371244cbSSimon Glass 36371244cbSSimon Glasscomm -23 ${configs} ${whitelist} > ${suspects} 37371244cbSSimon Glass 38371244cbSSimon Glasscat `find ${srctree} -name "Kconfig*"` |sed -n \ 391f54a47cSBin Meng -e 's/^\s*config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ 401f54a47cSBin Meng -e 's/^\s*menuconfig \([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ 411f54a47cSBin Meng |sort |uniq > ${ok} 42371244cbSSimon Glasscomm -23 ${suspects} ${ok} >${new_adhoc} 43371244cbSSimon Glassif [ -s ${new_adhoc} ]; then 441bdd942bSMasahiro Yamada echo >&2 "Error: You must add new CONFIG options using Kconfig" 451bdd942bSMasahiro Yamada echo >&2 "The following new ad-hoc CONFIG options were detected:" 461bdd942bSMasahiro Yamada cat >&2 ${new_adhoc} 471bdd942bSMasahiro Yamada echo >&2 481bdd942bSMasahiro Yamada echo >&2 "Please add these via Kconfig instead. Find a suitable Kconfig" 491bdd942bSMasahiro Yamada echo >&2 "file and add a 'config' or 'menuconfig' option." 50371244cbSSimon Glass # Don't delete the temporary files in case they are useful 51371244cbSSimon Glass exit 1 52371244cbSSimon Glasselse 53371244cbSSimon Glass rm ${suspects} ${ok} ${new_adhoc} 54371244cbSSimon Glassfi 55