3 # This script is used to configure the Linux kernel.
5 # It was inspired by the challenge in the original Configure script
6 # to ``do something better'', combined with the actual need to ``do
7 # something better'' because the old configure script wasn't flexible
10 # Raymond Chen was the original author of Configure.
11 # Michael Elizabeth Chastain (mec@shout.net) is the current maintainer.
13 # 050793 - use IFS='@' to get around a bug in a pre-version of bash-1.13
16 # 030995 (storner@osiris.ping.dk) - added support for tri-state answers,
17 # for selecting modules to compile.
19 # 180995 Bernhard Kaindl (bkaindl@ping.at) - added dummy functions for
20 # use with a config.in modified for make menuconfig.
22 # 301195 (boldt@math.ucsb.edu) - added help text support
24 # 281295 Paul Gortmaker - make tri_state functions collapse to boolean
25 # if module support is not enabled.
27 # 010296 Aaron Ucko (ucko@vax1.rockhurst.edu) - fix int and hex to accept
30 # 150296 Dick Streefland (dicks@tasking.nl) - report new configuration
31 # items and ask for a value even when doing a "make oldconfig"
33 # 200396 Tom Dyas (tdyas@eden.rutgers.edu) - when the module option is
34 # chosen for an item, define the macro <option_name>_MODULE
36 # 090397 Axel Boldt (boldt@math.ucsb.edu) - avoid ? and + in regular
37 # expressions for GNU expr since version 1.15 and up use \? and \+.
39 # 300397 Phil Blundell (pjb27@cam.ac.uk) - added support for min/max
40 # arguments to "int", allow dep_tristate to take a list of dependencies
41 # rather than just one.
43 # 090398 Axel Boldt (boldt@math.ucsb.edu) - allow for empty lines in help
46 # 102598 Michael Chastain (mec@shout.net) - put temporary files in
47 # current directory, not in /tmp.
49 # 24 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
50 # - Improve the exit message (Jeff Ronne).
53 # Make sure we're really running bash.
55 # I would really have preferred to write this script in a language with
56 # better string handling, but alas, bash is the only scripting language
57 # that I can be reasonable sure everybody has on their linux machine.
59 [ -z "$BASH" ] && { echo "Configure requires bash" 1>&2; exit 1; }
61 # Disable filename globbing once and for all.
62 # Enable function cacheing.
66 # Dummy functions for use with a config.in modified for menuconf
68 function mainmenu_option
() {
71 function mainmenu_name
() {
79 # help prints the corresponding help text from Configure.help to stdout
84 if [ -f Documentation
/Configure.
help ]
86 #first escape regexp special characters in the argument:
87 var
=$
(echo "$1"|
sed 's/[][\/.^$*]/\\&/g')
88 #now pick out the right help text:
89 text
=$
(sed -n "/^$var[ ]*\$/,\${
96 }" Documentation
/Configure.
help)
99 echo; echo " Sorry, no help available for this option yet.";echo
101 (echo; echo "$text") |
${PAGER:-more}
105 echo " Can't access the file Documentation/Configure.help which"
106 echo " should contain the help texts."
113 # readln reads a line into $ans.
115 # readln prompt default oldval
118 if [ "$DEFAULT" = "-d" -a -n "$3" ]; then
123 [ -z "$3" ] && echo -n "(NEW) "
124 IFS
='@' read ans ||
exit 1
125 [ -z "$ans" ] && ans
=$2
130 # comment does some pretty-printing
134 function comment
() {
135 echo "*"; echo "* $1" ; echo "*"
136 (echo "" ; echo "#"; echo "# $1" ; echo "#") >>$CONFIG
137 (echo "" ; echo "/*"; echo " * $1" ; echo " */") >>$CONFIG_H
141 # define_bool sets the value of a boolean argument
143 # define_bool define value
145 function define_bool
() {
148 echo "$1=y" >>$CONFIG
149 echo "#define $1 1" >>$CONFIG_H
153 echo "$1=m" >>$CONFIG
154 echo "#undef $1" >>$CONFIG_H
155 echo "#define $1_MODULE 1" >>$CONFIG_H
159 echo "# $1 is not set" >>$CONFIG
160 echo "#undef $1" >>$CONFIG_H
167 # bool processes a boolean argument
169 # bool question define
172 old
=$
(eval echo "\${$2}")
175 "y" |
"m") defprompt
="Y/n/?"
178 "n") defprompt
="N/y/?"
182 readln
"$1 ($2) [$defprompt] " "$def" "$old"
184 [yY
] |
[yY
]es
) define_bool
"$2" "y"
186 [nN
] |
[nN
]o
) define_bool
"$2" "n"
195 # tristate processes a tristate argument
197 # tristate question define
199 function tristate
() {
200 if [ "$CONFIG_MODULES" != "y" ]; then
203 old
=$
(eval echo "\${$2}")
206 "y") defprompt
="Y/m/n/?"
208 "m") defprompt
="M/n/y/?"
210 "n") defprompt
="N/y/m/?"
214 readln
"$1 ($2) [$defprompt] " "$def" "$old"
216 [yY
] |
[yY
]es
) define_bool
"$2" "y"
218 [nN
] |
[nN
]o
) define_bool
"$2" "n"
220 [mM
] ) define_bool
"$2" "m"
230 # dep_tristate processes a tristate argument that depends upon
231 # another option or options. If any of the options we depend upon is a
232 # module, then the only allowable options are M or N. If all are Y, then
233 # this is a normal tristate. This is used in cases where modules
234 # are nested, and one module requires the presence of something
235 # else in the kernel.
237 # dep_tristate question define default ...
239 function dep_tristate
() {
240 old
=$
(eval echo "\${$2}")
246 while [ $# -gt 0 ]; do
249 define_bool
"$var" "n"
259 if [ $need_module = 1 ]; then
260 if [ "$CONFIG_MODULES" = "y" ]; then
262 "y" |
"m") defprompt
="M/n/?"
265 "n") defprompt
="N/m/?"
269 readln
"$ques ($var) [$defprompt] " "$def" "$old"
271 [nN
] |
[nN
]o
) define_bool
"$var" "n"
273 [mM
] ) define_bool
"$var" "m"
276 echo " This answer is not allowed, because it is not consistent with"
277 echo " your other choices."
278 echo " This driver depends on another one which you chose to compile"
279 echo " as a module. This means that you can either compile this one"
280 echo " as a module as well (with M) or leave it out altogether (N)."
289 tristate
"$ques" "$var"
294 # define_int sets the value of a integer argument
296 # define_int define value
298 function define_int
() {
299 echo "$1=$2" >>$CONFIG
300 echo "#define $1 ($2)" >>$CONFIG_H
305 # int processes an integer argument with optional limits
307 # int question define default [min max]
310 old
=$
(eval echo "\${$2}")
312 if [ $# -gt 3 ]; then
317 if [ $# -gt 4 ]; then
323 readln
"$1 ($2) [$def] " "$def" "$old"
324 if expr \
( \
( $ans + 0 \
) \
>= $min \
) \
& \
( $ans \
<= $max \
) >/dev
/null
2>&1 ; then
325 define_int
"$2" "$ans"
334 # define_hex sets the value of a hexadecimal argument
336 # define_hex define value
338 function define_hex
() {
339 echo "$1=$2" >>$CONFIG
340 echo "#define $1 0x${2#*[x,X]}" >>$CONFIG_H
345 # hex processes an hexadecimal argument
347 # hex question define default
350 old
=$
(eval echo "\${$2}")
354 readln
"$1 ($2) [$def] " "$def" "$old"
356 if expr "$ans" : '[0-9a-fA-F][0-9a-fA-F]*$' > /dev
/null
; then
357 define_hex
"$2" "$ans"
366 # define_string sets the value of a string argument
368 # define_string define value
370 function define_string
() {
371 echo "$1="'"'$2'"' >>$CONFIG
372 echo "#define $1 "'"'$2'"' >>$CONFIG_H
377 # string processes a string argument
379 # string question define default
382 old
=$
(eval echo "\${$2}")
384 readln
"$1 ($2) [$def] " "$def" "$old"
385 define_string
"$2" "$ans"
388 # choice processes a choice list (1-out-of-n)
390 # choice question choice-list default
392 # The choice list has a syntax of:
393 # NAME WHITESPACE VALUE { WHITESPACE NAME WHITESPACE VALUE }
394 # The user may enter any unique prefix of one of the NAMEs and
395 # choice will define VALUE as if it were a boolean option.
396 # VALUE must be in all uppercase. Normally, VALUE is of the
397 # form CONFIG_<something>. Thus, if the user selects <something>,
398 # the CPP symbol CONFIG_<something> will be defined and the
399 # shell variable CONFIG_<something> will be set to "y".
407 # determine default answer:
411 while [ -n "$2" ]; do
412 if [ -n "$names" ]; then
417 if [ "$(eval echo \"\${$2}\")" = "y" ]; then
425 while [ -z "$val" ]; do
427 readln
"$question ($names) [$def] " "$def" "$old"
428 ans
=$
(echo $ans |
tr a-z A-Z
)
430 while [ -n "$1" ]; do
431 name
=$
(echo $1 |
tr a-z A-Z
)
434 if [ "$name" = "$ans" ]; then
436 break # stop on exact match
438 if [ -n "$val" ]; then
440 " Sorry, \"$ans\" is ambiguous; please enter a longer string."
451 if [ "$val" = "" -a "$ambg" = "n" ]; then
456 while [ -n "$2" ]; do
457 if [ "$2" = "$val" ]; then
468 CONFIG_H
=.tmpconfig.h
469 trap "rm -f $CONFIG $CONFIG_H ; exit 1" 1 2
472 # Make sure we start out with a clean slate.
475 echo "# Automatically generated make config: don't edit" >> $CONFIG
478 echo "/*" > $CONFIG_H
479 echo " * Automatically generated C config: don't edit" >> $CONFIG_H
480 echo " */" >> $CONFIG_H
481 echo "#define AUTOCONF_INCLUDED" >> $CONFIG_H
484 if [ "$1" = "-d" ] ; then
489 CONFIG_IN
=.
/config.
in
490 if [ "$1" != "" ] ; then
494 DEFAULTS
=arch
/$ARCH/defconfig
495 if [ -f .config
]; then
499 if [ -f $DEFAULTS ]; then
501 echo "# Using defaults found in" $DEFAULTS
504 sed -e 's/# \(.*\) is not.*/\1=n/' < $DEFAULTS > .config-is-not.$$
509 echo "# No defaults found"
516 if [ -f .config
]; then
517 mv .config .config.old
519 mv .tmpconfig .config
520 mv .tmpconfig.h include
/linux
/autoconf.h
523 echo "*** End of Linux kernel configuration."
524 echo "*** Check the top-level Makefile for additional configuration."
525 if [ ! -f .hdepend
-o "$CONFIG_MODVERSIONS" = "y" ] ; then
526 echo "*** Next, you must run 'make dep'."
528 echo "*** Next, you may run 'make zImage', 'make zdisk', or 'make zlilo'."