URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [scripts/] [Menuconfig] - Rev 1765
Compare with Previous | Blame | View Log
#! /bin/sh## This script is used to configure the linux kernel.## It was inspired by a desire to not have to hit <enter> 9 million times# or startup the X server just to change a single kernel parameter.## This script attempts to parse the configuration files, which are# scattered throughout the kernel source tree, and creates a temporary# set of mini scripts which are in turn used to create nested menus and# radiolists.## It uses a very modified/mutilated version of the "dialog" utility# written by Savio Lam (lam836@cs.cuhk.hk). Savio is not responsible# for this script or the version of dialog used by this script.# Please do not contact him with questions. The official version of# dialog is available at sunsite.unc.edu or a sunsite mirror.## Portions of this script were borrowed from the original Configure# script.## William Roadcap was the original author of Menuconfig.# Michael Elizabeth Chastain (mec@shout.net) is the current maintainer.## 070497 Bernhard Kaindl (bkaindl@netway.at) - get default values for# new bool, tristate and dep_tristate parameters from the defconfig file.# new configuration parameters are marked with '(NEW)' as in make config.## 180697 Bernhard Kaindl (bkaindl@netway.at) - added the needed support# for string options. They are handled like the int and hex options.## 081297 Pavel Machek (pavel@atrey.karlin.mff.cuni.cz) - better error# handling## 131197 Michael Chastain (mec@shout.net) - output all lines for a# choice list, not just the selected one. This makes the output# the same as Configure output, which is important for smart config# dependencies.## 101297 Michael Chastain (mec@shout.net) - remove sound driver cruft.## 221297 Michael Chastain (mec@shout.net) - make define_bool actually# define its arguments so that later tests on them work right.## 160198 Michael Chastain (mec@shout.net) - fix bug with 'c' command# (complement existing value) when used on virgin uninitialized variables.## 090398 Axel Boldt (boldt@math.ucsb.edu) - allow for empty lines in help# texts.## 12 Dec 1998, Michael Elizabeth Chastain (mec@shout.net)# Remove a /tmp security hole in get_def (also makes it faster).# Give uninitialized variables canonical values rather than null value.# Change a lot of places to call set_x_info uniformly.# Take out message about preparing version (old sound driver cruft).## 13 Dec 1998, Riley H Williams <Riley@Williams.Name># When an error occurs, actually display the error message as well as# our comments thereon.## 31 Dec 1998, Michael Elizabeth Chastain (mec@shout.net)# Fix mod_bool to honor $CONFIG_MODULES.# Fix dep_tristate to call define_bool when dependency is "n".## 02 January 1999, Michael Elizabeth Chastain (mec@shout.net)# Blow away lxdialog.scrltmp on entry to activate_menu. This protects# against people who use commands like ' ' to select menus.## 24 January 1999, Michael Elizabeth Chastain, <mec@shout.net># - Improve the exit message (Jeff Ronne).## 06 July 1999, Andrzej M. Krzysztofowicz, <ankry@mif.pg.gda.pl># - Support for multiple conditions in dep_tristate().# - Implemented new functions: define_tristate(), define_int(), define_hex(),# define_string(), dep_bool().## 12 November 2001, Keith Owens <kaos@ocs.com.au># Escape double quotes on eval so the quotes are still there on the second# evaluation, required to handle strings with special characters.### Change this to TRUE if you prefer all kernel options listed# in a single menu rather than the standard menu hierarchy.#single_menu_mode=## Make sure we're really running bash.#[ -z "$BASH" ] && { echo "Menuconfig requires bash" 1>&2; exit 1; }## Cache function definitions, turn off posix compliance#set -h +o posix# Given a configuration variable, set the global variable $x to its value,# and the global variable $info to the string " (NEW)" if this is a new# variable.## This function looks for: (1) the current value, or (2) the default value# from the arch-dependent defconfig file, or (3) a default passed by the caller.function set_x_info () {eval x=\$$1if [ -z "$x" ]; theneval `sed -n -e 's/# \(.*\) is not set.*/\1=n/' -e "/^$1=/p" arch/$ARCH/defconfig`eval x=\${$1:-\"$2\"}eval $1=$xeval INFO_$1="' (NEW)'"fieval info=\"\$INFO_$1\"}## Load the functions used by the config.in files.## I do this because these functions must be redefined depending# on whether they are being called for interactive use or for# saving a configuration to a file.## Thank the heavens bash supports nesting function definitions.#load_functions () {## Additional comments#function comment () {comment_ctr=$[ comment_ctr + 1 ]echo -ne "': $comment_ctr' '--- $1' " >>MCmenu}## Define a boolean to a specific value.#function define_bool () {eval $1=$2}function define_tristate () {eval $1=$2}function define_hex () {eval $1=$2}function define_int () {eval $1=$2}function define_string () {eval $1=\"$2\"}## Create a boolean (Yes/No) function for our current menu# which calls our local bool function.#function bool () {set_x_info "$2" "n"case $x iny|m) flag="*" ;;n) flag=" " ;;esacecho -ne "'$2' '[$flag] $1$info' " >>MCmenuecho -e "function $2 () { l_bool '$2' \"\$1\" ;}\n" >>MCradiolists}## Create a tristate (Yes/No/Module) radiolist function# which calls our local tristate function.## Collapses to a boolean (Yes/No) if module support is disabled.#function tristate () {if [ "$CONFIG_MODULES" != "y" ]thenbool "$1" "$2"elseset_x_info "$2" "n"case $x iny) flag="*" ;;m) flag="M" ;;*) flag=" " ;;esacecho -ne "'$2' '<$flag> $1$info' " >>MCmenuecho -e "function $2 () { l_tristate '$2' \"\$1\" ;}" >>MCradiolistsfi}## Create a tristate radiolist function which is dependent on# another kernel configuration option.## Quote from the original configure script:## If the option we depend upon is a module,# then the only allowable options are M or N. If Y, then# this is a normal tristate. This is used in cases where modules# are nested, and one module requires the presence of something# else in the kernel.#function dep_tristate () {ques="$1"var="$2"dep=yshift 2while [ $# -gt 0 ]; doif [ "$1" = y ]; thenshiftelif [ "$1" = m ]; thendep=mshiftelsedep=nshift $#fidoneif [ "$dep" = y ]; thentristate "$ques" "$var"elif [ "$dep" = m ]; thenmod_bool "$ques" "$var"elsedefine_tristate "$var" nfi}## Same as above, but now only Y and N are allowed as dependency# (i.e. third and next arguments).#function dep_bool () {ques="$1"var="$2"dep=yshift 2while [ $# -gt 0 ]; doif [ "$1" = y ]; thenshiftelsedep=nshift $#fidoneif [ "$dep" = y ]; thenbool "$ques" "$var"elsedefine_bool "$var" nfi}function dep_mbool () {ques="$1"var="$2"dep=yshift 2while [ $# -gt 0 ]; doif [ "$1" = y -o "$1" = m ]; thenshiftelsedep=nshift $#fidoneif [ "$dep" = y ]; thenbool "$ques" "$var"elsedefine_bool "$var" nfi}## Add a menu item which will call our local int function.#function int () {set_x_info "$2" "$3"echo -ne "'$2' '($x) $1$info' " >>MCmenuecho -e "function $2 () { l_int '$1' '$2' '$3' '$x' ;}" >>MCradiolists}## Add a menu item which will call our local hex function.#function hex () {set_x_info "$2" "$3"x=${x##*[x,X]}echo -ne "'$2' '($x) $1$info' " >>MCmenuecho -e "function $2 () { l_hex '$1' '$2' '$3' '$x' ;}" >>MCradiolists}## Add a menu item which will call our local string function.#function string () {set_x_info "$2" "$3"echo -ne "'$2' ' $1: \"$x\"$info' " >>MCmenuecho -e "function $2 () { l_string '$1' '$2' '$3' '$x' ;}" >>MCradiolists}## Add a menu item which will call our local One-of-Many choice list.#function choice () {## Need to remember params cause they're gonna get reset.#title=$1choices=$2default=$3current=## Find out if one of the choices is already set.# If it's not then make it the default.#set -- $choicesfirstchoice=$2while [ -n "$2" ]doif eval [ \"_\$$2\" = \"_y\" ]thencurrent=$1breakfishift ; shiftdone: ${current:=$default}echo -ne "'$firstchoice' '($current) $title' " >>MCmenuecho -e "function $firstchoice () \{ l_choice '$title' \"$choices\" \"$current\" ;}" >>MCradiolists}} # END load_functions()## Extract available help for an option from Configure.help# and send it to standard output.## Most of this function was borrowed from the original kernel# Configure script.#function extract_help () {if [ -f Documentation/Configure.help ]then#first escape regexp special characters in the argument:var=$(echo "$1"|sed 's/[][\/.^$*]/\\&/g')#now pick out the right help text:text=$(sed -n "/^$var[ ]*\$/,\${/^$var[ ]*\$/c\\${var}:\\/^#/b/^[^ ]/qs/^ ///<file:\\([^>]*\\)>/s//\\1/gp}" Documentation/Configure.help)if [ -z "$text" ]thenecho "There is no help available for this kernel option."return 1elseecho "$text"fielseecho "There is no help available for this kernel option."return 1fi}## Activate a help dialog.#function help () {if extract_help $1 >help.outthen$DIALOG --backtitle "$backtitle" --title "$2"\--textbox help.out $ROWS $COLSelse$DIALOG --backtitle "$backtitle" \--textbox help.out $ROWS $COLSfirm -f help.out}## Show the README file.#function show_readme () {$DIALOG --backtitle "$backtitle" \--textbox scripts/README.Menuconfig $ROWS $COLS}## Begin building the dialog menu command and Initialize the# Radiolist function file.#function menu_name () {echo -ne "$DIALOG --title '$1'\--backtitle '$backtitle' \--menu '$menu_instructions' \$ROWS $COLS $((ROWS-10)) \'$default' " >MCmenu>MCradiolists}## Add a submenu option to the menu currently under construction.#function submenu () {echo -ne "'activate_menu $2' '$1 --->' " >>MCmenu}## Handle a boolean (Yes/No) option.#function l_bool () {if [ -n "$2" ]thencase "$2" iny|m) eval $1=y ;;c) eval x=\$$1case $x iny) eval $1=n ;;n) eval $1=y ;;*) eval $1=y ;;esac ;;*) eval $1=n ;;esacelseecho -ne "\007"fi}## Same as bool() except options are (Module/No)#function mod_bool () {if [ "$CONFIG_MODULES" != "y" ]; thendefine_bool "$2" "n"elseset_x_info "$2" "n"case $x iny|m) flag='M' ;;*) flag=' ' ;;esacecho -ne "'$2' '<$flag> $1$info' " >>MCmenuecho -e "function $2 () { l_mod_bool '$2' \"\$1\" ;}" >>MCradiolistsfi}## Same as l_bool() except options are (Module/No)#function l_mod_bool() {if [ -n "$2" ]thencase "$2" iny) echo -en "\007"${DIALOG} --backtitle "$backtitle" \--infobox "\This feature depends on another which has been configured as a module. \As a result, this feature will be built as a module." 4 70sleep 5eval $1=m ;;m) eval $1=m ;;c) eval x=\$$1case $x inm) eval $1=n ;;n) eval $1=m ;;*) eval $1=m ;;esac ;;*) eval $1=n ;;esacelseecho -ne "\007"fi}## Handle a tristate (Yes/No/Module) option.#function l_tristate () {if [ -n "$2" ]theneval x=\$$1case "$2" iny) eval $1=y ;;m) eval $1=m ;;c) eval x=\$$1case $x iny) eval $1=n ;;n) eval $1=m ;;m) eval $1=y ;;*) eval $1=y ;;esac ;;*) eval $1=n ;;esacelseecho -ne "\007"fi}## Create a dialog for entering an integer into a kernel option.#function l_int () {while truedoif $DIALOG --title "$1" \--backtitle "$backtitle" \--inputbox "$inputbox_instructions_int" \10 75 "$4" 2>MCdialog.outthenanswer="`cat MCdialog.out`"answer="${answer:-$3}"# Semantics of + and ? in GNU expr changed, so# we avoid them:if expr "$answer" : '0$' '|' "$answer" : '[1-9][0-9]*$' '|' "$answer" : '-[1-9][0-9]*$' >/dev/nulltheneval $2=\"$answer\"elseeval $2=\"$3\"echo -en "\007"${DIALOG} --backtitle "$backtitle" \--infobox "You have made an invalid entry." 3 43sleep 2fibreakfihelp "$2" "$1"done}## Create a dialog for entering a hexadecimal into a kernel option.#function l_hex () {while truedoif $DIALOG --title "$1" \--backtitle "$backtitle" \--inputbox "$inputbox_instructions_hex" \10 75 "$4" 2>MCdialog.outthenanswer="`cat MCdialog.out`"answer="${answer:-$3}"answer="${answer##*[x,X]}"if expr "$answer" : '[0-9a-fA-F][0-9a-fA-F]*$' >/dev/nulltheneval $2=\"$answer\"elseeval $2=\"$3\"echo -en "\007"${DIALOG} --backtitle "$backtitle" \--infobox "You have made an invalid entry." 3 43sleep 2fibreakfihelp "$2" "$1"done}## Create a dialog for entering a string into a kernel option.#function l_string () {while truedoif $DIALOG --title "$1" \--backtitle "$backtitle" \--inputbox "$inputbox_instructions_string" \10 75 "$4" 2>MCdialog.outthenanswer="`cat MCdialog.out`"answer="${answer:-$3}"## Someone may add a nice check for the entered# string here...#eval $2=\"$answer\"breakfihelp "$2" "$1"done}## Handle a one-of-many choice list.#function l_choice () {## Need to remember params cause they're gonna get reset.#title="$1"choices="$2"current="$3"chosen=## Scan current value of choices and set radiolist switches.#list=set -- $choicesfirstchoice=$2while [ -n "$2" ]docase "$1" in"$current"*) if [ -z "$chosen" ]; thenlist="$list $2 $1 ON "chosen=1elselist="$list $2 $1 OFF "fi ;;*) list="$list $2 $1 OFF " ;;esacshift ; shiftdonewhile truedoif $DIALOG --title "$title" \--backtitle "$backtitle" \--radiolist "$radiolist_instructions" \15 70 6 $list 2>MCdialog.outthenchoice=`cat MCdialog.out`breakfihelp "$firstchoice" "$title"done## Now set the boolean value of each option based on# the selection made from the radiolist.#set -- $choiceswhile [ -n "$2" ]doif [ "$2" = "$choice" ]theneval $2=\"y\"elseeval $2=\"n\"fishift ; shiftdone}## Call awk, and watch for error codes, etc.#function callawk () {awk "$1" || { echo "Awk died with error code $?. Giving up."; exit 1; }}## A faster awk based recursive parser. (I hope)#function parser1 () {callawk 'BEGIN {menu_no = 0comment_is_option = 0parser("'$CONFIG_IN'","MCmenu0")}function parser(ifile,menu) {while (getline <ifile) {if ($1 == "mainmenu_option") {comment_is_option = "1"}else if ($1 == "comment" && comment_is_option == "1") {comment_is_option= "0"sub($1,"",$0)++menu_noprintf("submenu %s MCmenu%s\n", $0, menu_no) >>menunewmenu = sprintf("MCmenu%d", menu_no);printf( "function MCmenu%s () {\n"\"default=$1\n"\"menu_name %s\n",\menu_no, $0) >newmenuparser(ifile, newmenu)}else if ($0 ~ /^#|\$MAKE|mainmenu_name/) {printf("") >>menu}else if ($1 ~ "endmenu") {printf("}\n") >>menureturn}else if ($1 == "source") {parser($2,menu)}else {print >>menu}}}'}## Secondary parser for single menu mode.#function parser2 () {callawk 'BEGIN {parser("'$CONFIG_IN'","MCmenu0")}function parser(ifile,menu) {while (getline <ifile) {if ($0 ~ /^#|$MAKE|mainmenu_name/) {printf("") >>menu}else if ($1 ~ /mainmenu_option|endmenu/) {printf("") >>menu}else if ($1 == "source") {parser($2,menu)}else {print >>menu}}}'}## Parse all the config.in files into mini scripts.#function parse_config_files () {rm -f MCmenu*echo "function MCmenu0 () {" >MCmenu0echo 'default=$1' >>MCmenu0echo "menu_name 'Main Menu'" >>MCmenu0if [ "_$single_menu_mode" = "_TRUE" ]thenparser2elseparser1fiecho "comment ''" >>MCmenu0echo "g_alt_config" >>MCmenu0echo "s_alt_config" >>MCmenu0echo "}" >>MCmenu0## These mini scripts must be sourced into the current# environment in order for all of this to work. Leaving# them on the disk as executables screws up the recursion# in activate_menu(), among other things. Once they are# sourced we can discard them.#for i in MCmenu*doecho -n "."source ./$idonerm -f MCmenu*}## This is the menu tree's bootstrap.## Executes the parsed menus on demand and creates a set of functions,# one per configuration option. These functions will in turn execute# dialog commands or recursively call other menus.#function activate_menu () {rm -f lxdialog.scrltmpwhile truedocomment_ctr=0 #So comment lines get unique tags$1 "$default" 2> MCerror #Create the lxdialog menu & functionsif [ "$?" != "0" ]thenclearcat <<EOMMenuconfig has encountered a possible error in one of the kernel'sconfiguration files and is unable to continue. Here is the errorreport:EOMsed 's/^/ Q> /' MCerrorcat <<EOMPlease report this to the maintainer <mec@shout.net>. You may alsosend a problem report to <linux-kernel@vger.kernel.org>.Please indicate the kernel version you are trying to configure andwhich menu you were trying to enter when this error occurred.EOMcleanupexit 1firm -f MCerror. ./MCradiolists #Source the menu's functions. ./MCmenu 2>MCdialog.out #Activate the lxdialog menuret=$?read selection <MCdialog.outcase "$ret" in0|3|4|5|6)defaults="$selection$defaults" #pseudo stackcase "$ret" in0) eval $selection ;;3) eval $selection y ;;4) eval $selection n ;;5) eval $selection m ;;6) eval $selection c ;;esacdefault="${defaults%%*}" defaults="${defaults#*}";;2)default="${selection%%\ *}"case "$selection" in*"-->"*|*"alt_config"*)show_readme ;;*)eval help $selection ;;esac;;255|1)break;;139)stty saneclearcat <<EOMThere seems to be a problem with the lxdialog companion utility which isbuilt prior to running Menuconfig. Usually this is an indicator that youhave upgraded/downgraded your ncurses libraries and did not remove theold ncurses header file(s) in /usr/include or /usr/include/ncurses.It is VERY important that you have only one set of ncurses header filesand that those files are properly version matched to the ncurses librariesinstalled on your machine.You may also need to rebuild lxdialog. This can be done by moving tothe /usr/src/linux/scripts/lxdialog directory and issuing the"make clean all" command.If you have verified that your ncurses install is correct, you may emailthe maintainer <mec@shout.net> or post a message to<linux-kernel@vger.kernel.org> for additional assistance.EOMcleanupexit 139;;esacdone}## Create a menu item to load an alternate configuration file.#g_alt_config () {echo -n "get_alt_config 'Load an Alternate Configuration File' "\>>MCmenu}## Get alternate config file name and load the# configuration from it.#get_alt_config () {set -f ## Switch file expansion OFFwhile truedoALT_CONFIG="${ALT_CONFIG:-$DEFAULTS}"$DIALOG --backtitle "$backtitle" \--inputbox "\Enter the name of the configuration file you wish to load. \Accept the name shown to restore the configuration you \last retrieved. Leave blank to abort."\11 55 "$ALT_CONFIG" 2>MCdialog.outif [ "$?" = "0" ]thenALT_CONFIG=`cat MCdialog.out`[ "_" = "_$ALT_CONFIG" ] && breakif eval [ -r \"$ALT_CONFIG\" ]theneval load_config_file \"$ALT_CONFIG\"breakelseecho -ne "\007"$DIALOG --backtitle "$backtitle" \--infobox "File does not exist!" 3 38sleep 2fielsecat <<EOM >help.outFor various reasons, one may wish to keep several different kernelconfigurations available on a single machine.If you have saved a previous configuration in a file other than thekernel's default, entering the name of the file here will allow youto modify that configuration.If you are uncertain, then you have probably never used alternateconfiguration files. You should therefor leave this blank to abort.EOM$DIALOG --backtitle "$backtitle"\--title "Load Alternate Configuration"\--textbox help.out $ROWS $COLSfidoneset +f ## Switch file expansion ONrm -f help.out MCdialog.out}## Create a menu item to store an alternate config file.#s_alt_config () {echo -n "save_alt_config 'Save Configuration to an Alternate File' "\>>MCmenu}## Get an alternate config file name and save the current# configuration to it.#save_alt_config () {set -f ## Switch file expansion OFFwhile truedo$DIALOG --backtitle "$backtitle" \--inputbox "\Enter a filename to which this configuration should be saved \as an alternate. Leave blank to abort."\10 55 "$ALT_CONFIG" 2>MCdialog.outif [ "$?" = "0" ]thenALT_CONFIG=`cat MCdialog.out`[ "_" = "_$ALT_CONFIG" ] && breakif eval touch $ALT_CONFIG 2>/dev/nulltheneval save_configuration $ALT_CONFIGload_functions ## RELOADbreakelseecho -ne "\007"$DIALOG --backtitle "$backtitle" \--infobox "Can't create file! Probably a nonexistent directory." 3 60sleep 2fielsecat <<EOM >help.outFor various reasons, one may wish to keep different kernelconfigurations available on a single machine.Entering a file name here will allow you to later retrieve, modifyand use the current configuration as an alternate to whateverconfiguration options you have selected at that time.If you are uncertain what all this means then you should probablyleave this blank.EOM$DIALOG --backtitle "$backtitle"\--title "Save Alternate Configuration"\--textbox help.out $ROWS $COLSfidoneset +f ## Switch file expansion ONrm -f help.out MCdialog.out}## Load config options from a file.# Converts all "# OPTION is not set" lines to "OPTION=n" lines#function load_config_file () {awk '/# .* is not set.*/ { printf("%s=n\n", $2) }! /# .* is not set.*/ { print }' $1 >.tmpconfigsource ./.tmpconfigrm -f .tmpconfig}## Just what it says.#save_configuration () {echoecho -n "Saving your kernel configuration."## Now, let's redefine the configuration functions for final# output to the config files.## Nested function definitions, YIPEE!#function bool () {set_x_info "$2" "n"eval define_bool \"$2\" \"$x\"}function tristate () {set_x_info "$2" "n"eval define_tristate \"$2\" \"$x\"}function dep_tristate () {set_x_info "$2" "n"var="$2"shift 2while [ $# -gt 0 ]; doif [ "$1" = y ]; thenshiftelif [ "$1" = m -a "$x" != n ]; thenx=m; shiftelsex=n; shift $#fidonedefine_tristate "$var" "$x"}function dep_bool () {set_x_info "$2" "n"var="$2"shift 2while [ $# -gt 0 ]; doif [ "$1" = y ]; thenshiftelsex=n; shift $#fidonedefine_bool "$var" "$x"}function dep_mbool () {set_x_info "$2" "n"var="$2"shift 2while [ $# -gt 0 ]; doif [ "$1" = y -o "$1" = m ]; thenshiftelsex=n; shift $#fidonedefine_bool "$var" "$x"}function int () {set_x_info "$2" "$3"echo "$2=$x" >>$CONFIGecho "#define $2 ($x)" >>$CONFIG_H}function hex () {set_x_info "$2" "$3"echo "$2=$x" >>$CONFIGecho "#define $2 0x${x##*[x,X]}" >>$CONFIG_H}function string () {set_x_info "$2" "$3"echo "$2=\"$x\"" >>$CONFIGecho "#define $2 \"$x\"" >>$CONFIG_H}function define_hex () {eval $1=\"$2\"echo "$1=$2" >>$CONFIGecho "#define $1 0x${2##*[x,X]}" >>$CONFIG_H}function define_int () {eval $1=\"$2\"echo "$1=$2" >>$CONFIGecho "#define $1 ($2)" >>$CONFIG_H}function define_string () {eval $1=\"$2\"echo "$1=\"$2\"" >>$CONFIGecho "#define $1 \"$2\"" >>$CONFIG_H}function define_bool () {define_tristate "$1" "$2"}function define_tristate () {eval $1=\"$2\"case "$2" iny)echo "$1=y" >>$CONFIGecho "#define $1 1" >>$CONFIG_H;;m)if [ "$CONFIG_MODULES" = "y" ]thenecho "$1=m" >>$CONFIGecho "#undef $1" >>$CONFIG_Hecho "#define $1_MODULE 1" >>$CONFIG_Helseecho "$1=y" >>$CONFIGecho "#define $1 1" >>$CONFIG_Hfi;;n)echo "# $1 is not set" >>$CONFIGecho "#undef $1" >>$CONFIG_H;;esac}function choice () {## Find the first choice that's already set to 'y'#choices="$2"default="$3"current=chosen=set -- $choiceswhile [ -n "$2" ]doif eval [ \"_\$$2\" = \"_y\" ]thencurrent=$1breakfishift ; shiftdone## Use the default if none were set.#: ${current:=$default}## Output all choices (to be compatible with other configs).#set -- $choiceswhile [ -n "$2" ]docase "$1" in"$current"*) if [ -z "$chosen" ]; thendefine_bool "$2" "y"chosen=1elsedefine_bool "$2" "n"fi ;;*) define_bool "$2" "n" ;;esacshift ; shiftdone}function mainmenu_name () {:}function mainmenu_option () {comment_is_option=TRUE}function endmenu () {:}function comment () {if [ "$comment_is_option" ]thencomment_is_option=echo >>$CONFIGecho "#" >>$CONFIGecho "# $1" >>$CONFIGecho "#" >>$CONFIGecho >>$CONFIG_Hecho "/*" >>$CONFIG_Hecho " * $1" >>$CONFIG_Hecho " */" >>$CONFIG_Hfi}echo -n "."DEF_CONFIG="${1:-.config}"DEF_CONFIG_H="include/linux/autoconf.h"CONFIG=.tmpconfigCONFIG_H=.tmpconfig.hecho "#" >$CONFIGecho "# Automatically generated by make menuconfig: don't edit" >>$CONFIGecho "#" >>$CONFIGecho "/*" >$CONFIG_Hecho " * Automatically generated by make menuconfig: don't edit" >>$CONFIG_Hecho " */" >>$CONFIG_Hecho "#define AUTOCONF_INCLUDED" >> $CONFIG_Hecho -n "."if . $CONFIG_IN >>.menuconfig.log 2>&1thenif [ "$DEF_CONFIG" = ".config" ]thenmv $CONFIG_H $DEF_CONFIG_Hfiif [ -f "$DEF_CONFIG" ]thenrm -f ${DEF_CONFIG}.oldmv $DEF_CONFIG ${DEF_CONFIG}.oldfimv $CONFIG $DEF_CONFIGreturn 0elsereturn 1fi}## Remove temporary files#cleanup () {cleanup1cleanup2}cleanup1 () {rm -f MCmenu* MCradiolists MCdialog.out help.out}cleanup2 () {rm -f .tmpconfig .tmpconfig.h}set_geometry () {# Some distributions export these with incorrect values# which can really screw up some ncurses programs.LINES= COLUMNS=ROWS=${1:-24} COLS=${2:-80}# Just in case the nasty rlogin bug returns.#[ $ROWS = 0 ] && ROWS=24[ $COLS = 0 ] && COLS=80if [ $ROWS -lt 19 -o $COLS -lt 80 ]thenecho -e "\n\007Your display is too small to run Menuconfig!"echo "It must be at least 19 lines by 80 columns."exit 1fiROWS=$((ROWS-4)) COLS=$((COLS-5))}set_geometry `stty size 2>/dev/null`menu_instructions="\Arrow keys navigate the menu. \<Enter> selects submenus --->. \Highlighted letters are hotkeys. \Pressing <Y> includes, <N> excludes, <M> modularizes features. \Press <Esc><Esc> to exit, <?> for Help. \Legend: [*] built-in [ ] excluded <M> module < > module capable"radiolist_instructions="\Use the arrow keys to navigate this window or \press the hotkey of the item you wish to select \followed by the <SPACE BAR>.Press <?> for additional information about this option."inputbox_instructions_int="\Please enter a decimal value. \Fractions will not be accepted. \Use the <TAB> key to move from the input field to the buttons below it."inputbox_instructions_hex="\Please enter a hexadecimal value. \Use the <TAB> key to move from the input field to the buttons below it."inputbox_instructions_string="\Please enter a string value. \Use the <TAB> key to move from the input field to the buttons below it."DIALOG="./scripts/lxdialog/lxdialog"kernel_version="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}"backtitle="Linux Kernel v$kernel_version Configuration"trap "cleanup ; exit 1" 1 2 15## Locate default files.#CONFIG_IN=./config.inif [ "$1" != "" ] ; thenCONFIG_IN=$1fiDEFAULTS=arch/$ARCH/defconfigif [ -f .config ]; thenDEFAULTS=.configfiif [ -f $DEFAULTS ]thenecho "Using defaults found in" $DEFAULTSload_config_file $DEFAULTSelseecho "No defaults found"fi# Fresh new log.>.menuconfig.log# Load the functions used by the config.in files.echo -n "Preparing scripts: functions"load_functionsif [ ! -e $CONFIG_IN ]thenecho "Your main config.in file ($CONFIG_IN) does not exist"exit 1fiif [ ! -x $DIALOG ]thenecho "Your lxdialog utility does not exist"exit 1fi## Read config.in files and parse them into one shell function per menu.#echo -n ", parsing"parse_config_files $CONFIG_INecho "done."## Start the ball rolling from the top.#activate_menu MCmenu0## All done!#cleanup1## Confirm and Save#if $DIALOG --backtitle "$backtitle" \--yesno "Do you wish to save your new kernel configuration?" 5 60thensave_configurationechoechoecho "*** End of Linux kernel configuration."echo "*** Check the top-level Makefile for additional configuration."if [ ! -f .hdepend -o "$CONFIG_MODVERSIONS" = "y" ] ; thenecho "*** Next, you must run 'make dep'."elseecho "*** Next, you may run 'make bzImage', 'make bzdisk', or 'make install'."fiechoelseechoechoecho Your kernel configuration changes were NOT saved.echofi# Remove log if empty.if [ ! -s .menuconfig.log ] ; thenrm -f .menuconfig.logfiexit 0
