aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/config
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /scripts/config
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'scripts/config')
-rwxr-xr-xscripts/config66
1 files changed, 18 insertions, 48 deletions
diff --git a/scripts/config b/scripts/config
index bb4d3deb6d1..a7c7c4b8e95 100755
--- a/scripts/config
+++ b/scripts/config
@@ -1,9 +1,6 @@
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
7usage() { 4usage() {
8 cat >&2 <<EOL 5 cat >&2 <<EOL
9Manipulate options in a .config file from the command line. 6Manipulate options in a .config file from the command line.
@@ -17,7 +14,6 @@ commands:
17 Set option to "string" 14 Set option to "string"
18 --set-val option value 15 --set-val option value
19 Set option to value 16 Set option to value
20 --undefine|-u option Undefine option
21 --state|-s option Print state of option (n,y,m,undef) 17 --state|-s option Print state of option (n,y,m,undef)
22 18
23 --enable-after|-E beforeopt option 19 --enable-after|-E beforeopt option
@@ -30,17 +26,10 @@ commands:
30 commands can be repeated multiple times 26 commands can be repeated multiple times
31 27
32options: 28options:
33 --file config-file .config file to change (default .config) 29 --file .config file to change (default .config)
34 --keep-case|-k Keep next symbols' case (dont' upper-case it)
35 30
36config doesn't check the validity of the .config file. This is done at next 31config doesn't check the validity of the .config file. This is done at next
37make time. 32 make time.
38
39By default, config will upper-case the given symbol. Use --keep-case to keep
40the case of all following symbols unchanged.
41
42config uses 'CONFIG_' as the default symbol prefix. Set the environment
43variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" config ...
44EOL 33EOL
45 exit 1 34 exit 1
46} 35}
@@ -51,13 +40,11 @@ checkarg() {
51 usage 40 usage
52 fi 41 fi
53 case "$ARG" in 42 case "$ARG" in
54 ${CONFIG_}*) 43 CONFIG_*)
55 ARG="${ARG/${CONFIG_}/}" 44 ARG="${ARG/CONFIG_/}"
56 ;; 45 ;;
57 esac 46 esac
58 if [ "$MUNGE_CASE" = "yes" ] ; then 47 ARG="`echo $ARG | tr a-z A-Z`"
59 ARG="`echo $ARG | tr a-z A-Z`"
60 fi
61} 48}
62 49
63set_var() { 50set_var() {
@@ -74,12 +61,6 @@ set_var() {
74 fi 61 fi
75} 62}
76 63
77undef_var() {
78 local name=$1
79
80 sed -ri "/^($name=|# $name is not set)/d" "$FN"
81}
82
83if [ "$1" = "--file" ]; then 64if [ "$1" = "--file" ]; then
84 FN="$2" 65 FN="$2"
85 if [ "$FN" = "" ] ; then 66 if [ "$FN" = "" ] ; then
@@ -94,15 +75,10 @@ if [ "$1" = "" ] ; then
94 usage 75 usage
95fi 76fi
96 77
97MUNGE_CASE=yes
98while [ "$1" != "" ] ; do 78while [ "$1" != "" ] ; do
99 CMD="$1" 79 CMD="$1"
100 shift 80 shift
101 case "$CMD" in 81 case "$CMD" in
102 --keep-case|-k)
103 MUNGE_CASE=no
104 continue
105 ;;
106 --refresh) 82 --refresh)
107 ;; 83 ;;
108 --*-after) 84 --*-after)
@@ -119,58 +95,52 @@ while [ "$1" != "" ] ; do
119 esac 95 esac
120 case "$CMD" in 96 case "$CMD" in
121 --enable|-e) 97 --enable|-e)
122 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y" 98 set_var "CONFIG_$ARG" "CONFIG_$ARG=y"
123 ;; 99 ;;
124 100
125 --disable|-d) 101 --disable|-d)
126 set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set" 102 set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set"
127 ;; 103 ;;
128 104
129 --module|-m) 105 --module|-m)
130 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m" 106 set_var "CONFIG_$ARG" "CONFIG_$ARG=m"
131 ;; 107 ;;
132 108
133 --set-str) 109 --set-str)
134 # sed swallows one level of escaping, so we need double-escaping 110 set_var "CONFIG_$ARG" "CONFIG_$ARG=\"$1\""
135 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\""
136 shift 111 shift
137 ;; 112 ;;
138 113
139 --set-val) 114 --set-val)
140 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1" 115 set_var "CONFIG_$ARG" "CONFIG_$ARG=$1"
141 shift 116 shift
142 ;; 117 ;;
143 --undefine|-u)
144 undef_var "${CONFIG_}$ARG"
145 ;;
146 118
147 --state|-s) 119 --state|-s)
148 if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then 120 if grep -q "# CONFIG_$ARG is not set" $FN ; then
149 echo n 121 echo n
150 else 122 else
151 V="$(grep "^${CONFIG_}$ARG=" $FN)" 123 V="$(grep "^CONFIG_$ARG=" $FN)"
152 if [ $? != 0 ] ; then 124 if [ $? != 0 ] ; then
153 echo undef 125 echo undef
154 else 126 else
155 V="${V/#${CONFIG_}$ARG=/}" 127 V="${V/CONFIG_$ARG=/}"
156 V="${V/#\"/}" 128 V="${V/\"/}"
157 V="${V/%\"/}" 129 echo "$V"
158 V="${V//\\\"/\"}"
159 echo "${V}"
160 fi 130 fi
161 fi 131 fi
162 ;; 132 ;;
163 133
164 --enable-after|-E) 134 --enable-after|-E)
165 set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A" 135 set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A"
166 ;; 136 ;;
167 137
168 --disable-after|-D) 138 --disable-after|-D)
169 set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A" 139 set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A"
170 ;; 140 ;;
171 141
172 --module-after|-M) 142 --module-after|-M)
173 set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A" 143 set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A"
174 ;; 144 ;;
175 145
176 # undocumented because it ignores --file (fixme) 146 # undocumented because it ignores --file (fixme)