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" <yann.morin.1998@free.fr>
Signed-off-by: Michal Marek <mmarek@suse.cz>
This commit is contained in:
Yann E. MORIN 2012-06-08 01:48:56 +02:00 committed by Michal Marek
parent 4edc7e32af
commit f5ef2f7bf2

View File

@ -1,6 +1,9 @@
#!/bin/bash #!/bin/bash
# Manipulate options in a .config file from the command line # Manipulate options in a .config file from the command line
# If no prefix forced, use the default CONFIG_
CONFIG_="${CONFIG_-CONFIG_}"
usage() { usage() {
cat >&2 <<EOL cat >&2 <<EOL
Manipulate options in a .config file from the command line. Manipulate options in a .config file from the command line.
@ -34,6 +37,9 @@ make time.
By default, config will upper-case the given symbol. Use --keep-case to keep By default, config will upper-case the given symbol. Use --keep-case to keep
the case of all following symbols unchanged. the case of all following symbols unchanged.
config uses 'CONFIG_' as the default symbol prefix. Set the environment
variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" config ...
EOL EOL
exit 1 exit 1
} }
@ -44,8 +50,8 @@ checkarg() {
usage usage
fi fi
case "$ARG" in case "$ARG" in
CONFIG_*) ${CONFIG_}*)
ARG="${ARG/CONFIG_/}" ARG="${ARG/${CONFIG_}/}"
;; ;;
esac esac
if [ "$MUNGE_CASE" = "yes" ] ; then if [ "$MUNGE_CASE" = "yes" ] ; then
@ -107,37 +113,37 @@ while [ "$1" != "" ] ; do
esac esac
case "$CMD" in case "$CMD" in
--enable|-e) --enable|-e)
set_var "CONFIG_$ARG" "CONFIG_$ARG=y" set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
;; ;;
--disable|-d) --disable|-d)
set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set" set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
;; ;;
--module|-m) --module|-m)
set_var "CONFIG_$ARG" "CONFIG_$ARG=m" set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
;; ;;
--set-str) --set-str)
# sed swallows one level of escaping, so we need double-escaping # sed swallows one level of escaping, so we need double-escaping
set_var "CONFIG_$ARG" "CONFIG_$ARG=\"${1//\"/\\\\\"}\"" set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\""
shift shift
;; ;;
--set-val) --set-val)
set_var "CONFIG_$ARG" "CONFIG_$ARG=$1" set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
shift shift
;; ;;
--state|-s) --state|-s)
if grep -q "# CONFIG_$ARG is not set" $FN ; then if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
echo n echo n
else else
V="$(grep "^CONFIG_$ARG=" $FN)" V="$(grep "^${CONFIG_}$ARG=" $FN)"
if [ $? != 0 ] ; then if [ $? != 0 ] ; then
echo undef echo undef
else else
V="${V/#CONFIG_$ARG=/}" V="${V/#${CONFIG_}$ARG=/}"
V="${V/#\"/}" V="${V/#\"/}"
V="${V/%\"/}" V="${V/%\"/}"
V="${V/\\\"/\"}" V="${V/\\\"/\"}"
@ -147,15 +153,15 @@ while [ "$1" != "" ] ; do
;; ;;
--enable-after|-E) --enable-after|-E)
set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A" set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
;; ;;
--disable-after|-D) --disable-after|-D)
set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A" set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A"
;; ;;
--module-after|-M) --module-after|-M)
set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A" set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
;; ;;
# undocumented because it ignores --file (fixme) # undocumented because it ignores --file (fixme)