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