From 4edc7e32affd40ceb06ba58ff55e4664396b24c7 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Fri, 8 Jun 2012 01:48:55 +0200 Subject: scripts/config: add option to not upper-case symbols Currently, scripts/config mangles the config option symbols to always be upper-case. While the Linux kernel almost exclusively uses upper-case symbols, there are still a few symbols with lower-case which this script can not handle: $ grep -r -E '^[[:space:]]*config[[:space:]]+[^[:space:]]*[[:lower:]][^[:space:]=.]*$' . |wc -l 173 (that's roughly 1.3% of the symbols in 3.5-rc1) Eg.: ./arch/arm/Kconfig:config VFPv3 ./arch/powerpc/platforms/Kconfig.cputype:config 40x ./arch/x86/Kconfig:config SCx200HR_TIMER ./drivers/video/console/Kconfig:config FONT_8x8 ./drivers/video/Kconfig:config NTSC_640x480 Also, other projects that use kconfig may allow for lower- or mixed-case symbols, and may find easier to reuse this script than implement each their own (potentially flawed) logic. For such a use-case, see: http://marc.info/?l=linux-kbuild&m=133409932115848&w=2 This patch adds a new option to keep the given case, and keep the current default to upper-case the symbols. Signed-off-by: "Yann E. MORIN" Signed-off-by: Michal Marek --- scripts/config | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'scripts/config') diff --git a/scripts/config b/scripts/config index ed6653ef9702..c5639fe5bba8 100755 --- a/scripts/config +++ b/scripts/config @@ -26,10 +26,14 @@ commands: commands can be repeated multiple times options: - --file .config file to change (default .config) + --file config-file .config file to change (default .config) + --keep-case|-k Keep next symbols' case (dont' upper-case it) config doesn't check the validity of the .config file. This is done at next - make time. +make time. + +By default, config will upper-case the given symbol. Use --keep-case to keep +the case of all following symbols unchanged. EOL exit 1 } @@ -44,7 +48,9 @@ checkarg() { ARG="${ARG/CONFIG_/}" ;; esac - ARG="`echo $ARG | tr a-z A-Z`" + if [ "$MUNGE_CASE" = "yes" ] ; then + ARG="`echo $ARG | tr a-z A-Z`" + fi } set_var() { @@ -75,10 +81,16 @@ if [ "$1" = "" ] ; then usage fi +MUNGE_CASE=yes while [ "$1" != "" ] ; do CMD="$1" shift case "$CMD" in + --keep-case|-k) + MUNGE_CASE=no + shift + continue + ;; --refresh) ;; --*-after) -- cgit v1.2.3 From f5ef2f7bf2e389f5c94d69e09268356f4c2b8220 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Fri, 8 Jun 2012 01:48:56 +0200 Subject: scripts/config: allow alternate prefix to config option symbol While the Linux kernel uses 'CONFIG_' as a prefix to the config options symbols, many projects that use kconfig may use different prefixes, or even none at all. If the CONFIG_ environment variable is set, use it as the prefix (empty is a valid prefix). Otherwise, use the default prefix 'CONFIG_'. This matches the support for alternate prefixes in scripts/kconfig/lkc.h, which uses the same logic (albeit with a C define instead of an environment variable). Signed-off-by: "Yann E. MORIN" Signed-off-by: Michal Marek --- scripts/config | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'scripts/config') diff --git a/scripts/config b/scripts/config index c5639fe5bba8..9723c7de07cc 100755 --- a/scripts/config +++ b/scripts/config @@ -1,6 +1,9 @@ #!/bin/bash # Manipulate options in a .config file from the command line +# If no prefix forced, use the default CONFIG_ +CONFIG_="${CONFIG_-CONFIG_}" + usage() { cat >&2 < Date: Fri, 8 Jun 2012 01:48:57 +0200 Subject: scripts/config: add option to undef a symbol It is currently possible to enable, disable or modularise a symbol. Also, an undefined symbol is reported as such. Add a new command to undefine a symbol, by removing the corresponding line from the .config file. Signed-off-by: "Yann E. MORIN" Signed-off-by: Michal Marek --- scripts/config | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'scripts/config') diff --git a/scripts/config b/scripts/config index 9723c7de07cc..f65a44a7886a 100755 --- a/scripts/config +++ b/scripts/config @@ -17,6 +17,7 @@ commands: Set option to "string" --set-val option value Set option to value + --undefine|-u option Undefine option --state|-s option Print state of option (n,y,m,undef) --enable-after|-E beforeopt option @@ -73,6 +74,12 @@ set_var() { fi } +undef_var() { + local name=$1 + + sed -ri "/^($name=|# $name is not set)/d" "$FN" +} + if [ "$1" = "--file" ]; then FN="$2" if [ "$FN" = "" ] ; then @@ -134,6 +141,9 @@ while [ "$1" != "" ] ; do set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1" shift ;; + --undefine|-u) + undef_var "${CONFIG_}$ARG" + ;; --state|-s) if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then -- cgit v1.2.3