home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / KERNEL-S / V1.2 / LINUX-1.2 / LINUX-1 / linux / Configure < prev    next >
Encoding:
Text File  |  1994-12-29  |  3.1 KB  |  148 lines

  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.
  28. set -f -h
  29.  
  30. #
  31. # readln reads a line into $ans.
  32. #
  33. #    readln prompt default
  34. #
  35. function 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. function comment () {
  51.     echo "*"; echo "* $1" ; echo "*"
  52.     (echo "" ; echo "#"; echo "# $1" ; echo "#") >>$CONFIG
  53.     (echo "" ; echo "/*"; echo " * $1" ; echo " */") >>$CONFIG_H
  54. }
  55.  
  56. #
  57. # bool processes a boolean argument
  58. #
  59. #    bool question define default
  60. #
  61. function bool () {
  62.     ans=""
  63.     def=$(eval echo "\${$2:-$3}")
  64.     while [ "$ans" != "y" -a "$ans" != "n" ]; do
  65.         readln "$1 ($2) [$def] " "$def"
  66.     done
  67.     if [ "$ans" = "y" ]; then
  68.         echo "$2=y" >>$CONFIG
  69.         echo "#define $2 1" >>$CONFIG_H
  70.     else
  71.         echo "# $2 is not set" >>$CONFIG
  72.         echo "#undef  $2" >>$CONFIG_H
  73.     fi
  74.     eval "$2=$ans"
  75. }
  76.  
  77. #
  78. # int processes an integer argument
  79. #
  80. #    int question define default
  81. #
  82. function int () {
  83.     # Slimier hack to get bash to rescan a line.
  84.     ans="x"
  85.     def=$(eval echo "\${$2:-$3}")
  86.     while [ $[$ans+0] != "$ans" ]; do
  87.         readln "$1 ($2) [$def] " "$def"
  88.     done
  89.     echo "$2=$ans" >>$CONFIG
  90.     echo "#define $2 ($ans)" >>$CONFIG_H
  91.     eval "$2=$ans"
  92. }
  93.  
  94. CONFIG=.tmpconfig
  95. CONFIG_H=.tmpconfig.h
  96. trap "rm -f $CONFIG $CONFIG_H ; exit 1" 1 2
  97.  
  98. #
  99. # Make sure we start out with a clean slate.
  100. #
  101. echo "#" > $CONFIG
  102. echo "# Automatically generated make config: don't edit" >> $CONFIG
  103. echo "#" >> $CONFIG
  104.  
  105. echo "/*" > $CONFIG_H
  106. echo " * Automatically generated C config: don't edit" >> $CONFIG_H
  107. echo " */" >> $CONFIG_H
  108.  
  109. DEFAULT=""
  110. if [ "$1" = "-d" ] ; then
  111.     DEFAULT="-d"
  112.     shift
  113. fi
  114.  
  115. CONFIG_IN=./config.in
  116. if [ "$1" != "" ] ; then
  117.     CONFIG_IN=$1
  118. fi
  119.  
  120. if [ -f ./.config ] ; then
  121.     . ./.config
  122.     sed -e 's/# \(.*\) is not.*/\1=n/' <./.config >/tmp/conf.$$
  123.     . /tmp/conf.$$
  124.     rm /tmp/conf.$$
  125. fi
  126. . $CONFIG_IN
  127.  
  128. if [ "$CONFIG_SOUND" = "y" ] ; then
  129.     $MAKE -C drivers/sound config || exit 1
  130. fi
  131.  
  132. rm -f .config.old
  133. if [ -f .config ]; then
  134.     mv .config .config.old
  135. fi
  136. mv .tmpconfig .config
  137. mv .tmpconfig.h include/linux/autoconf.h
  138.  
  139. echo
  140. echo "The linux kernel is now hopefully configured for your setup."
  141. echo "Check the top-level Makefile for additional configuration,"
  142. echo "and do a 'make dep ; make clean' if you want to be sure all"
  143. echo "the files are correctly re-made"
  144. echo
  145.  
  146. exit 0
  147.