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[ ]*\$/,\${
95 /<file:\\([^>]*\\)>/s//\\1/g
97 }" Documentation/Configure.help)
100 echo; echo " Sorry, no help available for this option yet.";echo
102 (echo; echo "$text") | ${PAGER:-more}
106 echo " Can't access the file Documentation/Configure.help which"
107 echo " should contain the help texts."
114 # readln reads a line into $ans.
116 # readln prompt default oldval
119 if [ "$DEFAULT" = "-d" -a -n "$3" ]; then
124 [ -z "$3" ] && echo -n "(NEW) "
125 IFS='@' read ans || exit 1
126 [ -z "$ans" ] && ans=$2
131 # comment does some pretty-printing
135 function comment () {
136 echo "*"; echo "* $1" ; echo "*"
137 (echo "" ; echo "#"; echo "# $1" ; echo "#") >>$CONFIG
138 (echo "" ; echo "/*"; echo " * $1" ; echo " */") >>$CONFIG_H
142 # define_bool sets the value of a boolean argument
144 # define_bool define value
146 function define_bool () {
147 define_tristate $1 $2
150 function define_tristate () {
153 echo "$1=y" >>$CONFIG
154 echo "#define $1 1" >>$CONFIG_H
158 echo "$1=m" >>$CONFIG
159 echo "#undef $1" >>$CONFIG_H
160 echo "#define $1_MODULE 1" >>$CONFIG_H
164 echo "# $1 is not set" >>$CONFIG
165 echo "#undef $1" >>$CONFIG_H
172 # bool processes a boolean argument
174 # bool question define
177 old=$(eval echo "\${$2}")
180 "y" | "m") defprompt="Y/n/?"
183 "n") defprompt="N/y/?"
187 readln "$1 ($2) [$defprompt] " "$def" "$old"
189 [yY] | [yY]es ) define_bool "$2" "y"
191 [nN] | [nN]o ) define_bool "$2" "n"
200 # tristate processes a tristate argument
202 # tristate question define
204 function tristate () {
205 if [ "$CONFIG_MODULES" != "y" ]; then
208 old=$(eval echo "\${$2}")
211 "y") defprompt="Y/m/n/?"
213 "m") defprompt="M/n/y/?"
215 "n") defprompt="N/y/m/?"
219 readln "$1 ($2) [$defprompt] " "$def" "$old"
221 [yY] | [yY]es ) define_tristate "$2" "y"
223 [nN] | [nN]o ) define_tristate "$2" "n"
225 [mM] ) define_tristate "$2" "m"
235 # dep_tristate processes a tristate argument that depends upon
236 # another option or options. If any of the options we depend upon is a
237 # module, then the only allowable options are M or N. If all are Y, then
238 # this is a normal tristate. This is used in cases where modules
239 # are nested, and one module requires the presence of something
240 # else in the kernel.
242 # dep_tristate question define default ...
244 function dep_tristate () {
245 old=$(eval echo "\${$2}")
251 while [ $# -gt 0 ]; do
254 define_tristate "$var" "n"
264 if [ $need_module = 1 ]; then
265 if [ "$CONFIG_MODULES" = "y" ]; then
267 "y" | "m") defprompt="M/n/?"
270 "n") defprompt="N/m/?"
274 readln "$ques ($var) [$defprompt] " "$def" "$old"
276 [nN] | [nN]o ) define_tristate "$var" "n"
278 [mM] ) define_tristate "$var" "m"
281 echo " This answer is not allowed, because it is not consistent with"
282 echo " your other choices."
283 echo " This driver depends on another one which you chose to compile"
284 echo " as a module. This means that you can either compile this one"
285 echo " as a module as well (with M) or leave it out altogether (N)."
294 tristate "$ques" "$var"
298 function dep_bool () {
302 while [ $# -gt 0 ]; do
305 define_bool "$var" "n"
315 function dep_mbool () {
319 while [ $# -gt 0 ]; do
322 define_bool "$var" "n"
333 # define_int sets the value of a integer argument
335 # define_int define value
337 function define_int () {
338 echo "$1=$2" >>$CONFIG
339 echo "#define $1 ($2)" >>$CONFIG_H
344 # int processes an integer argument with optional limits
346 # int question define default
349 old=$(eval echo "\${$2}")
352 readln "$1 ($2) [$def] " "$def" "$old"
353 if expr "$ans" : '[0-9]*$' > /dev/null; then
354 define_int "$2" "$ans"
363 # define_hex sets the value of a hexadecimal argument
365 # define_hex define value
367 function define_hex () {
368 echo "$1=$2" >>$CONFIG
369 echo "#define $1 0x${2#*[x,X]}" >>$CONFIG_H
374 # hex processes an hexadecimal argument
376 # hex question define default
379 old=$(eval echo "\${$2}")
383 readln "$1 ($2) [$def] " "$def" "$old"
385 if expr "$ans" : '[0-9a-fA-F][0-9a-fA-F]*$' > /dev/null; then
386 define_hex "$2" "$ans"
395 # define_string sets the value of a string argument
397 # define_string define value
399 function define_string () {
400 echo "$1=\"$2\"" >>$CONFIG
401 echo "#define $1 \"$2\"" >>$CONFIG_H
406 # string processes a string argument
408 # string question define default
411 old=$(eval echo "\${$2}")
414 if [ "$old" = "?" ]; then
415 readln "$1 ($2) [$def] " "$def" ""
417 readln "$1 ($2) [$def] " "$def" "$old"
419 if [ "$ans" = "?" ]; then
425 define_string "$2" "$ans"
428 # choice processes a choice list (1-out-of-n)
430 # choice question choice-list default
432 # The choice list has a syntax of:
433 # NAME WHITESPACE VALUE { WHITESPACE NAME WHITESPACE VALUE }
434 # The user may enter any unique prefix of one of the NAMEs and
435 # choice will define VALUE as if it were a boolean option.
436 # VALUE must be in all uppercase. Normally, VALUE is of the
437 # form CONFIG_<something>. Thus, if the user selects <something>,
438 # the CPP symbol CONFIG_<something> will be defined and the
439 # shell variable CONFIG_<something> will be set to "y".
447 # determine default answer:
451 while [ -n "$2" ]; do
452 if [ -n "$names" ]; then
457 if [ "$(eval echo \"\${$2}\")" = "y" ]; then
465 while [ -z "$val" ]; do
467 readln "$question ($names) [$def] " "$def" "$old"
468 ans=$(echo $ans | tr a-z A-Z)
470 while [ -n "$1" ]; do
471 name=$(echo $1 | tr a-z A-Z)
473 "$ans"* | */"$ans"* )
475 "$ans" | */"$ans"/* | \
476 "$ans"/* | */"$ans" )
481 if [ -n "$val" ]; then
483 " Sorry, \"$ans\" is ambiguous; please enter a longer string."
494 if [ "$val" = "" -a "$ambg" = "n" ]; then
499 while [ -n "$2" ]; do
500 if [ "$2" = "$val" ]; then
511 CONFIG_H=.tmpconfig.h
512 trap "rm -f $CONFIG $CONFIG_H ; exit 1" 1 2
515 # Make sure we start out with a clean slate.
518 echo "# Automatically generated make config: don't edit" >> $CONFIG
521 echo "/*" > $CONFIG_H
522 echo " * Automatically generated C config: don't edit" >> $CONFIG_H
523 echo " */" >> $CONFIG_H
524 echo "#define AUTOCONF_INCLUDED" >> $CONFIG_H
527 if [ "$1" = "-d" ] ; then
532 CONFIG_IN=./config.in
533 if [ "$1" != "" ] ; then
537 DEFAULTS=arch/$ARCH/defconfig
538 if [ -f .config ]; then
542 if [ -f $DEFAULTS ]; then
544 echo "# Using defaults found in" $DEFAULTS
547 sed -e 's/# \(CONFIG_[^ ]*\) is not.*/\1=n/' <$DEFAULTS >.config-is-not.$$
552 echo "# No defaults found"
559 if [ -f .config ]; then
560 mv .config .config.old
562 mv .tmpconfig .config
563 mv .tmpconfig.h include/linux/autoconf.h
566 echo "*** End of Linux kernel configuration."
567 echo "*** Check the top-level Makefile for additional configuration."
568 if [ ! -f .hdepend -o "$CONFIG_MODVERSIONS" = "y" ] ; then
569 echo "*** Next, you must run 'make dep'."
571 echo "*** Next, you may run 'make bzImage', 'make bzdisk', or 'make install'."