Skip to content

Commit

Permalink
scripts/config: allow alternate prefix to config option symbol
Browse files Browse the repository at this point in the history
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" <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
yann-morin-1998 authored and michal42 committed Jun 28, 2012
1 parent 4edc7e3 commit f5ef2f7
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions scripts/config
Original file line number Diff line number Diff line change
@@ -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 <<EOL
Manipulate options in a .config file from the command line.
Expand Down Expand Up @@ -34,6 +37,9 @@ make time.
By default, config will upper-case the given symbol. Use --keep-case to keep
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
exit 1
}
Expand All @@ -44,8 +50,8 @@ checkarg() {
usage
fi
case "$ARG" in
CONFIG_*)
ARG="${ARG/CONFIG_/}"
${CONFIG_}*)
ARG="${ARG/${CONFIG_}/}"
;;
esac
if [ "$MUNGE_CASE" = "yes" ] ; then
Expand Down Expand Up @@ -107,37 +113,37 @@ while [ "$1" != "" ] ; do
esac
case "$CMD" in
--enable|-e)
set_var "CONFIG_$ARG" "CONFIG_$ARG=y"
set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
;;

--disable|-d)
set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set"
set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
;;

--module|-m)
set_var "CONFIG_$ARG" "CONFIG_$ARG=m"
set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
;;

--set-str)
# 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
;;

--set-val)
set_var "CONFIG_$ARG" "CONFIG_$ARG=$1"
set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
shift
;;

--state|-s)
if grep -q "# CONFIG_$ARG is not set" $FN ; then
if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
echo n
else
V="$(grep "^CONFIG_$ARG=" $FN)"
V="$(grep "^${CONFIG_}$ARG=" $FN)"
if [ $? != 0 ] ; then
echo undef
else
V="${V/#CONFIG_$ARG=/}"
V="${V/#${CONFIG_}$ARG=/}"
V="${V/#\"/}"
V="${V/%\"/}"
V="${V/\\\"/\"}"
Expand All @@ -147,15 +153,15 @@ while [ "$1" != "" ] ; do
;;

--enable-after|-E)
set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A"
set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
;;

--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)
set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A"
set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
;;

# undocumented because it ignores --file (fixme)
Expand Down

0 comments on commit f5ef2f7

Please sign in to comment.