Skip to content

Commit f5ef2f7

Browse files
yann-morin-1998michal42
authored andcommitted
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>
1 parent 4edc7e3 commit f5ef2f7

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

scripts/config

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22
# Manipulate options in a .config file from the command line
33

4+
# If no prefix forced, use the default CONFIG_
5+
CONFIG_="${CONFIG_-CONFIG_}"
6+
47
usage() {
58
cat >&2 <<EOL
69
Manipulate options in a .config file from the command line.
@@ -34,6 +37,9 @@ make time.
3437
3538
By default, config will upper-case the given symbol. Use --keep-case to keep
3639
the case of all following symbols unchanged.
40+
41+
config uses 'CONFIG_' as the default symbol prefix. Set the environment
42+
variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" config ...
3743
EOL
3844
exit 1
3945
}
@@ -44,8 +50,8 @@ checkarg() {
4450
usage
4551
fi
4652
case "$ARG" in
47-
CONFIG_*)
48-
ARG="${ARG/CONFIG_/}"
53+
${CONFIG_}*)
54+
ARG="${ARG/${CONFIG_}/}"
4955
;;
5056
esac
5157
if [ "$MUNGE_CASE" = "yes" ] ; then
@@ -107,37 +113,37 @@ while [ "$1" != "" ] ; do
107113
esac
108114
case "$CMD" in
109115
--enable|-e)
110-
set_var "CONFIG_$ARG" "CONFIG_$ARG=y"
116+
set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
111117
;;
112118

113119
--disable|-d)
114-
set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set"
120+
set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
115121
;;
116122

117123
--module|-m)
118-
set_var "CONFIG_$ARG" "CONFIG_$ARG=m"
124+
set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
119125
;;
120126

121127
--set-str)
122128
# sed swallows one level of escaping, so we need double-escaping
123-
set_var "CONFIG_$ARG" "CONFIG_$ARG=\"${1//\"/\\\\\"}\""
129+
set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\""
124130
shift
125131
;;
126132

127133
--set-val)
128-
set_var "CONFIG_$ARG" "CONFIG_$ARG=$1"
134+
set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
129135
shift
130136
;;
131137

132138
--state|-s)
133-
if grep -q "# CONFIG_$ARG is not set" $FN ; then
139+
if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
134140
echo n
135141
else
136-
V="$(grep "^CONFIG_$ARG=" $FN)"
142+
V="$(grep "^${CONFIG_}$ARG=" $FN)"
137143
if [ $? != 0 ] ; then
138144
echo undef
139145
else
140-
V="${V/#CONFIG_$ARG=/}"
146+
V="${V/#${CONFIG_}$ARG=/}"
141147
V="${V/#\"/}"
142148
V="${V/%\"/}"
143149
V="${V/\\\"/\"}"
@@ -147,15 +153,15 @@ while [ "$1" != "" ] ; do
147153
;;
148154

149155
--enable-after|-E)
150-
set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A"
156+
set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
151157
;;
152158

153159
--disable-after|-D)
154-
set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A"
160+
set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A"
155161
;;
156162

157163
--module-after|-M)
158-
set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A"
164+
set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
159165
;;
160166

161167
# undocumented because it ignores --file (fixme)

0 commit comments

Comments
 (0)