aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/config
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/config')
-rwxr-xr-xscripts/config87
1 files changed, 41 insertions, 46 deletions
diff --git a/scripts/config b/scripts/config
index db6084b78a1..608d7fdb13e 100755
--- a/scripts/config
+++ b/scripts/config
@@ -9,8 +9,10 @@ config options command ...
9commands: 9commands:
10 --enable|-e option Enable option 10 --enable|-e option Enable option
11 --disable|-d option Disable option 11 --disable|-d option Disable option
12 --module|-m option Turn option into a module 12 --module|-m option Turn option into a module
13 --state|-s option Print state of option (n,y,m,undef) 13 --set-str option value
14 Set option to "value"
15 --state|-s option Print state of option (n,y,m,undef)
14 16
15 --enable-after|-E beforeopt option 17 --enable-after|-E beforeopt option
16 Enable option directly after other option 18 Enable option directly after other option
@@ -26,8 +28,6 @@ options:
26 28
27config doesn't check the validity of the .config file. This is done at next 29config doesn't check the validity of the .config file. This is done at next
28 make time. 30 make time.
29The options need to be already in the file before they can be changed,
30but sometimes you can cheat with the --*-after options.
31EOL 31EOL
32 exit 1 32 exit 1
33} 33}
@@ -45,8 +45,18 @@ checkarg() {
45 ARG="`echo $ARG | tr a-z A-Z`" 45 ARG="`echo $ARG | tr a-z A-Z`"
46} 46}
47 47
48replace() { 48set_var() {
49 sed -i -e "$@" $FN 49 local name=$1 new=$2 before=$3
50
51 name_re="^($name=|# $name is not set)"
52 before_re="^($before=|# $before is not set)"
53 if test -n "$before" && grep -Eq "$before_re" "$FN"; then
54 sed -ri "/$before_re/a $new" "$FN"
55 elif grep -Eq "$name_re" "$FN"; then
56 sed -ri "s:$name_re.*:$new:" "$FN"
57 else
58 echo "$new" >>"$FN"
59 fi
50} 60}
51 61
52if [ "$1" = "--file" ]; then 62if [ "$1" = "--file" ]; then
@@ -54,8 +64,7 @@ if [ "$1" = "--file" ]; then
54 if [ "$FN" = "" ] ; then 64 if [ "$FN" = "" ] ; then
55 usage 65 usage
56 fi 66 fi
57 shift 67 shift 2
58 shift
59else 68else
60 FN=.config 69 FN=.config
61fi 70fi
@@ -68,27 +77,39 @@ while [ "$1" != "" ] ; do
68 CMD="$1" 77 CMD="$1"
69 shift 78 shift
70 case "$CMD" in 79 case "$CMD" in
71 --enable|-e) 80 --refresh)
81 ;;
82 --*-after)
83 checkarg "$1"
84 A=$ARG
85 checkarg "$2"
86 B=$ARG
87 shift 2
88 ;;
89 --*)
72 checkarg "$1" 90 checkarg "$1"
73 replace "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/"
74 shift 91 shift
75 ;; 92 ;;
93 esac
94 case "$CMD" in
95 --enable|-e)
96 set_var "CONFIG_$ARG" "CONFIG_$ARG=y"
97 ;;
76 98
77 --disable|-d) 99 --disable|-d)
78 checkarg "$1" 100 set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set"
79 replace "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/"
80 shift
81 ;; 101 ;;
82 102
83 --module|-m) 103 --module|-m)
84 checkarg "$1" 104 set_var "CONFIG_$ARG" "CONFIG_$ARG=m"
85 replace "s/CONFIG_$ARG=y/CONFIG_$ARG=m/" \ 105 ;;
86 -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=m/" 106
107 --set-str)
108 set_var "CONFIG_$ARG" "CONFIG_$ARG=\"$1\""
87 shift 109 shift
88 ;; 110 ;;
89 111
90 --state|-s) 112 --state|-s)
91 checkarg "$1"
92 if grep -q "# CONFIG_$ARG is not set" $FN ; then 113 if grep -q "# CONFIG_$ARG is not set" $FN ; then
93 echo n 114 echo n
94 else 115 else
@@ -101,44 +122,18 @@ while [ "$1" != "" ] ; do
101 echo "$V" 122 echo "$V"
102 fi 123 fi
103 fi 124 fi
104 shift
105 ;; 125 ;;
106 126
107 --enable-after|-E) 127 --enable-after|-E)
108 checkarg "$1" 128 set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A"
109 A=$ARG
110 checkarg "$2"
111 B=$ARG
112 replace "/CONFIG_$A=[my]/aCONFIG_$B=y" \
113 -e "/# CONFIG_$ARG is not set/a/CONFIG_$ARG=y" \
114 -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/"
115 shift
116 shift
117 ;; 129 ;;
118 130
119 --disable-after|-D) 131 --disable-after|-D)
120 checkarg "$1" 132 set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A"
121 A=$ARG
122 checkarg "$2"
123 B=$ARG
124 replace "/CONFIG_$A=[my]/a# CONFIG_$B is not set" \
125 -e "/# CONFIG_$ARG is not set/a/# CONFIG_$ARG is not set" \
126 -e "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/"
127 shift
128 shift
129 ;; 133 ;;
130 134
131 --module-after|-M) 135 --module-after|-M)
132 checkarg "$1" 136 set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A"
133 A=$ARG
134 checkarg "$2"
135 B=$ARG
136 replace "/CONFIG_$A=[my]/aCONFIG_$B=m" \
137 -e "/# CONFIG_$ARG is not set/a/CONFIG_$ARG=m" \
138 -e "s/CONFIG_$ARG=y/CONFIG_$ARG=m/" \
139 -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=m/"
140 shift
141 shift
142 ;; 137 ;;
143 138
144 # undocumented because it ignores --file (fixme) 139 # undocumented because it ignores --file (fixme)