The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/scripts/Configure

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #! /bin/sh
    2 #
    3 # This script is used to configure the Linux kernel.
    4 #
    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
    8 # enough.
    9 #
   10 # Raymond Chen was the original author of Configure.
   11 # Michael Elizabeth Chastain (mec@shout.net) is the current maintainer.
   12 #
   13 # 050793 - use IFS='@' to get around a bug in a pre-version of bash-1.13
   14 # with an empty IFS.
   15 #
   16 # 030995 (storner@osiris.ping.dk) - added support for tri-state answers,
   17 # for selecting modules to compile.
   18 #
   19 # 180995 Bernhard Kaindl (bkaindl@ping.at) - added dummy functions for
   20 # use with a config.in modified for make menuconfig.
   21 #
   22 # 301195 (boldt@math.ucsb.edu) - added help text support
   23 #
   24 # 281295 Paul Gortmaker - make tri_state functions collapse to boolean
   25 # if module support is not enabled.
   26 #
   27 # 010296 Aaron Ucko (ucko@vax1.rockhurst.edu) - fix int and hex to accept
   28 # arbitrary ranges
   29 #
   30 # 150296 Dick Streefland (dicks@tasking.nl) - report new configuration
   31 # items and ask for a value even when doing a "make oldconfig"
   32 #
   33 # 200396 Tom Dyas (tdyas@eden.rutgers.edu) - when the module option is
   34 # chosen for an item, define the macro <option_name>_MODULE
   35 #
   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 \+.
   38 #
   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.
   42 #
   43 # 090398 Axel Boldt (boldt@math.ucsb.edu) - allow for empty lines in help
   44 # texts.
   45 #
   46 # 102598 Michael Chastain (mec@shout.net) - put temporary files in
   47 # current directory, not in /tmp.
   48 #
   49 # 24 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
   50 # - Improve the exit message (Jeff Ronne).
   51 
   52 #
   53 # Make sure we're really running bash.
   54 #
   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.
   58 #
   59 [ -z "$BASH" ] && { echo "Configure requires bash" 1>&2; exit 1; }
   60 
   61 # Disable filename globbing once and for all.
   62 # Enable function cacheing.
   63 set -f -h
   64 
   65 #
   66 # Dummy functions for use with a config.in modified for menuconf
   67 #
   68 function mainmenu_option () {
   69         :
   70 }
   71 function mainmenu_name () {
   72         :
   73 }
   74 function endmenu () {
   75         :
   76 }
   77 
   78 #
   79 # help prints the corresponding help text from Configure.help to stdout
   80 #
   81 #       help variable
   82 #
   83 function help () {
   84   if [ -f Documentation/Configure.help ]
   85   then
   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[     ]*\$/,\${
   90                         /^$var[         ]*\$/c\\
   91 ${var}:\\
   92 
   93                         /^#/b
   94                         /^[^    ]/q
   95                         /<file:\\([^>]*\\)>/s//\\1/g
   96                         p
   97                     }" Documentation/Configure.help)
   98      if [ -z "$text" ]
   99      then
  100           echo; echo "  Sorry, no help available for this option yet.";echo
  101      else
  102           (echo; echo "$text") | ${PAGER:-more}
  103      fi
  104   else
  105      echo;
  106      echo "  Can't access the file Documentation/Configure.help which"
  107      echo "  should contain the help texts."
  108      echo
  109   fi
  110 }
  111 
  112 
  113 #
  114 # readln reads a line into $ans.
  115 #
  116 #       readln prompt default oldval
  117 #
  118 function readln () {
  119         if [ "$DEFAULT" = "-d" -a -n "$3" ]; then
  120                 echo "$1"
  121                 ans=$2
  122         else
  123                 echo -n "$1"
  124                 [ -z "$3" ] && echo -n "(NEW) "
  125                 IFS='@' read ans || exit 1
  126                 [ -z "$ans" ] && ans=$2
  127         fi
  128 }
  129 
  130 #
  131 # comment does some pretty-printing
  132 #
  133 #       comment 'xxx'
  134 # 
  135 function comment () {
  136         echo "*"; echo "* $1" ; echo "*"
  137         (echo "" ; echo "#"; echo "# $1" ; echo "#") >>$CONFIG
  138         (echo "" ; echo "/*"; echo " * $1" ; echo " */") >>$CONFIG_H
  139 }
  140 
  141 #
  142 # define_bool sets the value of a boolean argument
  143 #
  144 #       define_bool define value
  145 #
  146 function define_bool () {
  147         define_tristate $1 $2
  148 }
  149 
  150 function define_tristate () {
  151         case "$2" in
  152          "y")
  153                 echo "$1=y" >>$CONFIG
  154                 echo "#define $1 1" >>$CONFIG_H
  155                 ;;
  156 
  157          "m")
  158                 echo "$1=m" >>$CONFIG
  159                 echo "#undef  $1" >>$CONFIG_H
  160                 echo "#define $1_MODULE 1" >>$CONFIG_H
  161                 ;;
  162 
  163          "n")
  164                 echo "# $1 is not set" >>$CONFIG
  165                 echo "#undef  $1" >>$CONFIG_H
  166                 ;;
  167         esac
  168         eval "$1=$2"
  169 }
  170 
  171 #
  172 # bool processes a boolean argument
  173 #
  174 #       bool question define
  175 #
  176 function bool () {
  177         old=$(eval echo "\${$2}")
  178         def=${old:-'n'}
  179         case "$def" in
  180          "y" | "m") defprompt="Y/n/?"
  181               def="y"
  182               ;;
  183          "n") defprompt="N/y/?"
  184               ;;
  185         esac
  186         while :; do
  187           readln "$1 ($2) [$defprompt] " "$def" "$old"
  188           case "$ans" in
  189             [yY] | [yY]es ) define_bool "$2" "y"
  190                             break;;
  191             [nN] | [nN]o )  define_bool "$2" "n"
  192                             break;;
  193             * )             help "$2"
  194                             ;;
  195           esac
  196         done
  197 }
  198 
  199 #
  200 # tristate processes a tristate argument
  201 #
  202 #       tristate question define
  203 #
  204 function tristate () {
  205         if [ "$CONFIG_MODULES" != "y" ]; then
  206           bool "$1" "$2"
  207         else 
  208           old=$(eval echo "\${$2}")
  209           def=${old:-'n'}
  210           case "$def" in
  211            "y") defprompt="Y/m/n/?"
  212                 ;;
  213            "m") defprompt="M/n/y/?"
  214                 ;;
  215            "n") defprompt="N/y/m/?"
  216                 ;;
  217           esac
  218           while :; do
  219             readln "$1 ($2) [$defprompt] " "$def" "$old"
  220             case "$ans" in
  221               [yY] | [yY]es ) define_tristate "$2" "y"
  222                               break ;;
  223               [nN] | [nN]o )  define_tristate "$2" "n"
  224                               break ;;
  225               [mM] )          define_tristate "$2" "m"
  226                               break ;;
  227               * )             help "$2"
  228                               ;;
  229             esac
  230           done
  231         fi
  232 }
  233 
  234 #
  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.
  241 #
  242 #       dep_tristate question define default ...
  243 #
  244 function dep_tristate () {
  245         old=$(eval echo "\${$2}")
  246         def=${old:-'n'}
  247         ques=$1
  248         var=$2
  249         need_module=0
  250         shift 2
  251         while [ $# -gt 0 ]; do
  252           case "$1" in
  253             n)
  254               define_tristate "$var" "n"
  255               return
  256               ;;
  257             m)
  258               need_module=1
  259               ;;
  260           esac
  261           shift
  262         done
  263 
  264         if [ $need_module = 1 ]; then
  265            if [ "$CONFIG_MODULES" = "y" ]; then
  266                 case "$def" in
  267                  "y" | "m") defprompt="M/n/?"
  268                       def="m"
  269                       ;;
  270                  "n") defprompt="N/m/?"
  271                       ;;
  272                 esac
  273                 while :; do
  274                   readln "$ques ($var) [$defprompt] " "$def" "$old"
  275                   case "$ans" in
  276                       [nN] | [nN]o )  define_tristate "$var" "n"
  277                                       break ;;
  278                       [mM] )          define_tristate "$var" "m"
  279                                       break ;;
  280                       [yY] | [yY]es ) echo 
  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)."
  286                                       echo
  287                                       ;;
  288                       * )             help "$var"
  289                                       ;;
  290                   esac
  291                 done
  292            fi
  293         else
  294            tristate "$ques" "$var"
  295         fi
  296 }
  297 
  298 function dep_bool () {
  299         ques=$1
  300         var=$2
  301         shift 2
  302         while [ $# -gt 0 ]; do
  303           case "$1" in
  304             m | n)
  305               define_bool "$var" "n"
  306               return
  307               ;;
  308           esac
  309           shift
  310         done
  311 
  312         bool "$ques" "$var"
  313 }
  314 
  315 function dep_mbool () {
  316         ques=$1
  317         var=$2
  318         shift 2
  319         while [ $# -gt 0 ]; do
  320           case "$1" in
  321             n)
  322               define_bool "$var" "n"
  323               return
  324               ;;
  325           esac
  326           shift
  327         done
  328 
  329         bool "$ques" "$var"
  330 }
  331 
  332 #
  333 # define_int sets the value of a integer argument
  334 #
  335 #       define_int define value
  336 #
  337 function define_int () {
  338         echo "$1=$2" >>$CONFIG
  339         echo "#define $1 ($2)" >>$CONFIG_H
  340         eval "$1=$2"
  341 }
  342 
  343 #
  344 # int processes an integer argument with optional limits
  345 #
  346 #       int question define default
  347 #
  348 function int () {
  349         old=$(eval echo "\${$2}")
  350         def=${old:-$3}
  351         while :; do
  352           readln "$1 ($2) [$def] " "$def" "$old"
  353           if expr "$ans" : '[0-9]*$' > /dev/null; then
  354             define_int "$2" "$ans"
  355             break
  356           else
  357             help "$2"
  358           fi
  359         done
  360 }
  361 
  362 #
  363 # define_hex sets the value of a hexadecimal argument
  364 #
  365 #       define_hex define value
  366 #
  367 function define_hex () {
  368         echo "$1=$2" >>$CONFIG
  369         echo "#define $1 0x${2#*[x,X]}" >>$CONFIG_H
  370         eval "$1=$2"
  371 }
  372 
  373 #
  374 # hex processes an hexadecimal argument
  375 #
  376 #       hex question define default
  377 #
  378 function hex () {
  379         old=$(eval echo "\${$2}")
  380         def=${old:-$3}
  381         def=${def#*[x,X]}
  382         while :; do
  383           readln "$1 ($2) [$def] " "$def" "$old"
  384           ans=${ans#*[x,X]}
  385           if expr "$ans" : '[0-9a-fA-F][0-9a-fA-F]*$' > /dev/null; then
  386             define_hex "$2" "$ans"
  387             break
  388           else
  389             help "$2"
  390           fi
  391         done
  392 }
  393 
  394 #
  395 # define_string sets the value of a string argument
  396 #
  397 #       define_string define value
  398 #
  399 function define_string () {
  400         echo "$1=\"$2\"" >>$CONFIG
  401         echo "#define $1 \"$2\"" >>$CONFIG_H
  402         eval "$1=\"$2\""
  403 }
  404 
  405 #
  406 # string processes a string argument
  407 #
  408 #       string question define default
  409 #
  410 function string () {
  411         old=$(eval echo "\${$2}")
  412         def=${old:-$3}
  413         while :; do
  414           if [ "$old" = "?" ]; then
  415              readln "$1 ($2) [$def] " "$def" ""
  416           else
  417              readln "$1 ($2) [$def] " "$def" "$old"
  418           fi
  419           if [ "$ans" = "?" ]; then
  420             help "$2"
  421           else
  422             break
  423           fi
  424         done
  425         define_string "$2" "$ans"
  426 }
  427 #
  428 # choice processes a choice list (1-out-of-n)
  429 #
  430 #       choice question choice-list default
  431 #
  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".
  440 #
  441 function choice () {
  442         question="$1"
  443         choices="$2"
  444         old=
  445         def=$3
  446 
  447         # determine default answer:
  448         names=""
  449         set -- $choices
  450         firstvar=$2
  451         while [ -n "$2" ]; do
  452                 if [ -n "$names" ]; then
  453                         names="$names, $1"
  454                 else
  455                         names="$1"
  456                 fi
  457                 if [ "$(eval echo \"\${$2}\")" = "y" ]; then
  458                         old=$1
  459                         def=$1
  460                 fi
  461                 shift; shift
  462         done
  463 
  464         val=""
  465         while [ -z "$val" ]; do
  466                 ambg=n
  467                 readln "$question ($names) [$def] " "$def" "$old"
  468                 ans=$(echo $ans | tr a-z A-Z)
  469                 set -- $choices
  470                 while [ -n "$1" ]; do
  471                         name=$(echo $1 | tr a-z A-Z)
  472                         case "$name" in
  473                                 "$ans"* | */"$ans"* )
  474                                         case "$name" in
  475                                                 "$ans" | */"$ans"/* | \
  476                                                 "$ans"/* | */"$ans" )
  477                                                         val="$2"
  478                                                         break # exact match
  479                                                 ;;
  480                                         esac
  481                                         if [ -n "$val" ]; then
  482                                                 echo;echo \
  483                 "  Sorry, \"$ans\" is ambiguous; please enter a longer string."
  484                                                 echo
  485                                                 val=""
  486                                                 ambg=y
  487                                                 break
  488                                         else
  489                                                 val="$2"
  490                                         fi;;
  491                         esac
  492                         shift; shift
  493                 done
  494                 if [ "$val" = "" -a "$ambg" = "n" ]; then
  495                         help "$firstvar"
  496                 fi
  497         done
  498         set -- $choices
  499         while [ -n "$2" ]; do
  500                 if [ "$2" = "$val" ]; then
  501                         echo "  defined $val"
  502                         define_bool "$2" "y"
  503                 else
  504                         define_bool "$2" "n"
  505                 fi
  506                 shift; shift
  507         done
  508 }
  509 
  510 CONFIG=.tmpconfig
  511 CONFIG_H=.tmpconfig.h
  512 trap "rm -f $CONFIG $CONFIG_H ; exit 1" 1 2
  513 
  514 #
  515 # Make sure we start out with a clean slate.
  516 #
  517 echo "#" > $CONFIG
  518 echo "# Automatically generated make config: don't edit" >> $CONFIG
  519 echo "#" >> $CONFIG
  520 
  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
  525 
  526 DEFAULT=""
  527 if [ "$1" = "-d" ] ; then
  528         DEFAULT="-d"
  529         shift
  530 fi
  531 
  532 CONFIG_IN=./config.in
  533 if [ "$1" != "" ] ; then
  534         CONFIG_IN=$1
  535 fi
  536 
  537 DEFAULTS=arch/$ARCH/defconfig
  538 if [ -f .config ]; then
  539   DEFAULTS=.config
  540 fi
  541 
  542 if [ -f $DEFAULTS ]; then
  543   echo "#"
  544   echo "# Using defaults found in" $DEFAULTS
  545   echo "#"
  546   . $DEFAULTS
  547   sed -e 's/# \(CONFIG_[^ ]*\) is not.*/\1=n/' <$DEFAULTS >.config-is-not.$$
  548   . .config-is-not.$$
  549   rm .config-is-not.$$
  550 else
  551   echo "#"
  552   echo "# No defaults found"
  553   echo "#"
  554 fi
  555 
  556 . $CONFIG_IN
  557 
  558 rm -f .config.old
  559 if [ -f .config ]; then
  560         mv .config .config.old
  561 fi
  562 mv .tmpconfig .config
  563 mv .tmpconfig.h include/linux/autoconf.h
  564 
  565 echo
  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'."
  570 else
  571     echo "*** Next, you may run 'make bzImage', 'make bzdisk', or 'make install'."
  572 fi
  573 echo
  574 
  575 exit 0

Cache object: 8ba4a60c7454f737bd830148642dfd88


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.