3 # This script is used to configure the Undernet Daemon.
4 # It was copied from the linux kernel distribution and only slightly
7 # 170897 (carlo@runaway.xs4all.nl) -
8 # Changed the default configuration file to be defconfig.
9 # Changed the location of autoconf.h to be 'include/'.
10 # Changed the final text printed at the end.
11 # Changed replacement to only match 'is not set' (and not 'is not').
12 # Added function string() and define_string().
13 # Added function define_macro()
15 # 180897 (carlo@runaway.xs4all.nl) -
16 # Changed bool() so it can take a default argument.
17 # Introduced hard link ../.config, to inherit config files over new
19 # Got rid of 'is not set' and using '=n' instead.
20 # Changed configuration help file to be doc/Configure.help.
21 # Changed DEFAULT into USE_DEFAULT, which is asked for in config.in.
23 # 210897 (carlo@runaway.xs4all.nl) -
24 # Changed the location of autoconf.h and .config to be 'configure/'.
25 # Fixed the script to work with a general 'sh' and not only with bash.
26 # (removing 'function', using `` instead of $(), using \\$ inside
27 # that instead of \$, using 'eval set -- $choices' rather then
28 # 'set -- $choices', introduction of function 'expr' instead of
29 # using external executable 'expr', using set -fh rather then
30 # set -f -h, using "" around reg.exp rather then '' and removing
31 # unnecessary backslashes from it).
32 # Removed tristate and hex functions.
33 # Making the hardlink to ../.config only when configure/.config doesn't exist.
35 # 280897 (carlo@runaway.xs4all.nl) -
36 # Added CONFIG_NEW: Ask if one wants to use this configuration as main
38 # Changed /bin/rm into $RM, so now this environment variable must be set!
40 # 290897 (carlo@runaway.xs4all.nl) -
41 # Added support for the solaris Born shell.
42 # Changed the directory configure/ to config/ in order not to collide with
43 # GNU autoconf in the future.
45 # 020997 (carlo@runaway.xs4all.nl) -
46 # The future is here... renamed 'config.in' to 'config-sh', reserving
47 # 'file.in' for input files of autoconfs' 'configure' script.
48 # 'autoconf.h' has been renamed to 'config.h', because it would be confusing
49 # otherwise with autoconf.
50 # Changed Configure to be run from within config/.
52 # 050997 (carlo@runaway.xs4all.nl) -
53 # Don't use 'def={$old:-$3}' but instead the equivalent ': ${def=$3}' because
54 # some sh don't understand the first expression.
55 # Pressing a 'c' at any question continues in 'batch' mode.
57 # 220199 (carlo@runaway.xs4all.nl) -
58 # Put MACRO name at front, making it easier to find it when scanning
59 # through the defaults to change just one.
60 # Make pressing 'c' stop at every paragraph, and pressing 'C' finish the
63 # -----------------------------------------------------------------------------
65 # This script is used to configure the linux kernel.
67 # It was inspired by the challenge in the original Configure script
68 # to ``do something better'', combined with the actual need to ``do
69 # something better'' because the old configure script wasn't flexible
72 # Please send comments / questions / bug fixes to raymondc@microsoft.com.
74 # ***** IMPORTANT COMPATIBILITY NOTE ****
75 # If configuration changes are made which might adversely effect
76 # Menuconfig or xconfig, please notify the respective authors so that
77 # those utilities can be updated in parallel.
79 # Menuconfig: <roadcapw@cfw.com>
80 # xconfig: <apenwarr@foxnet.net> <eric@aib.com>
81 # ****************************************
83 # Each line in the config file is a command.
85 # 050793 - use IFS='@' to get around a bug in a pre-version of bash-1.13
88 # 030995 (storner@osiris.ping.dk) - added support for tri-state answers,
89 # for selecting modules to compile.
91 # 180995 Bernhard Kaindl (bkaindl@ping.at) - added dummy functions for
92 # use with a config.in modified for make menuconfig.
94 # 301195 (boldt@math.ucsb.edu) - added help text support
96 # 281295 Paul Gortmaker - make tri_state functions collapse to boolean
97 # if module support is not enabled.
99 # 010296 Aaron Ucko (ucko@vax1.rockhurst.edu) - fix int and hex to accept
102 # 150296 Dick Streefland (dicks@tasking.nl) - report new configuration
103 # items and ask for a value even when doing a "make oldconfig"
105 # 200396 Tom Dyas (tdyas@eden.rutgers.edu) - when the module option is
106 # chosen for an item, define the macro <option_name>_MODULE
108 # 090397 Axel Boldt (boldt@math.ucsb.edu) - avoid ? and + in regular
109 # expressions for GNU expr since version 1.15 and up use \? and \+.
111 #### Start of system configuration section. ####
116 unet_cv_sys_set_h=@unet_cv_sys_set_h@
118 #### End of system configuration section. ####
120 # Disable filename globbing
123 if test $unet_cv_sys_set_h = yes; then
127 # Figure out how to do 'echo' without newline:
130 if [ "`eval echo -n 'a'`" = "-n a" ] ; then
136 # Check if ${VAR:-def} works
138 DUMMY_VAR2="some value"
139 DUMMY_VAR=${DUMMY_VAR:-test}
140 DUMMY_VAR2=${DUMMY_VAR2:-test}
141 if [ "$DUMMY_VAR" != "test" -o "$DUMMY_VAR2" != "some value" ]; then
142 echo "You /bin/sh doesn't understand '\${VAR:-default}'"
147 # Dummy functions for use with a config.in modified for menuconf
160 # help prints the corresponding help text from Configure.help to stdout
165 if [ -f ../doc/Configure.help ]
167 #first escape regexp special characters in the argument:
168 var=`echo "$1"|sed 's/[][\/.^$*]/\\&/g'`
169 #now pick out the right help text:
170 text=`sed -n "/^$var[ ]*\\$/,\\${
175 }" ../doc/Configure.help`
178 echo; echo " Sorry, no help available for this option yet.";echo
180 (echo; echo "$text"; echo) | ${PAGER:-more}
184 echo " Can't access the file doc/Configure.help which"
185 echo " should contain the help texts."
192 # readln reads a line into $ans.
194 # readln macro prompt default oldval
197 echo $1 | awk '{ printf("%-20.20s: ", $1); }'
198 if [ "$USE_DEFAULT" != "n" -a -n "$4" ]; then
203 [ -z "$4" ] && echo $n "(NEW) $c"
204 IFS='@' read ans </dev/tty || exit 1
205 [ -z "$ans" ] && ans=$3
206 if [ "$ans" = "c" -o "$ans" = "C" ]; then
214 # comment does some pretty-printing
220 echo "*-----------------------------------------------------------------------------";
223 (echo "" ; echo "#"; echo "# $1" ; echo "#") >>$CONFIG
224 (echo "" ; echo "/*"; echo " * $1" ; echo " */") >>$CONFIG_H
225 if [ "$USE_DEFAULT" = "c" ]; then
231 # define_bool sets the value of a boolean argument
233 # define_bool define value
238 echo "$1=y" >>$CONFIG
239 echo "#define $1" >>$CONFIG_H
243 echo "$1=n" >>$CONFIG
244 echo "#undef $1" >>$CONFIG_H
251 # expr determines if string matches a regular expression
253 # expr string reg_exp
256 MATCH=`echo $1 | egrep -e $2`
257 if [ -z "$MATCH" ]; then
265 # bool processes a boolean argument
267 # bool question define
270 old=`eval echo "\\${$2}"`
271 if [ -z "$old" -a -n "$3" ]; then
287 readln $2 "$1 [$defprompt] " "$def" "$old"
307 # define_int sets the value of a integer argument
309 # define_int define value
312 echo "$1=$2" >>$CONFIG
313 echo "#define $1 ($2)" >>$CONFIG_H
318 # int processes an integer argument
320 # int question define default
323 old=`eval echo "\\${$2}"`
326 readln $2 "$1 [$def] " "$def" "$old"
327 if expr "$ans" "^0$|^(-[1-9]|[1-9])[0-9]*$"; then
328 define_int "$2" "$ans"
337 # choice processes a choice list (1-out-of-n)
339 # choice question choice-list default
341 # The choice list has a syntax of:
342 # NAME WHITESPACE VALUE { WHITESPACE NAME WHITESPACE VALUE }
343 # The user may enter any unique prefix of one of the NAMEs and
344 # choice will define VALUE as if it were a boolean option.
345 # VALUE must be in all uppercase. Normally, VALUE is of the
346 # form CONFIG_<something>. Thus, if the user selects <something>,
347 # the CPP symbol CONFIG_<something> will be defined and the
348 # shell variable CONFIG_<something> will be set to "y".
356 # determine default answer:
360 while [ -n "$2" ]; do
361 if [ -n "$names" ]; then
366 if [ "`eval echo "\\${$2}"`" = "y" ]; then
374 while [ -z "$val" ]; do
376 readln $names "$question [$def] " "$def" "$old"
377 ans=`echo $ans | tr a-z A-Z`
379 while [ -n "$1" ]; do
380 name=`echo $1 | tr a-z A-Z`
383 if [ "$name" = "$ans" ]; then
385 break # stop on exact match
387 if [ -n "$val" ]; then
390 " Sorry, \"$ans\" is ambiguous; please enter a longer string."
402 if [ "$val" = "" -a "$ambg" = "n" ]; then
407 while [ -n "$2" ]; do
408 if [ "$2" = "$val" ]; then
419 # define_macro sets the value of a macro argument
421 # define_macro define value
425 echo "$1=\"$2\"" >>$CONFIG
426 echo "#define $1 $2" >>$CONFIG_H
432 # define_string sets the value of a string argument
434 # define_string define value
438 echo "$1=\"$2\"" >>$CONFIG
439 echo "#define $1 \"$2\"" >>$CONFIG_H
445 # string processes a string argument
447 # string question define default
450 old=`eval echo "\\${$2}"`
453 readln $2 "$1 [$def] " "$def" "$old"
454 if expr "$ans" "^[^\"].*[^\"]$"; then
455 define_string "$2" "$ans"
464 CONFIG_H=.tmpconfig.h
465 trap "$RM -f $CONFIG $CONFIG_H ; exit 1" 1 2 15
468 # Make sure we start out with a clean slate.
471 echo "# Configuration default generated for:" > $CONFIG
472 echo '# `pwd`' > $CONFIG
474 echo "# Automatically generated by 'make config': don't edit" >> $CONFIG
477 echo "/*" > $CONFIG_H
478 echo " * Automatically generated C config: don't edit" >> $CONFIG_H
479 echo " */" >> $CONFIG_H
480 echo "#ifndef INCLUDED_config_h" >> $CONFIG_H
481 echo "#define INCLUDED_config_h" >> $CONFIG_H
482 echo "#ifndef INCLUDED_setup_h" >> $CONFIG_H
483 echo "#include \"setup.h\"">> $CONFIG_H
484 echo "#endif" >> $CONFIG_H
485 echo "#define AUTOCONF_INCLUDED" >> $CONFIG_H
487 CONFIG_IN=./config-sh
488 if [ "$1" != "" ] ; then
493 if [ -r .config ]; then
496 if [ -r ../../.config ]; then
498 echo "* WARNING: Inheriting .config from previous version!"
499 DEFAULTS=../../.config
503 if [ -r $DEFAULTS ]; then
505 echo "* Using defaults found in" $DEFAULTS
506 echo "* If you type a 'C' the script will finish using all defaults."
507 echo "* If you type a 'c' the script will skip to the next paragraph."
512 echo "* No defaults found"
518 echo "#endif /* INCLUDED_config_h */" >> $CONFIG_H
520 mv $CONFIG_H config.h
522 if [ -f .config ]; then
523 # Keep the inode of .config (hardlink to ../../.config) intact:
524 cp .config .config.old
525 cat $CONFIG > .config
528 if test ! -f .config -o ! -r ../../.config; then
529 if [ "$CONFIG_BATCH" = "y" ]; then
537 bool 'Use .config of THIS source tree as your upgrade default' CONFIG_NEW
539 if [ ! -f .config ]; then
542 if [ "$CONFIG_NEW" = "y" ]; then
545 $RM -f .config .config.cache
546 ln $CONFIG_CURDIR/.config .config
547 ln $CONFIG_CURDIR/config.cache .config.cache
549 echo "NOTE: Linking ../.config to THIS source tree's configuration !"
550 echo "(The configuration of this source tree will be used as default when you upgrade)"