aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/config
diff options
context:
space:
mode:
authorYann E. MORIN <yann.morin.1998@free.fr>2012-06-07 19:48:56 -0400
committerMichal Marek <mmarek@suse.cz>2012-06-28 04:38:54 -0400
commitf5ef2f7bf2e389f5c94d69e09268356f4c2b8220 (patch)
tree7bb49fb2f01e96d8ab5aef4bf123053d076afaa9 /scripts/config
parent4edc7e32affd40ceb06ba58ff55e4664396b24c7 (diff)
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>
Diffstat (limited to 'scripts/config')
-rwxr-xr-xscripts/config32
1 files changed, 19 insertions, 13 deletions
diff --git a/scripts/config b/scripts/config
index c5639fe5bba8..9723c7de07cc 100755
--- a/scripts/config
+++ b/scripts/config
@@ -1,6 +1,9 @@
1#!/bin/bash 1#!/bin/bash
2# Manipulate options in a .config file from the command line 2# Manipulate options in a .config file from the command line
3 3
4# If no prefix forced, use the default CONFIG_
5CONFIG_="${CONFIG_-CONFIG_}"
6
4usage() { 7usage() {
5 cat >&2 <<EOL 8 cat >&2 <<EOL
6Manipulate options in a .config file from the command line. 9Manipulate options in a .config file from the command line.
@@ -34,6 +37,9 @@ make time.
34 37
35By default, config will upper-case the given symbol. Use --keep-case to keep 38By default, config will upper-case the given symbol. Use --keep-case to keep
36the case of all following symbols unchanged. 39the case of all following symbols unchanged.
40
41config uses 'CONFIG_' as the default symbol prefix. Set the environment
42variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" config ...
37EOL 43EOL
38 exit 1 44 exit 1
39} 45}
@@ -44,8 +50,8 @@ checkarg() {
44 usage 50 usage
45 fi 51 fi
46 case "$ARG" in 52 case "$ARG" in
47 CONFIG_*) 53 ${CONFIG_}*)
48 ARG="${ARG/CONFIG_/}" 54 ARG="${ARG/${CONFIG_}/}"
49 ;; 55 ;;
50 esac 56 esac
51 if [ "$MUNGE_CASE" = "yes" ] ; then 57 if [ "$MUNGE_CASE" = "yes" ] ; then
@@ -107,37 +113,37 @@ while [ "$1" != "" ] ; do
107 esac 113 esac
108 case "$CMD" in 114 case "$CMD" in
109 --enable|-e) 115 --enable|-e)
110 set_var "CONFIG_$ARG" "CONFIG_$ARG=y" 116 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
111 ;; 117 ;;
112 118
113 --disable|-d) 119 --disable|-d)
114 set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set" 120 set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
115 ;; 121 ;;
116 122
117 --module|-m) 123 --module|-m)
118 set_var "CONFIG_$ARG" "CONFIG_$ARG=m" 124 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
119 ;; 125 ;;
120 126
121 --set-str) 127 --set-str)
122 # sed swallows one level of escaping, so we need double-escaping 128 # 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//\"/\\\\\"}\""
124 shift 130 shift
125 ;; 131 ;;
126 132
127 --set-val) 133 --set-val)
128 set_var "CONFIG_$ARG" "CONFIG_$ARG=$1" 134 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
129 shift 135 shift
130 ;; 136 ;;
131 137
132 --state|-s) 138 --state|-s)
133 if grep -q "# CONFIG_$ARG is not set" $FN ; then 139 if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
134 echo n 140 echo n
135 else 141 else
136 V="$(grep "^CONFIG_$ARG=" $FN)" 142 V="$(grep "^${CONFIG_}$ARG=" $FN)"
137 if [ $? != 0 ] ; then 143 if [ $? != 0 ] ; then
138 echo undef 144 echo undef
139 else 145 else
140 V="${V/#CONFIG_$ARG=/}" 146 V="${V/#${CONFIG_}$ARG=/}"
141 V="${V/#\"/}" 147 V="${V/#\"/}"
142 V="${V/%\"/}" 148 V="${V/%\"/}"
143 V="${V/\\\"/\"}" 149 V="${V/\\\"/\"}"
@@ -147,15 +153,15 @@ while [ "$1" != "" ] ; do
147 ;; 153 ;;
148 154
149 --enable-after|-E) 155 --enable-after|-E)
150 set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A" 156 set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
151 ;; 157 ;;
152 158
153 --disable-after|-D) 159 --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"
155 ;; 161 ;;
156 162
157 --module-after|-M) 163 --module-after|-M)
158 set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A" 164 set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
159 ;; 165 ;;
160 166
161 # undocumented because it ignores --file (fixme) 167 # undocumented because it ignores --file (fixme)