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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [scripts/] [Menuconfig] - Blame information for rev 199

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

Line No. Rev Author Line
1 199 simons
#! /bin/sh
2
#
3
# This script is used to configure the linux kernel.
4
#
5
# It was inspired by a desire to not have to hit  9 million times
6
# or startup the X server just to change a single kernel parameter.
7
#
8
# This script attempts to parse the configuration files, which are
9
# scattered throughout the kernel source tree, and creates a temporary
10
# set of mini scripts which are in turn used to create nested menus and
11
# radiolists.
12
#
13
# It uses a very modified/mutilated version of the "dialog" utility
14
# written by Savio Lam (lam836@cs.cuhk.hk). Savio is not responsible
15
# for this script or the version of dialog used by this script.
16
# Please do not contact him with questions. The official version of
17
# dialog is available at sunsite.unc.edu or a sunsite mirror.
18
#
19
# Portions of this script were borrowed from the original Configure
20
# script.
21
#
22
# Please send comments / questions / bug fixes to roadcapw@titus.org
23
#
24
# 070498 Stepan Kasal  - one change borrowed
25
# from 2.1.x version:
26
#     131197 Michael Chastain (mec@shout.net) - output all lines for a
27
#     choice list, not just the selected one.  This makes the output
28
#     the same as Configure output, which is important for smart config
29
#     dependencies.
30
# It also fixes the bug when menuconfig sets CONFIG_M386=y every time
31
# it is ran.
32
#----------------------------------------------------------------------------
33
 
34
#
35
# Make sure we're really running bash.
36
#
37
[ -z "$BASH" ] && { echo "Menuconfig requires bash" 1>&2; exit 1; }
38
 
39
#
40
# Cache function definitions, turn off posix compliance
41
#
42
set -h +o posix
43
 
44
 
45
#
46
# If you prefer all kernel options listed in a single menu rather than
47
# the standard menu hierarchy, set SINGLE_MENU_MODE to "TRUE" in your
48
# environment.
49
#
50
single_menu_mode="${SINGLE_MENU_MODE:-FALSE}"
51
 
52
 
53
#
54
# Load the functions used by the config.in files.
55
#
56
# I do this because these functions must be redefined depending
57
# on whether they are being called for interactive use or for
58
# saving a configuration to a file.
59
#
60
# Thank the heavens bash supports nesting function definitions.
61
#
62
load_functions () {
63
 
64
#
65
# Additional comments
66
#
67
function comment () {
68
        comment_ctr=$[ comment_ctr + 1 ]
69
        echo -ne "': $comment_ctr' '--- $1' " >>MCmenu
70
}
71
 
72
#
73
# Define a boolean to a specific value.
74
#
75
function define_bool () {
76
        eval $1=$2
77
}
78
 
79
#
80
# Define an int to a specific value.
81
#
82
 
83
function define_int () {
84
        eval $1=$2
85
}
86
 
87
#
88
# Create a boolean (Yes/No) function for our current menu
89
# which calls our local bool function.
90
#
91
function bool () {
92
        eval $2=\${$2:-'n'}  x=\$$2
93
 
94
        case $x in
95
        y|m)    flag="*" ;;
96
        n)      flag=" " ;;
97
        esac
98
 
99
        echo -ne "'$2' '[$flag] $1' " >>MCmenu
100
 
101
        echo -e "function $2 () { l_bool '$2' \"\$1\" ;}\n" >>MCradiolists
102
}
103
 
104
#
105
# Create a tristate (Yes/No/Module) radiolist function
106
# which calls our local tristate function.
107
#
108
# Collapses to a boolean (Yes/No) if module support is disabled.
109
#
110
function tristate () {
111
        if [ "$CONFIG_MODULES" != "y" ]
112
        then
113
                bool "$1" "$2"
114
        else
115
                eval $2=\${$2:-'n'}  x=\$$2
116
 
117
                case $x in
118
                y) flag="*" ;;
119
                m) flag="M" ;;
120
                *) flag=" " ;;
121
                esac
122
 
123
                echo -ne "'$2' '<$flag> $1' " >>MCmenu
124
 
125
                echo -e "
126
                function $2 () { l_tristate '$2' \"\$1\" ;}" >>MCradiolists
127
        fi
128
}
129
 
130
#
131
# Create a tristate radiolist function which is dependent on
132
# another kernel configuration option.
133
#
134
# Quote from the original configure script:
135
#
136
#       If the option we depend upon is a module,
137
#       then the only allowable options are M or N.  If Y, then
138
#       this is a normal tristate.  This is used in cases where modules
139
#       are nested, and one module requires the presence of something
140
#       else in the kernel.
141
#
142
function dep_tristate () {
143
        if [ "$CONFIG_MODULES" != "y" ]
144
        then
145
                bool "$1" "$2"
146
        else
147
                if  eval [ "_$3" != "_m" ]
148
                then
149
                        tristate "$1" "$2" $3
150
                else
151
                        mod_bool "$1" "$2"
152
                fi
153
        fi
154
}
155
 
156
#
157
# Add a menu item which will call our local int function.
158
#
159
function int () {
160
        eval $2=\${$2:-"$3"} x=\$$2
161
 
162
        echo -ne "'$2' '($x) $1' " >>MCmenu
163
 
164
        echo -e "function $2 () { l_int '$1' '$2' '$3' '$x' ;}" >>MCradiolists
165
}
166
 
167
#
168
# Add a menu item which will call our local int function.
169
#
170
function hex () {
171
        eval $2=\${$2:-"$3"} x=\${$2##*[x,X]}
172
 
173
        echo -ne "'$2' '($x) $1' " >>MCmenu
174
 
175
        echo -e "function $2 () { l_hex '$1' '$2' '$3' '$x' ;}" >>MCradiolists
176
}
177
 
178
#
179
# Add a menu item which will call our local One-of-Many choice list.
180
#
181
function choice () {
182
        #
183
        # Need to remember params cause they're gonna get reset.
184
        #
185
        title=$1
186
        choices=$2
187
        default=$3
188
        current=
189
 
190
        #
191
        # Find out if one of the choices is already set.
192
        # If it's not then make it the default.
193
        #
194
        set -- $choices
195
        firstchoice=$2
196
 
197
        while [ -n "$2" ]
198
        do
199
                if eval [ "_\$$2" = "_y" ]
200
                then
201
                        current=$1
202
                        break
203
                fi
204
                shift ; shift
205
        done
206
 
207
        : ${current:=$default}
208
 
209
        echo -ne "'$firstchoice' '($current) $title' " >>MCmenu
210
 
211
        echo -e "
212
        function $firstchoice () \
213
                { l_choice '$title' \"$choices\" $current ;}" >>MCradiolists
214
}
215
 
216
} # END load_functions()
217
 
218
 
219
 
220
 
221
 
222
#
223
# Extract available help for an option from Configure.help
224
# and send it to standard output.
225
#
226
# Most of this function was borrowed from the original kernel
227
# Configure script.
228
#
229
function extract_help () {
230
  if [ -f Documentation/Configure.help ]
231
  then
232
     #first escape regexp special characters in the argument:
233
     var=$(echo "$1"|sed 's/[][\/.^$*]/\\&/g')
234
     #now pick out the right help text:
235
     text=$(sed -n "/^$var[     ]*\$/,\${
236
                        /^$var[         ]*\$/d
237
                        /^#.*/d
238
                        /^[     ]*\$/q
239
                        s/^  //
240
                        p
241
                    }" Documentation/Configure.help)
242
 
243
     if [ -z "$text" ]
244
     then
245
          echo "There is no help available for this kernel option."
246
          return 1
247
     else
248
          echo "$text"
249
     fi
250
  else
251
         echo "There is no help available for this kernel option."
252
         return 1
253
  fi
254
}
255
 
256
#
257
# Activate a help dialog.
258
#
259
function help () {
260
        if extract_help $1 >help.out
261
        then
262
                $DIALOG --backtitle "$backtitle" --title "$2"\
263
                        --textbox help.out $ROWS $COLS
264
        else
265
                $DIALOG --backtitle "$backtitle" \
266
                        --textbox help.out $ROWS $COLS
267
        fi
268
        rm help.out
269
}
270
 
271
#
272
# Show the README file.
273
#
274
function show_readme () {
275
        $DIALOG --backtitle "$backtitle" \
276
                --textbox scripts/README.Menuconfig $ROWS $COLS
277
}
278
 
279
#
280
# Begin building the dialog menu command and Initialize the
281
# Radiolist function file.
282
#
283
function menu_name () {
284
        echo -ne "$DIALOG --title '$1'\
285
                        --backtitle '$backtitle' \
286
                        --menu '$menu_instructions' \
287
                        $ROWS $COLS $((ROWS-10)) \
288
                        '$default' " >MCmenu
289
        >MCradiolists
290
}
291
 
292
#
293
# Add a submenu option to the menu currently under construction.
294
#
295
function submenu () {
296
        echo -ne "'activate_menu $2' '$1  --->' " >>MCmenu
297
}
298
 
299
#
300
# Create a menu entry to handle the traditional sound configuration.
301
#
302
function soundcfg () {
303
        echo -ne "'l_soundcfg' "\
304
                 "'Old configuration script "\
305
                 "(For: SM Wave, PSS & AudioTrix Pro) -->' " >>MCmenu
306
}
307
 
308
#
309
# Startup the traditional sound configuration program.
310
#
311
function l_soundcfg () {
312
        clear
313
        $MAKE -C drivers/sound config
314
}
315
 
316
#
317
# Handle a boolean (Yes/No) option.
318
#
319
function l_bool () {
320
        if [ -n "$2" ]
321
        then
322
                case "$2" in
323
                y|m)    eval $1=y ;;
324
                c)      eval x=\$$1
325
                        case $x in
326
                        y) eval $1=n ;;
327
                        n) eval $1=y ;;
328
                        esac ;;
329
                *)      eval $1=n ;;
330
                esac
331
        else
332
                echo -ne "\007"
333
        fi
334
}
335
 
336
#
337
# Same as bool() except options are (Module/No)
338
#
339
function mod_bool () {
340
        eval $2=\${$2:-'n'}  x=\$$2
341
 
342
        case $x in
343
        y|m) flag='M' ;;
344
        *)   flag=' ' ;;
345
        esac
346
 
347
        echo -ne "'$2' '<$flag> $1' " >>MCmenu
348
 
349
        echo -e "function $2 () { l_mod_bool '$2' \"\$1\" ;}" >>MCradiolists
350
}
351
 
352
#
353
# Same as l_bool() except options are (Module/No)
354
#
355
function l_mod_bool() {
356
        if [ -n "$2" ]
357
        then
358
                case "$2" in
359
                y)      echo -en "\007"
360
                        ${DIALOG} --backtitle "$backtitle" \
361
                                  --infobox "\
362
This feature depends on another which has been configured as a module.  \
363
As a result, this feature will be built as a module." 4 70
364
                        sleep 5
365
                        eval $1=m ;;
366
                m)      eval $1=m ;;
367
                c)      eval x=\$$1
368
                        case $x in
369
                        m) eval $1=n ;;
370
                        n) eval $1=m ;;
371
                        esac ;;
372
                *)      eval $1=n ;;
373
                esac
374
        else
375
                echo -ne "\007"
376
        fi
377
}
378
 
379
#
380
# Handle a tristate (Yes/No/Module) option.
381
#
382
function l_tristate () {
383
        if [ -n "$2" ]
384
        then
385
                eval x=\$$1
386
 
387
                case "$2" in
388
                y) eval $1=y ;;
389
                m) eval $1=m ;;
390
                c) eval x=\$$1
391
                   case $x in
392
                   y) eval $1=n ;;
393
                   n) eval $1=m ;;
394
                   m) eval $1=y ;;
395
                   esac ;;
396
                *) eval $1=n ;;
397
                esac
398
        else
399
                echo -ne "\007"
400
        fi
401
}
402
 
403
#
404
# Create a dialog for entering an integer into a kernel option.
405
#
406
function l_int () {
407
        while true
408
        do
409
                if $DIALOG --title "$1" \
410
                        --backtitle "$backtitle" \
411
                        --inputbox "$inputbox_instructions_int" \
412
                        10 75 "$4" 2>MCdialog.out
413
                then
414
                        answer="`cat MCdialog.out`"
415
                        answer="${answer:-$3}"
416
 
417
                        # Avoid problems with GNU vs POSIX expr semantics.
418
                        if expr "$answer" : '0$\|-[1-9][0-9]*$\|[1-9][0-9]*$' >/dev/null
419
                        then
420
                                eval $2="$answer"
421
                        else
422
                                eval $2="$3"
423
                                echo -en "\007"
424
                                ${DIALOG} --backtitle "$backtitle" \
425
                                        --infobox "You have made an invalid entry." 3 43
426
                                sleep 2
427
                        fi
428
 
429
                        break
430
                fi
431
 
432
                help "$2" "$1"
433
        done
434
}
435
 
436
#
437
# Create a dialog for entering a hexadecimal into a kernel option.
438
#
439
function l_hex () {
440
        while true
441
        do
442
                if $DIALOG --title "$1" \
443
                        --backtitle "$backtitle" \
444
                        --inputbox "$inputbox_instructions_hex" \
445
                        10 75 "$4" 2>MCdialog.out
446
                then
447
                        answer="`cat MCdialog.out`"
448
                        answer="${answer:-$3}"
449
                        answer="${answer##*[x,X]}"
450
 
451
                        # Avoid problems with GNU vs POSIX expr semantics.
452
                        if expr "$answer" : '[0-9a-fA-F][0-9a-fA-F]*$' >/dev/null
453
                        then
454
                                eval $2="$answer"
455
                        else
456
                                eval $2="$3"
457
                                echo -en "\007"
458
                                ${DIALOG} --backtitle "$backtitle" \
459
                                        --infobox "You have made an invalid entry." 3 43
460
                                sleep 2
461
                        fi
462
 
463
                        break
464
                fi
465
 
466
                help "$2" "$1"
467
        done
468
}
469
 
470
#
471
# Handle a one-of-many choice list.
472
#
473
function l_choice () {
474
        #
475
        # Need to remember params cause they're gonna get reset.
476
        #
477
        title="$1"
478
        choices="$2"
479
        current="$3"
480
 
481
        #
482
        # Scan current value of choices and set radiolist switches.
483
        #
484
        list=
485
        set -- $choices
486
        firstchoice=$2
487
        while [ -n "$2" ]
488
        do
489
                case "$1" in
490
                "$current")     list="$list $2 $1 ON "  ;;
491
                *)              list="$list $2 $1 OFF " ;;
492
                esac
493
 
494
                shift ; shift
495
        done
496
 
497
        while true
498
        do
499
                if $DIALOG --title "$title" \
500
                        --backtitle "$backtitle" \
501
                        --radiolist "$radiolist_instructions" \
502
                        15 70 6 $list 2>MCdialog.out
503
                then
504
                        choice=`cat MCdialog.out`
505
                        break
506
                fi
507
 
508
                help "$firstchoice" "$title"
509
        done
510
 
511
        #
512
        # Now set the boolean value of each option based on
513
        # the selection made from the radiolist.
514
        #
515
        set -- $choices
516
        while [ -n "$2" ]
517
        do
518
                if [ "$2" = "$choice" ]
519
                then
520
                        eval $2="y"
521
                else
522
                        eval $2="n"
523
                fi
524
 
525
                shift ; shift
526
        done
527
}
528
 
529
 
530
#
531
# A faster awk based recursive parser. (I hope)
532
#
533
function parser1 () {
534
awk '
535
BEGIN {
536
        menu_no = 0
537
        comment_is_option = 0
538
        parser("'$CONFIG_IN'","MCmenu0")
539
}
540
 
541
function parser(ifile,menu) {
542
 
543
        while (getline 
544
                if ($1 == "mainmenu_option") {
545
                        comment_is_option = "1"
546
                }
547
                else if ($1 == "comment" && comment_is_option == "1") {
548
                        comment_is_option= "0"
549
                        sub($1,"",$0)
550
                        ++menu_no
551
 
552
                        printf("submenu %s MCmenu%s\n", $0, menu_no) >>menu
553
 
554
                        printf( "function MCmenu%s () {\n"\
555
                                "default=$1\n"\
556
                                "menu_name %s\n",\
557
                                 menu_no, $0) >"MCmenu"menu_no
558
 
559
                        parser(ifile, "MCmenu"menu_no)
560
                }
561
                else if ($1 ~ "endmenu") {
562
                        printf("}\n") >>menu
563
                        return
564
                }
565
                else if ($0 ~ /^#|\$MAKE|mainmenu_name/) {
566
                        printf("") >>menu
567
                }
568
                else if ($1 == "source") {
569
                        # Yuk!  Blah!  Phooey!
570
                        if ($2 ~ "drivers/sound") {
571
                                printf("soundcfg\n") >>menu
572
                        }
573
 
574
                        parser($2,menu)
575
                }
576
                else {
577
                        print >>menu
578
                }
579
        }
580
}'
581
}
582
 
583
#
584
# Secondary parser for single menu mode.
585
#
586
function parser2 () {
587
awk '
588
BEGIN {
589
        parser("'$CONFIG_IN'","MCmenu0")
590
}
591
 
592
function parser(ifile,menu) {
593
 
594
        while (getline 
595
                if ($1 ~ /mainmenu_option|endmenu/) {
596
                        printf("") >>menu
597
                }
598
                else if ($0 ~ /^#|\$MAKE|mainmenu_name/) {
599
                        printf("") >>menu
600
                }
601
                else if ($1 == "source") {
602
                        if ($2 ~ "drivers/sound") {
603
                                printf("soundcfg\n") >>menu
604
                        }
605
                        parser($2,menu)
606
                }
607
                else {
608
                        print >>menu
609
                }
610
        }
611
}'
612
}
613
 
614
#
615
# Parse all the config.in files into mini scripts.
616
#
617
function parse_config_files () {
618
        rm -f MCmenu*
619
 
620
        echo "function MCmenu0 () {" >MCmenu0
621
        echo 'default=$1' >>MCmenu0
622
        echo "menu_name 'Main Menu'" >>MCmenu0
623
 
624
        if [ "_$single_menu_mode" = "_TRUE" ]
625
        then
626
                parser2
627
        else
628
                parser1
629
        fi
630
 
631
        echo "comment ''"       >>MCmenu0
632
        echo "g_alt_config"     >>MCmenu0
633
        echo "s_alt_config"     >>MCmenu0
634
 
635
        echo "}" >>MCmenu0
636
 
637
        #
638
        # These mini scripts must be sourced into the current
639
        # environment in order for all of this to work.  Leaving
640
        # them on the disk as executables screws up the recursion
641
        # in activate_menu(), among other things.  Once they are
642
        # sourced we can discard them.
643
        #
644
        for i in MCmenu*
645
        do
646
                source ./$i
647
        done
648
 
649
        rm -f MCmenu*
650
}
651
 
652
#
653
# This is the menu tree's bootstrap.
654
#
655
# Executes the parsed menus on demand and creates a set of functions,
656
# one per configuration option.  These functions will in turn execute
657
# dialog commands or recursively call other menus.
658
#
659
function activate_menu () {
660
        while true
661
        do
662
                comment_ctr=0           #So comment lines get unique tags
663
 
664
                $1 "$default"           #Create the lxdialog menu & functions
665
 
666
                if [ "$?" != "0" ]
667
                then
668
                        clear
669
                        cat <
670

671
Menuconfig has encountered a possible error in one of the kernel's
672
configuration files and is unable to continue.
673
 
674
Please report this to the author .  You may also
675
send a problem report to linux-kernel@vger.rutgers.edu or post a
676
message to the linux.dev.kernel news group.
677
 
678
Please indicate the kernel version you are trying to configure and
679
which menu you were trying to enter when this error occurred.
680
 
681
EOM
682
                        cleanup
683
                        exit 1
684
                fi
685
 
686
                . ./MCradiolists                #Source the menu's functions
687
 
688
                . ./MCmenu 2>MCdialog.out       #Activate the lxdialog menu
689
                ret=$?
690
 
691
                read selection 
692
 
693
                case "$ret" in
694
                0|3|4|5|6)
695
                        defaults="$selection$defaults"  #pseudo stack
696
                        case "$ret" in
697
                        0) eval $selection   ;;
698
                        3) eval $selection y ;;
699
                        4) eval $selection n ;;
700
                        5) eval $selection m ;;
701
                        6) eval $selection c ;;
702
                        esac
703
                        default="${defaults%%*}" defaults="${defaults#*}"
704
                        ;;
705
                2)
706
                        default="${selection%%\ *}"
707
 
708
                        case "$selection" in
709
                        *"-->"*|*"alt_config"*)
710
                                show_readme ;;
711
                        *)
712
                                eval help $selection ;;
713
                        esac
714
                        ;;
715
                255|1)
716
                        break
717
                        ;;
718
                139)
719
                        stty sane
720
                        clear
721
                        cat <
722

723
There seems to be a problem with the lxdialog companion utility which is
724
built prior to running Menuconfig.  Usually this is an indicator that you
725
have upgraded/downgraded your ncurses libraries and did not remove the
726
old ncurses header file(s) in /usr/include or /usr/include/ncurses.
727
 
728
It is VERY important that you have only one set of ncurses header files
729
and that those files are properly version matched to the ncurses libraries
730
installed on your machine.
731
 
732
You may also need to rebuild lxdialog.  This can be done by moving to
733
the /usr/src/linux/scripts/lxdialog directory and issuing the
734
"make clean all" command.
735
 
736
If you have verified that your ncurses install is correct, you may email
737
the author  or post a message on the linux.dev.kernel
738
news group for additional assistance.
739
 
740
EOM
741
                        cleanup
742
                        exit 139
743
                        ;;
744
                esac
745
        done
746
}
747
 
748
#
749
# Create a menu item to load an alternate configuration file.
750
#
751
g_alt_config () {
752
        echo -n "get_alt_config 'Load an Alternate Configuration File' "\
753
                >>MCmenu
754
}
755
 
756
#
757
# Get alternate config file name and load the
758
# configuration from it.
759
#
760
get_alt_config () {
761
        set -f ## Switch file expansion OFF
762
 
763
        while true
764
        do
765
                ALT_CONFIG="${ALT_CONFIG:-$_CONFIG}"
766
 
767
                $DIALOG --backtitle "$backtitle" \
768
                        --inputbox "\
769
Enter the name of the configuration file you wish to load.  \
770
Accept the name shown to restore the configuration you \
771
last retrieved.  Leave blank to abort."\
772
                        11 55 "$ALT_CONFIG" 2>MCdialog.out
773
 
774
                if [ "$?" = "0" ]
775
                then
776
                        ALT_CONFIG=`cat MCdialog.out`
777
 
778
                        [ "_" = "_$ALT_CONFIG" ] && break
779
 
780
                        if eval [ -r "$ALT_CONFIG" ]
781
                        then
782
                                eval load_config_file "$ALT_CONFIG"
783
                                break
784
                        else
785
                                echo -ne "\007"
786
                                $DIALOG --backtitle "$backtitle" \
787
                                        --infobox "File does not exist!"  3 38
788
                                sleep 2
789
                        fi
790
                else
791
                        cat <help.out
792
 
793
For various reasons, one may wish to keep several different kernel
794
configurations available on a single machine.
795
 
796
If you have saved a previous configuration in a file other than the
797
kernel's default, entering the name of the file here will allow you
798
to modify that configuration.
799
 
800
If you are uncertain, then you have probably never used alternate
801
configuration files.  You should therefor leave this blank to abort.
802
 
803
EOM
804
                        $DIALOG --backtitle "$backtitle"\
805
                                --title "Load Alternate Configuration"\
806
                                --textbox help.out $ROWS $COLS
807
                fi
808
        done
809
 
810
        set +f ## Switch file expansion ON
811
        rm -f help.out MCdialog.out
812
}
813
 
814
#
815
# Create a menu item to store an alternate config file.
816
#
817
s_alt_config () {
818
        echo -n "save_alt_config 'Save Configuration to an Alternate File' "\
819
                 >>MCmenu
820
}
821
 
822
#
823
# Get an alternate config file name and save the current
824
# configuration to it.
825
#
826
save_alt_config () {
827
        set -f  ## Switch file expansion OFF
828
 
829
        while true
830
        do
831
 
832
                $DIALOG --backtitle "$backtitle" \
833
                        --inputbox "\
834
Enter a filename to which this configuration should be saved \
835
as an alternate.  Leave blank to abort."\
836
                        10 55 "$ALT_CONFIG" 2>MCdialog.out
837
 
838
                if [ "$?" = "0" ]
839
                then
840
                        ALT_CONFIG=`cat MCdialog.out`
841
 
842
                        [ "_" = "_$ALT_CONFIG" ] && break
843
 
844
                        if eval touch $ALT_CONFIG 2>/dev/null
845
                        then
846
                                eval save_configuration $ALT_CONFIG
847
                                load_functions  ## RELOAD
848
                                break
849
                        else
850
                                echo -ne "\007"
851
                                $DIALOG --backtitle "$backtitle" \
852
                                        --infobox "Can't create file!  Probably a nonexistent directory." 3 60
853
                                sleep 2
854
                        fi
855
                else
856
                        cat <help.out
857
 
858
For various reasons, one may wish to keep different kernel
859
configurations available on a single machine.
860
 
861
Entering a file name here will allow you to later retrieve, modify
862
and use the current configuration as an alternate to whatever
863
configuration options you have selected at that time.
864
 
865
If you are uncertain what all this means then you should probably
866
leave this blank.
867
EOM
868
                        $DIALOG --backtitle "$backtitle"\
869
                                --title "Save Alternate Configuration"\
870
                                --textbox help.out $ROWS $COLS
871
                fi
872
        done
873
 
874
        set +f  ## Switch file expansion ON
875
        rm -f help.out MCdialog.out
876
}
877
 
878
 
879
#
880
# Load config file into the environment converting all
881
# "# OPTION is not set" lines to "OPTION=n".
882
#
883
# The $ARCH defaults are loaded first so "new"/previously
884
# unconfigured parameters are assigned the proper defaults.
885
#
886
function load_config_file () {
887
        eval "`sed -e 's/# \(.*\) is not set.*/\1=n/' arch/$ARCH/defconfig $1`"
888
}
889
 
890
 
891
#
892
# Just what it says.
893
#
894
save_configuration () {
895
        ${DIALOG} --backtitle "$backtitle" \
896
                  --infobox "Saving your kernel configuration..."  3 40
897
 
898
        #
899
        # Now, let's redefine the configuration functions for final
900
        # output to the config files.
901
        #
902
        # Nested function definitions, YIPEE!
903
        #
904
        function bool () {
905
                eval define_bool "$2" "\${$2:-n}"
906
        }
907
 
908
        function tristate () {
909
                eval define_bool "$2" "\${$2:-n}"
910
        }
911
 
912
        function dep_tristate () {
913
                eval x=\${$2:-n}
914
 
915
                if eval [ "_$3" = "_m" ]
916
                then
917
                        if [ "$x" = "y" ]
918
                        then
919
                                x="m"
920
                        fi
921
                fi
922
 
923
                define_bool "$2" "$x"
924
        }
925
 
926
        function int () {
927
                eval x=\${$2:-"$3"}
928
                echo "$2=$x"            >>$CONFIG
929
                echo "#define $2 ($x)"  >>$CONFIG_H
930
        }
931
 
932
        function hex () {
933
                eval x=\${$2:-"$3"}
934
                echo "$2=$x"                     >>$CONFIG
935
                echo "#define $2 0x${x##*[x,X]}" >>$CONFIG_H
936
        }
937
 
938
        function define_bool () {
939
                eval $1="$2"
940
 
941
                case "$2" in
942
                y)
943
                        echo "$1=y"             >>$CONFIG
944
                        echo "#define $1 1"     >>$CONFIG_H
945
                        ;;
946
 
947
                m)
948
                        if [ "$CONFIG_MODULES" = "y" ]
949
                        then
950
                                echo "$1=m"                >>$CONFIG
951
                                echo "#undef  $1"          >>$CONFIG_H
952
                                echo "#define $1_MODULE 1" >>$CONFIG_H
953
                        else
954
                                echo "$1=y"             >>$CONFIG
955
                                echo "#define $1 1"     >>$CONFIG_H
956
                        fi
957
                        ;;
958
 
959
                n)
960
                        echo "# $1 is not set"  >>$CONFIG
961
                        echo "#undef  $1"       >>$CONFIG_H
962
                        ;;
963
                esac
964
        }
965
 
966
        function define_int () {
967
                eval $1="$2"
968
                echo "$1=$2" >>$CONFIG
969
                echo "#define $1 $2" >>$CONFIG_H
970
        }
971
 
972
 
973
        function choice () {
974
                #
975
                # Find the first choice that's already set to 'y'
976
                #
977
                choices="$2"
978
                default="$3"
979
                current=
980
 
981
                set -- $choices
982
                while [ -n "$2" ]
983
                do
984
                        if eval [ "_\$$2" = "_y" ]
985
                        then
986
                                current=$1
987
                                break
988
                        fi
989
                        shift ; shift
990
                done
991
 
992
                #
993
                # Use the default if none were set.
994
                #
995
                : ${current:=$default}
996
 
997
                #
998
                # Output all choices (to be compatible with other configs).
999
                #
1000
                set -- $choices
1001
                while [ -n "$2" ]
1002
                do
1003
                        if eval [ "$1" = "$current" ]
1004
                        then
1005
                            define_bool "$2" "y"
1006
                        else
1007
                            define_bool "$2" "n"
1008
                        fi
1009
                        shift ; shift
1010
                done
1011
        }
1012
 
1013
        function mainmenu_name () {
1014
                :
1015
        }
1016
 
1017
        function mainmenu_option () {
1018
                comment_is_option=TRUE
1019
        }
1020
 
1021
        function endmenu () {
1022
                :
1023
        }
1024
 
1025
        function comment () {
1026
                if [ "$comment_is_option" ]
1027
                then
1028
                        comment_is_option=
1029
                        echo        >>$CONFIG
1030
                        echo "#"    >>$CONFIG
1031
                        echo "# $1" >>$CONFIG
1032
                        echo "#"    >>$CONFIG
1033
 
1034
                        echo         >>$CONFIG_H
1035
                        echo "/*"    >>$CONFIG_H
1036
                        echo " * $1" >>$CONFIG_H
1037
                        echo " */"   >>$CONFIG_H
1038
                fi
1039
        }
1040
 
1041
        DEF_CONFIG="${1:-$_CONFIG}"
1042
        DEF_CONFIG_H="$AUTOCONF_H"
1043
 
1044
        CONFIG=.tmpconfig
1045
        CONFIG_H=.tmpconfig.h
1046
 
1047
        echo "#" >$CONFIG
1048
        echo "# Automatically generated by make menuconfig: don't edit" >>$CONFIG
1049
        echo "#" >>$CONFIG
1050
 
1051
        echo "/*" >$CONFIG_H
1052
        echo " * Automatically generated by make menuconfig: don't edit" >>$CONFIG_H
1053
        echo " */" >>$CONFIG_H
1054
 
1055
        MAKE=:  #To prevent sound Makefile from running.
1056
 
1057
        if . $CONFIG_IN >>.menuconfig.log 2>&1
1058
        then
1059
                #
1060
                # Skip these steps if we are saving to an
1061
                # alternate configuration file.
1062
                #
1063
                if [ "$DEF_CONFIG" = "$_CONFIG" ]
1064
                then
1065
                        #
1066
                        # Create the sound driver's config files for cards
1067
                        # Which are compatible with the new config method.
1068
                        #
1069
                        if [ "_$CONFIG_TRIX"   != "_y" -a\
1070
                             "_$CONFIG_PSS"    != "_y" -a\
1071
                             "_$CONFIG_SMWAVE" != "_y"   ]
1072
                        then
1073
                                make -C drivers/sound kernelconfig >>.menuconfig.log 2>&1
1074
                        fi
1075
 
1076
                        mv $CONFIG_H $DEF_CONFIG_H
1077
                fi
1078
 
1079
                if [ -f "$DEF_CONFIG" ]
1080
                then
1081
                        rm -f ${DEF_CONFIG}.old
1082
                        mv $DEF_CONFIG ${DEF_CONFIG}.old
1083
                fi
1084
 
1085
                mv $CONFIG $DEF_CONFIG
1086
 
1087
                return 0
1088
        else
1089
                return 1
1090
        fi
1091
}
1092
 
1093
 
1094
#
1095
# Remove temporary files
1096
#
1097
cleanup () {
1098
        cleanup1
1099
        cleanup2
1100
        stty $S_TERMIO
1101
}
1102
 
1103
cleanup1 () {
1104
        rm -f MCmenu* MCradiolists MCdialog.out help.out
1105
}
1106
 
1107
cleanup2 () {
1108
        rm -f .tmpconfig .tmpconfig.h
1109
}
1110
 
1111
set_geometry () {
1112
        # Some distributions export these with incorrect values
1113
        # which can really screw up some ncurses programs.
1114
        LINES=  COLUMNS=
1115
 
1116
        ROWS=${1:-24}  COLS=${2:-80}
1117
 
1118
        # Just in case the nasty rlogin bug returns.
1119
        #
1120
        [ $ROWS = 0 ] && ROWS=24
1121
        [ $COLS = 0 ] && COLS=80
1122
 
1123
        if [ $ROWS -lt 19 -o $COLS -lt 80 ]
1124
        then
1125
                echo -e "\n\007Your display is too small to run Menuconfig!"
1126
                echo "It must be at least 19 lines by 80 columns."
1127
                exit 0
1128
        fi
1129
 
1130
        ROWS=$((ROWS-4))  COLS=$((COLS-5))
1131
}
1132
 
1133
S_TERMIO=`stty -g`
1134
 
1135
set_geometry `stty size 2>/dev/null`
1136
 
1137
menu_instructions="\
1138
Arrow keys navigate the menu.  \
1139
 selects submenus --->.  \
1140
Highlighted letters are hotkeys.  \
1141
Pressing  includes,  excludes,  modularizes features.  \
1142
Press  to exit,  for Help.  \
1143
Legend: [*] built-in  [ ] excluded   module  < > module capable"
1144
 
1145
radiolist_instructions="\
1146
Use the arrow keys to navigate this window or \
1147
press the hotkey of the item you wish to select \
1148
followed by the .
1149
Press  for additional information about this option."
1150
 
1151
inputbox_instructions_int="\
1152
Please enter a decimal value. \
1153
Fractions will not be accepted.  \
1154
Use the  key to move from the input field to the buttons below it."
1155
 
1156
inputbox_instructions_hex="\
1157
Please enter a hexadecimal value. \
1158
Use the  key to move from the input field to the buttons below it."
1159
 
1160
DIALOG="${DIALOG:-./scripts/lxdialog/lxdialog}"
1161
 
1162
kernel_version="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}"
1163
 
1164
backtitle="Linux Kernel v$kernel_version Configuration"
1165
 
1166
trap "cleanup ; rm -f .menuconfig ; exit 1" 1 2 15
1167
 
1168
 
1169
#
1170
# Locate default files.
1171
#
1172
DEFAULTS="arch/$ARCH/defconfig"
1173
 
1174
CONFIG_IN="${1:-./config.in}"
1175
 
1176
_CONFIG="${2:-.config}"
1177
 
1178
if [ -f "$_CONFIG" ]; then
1179
  DEFAULTS=$_CONFIG
1180
fi
1181
 
1182
AUTOCONF_H="${3:-include/linux/autoconf.h}"
1183
 
1184
if [ -f $DEFAULTS ]
1185
then
1186
  echo
1187
  echo "Using defaults found in" $DEFAULTS
1188
  load_config_file $DEFAULTS
1189
else
1190
  echo
1191
  echo "No defaults found"
1192
fi
1193
 
1194
# Fresh new log.
1195
>.menuconfig.log
1196
 
1197
$DIALOG --backtitle "$backtitle" \
1198
        --infobox "Preparing configuration scripts..." 3 40
1199
 
1200
#
1201
# Check kernel version of previous menuconfig build.
1202
# If it's different then we should tell the sound driver
1203
# to rebuild its Config.in file.
1204
#
1205
rebuildsound=TRUE
1206
if [ -e .menuconfig ]
1207
then
1208
        read x <.menuconfig
1209
        if [ "$x" = "# $kernel_version" ]
1210
        then
1211
                rebuildsound=
1212
        fi
1213
fi
1214
 
1215
if [ "$rebuildsound" ]
1216
then
1217
        # Activate the Linux compatible sound configuration.
1218
        # This may not work for all sound cards.  (See sound docs)
1219
        #
1220
        make -C drivers/sound mkscript kernelconfig >>.menuconfig.log 2>&1
1221
 
1222
        echo "# $kernel_version" >.menuconfig
1223
fi
1224
 
1225
# Load the functions used by the config.in files.
1226
load_functions
1227
 
1228
#
1229
# Read config.in files and parse them into one shell function per menu.
1230
#
1231
parse_config_files $CONFIG_IN
1232
 
1233
#
1234
# Start the ball rolling from the top.
1235
#
1236
activate_menu MCmenu0
1237
 
1238
#
1239
# All done!
1240
#
1241
cleanup1
1242
 
1243
#
1244
# Confirm and Save
1245
#
1246
if $DIALOG --backtitle "$backtitle" \
1247
           --yesno "Do you wish to save your new kernel configuration?" 5 60
1248
 
1249
then
1250
        save_configuration
1251
        stty $S_TERMIO
1252
        clear
1253
 
1254
        cat <
1255
 
1256
 
1257
The linux kernel is now hopefully configured for your setup.
1258
Check the top-level Makefile for additional configuration,
1259
and do a 'make dep ; make clean' if you want to be sure all
1260
the files are correctly re-made.
1261
 
1262
EOM
1263
else
1264
        clear
1265
        stty $S_TERMIO
1266
        echo -e "Your kernel configuration changes were NOT saved.\n"
1267
fi
1268
 
1269
 
1270
exit 0
1271
 

powered by: WebSVN 2.1.0

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