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
() {
146 define_tristate
$1 $2
149 function define_tristate
() {
152 echo "$1=y" >>$CONFIG
153 echo "#define $1 1" >>$CONFIG_H
157 echo "$1=m" >>$CONFIG
158 echo "#undef $1" >>$CONFIG_H
159 echo "#define $1_MODULE 1" >>$CONFIG_H
163 echo "# $1 is not set" >>$CONFIG
164 echo "#undef $1" >>$CONFIG_H
171 # bool processes a boolean argument
173 # bool question define
176 old
=$
(eval echo "\${$2}")
179 "y" |
"m") defprompt
="Y/n/?"
182 "n") defprompt
="N/y/?"
186 readln
"$1 ($2) [$defprompt] " "$def" "$old"
188 [yY
] |
[yY
]es
) define_bool
"$2" "y"
190 [nN
] |
[nN
]o
) define_bool
"$2" "n"
199 # tristate processes a tristate argument
201 # tristate question define
203 function tristate
() {
204 if [ "$CONFIG_MODULES" != "y" ]; then
207 old
=$
(eval echo "\${$2}")
210 "y") defprompt
="Y/m/n/?"
212 "m") defprompt
="M/n/y/?"
214 "n") defprompt
="N/y/m/?"
218 readln
"$1 ($2) [$defprompt] " "$def" "$old"
220 [yY
] |
[yY
]es
) define_tristate
"$2" "y"
222 [nN
] |
[nN
]o
) define_tristate
"$2" "n"
224 [mM
] ) define_tristate
"$2" "m"
234 # dep_tristate processes a tristate argument that depends upon
235 # another option or options. If any of the options we depend upon is a
236 # module, then the only allowable options are M or N. If all are Y, then
237 # this is a normal tristate. This is used in cases where modules
238 # are nested, and one module requires the presence of something
239 # else in the kernel.
241 # dep_tristate question define default ...
243 function dep_tristate
() {
244 old
=$
(eval echo "\${$2}")
250 while [ $# -gt 0 ]; do
253 define_tristate
"$var" "n"
263 if [ $need_module = 1 ]; then
264 if [ "$CONFIG_MODULES" = "y" ]; then
266 "y" |
"m") defprompt
="M/n/?"
269 "n") defprompt
="N/m/?"
273 readln
"$ques ($var) [$defprompt] " "$def" "$old"
275 [nN
] |
[nN
]o
) define_tristate
"$var" "n"
277 [mM
] ) define_tristate
"$var" "m"
280 echo " This answer is not allowed, because it is not consistent with"
281 echo " your other choices."
282 echo " This driver depends on another one which you chose to compile"
283 echo " as a module. This means that you can either compile this one"
284 echo " as a module as well (with M) or leave it out altogether (N)."
293 tristate
"$ques" "$var"
297 function dep_bool
() {
301 while [ $# -gt 0 ]; do
304 define_bool
"$var" "n"
314 function dep_mbool
() {
318 while [ $# -gt 0 ]; do
321 define_bool
"$var" "n"
332 # define_int sets the value of a integer argument
334 # define_int define value
336 function define_int
() {
337 echo "$1=$2" >>$CONFIG
338 echo "#define $1 ($2)" >>$CONFIG_H
343 # int processes an integer argument with optional limits
345 # int question define default [min max]
348 old
=$
(eval echo "\${$2}")
350 if [ $# -gt 3 ]; then
355 if [ $# -gt 4 ]; then
361 readln
"$1 ($2) [$def] " "$def" "$old"
362 if expr \
( \
( $ans + 0 \
) \
>= $min \
) \
& \
( $ans \
<= $max \
) >/dev
/null
2>&1 ; then
363 define_int
"$2" "$ans"
372 # define_hex sets the value of a hexadecimal argument
374 # define_hex define value
376 function define_hex
() {
377 echo "$1=$2" >>$CONFIG
378 echo "#define $1 0x${2#*[x,X]}" >>$CONFIG_H
383 # hex processes an hexadecimal argument
385 # hex question define default
388 old
=$
(eval echo "\${$2}")
392 readln
"$1 ($2) [$def] " "$def" "$old"
394 if expr "$ans" : '[0-9a-fA-F][0-9a-fA-F]*$' > /dev
/null
; then
395 define_hex
"$2" "$ans"
404 # define_string sets the value of a string argument
406 # define_string define value
408 function define_string
() {
409 echo "$1=\"$2\"" >>$CONFIG
410 echo "#define $1 \"$2\"" >>$CONFIG_H
415 # string processes a string argument
417 # string question define default
420 old
=$
(eval echo "\${$2}")
422 readln
"$1 ($2) [$def] " "$def" "$old"
423 define_string
"$2" "$ans"
426 # choice processes a choice list (1-out-of-n)
428 # choice question choice-list default
430 # The choice list has a syntax of:
431 # NAME WHITESPACE VALUE { WHITESPACE NAME WHITESPACE VALUE }
432 # The user may enter any unique prefix of one of the NAMEs and
433 # choice will define VALUE as if it were a boolean option.
434 # VALUE must be in all uppercase. Normally, VALUE is of the
435 # form CONFIG_<something>. Thus, if the user selects <something>,
436 # the CPP symbol CONFIG_<something> will be defined and the
437 # shell variable CONFIG_<something> will be set to "y".
445 # determine default answer:
449 while [ -n "$2" ]; do
450 if [ -n "$names" ]; then
455 if [ "$(eval echo \"\${$2}\")" = "y" ]; then
463 while [ -z "$val" ]; do
465 readln
"$question ($names) [$def] " "$def" "$old"
466 ans
=$
(echo $ans |
tr a-z A-Z
)
468 while [ -n "$1" ]; do
469 name
=$
(echo $1 |
tr a-z A-Z
)
472 if [ "$name" = "$ans" ]; then
474 break # stop on exact match
476 if [ -n "$val" ]; then
478 " Sorry, \"$ans\" is ambiguous; please enter a longer string."
489 if [ "$val" = "" -a "$ambg" = "n" ]; then
494 while [ -n "$2" ]; do
495 if [ "$2" = "$val" ]; then
506 CONFIG_H
=.tmpconfig.h
507 trap "rm -f $CONFIG $CONFIG_H ; exit 1" 1 2
510 # Make sure we start out with a clean slate.
513 echo "# Automatically generated make config: don't edit" >> $CONFIG
516 echo "/*" > $CONFIG_H
517 echo " * Automatically generated C config: don't edit" >> $CONFIG_H
518 echo " */" >> $CONFIG_H
519 echo "#define AUTOCONF_INCLUDED" >> $CONFIG_H
522 if [ "$1" = "-d" ] ; then
527 CONFIG_IN
=.
/config.
in
528 if [ "$1" != "" ] ; then
532 DEFAULTS
=arch
/$ARCH/defconfig
533 if [ -f .config
]; then
537 if [ -f $DEFAULTS ]; then
539 echo "# Using defaults found in" $DEFAULTS
542 sed -e 's/# \(.*\) is not.*/\1=n/' < $DEFAULTS > .config-is-not.$$
547 echo "# No defaults found"
554 if [ -f .config
]; then
555 mv .config .config.old
557 mv .tmpconfig .config
558 mv .tmpconfig.h include
/linux
/autoconf.h
561 echo "*** End of Linux kernel configuration."
562 echo "*** Check the top-level Makefile for additional configuration."
563 if [ ! -f .hdepend
-o "$CONFIG_MODVERSIONS" = "y" ] ; then
564 echo "*** Next, you must run 'make dep'."
566 echo "*** Next, you may run 'make zImage', 'make zdisk', or 'make zlilo'."