OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [scripts/] [Configure] - Blame information for rev 1629

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1629 jcastillo
#! /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
#              ***** IMPORTANT COMPATIBILITY NOTE ****
13
# If configuration changes are made which might adversely effect
14
# Menuconfig or xconfig, please notify the respective authors so that
15
# those utilities can be updated in parallel.
16
#
17
# Menuconfig:  
18
# xconfig:       
19
#              ****************************************
20
#
21
# Each line in the config file is a command.
22
#
23
# 050793 - use IFS='@' to get around a bug in a pre-version of bash-1.13
24
# with an empty IFS.
25
#
26
# 030995 (storner@osiris.ping.dk) - added support for tri-state answers,
27
# for selecting modules to compile.
28
#
29
# 180995 Bernhard Kaindl (bkaindl@ping.at) - added dummy functions for
30
# use with a config.in modified for make menuconfig.
31
#
32
# 301195 (boldt@math.ucsb.edu) - added help text support
33
#
34
# 281295 Paul Gortmaker - make tri_state functions collapse to boolean
35
# if module support is not enabled.
36
#
37
# 010296 Aaron Ucko (ucko@vax1.rockhurst.edu) - fix int and hex to accept
38
# arbitrary ranges
39
#
40
# 150296 Dick Streefland (dicks@tasking.nl) - report new configuration
41
# items and ask for a value even when doing a "make oldconfig"
42
#
43
# 200396 Tom Dyas (tdyas@eden.rutgers.edu) - when the module option is
44
# chosen for an item, define the macro _MODULE
45
#
46
# 090397 Axel Boldt (boldt@math.ucsb.edu) - avoid ? and + in regular
47
# expressions for GNU expr since version 1.15 and up use \? and \+.
48
 
49
# 040697 Larry Augustin (lma@varesearch.com) - integer expr test
50
# fails with GNU expr 1.12. Re-write to work with new and old expr.
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[         ]*\$/b
91
                        /^#.*/b
92
                        /^[     ]*\$/q
93
                        p
94
                    }" Documentation/Configure.help)
95
     if [ -z "$text" ]
96
     then
97
          echo; echo "  Sorry, no help available for this option yet.";echo
98
     else
99
          (echo; echo "$text"; echo) | ${PAGER:-more}
100
     fi
101
  else
102
     echo;
103
     echo "  Can't access the file Documentation/Configure.help which"
104
     echo "  should contain the help texts."
105
     echo
106
  fi
107
}
108
 
109
 
110
#
111
# readln reads a line into $ans.
112
#
113
#       readln prompt default oldval
114
#
115
function readln () {
116
        if [ "$DEFAULT" = "-d" -a -n "$3" ]; then
117
                echo "$1"
118
                ans=$2
119
        else
120
                echo -n "$1"
121
                [ -z "$3" ] && echo -n "(NEW) "
122
                IFS='@' read ans 
123
                [ -z "$ans" ] && ans=$2
124
        fi
125
}
126
 
127
#
128
# comment does some pretty-printing
129
#
130
#       comment 'xxx'
131
#
132
function comment () {
133
        echo "*"; echo "* $1" ; echo "*"
134
        (echo "" ; echo "#"; echo "# $1" ; echo "#") >>$CONFIG
135
        (echo "" ; echo "/*"; echo " * $1" ; echo " */") >>$CONFIG_H
136
}
137
 
138
#
139
# define_bool sets the value of a boolean argument
140
#
141
#       define_bool define value
142
#
143
function define_bool () {
144
        case "$2" in
145
         "y")
146
                echo "$1=y" >>$CONFIG
147
                echo "#define $1 1" >>$CONFIG_H
148
                ;;
149
 
150
         "m")
151
                echo "$1=m" >>$CONFIG
152
                echo "#undef  $1" >>$CONFIG_H
153
                echo "#define $1_MODULE 1" >>$CONFIG_H
154
                ;;
155
 
156
         "n")
157
                echo "# $1 is not set" >>$CONFIG
158
                echo "#undef  $1" >>$CONFIG_H
159
                ;;
160
        esac
161
        eval "$1=$2"
162
}
163
 
164
#
165
# bool processes a boolean argument
166
#
167
#       bool question define
168
#
169
function bool () {
170
        old=$(eval echo "\${$2}")
171
        def=${old:-'n'}
172
        case "$def" in
173
         "y" | "m") defprompt="Y/n/?"
174
              def="y"
175
              ;;
176
         "n") defprompt="N/y/?"
177
              ;;
178
        esac
179
        while :; do
180
          readln "$1 ($2) [$defprompt] " "$def" "$old"
181
          case "$ans" in
182
            [yY] | [yY]es ) define_bool "$2" "y"
183
                            break;;
184
            [nN] | [nN]o )  define_bool "$2" "n"
185
                            break;;
186
            * )             help "$2"
187
                            ;;
188
          esac
189
        done
190
}
191
 
192
#
193
# tristate processes a tristate argument
194
#
195
#       tristate question define
196
#
197
function tristate () {
198
        if [ "$CONFIG_MODULES" != "y" ]; then
199
          bool "$1" "$2"
200
        else
201
          old=$(eval echo "\${$2}")
202
          def=${old:-'n'}
203
          case "$def" in
204
           "y") defprompt="Y/m/n/?"
205
                ;;
206
           "m") defprompt="M/n/y/?"
207
                ;;
208
           "n") defprompt="N/y/m/?"
209
                ;;
210
          esac
211
          while :; do
212
            readln "$1 ($2) [$defprompt] " "$def" "$old"
213
            case "$ans" in
214
              [yY] | [yY]es ) define_bool "$2" "y"
215
                              break ;;
216
              [nN] | [nN]o )  define_bool "$2" "n"
217
                              break ;;
218
              [mM] )          define_bool "$2" "m"
219
                              break ;;
220
              * )             help "$2"
221
                              ;;
222
            esac
223
          done
224
        fi
225
}
226
 
227
#
228
# dep_tristate processes a tristate argument that depends upon
229
# another option.  If the option we depend upon is a module,
230
# then the only allowable options are M or N.  If Y, then
231
# this is a normal tristate.  This is used in cases where modules
232
# are nested, and one module requires the presence of something
233
# else in the kernel.
234
#
235
#       tristate question define default
236
#
237
function dep_tristate () {
238
        old=$(eval echo "\${$2}")
239
        def=${old:-'n'}
240
        if [ "$3" = "n" ]; then
241
                define_bool "$2" "n"
242
        elif [ "$3" = "y" ]; then
243
                tristate "$1" "$2"
244
        else
245
           if [ "$CONFIG_MODULES" = "y" ]; then
246
                case "$def" in
247
                 "y" | "m") defprompt="M/n/?"
248
                      def="m"
249
                      ;;
250
                 "n") defprompt="N/m/?"
251
                      ;;
252
                esac
253
                while :; do
254
                  readln "$1 ($2) [$defprompt] " "$def" "$old"
255
                  case "$ans" in
256
                      [nN] | [nN]o )  define_bool "$2" "n"
257
                                      break ;;
258
                      [mM] )          define_bool "$2" "m"
259
                                      break ;;
260
                      [yY] | [yY]es ) echo
261
   echo "  This answer is not allowed, because it is not consistent with"
262
   echo "  your other choices."
263
   echo "  This driver depends on another one which you chose to compile"
264
   echo "  as a module. This means that you can either compile this one"
265
   echo "  as a module as well (with M) or leave it out altogether (N)."
266
                                      echo
267
                                      ;;
268
                      * )             help "$2"
269
                                      ;;
270
                  esac
271
                done
272
           fi
273
        fi
274
}
275
 
276
#
277
# define_int sets the value of a integer argument
278
#
279
#       define_int define value
280
#
281
function define_int () {
282
        echo "$1=$2" >>$CONFIG
283
        echo "#define $1 ($2)" >>$CONFIG_H
284
        eval "$1=$2"
285
}
286
 
287
#
288
# int processes an integer argument
289
#
290
#       int question define default
291
# GNU expr changed handling of ?.  In older versions you need ?,
292
# in newer you need \?
293
OLD_EXPR=`expr "0" : '0\?'`
294
if [ $OLD_EXPR -eq 1 ]; then
295
    INT_EXPR='0$\|-\?[1-9][0-9]*$'
296
else
297
    INT_EXPR='0$\|-?[1-9][0-9]*$'
298
fi
299
function int () {
300
        old=$(eval echo "\${$2}")
301
        def=${old:-$3}
302
        while :; do
303
          readln "$1 ($2) [$def] " "$def" "$old"
304
          if expr "$ans" : $INT_EXPR > /dev/null; then
305
            define_int "$2" "$ans"
306
            break
307
          else
308
            help "$2"
309
          fi
310
        done
311
}
312
#
313
# define_hex sets the value of a hexadecimal argument
314
#
315
#       define_hex define value
316
#
317
function define_hex () {
318
        echo "$1=$2" >>$CONFIG
319
        echo "#define $1 0x${2#*[x,X]}" >>$CONFIG_H
320
        eval "$1=$2"
321
}
322
 
323
#
324
# hex processes an hexadecimal argument
325
#
326
#       hex question define default
327
#
328
function hex () {
329
        old=$(eval echo "\${$2}")
330
        def=${old:-$3}
331
        def=${def#*[x,X]}
332
        while :; do
333
          readln "$1 ($2) [$def] " "$def" "$old"
334
          ans=${ans#*[x,X]}
335
          if expr "$ans" : '[0-9a-fA-F][0-9a-fA-F]*$' > /dev/null; then
336
            define_hex "$2" "$ans"
337
            break
338
          else
339
            help "$2"
340
          fi
341
        done
342
}
343
 
344
#
345
# choice processes a choice list (1-out-of-n)
346
#
347
#       choice question choice-list default
348
#
349
# The choice list has a syntax of:
350
#       NAME WHITESPACE VALUE { WHITESPACE NAME WHITESPACE VALUE }
351
# The user may enter any unique prefix of one of the NAMEs and
352
# choice will define VALUE as if it were a boolean option.
353
# VALUE must be in all uppercase.  Normally, VALUE is of the
354
# form CONFIG_.  Thus, if the user selects ,
355
# the CPP symbol CONFIG_ will be defined and the
356
# shell variable CONFIG_ will be set to "y".
357
#
358
function choice () {
359
        question="$1"
360
        choices="$2"
361
        old=
362
        def=$3
363
 
364
        # determine default answer:
365
        names=""
366
        set -- $choices
367
        firstvar=$2
368
        while [ -n "$2" ]; do
369
                if [ -n "$names" ]; then
370
                        names="$names, $1"
371
                else
372
                        names="$1"
373
                fi
374
                if [ "$(eval echo \"\${$2}\")" = "y" ]; then
375
                        old=$1
376
                        def=$1
377
                fi
378
                shift; shift
379
        done
380
 
381
        val=""
382
        while [ -z "$val" ]; do
383
                ambg=n
384
                readln "$question ($names) [$def] " "$def" "$old"
385
                ans=$(echo $ans | tr a-z A-Z)
386
                set -- $choices
387
                while [ -n "$1" ]; do
388
                        name=$(echo $1 | tr a-z A-Z)
389
                        case "$name" in
390
                                "$ans"* )
391
                                        if [ "$name" = "$ans" ]; then
392
                                                val="$2"
393
                                                break   # stop on exact match
394
                                        fi
395
                                        if [ -n "$val" ]; then
396
                                                echo;echo \
397
                "  Sorry, \"$ans\" is ambiguous; please enter a longer string."
398
                                                echo
399
                                                val=""
400
                                                ambg=y
401
                                                break
402
                                        else
403
                                                val="$2"
404
                                        fi;;
405
                        esac
406
                        shift; shift
407
                done
408
                if [ "$val" = "" -a "$ambg" = "n" ]; then
409
                        help "$firstvar"
410
                fi
411
        done
412
        set -- $choices
413
        while [ -n "$2" ]; do
414
                if [ "$2" = "$val" ]; then
415
                        echo "  defined $val"
416
                        define_bool "$2" "y"
417
                else
418
                        define_bool "$2" "n"
419
                fi
420
                shift; shift
421
        done
422
}
423
 
424
CONFIG=.tmpconfig
425
CONFIG_H=.tmpconfig.h
426
trap "rm -f $CONFIG $CONFIG_H ; exit 1" 1 2
427
 
428
#
429
# Make sure we start out with a clean slate.
430
#
431
echo "#" > $CONFIG
432
echo "# Automatically generated make config: don't edit" >> $CONFIG
433
echo "#" >> $CONFIG
434
 
435
echo "/*" > $CONFIG_H
436
echo " * Automatically generated C config: don't edit" >> $CONFIG_H
437
echo " */" >> $CONFIG_H
438
echo "#define AUTOCONF_INCLUDED" >> $CONFIG_H
439
 
440
DEFAULT=""
441
if [ "$1" = "-d" ] ; then
442
        DEFAULT="-d"
443
        shift
444
fi
445
 
446
CONFIG_IN=./config.in
447
if [ "$1" != "" ] ; then
448
        CONFIG_IN=$1
449
fi
450
 
451
DEFAULTS=arch/$ARCH/defconfig
452
if [ -f .config ]; then
453
  DEFAULTS=.config
454
fi
455
 
456
if [ -f $DEFAULTS ]; then
457
  echo "#"
458
  echo "# Using defaults found in" $DEFAULTS
459
  echo "#"
460
  . $DEFAULTS
461
  sed -e 's/# \(.*\) is not.*/\1=n/' < $DEFAULTS > .tmp.conf.$$
462
  . .tmp.conf.$$
463
  rm .tmp.conf.$$
464
else
465
  echo "#"
466
  echo "# No defaults found"
467
  echo "#"
468
fi
469
 
470
. $CONFIG_IN
471
 
472
rm -f .config.old
473
if [ -f .config ]; then
474
        mv .config .config.old
475
fi
476
mv .tmpconfig .config
477
mv .tmpconfig.h include/linux/autoconf.h
478
 
479
echo
480
echo "The linux kernel is now hopefully configured for your setup."
481
echo "Check the top-level Makefile for additional configuration,"
482
echo "and do a 'make dep ; make clean' if you want to be sure all"
483
echo "the files are correctly re-made"
484
echo
485
 
486
exit 0

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.