linux-old/Configure
<<
>>
Prefs
   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# Please send comments / questions / bug fixes to raymondc@microsoft.com.
  11#
  12# Each line in the config file is a command.
  13#
  14# 050793 - use IFS='@' to get around a bug in a pre-version of bash-1.13
  15# with an empty IFS.
  16
  17#
  18# Make sure we're really running bash.
  19#
  20# I would really have preferred to write this script in a language with
  21# better string handling, but alas, bash is the only scripting language
  22# that I can be reasonable sure everybody has on their linux machine.
  23#
  24[ -z "$BASH" ] && { echo "Configure requires bash" 1>&2; exit 1; }
  25
  26# Disable filename globbing once and for all.
  27# Enable function cacheing.
  28set -f -h
  29
  30#
  31# readln reads a line into $ans.
  32#
  33#       readln prompt default
  34#
  35function readln () {
  36        if [ "$DEFAULT" = "-d" ]; then
  37                echo "$1"
  38                ans=$2
  39        else
  40                echo -n "$1"
  41                IFS='@' read ans </dev/tty || exit 1
  42                [ -z "$ans" ] && ans=$2
  43        fi
  44}
  45
  46#
  47# comment does some pretty-printing
  48#
  49#       comment 'xxx'
  50# 
  51function comment () {
  52        echo "*"; echo "* $1" ; echo "*"
  53        (echo "" ; echo "#"; echo "# $1" ; echo "#") >>$CONFIG
  54        (echo "" ; echo "/*"; echo " * $1" ; echo " */") >>$CONFIG_H
  55}
  56
  57#
  58# bool processes a boolean argument
  59#
  60#       bool question define default
  61#
  62function bool () {
  63        ans=""
  64        def=$(eval echo "\${$2:-$3}")
  65        while [ "$ans" != "y" -a "$ans" != "n" ]; do
  66                readln "$1 ($2) [$def] " "$def"
  67        done
  68        if [ "$ans" = "y" ]; then
  69                echo "$2=y" >>$CONFIG
  70                echo "#define $2 1" >>$CONFIG_H
  71        else
  72                echo "# $2 is not set" >>$CONFIG
  73                echo "#undef  $2" >>$CONFIG_H
  74        fi
  75        eval "$2=$ans"
  76}
  77
  78#
  79# int processes an integer argument
  80#
  81#       int question define default
  82#
  83function int () {
  84        # Slimier hack to get bash to rescan a line.
  85        ans="x"
  86        def=$(eval echo "\${$2:-$3}")
  87        while [ $[$ans+0] != "$ans" ]; do
  88                readln "$1 ($2) [$def] " "$def"
  89        done
  90        echo "$2=$ans" >>$CONFIG
  91        echo "#define $2 ($ans)" >>$CONFIG_H
  92        eval "$2=$ans"
  93}
  94
  95CONFIG=.tmpconfig
  96CONFIG_H=.tmpconfig.h
  97trap "rm -f $CONFIG $CONFIG_H ; exit 1" 1 2
  98
  99#
 100# Make sure we start out with a clean slate.
 101#
 102echo "#" > $CONFIG
 103echo "# Automatically generated make config: don't edit" >> $CONFIG
 104echo "#" >> $CONFIG
 105
 106echo "/*" > $CONFIG_H
 107echo " * Automatically generated C config: don't edit" >> $CONFIG_H
 108echo " */" >> $CONFIG_H
 109
 110DEFAULT=""
 111if [ "$1" = "-d" ] ; then
 112        DEFAULT="-d"
 113        shift
 114fi
 115
 116CONFIG_IN=./config.in
 117if [ "$1" != "" ] ; then
 118        CONFIG_IN=$1
 119fi
 120
 121if [ -f ./.config ] ; then
 122        . ./.config
 123        sed -e 's/# \(.*\) is not.*/\1=n/' <./.config >/tmp/conf.$$
 124        . /tmp/conf.$$
 125        rm /tmp/conf.$$
 126fi
 127. $CONFIG_IN
 128
 129if [ "$CONFIG_SOUND" = "y" ] ; then
 130        $MAKE -C drivers/sound config || exit 1
 131fi
 132
 133rm -f .config.old
 134if [ -f .config ]; then
 135        mv .config .config.old
 136fi
 137mv .tmpconfig .config
 138mv .tmpconfig.h include/linux/autoconf.h
 139
 140echo
 141echo "The linux kernel is now hopefully configured for your setup."
 142echo "Check the top-level Makefile for additional configuration,"
 143echo "and do a 'make dep ; make clean' if you want to be sure all"
 144echo "the files are correctly re-made"
 145echo
 146
 147exit 0
 148
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.