MIPS: TXx9: update defconfigs
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / scripts / config
blobdb6084b78a10dde77acda0f6365aa68ea239369e
1 #!/bin/bash
2 # Manipulate options in a .config file from the command line
4 usage() {
5 cat >&2 <<EOL
6 Manipulate options in a .config file from the command line.
7 Usage:
8 config options command ...
9 commands:
10 --enable|-e option Enable option
11 --disable|-d option Disable option
12 --module|-m option Turn option into a module
13 --state|-s option Print state of option (n,y,m,undef)
15 --enable-after|-E beforeopt option
16 Enable option directly after other option
17 --disable-after|-D beforeopt option
18 Disable option directly after other option
19 --module-after|-M beforeopt option
20 Turn option into module directly after other option
22 commands can be repeated multiple times
24 options:
25 --file .config file to change (default .config)
27 config doesn't check the validity of the .config file. This is done at next
28 make time.
29 The options need to be already in the file before they can be changed,
30 but sometimes you can cheat with the --*-after options.
31 EOL
32 exit 1
35 checkarg() {
36 ARG="$1"
37 if [ "$ARG" = "" ] ; then
38 usage
40 case "$ARG" in
41 CONFIG_*)
42 ARG="${ARG/CONFIG_/}"
44 esac
45 ARG="`echo $ARG | tr a-z A-Z`"
48 replace() {
49 sed -i -e "$@" $FN
52 if [ "$1" = "--file" ]; then
53 FN="$2"
54 if [ "$FN" = "" ] ; then
55 usage
57 shift
58 shift
59 else
60 FN=.config
63 if [ "$1" = "" ] ; then
64 usage
67 while [ "$1" != "" ] ; do
68 CMD="$1"
69 shift
70 case "$CMD" in
71 --enable|-e)
72 checkarg "$1"
73 replace "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/"
74 shift
77 --disable|-d)
78 checkarg "$1"
79 replace "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/"
80 shift
83 --module|-m)
84 checkarg "$1"
85 replace "s/CONFIG_$ARG=y/CONFIG_$ARG=m/" \
86 -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=m/"
87 shift
90 --state|-s)
91 checkarg "$1"
92 if grep -q "# CONFIG_$ARG is not set" $FN ; then
93 echo n
94 else
95 V="$(grep "^CONFIG_$ARG=" $FN)"
96 if [ $? != 0 ] ; then
97 echo undef
98 else
99 V="${V/CONFIG_$ARG=/}"
100 V="${V/\"/}"
101 echo "$V"
104 shift
107 --enable-after|-E)
108 checkarg "$1"
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
119 --disable-after|-D)
120 checkarg "$1"
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
131 --module-after|-M)
132 checkarg "$1"
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
144 # undocumented because it ignores --file (fixme)
145 --refresh)
146 yes "" | make oldconfig
150 usage
152 esac
153 done