diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/config | 32 |
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_ | ||
5 | CONFIG_="${CONFIG_-CONFIG_}" | ||
6 | |||
4 | usage() { | 7 | usage() { |
5 | cat >&2 <<EOL | 8 | cat >&2 <<EOL |
6 | Manipulate options in a .config file from the command line. | 9 | Manipulate options in a .config file from the command line. |
@@ -34,6 +37,9 @@ make time. | |||
34 | 37 | ||
35 | By default, config will upper-case the given symbol. Use --keep-case to keep | 38 | By default, config will upper-case the given symbol. Use --keep-case to keep |
36 | the case of all following symbols unchanged. | 39 | 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 ... | ||
37 | EOL | 43 | EOL |
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) |