]> git.sesse.net Git - vlc/blob - menuconfig
00d6ec4dee0ba27d76fd6ef3e46ad15ad3a8d9b7
[vlc] / menuconfig
1 #! /bin/sh
2 #
3 # VideoLAN Client configuration script, borrowed from linux menuconfig
4 # Cyril Deguet <asmax@videolan.org>
5 #
6 #-----------------------------------------------------------------
7 # William Roadcap was the original author of Menuconfig.
8 # Michael Elizabeth Chastain (mec@shout.net) is the current maintainer.
9 #
10 # 070497 Bernhard Kaindl (bkaindl@netway.at) - get default values for
11 # new bool, tristate and dep_tristate parameters from the defconfig file.
12 # new configuration parameters are marked with '(NEW)' as in make config.
13 #
14 # 180697 Bernhard Kaindl (bkaindl@netway.at) - added the needed support
15 # for string options. They are handled like the int and hex options.
16 #
17 # 081297 Pavel Machek (pavel@atrey.karlin.mff.cuni.cz) - better error 
18 # handling
19 #
20 # 131197 Michael Chastain (mec@shout.net) - output all lines for a
21 # choice list, not just the selected one.  This makes the output
22 # the same as Configure output, which is important for smart config
23 # dependencies.
24 #
25 # 101297 Michael Chastain (mec@shout.net) - remove sound driver cruft.
26 #
27 # 221297 Michael Chastain (mec@shout.net) - make define_bool actually
28 # define its arguments so that later tests on them work right.
29 #
30 # 160198 Michael Chastain (mec@shout.net) - fix bug with 'c' command
31 # (complement existing value) when used on virgin uninitialized variables.
32 #
33 # 090398 Axel Boldt (boldt@math.ucsb.edu) - allow for empty lines in help
34 # texts.
35 #
36 # 12 Dec 1998, Michael Elizabeth Chastain (mec@shout.net)
37 # Remove a /tmp security hole in get_def (also makes it faster).
38 # Give uninitialized variables canonical values rather than null value.
39 # Change a lot of places to call set_x_info uniformly.
40 # Take out message about preparing version (old sound driver cruft).
41 #
42 # 13 Dec 1998, Riley H Williams <Riley@Williams.Name>
43 # When an error occurs, actually display the error message as well as
44 # our comments thereon.
45 #
46 # 31 Dec 1998, Michael Elizabeth Chastain (mec@shout.net)
47 # Fix mod_bool to honor $CONFIG_MODULES.
48 # Fix dep_tristate to call define_bool when dependency is "n".
49 #
50 # 02 January 1999, Michael Elizabeth Chastain (mec@shout.net)
51 # Blow away lxdialog.scrltmp on entry to activate_menu.  This protects
52 # against people who use commands like ' ' to select menus.
53 #
54 # 24 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
55 # - Improve the exit message (Jeff Ronne).
56 #
57 # 06 July 1999, Andrzej M. Krzysztofowicz, <ankry@mif.pg.gda.pl>
58 # - Support for multiple conditions in dep_tristate().
59 # - Implemented new functions: define_tristate(), define_int(), define_hex(),
60 #   define_string(), dep_bool().
61 #
62 # 12 November 2001, Keith Owens <kaos@ocs.com.au>
63 # Escape double quotes on eval so the quotes are still there on the second
64 # evaluation, required to handle strings with special characters.
65
66
67
68 #
69 # Change this to TRUE if you prefer all kernel options listed
70 # in a single menu rather than the standard menu hierarchy.
71 #
72 single_menu_mode=
73
74 #
75 # Make sure we're really running bash.
76 #
77 [ -z "$BASH" ] && { echo "Menuconfig requires bash" 1>&2; exit 1; }
78
79 #
80 # Cache function definitions, turn off posix compliance
81 #
82 set -h +o posix
83
84
85
86 # Given a configuration variable, set the global variable $x to its value,
87 # and the global variable $info to the string " (NEW)" if this is a new
88 # variable.
89 #
90 # This function looks for: (1) the current value, or (2) the default value
91 # from the arch-dependent defconfig file, or (3) a default passed by the caller.
92
93 function set_x_info () {
94     eval x=\$$1
95     if [ -z "$x" ]; then
96         eval `sed -n -e 's/# \(.*\) is not set.*/\1=n/' -e "/^$1=/p" arch/$ARCH/defconfig`
97         eval x=\${$1:-\"$2\"}
98         eval $1=$x
99         eval INFO_$1="' (NEW)'"
100     fi
101     eval info=\"\$INFO_$1\"
102 }
103
104 #
105 # Load the functions used by the config.in files.
106 #
107 # I do this because these functions must be redefined depending
108 # on whether they are being called for interactive use or for
109 # saving a configuration to a file.
110 #
111 # Thank the heavens bash supports nesting function definitions.
112 #
113 load_functions () {
114
115 #
116 # Additional comments
117 #
118 function comment () {
119         comment_ctr=$[ comment_ctr + 1 ]
120         echo -ne "': $comment_ctr' '--- $1' " >>MCmenu
121 }
122
123 #
124 # Define a boolean to a specific value.
125 #
126 function define_bool () {
127         eval $1=$2
128 }
129
130 function define_tristate () {
131         eval $1=$2
132 }
133
134 function define_hex () {
135         eval $1=$2
136 }
137
138 function define_int () {
139         eval $1=$2
140 }
141
142 function define_string () {
143         eval $1=\"$2\"
144 }
145
146 #
147 # Create a boolean (Yes/No) function for our current menu
148 # which calls our local bool function.
149 #
150 function bool () {
151         set_x_info "$2" "n"
152
153         case $x in
154         y|m)    flag="*" ;;
155         n)      flag=" " ;;
156         esac
157
158         echo -ne "'$2' '[$flag] $1$info' " >>MCmenu
159
160         echo -e "function $2 () { l_bool '$2' \"\$1\" ;}\n" >>MCradiolists
161 }
162
163 #
164 # Create a tristate (Yes/No/Module) radiolist function
165 # which calls our local tristate function.
166 #
167 # Collapses to a boolean (Yes/No) if module support is disabled.
168 #
169 function tristate () {
170         if [ "$CONFIG_MODULES" != "y" ]
171         then
172                 bool "$1" "$2"
173         else
174                 set_x_info "$2" "n"
175         
176                 case $x in
177                 y) flag="*" ;;
178                 m) flag="M" ;;
179                 *) flag=" " ;;
180                 esac
181         
182                 echo -ne "'$2' '<$flag> $1$info' " >>MCmenu
183         
184                 echo -e "
185                 function $2 () { l_tristate '$2' \"\$1\" ;}" >>MCradiolists
186         fi
187 }
188
189 #
190 # Create a tristate radiolist function which is dependent on
191 # another kernel configuration option.
192 #
193 # Quote from the original configure script:
194 #
195 #       If the option we depend upon is a module,
196 #       then the only allowable options are M or N.  If Y, then
197 #       this is a normal tristate.  This is used in cases where modules
198 #       are nested, and one module requires the presence of something
199 #       else in the kernel.
200 #
201 function dep_tristate () {
202         ques="$1"
203         var="$2"
204         dep=y
205         shift 2
206         while [ $# -gt 0 ]; do
207                 if   [ "$1" = y ]; then
208                         shift
209                 elif [ "$1" = m ]; then
210                         dep=m
211                         shift
212                 else
213                         dep=n
214                         shift $#
215                 fi
216         done
217         if [ "$dep" = y ]; then
218             tristate "$ques" "$var"
219         elif [ "$dep" = m ]; then
220             mod_bool "$ques" "$var"
221         else 
222             define_tristate "$var" n
223         fi
224 }
225
226 #
227 #   Same as above, but now only Y and N are allowed as dependency
228 #   (i.e. third and next arguments).
229 #
230 function dep_bool () {
231         ques="$1"
232         var="$2"
233         dep=y
234         shift 2
235         while [ $# -gt 0 ]; do
236                 if [ "$1" = y ]; then
237                         shift
238                 else
239                         dep=n
240                         shift $#
241                 fi
242         done
243         if [ "$dep" = y ]; then
244             bool "$ques" "$var"
245         else 
246             define_bool "$var" n
247         fi
248 }
249
250 function dep_mbool () {
251         ques="$1"
252         var="$2"
253         dep=y
254         shift 2
255         while [ $# -gt 0 ]; do
256                 if [ "$1" = y -o "$1" = m ]; then
257                         shift
258                 else
259                         dep=n
260                         shift $#
261                 fi
262         done
263         if [ "$dep" = y ]; then
264             bool "$ques" "$var"
265         else 
266             define_bool "$var" n
267         fi
268 }
269
270 #
271 # Add a menu item which will call our local int function.
272
273 function int () {
274         set_x_info "$2" "$3"
275
276         echo -ne "'$2' '($x) $1$info' " >>MCmenu
277
278         echo -e "function $2 () { l_int '$1' '$2' '$3' '$x' ;}" >>MCradiolists
279 }
280
281 #
282 # Add a menu item which will call our local hex function.
283
284 function hex () {
285         set_x_info "$2" "$3"
286         x=${x##*[x,X]}
287
288         echo -ne "'$2' '($x) $1$info' " >>MCmenu
289
290         echo -e "function $2 () { l_hex '$1' '$2' '$3' '$x' ;}" >>MCradiolists
291 }
292
293 #
294 # Add a menu item which will call our local string function.
295
296 function string () {
297         set_x_info "$2" "$3"
298
299         echo -ne "'$2' '     $1: \"$x\"$info' " >>MCmenu
300
301         echo -e "function $2 () { l_string '$1' '$2' '$3' '$x' ;}" >>MCradiolists
302 }
303
304 #
305 # Add a menu item which will call our local One-of-Many choice list.
306 #
307 function choice () {
308         #
309         # Need to remember params cause they're gonna get reset.
310         #
311         title=$1
312         choices=$2
313         default=$3
314         current=
315
316         #
317         # Find out if one of the choices is already set.
318         # If it's not then make it the default.
319         #
320         set -- $choices
321         firstchoice=$2
322
323         while [ -n "$2" ]
324         do
325                 if eval [ \"_\$$2\" = \"_y\" ]
326                 then
327                         current=$1
328                         break
329                 fi
330                 shift ; shift
331         done
332
333         : ${current:=$default}
334
335         echo -ne "'$firstchoice' '($current) $title' " >>MCmenu
336
337         echo -e "
338         function $firstchoice () \
339                 { l_choice '$title' \"$choices\" \"$current\" ;}" >>MCradiolists
340 }
341
342 } # END load_functions()
343
344
345
346
347
348 #
349 # Extract available help for an option from Configure.help
350 # and send it to standard output.
351 #
352 # Most of this function was borrowed from the original kernel
353 # Configure script.
354 #
355 function extract_help () {
356   if [ -f doc/Configure.help ]
357   then
358      #first escape regexp special characters in the argument:
359      var=$(echo "$1"|sed 's/[][\/.^$*]/\\&/g')
360      #now pick out the right help text:
361      text=$(sed -n "/^$var[     ]*\$/,\${
362                         /^$var[         ]*\$/c\\
363 ${var}:\\
364
365                         /^#/b
366                         /^[^    ]/q
367                         s/^  //
368                         /<file:\\([^>]*\\)>/s//\\1/g
369                         p
370                     }" doc/Configure.help)
371
372      if [ -z "$text" ]
373      then
374           echo "There is no help available for this option."
375           return 1
376      else
377           echo "$text"
378      fi
379   else
380          echo "There is no help available for this option."
381          return 1
382   fi
383 }
384
385 #
386 # Activate a help dialog.
387 #
388 function help () {
389         if extract_help $1 >help.out
390         then
391                 $DIALOG --backtitle "$backtitle" --title "$2"\
392                         --textbox help.out $ROWS $COLS
393         else
394                 $DIALOG --backtitle "$backtitle" \
395                         --textbox help.out $ROWS $COLS
396         fi
397         rm -f help.out
398 }
399
400 #
401 # Show the README file.
402 #
403 function show_readme () {
404         $DIALOG --backtitle "$backtitle" \
405                 --textbox scripts/README.Menuconfig $ROWS $COLS
406 }
407
408 #
409 # Begin building the dialog menu command and Initialize the 
410 # Radiolist function file.
411 #
412 function menu_name () {
413         echo -ne "$DIALOG --title '$1'\
414                         --backtitle '$backtitle' \
415                         --menu '$menu_instructions' \
416                         $ROWS $COLS $((ROWS-10)) \
417                         '$default' " >MCmenu
418         >MCradiolists
419 }
420
421 #
422 # Add a submenu option to the menu currently under construction.
423 #
424 function submenu () {
425         echo -ne "'activate_menu $2' '$1  --->' " >>MCmenu
426 }
427
428 #
429 # Handle a boolean (Yes/No) option.
430 #
431 function l_bool () {
432         if [ -n "$2" ]
433         then
434                 case "$2" in
435                 y|m)    eval $1=y ;;
436                 c)      eval x=\$$1
437                         case $x in
438                         y) eval $1=n ;;
439                         n) eval $1=y ;;
440                         *) eval $1=y ;;
441                         esac ;;
442                 *)      eval $1=n ;;
443                 esac
444         else
445                 echo -ne "\007"
446         fi
447 }
448
449 #
450 # Same as bool() except options are (Module/No)
451 #
452 function mod_bool () {
453         if [ "$CONFIG_MODULES" != "y" ]; then
454             define_bool "$2" "n"
455         else
456             set_x_info "$2" "n"
457  
458             case $x in
459             y|m) flag='M' ;;
460             *)   flag=' ' ;;
461             esac
462  
463             echo -ne "'$2' '<$flag> $1$info' " >>MCmenu
464  
465             echo -e "function $2 () { l_mod_bool '$2' \"\$1\" ;}" >>MCradiolists
466         fi
467 }
468
469 #
470 # Same as l_bool() except options are (Module/No)
471 #
472 function l_mod_bool() {
473         if [ -n "$2" ]
474         then
475                 case "$2" in
476                 y)      echo -en "\007"
477                         ${DIALOG} --backtitle "$backtitle" \
478                                   --infobox "\
479 This feature depends on another which has been configured as a module.  \
480 As a result, this feature will be built as a module." 4 70
481                         sleep 5
482                         eval $1=m ;;
483                 m)      eval $1=m ;;
484                 c)      eval x=\$$1
485                         case $x in
486                         m) eval $1=n ;;
487                         n) eval $1=m ;;
488                         *) eval $1=m ;;
489                         esac ;;
490                 *)      eval $1=n ;;
491                 esac
492         else
493                 echo -ne "\007"
494         fi
495 }
496
497 #
498 # Handle a tristate (Yes/No/Module) option.
499 #
500 function l_tristate () {
501         if [ -n "$2" ]
502         then
503                 eval x=\$$1
504
505                 case "$2" in
506                 y) eval $1=y ;;
507                 m) eval $1=m ;;
508                 c) eval x=\$$1
509                    case $x in
510                    y) eval $1=n ;;
511                    n) eval $1=m ;;
512                    m) eval $1=y ;;
513                    *) eval $1=y ;;
514                    esac ;;
515                 *) eval $1=n ;;
516                 esac
517         else
518                 echo -ne "\007"
519         fi
520 }
521
522 #
523 # Create a dialog for entering an integer into a kernel option.
524 #
525 function l_int () {
526         while true
527         do
528                 if $DIALOG --title "$1" \
529                         --backtitle "$backtitle" \
530                         --inputbox "$inputbox_instructions_int" \
531                         10 75 "$4" 2>MCdialog.out
532                 then
533                         answer="`cat MCdialog.out`"
534                         answer="${answer:-$3}"
535
536                         # Semantics of + and ? in GNU expr changed, so
537                         # we avoid them:
538                         if expr "$answer" : '0$' '|' "$answer" : '[1-9][0-9]*$' '|' "$answer" : '-[1-9][0-9]*$' >/dev/null
539                         then
540                                 eval $2=\"$answer\"
541                         else
542                                 eval $2=\"$3\"
543                                 echo -en "\007"
544                                 ${DIALOG} --backtitle "$backtitle" \
545                                         --infobox "You have made an invalid entry." 3 43
546                                 sleep 2
547                         fi
548
549                         break
550                 fi
551
552                 help "$2" "$1"
553         done
554 }
555
556 #
557 # Create a dialog for entering a hexadecimal into a kernel option.
558 #
559 function l_hex () {
560         while true
561         do
562                 if $DIALOG --title "$1" \
563                         --backtitle "$backtitle" \
564                         --inputbox "$inputbox_instructions_hex" \
565                         10 75 "$4" 2>MCdialog.out
566                 then
567                         answer="`cat MCdialog.out`"
568                         answer="${answer:-$3}"
569                         answer="${answer##*[x,X]}"
570
571                         if expr "$answer" : '[0-9a-fA-F][0-9a-fA-F]*$' >/dev/null
572                         then
573                                 eval $2=\"$answer\"
574                         else
575                                 eval $2=\"$3\"
576                                 echo -en "\007"
577                                 ${DIALOG} --backtitle "$backtitle" \
578                                         --infobox "You have made an invalid entry." 3 43
579                                 sleep 2
580                         fi
581
582                         break
583                 fi
584
585                 help "$2" "$1"
586         done
587 }
588
589 #
590 # Create a dialog for entering a string into a kernel option.
591 #
592 function l_string () {
593         while true
594         do
595                 if $DIALOG --title "$1" \
596                         --backtitle "$backtitle" \
597                         --inputbox "$inputbox_instructions_string" \
598                         10 75 "$4" 2>MCdialog.out
599                 then
600                         answer="`cat MCdialog.out`"
601                         answer="${answer:-$3}"
602
603                         #
604                         # Someone may add a nice check for the entered
605                         # string here...
606                         #
607                         eval $2=\"$answer\"
608
609                         break
610                 fi
611
612                 help "$2" "$1"
613         done
614 }
615
616
617 #
618 # Handle a one-of-many choice list.
619 #
620 function l_choice () {
621         #
622         # Need to remember params cause they're gonna get reset.
623         #
624         title="$1"
625         choices="$2"
626         current="$3"
627         chosen=
628
629         #
630         # Scan current value of choices and set radiolist switches.
631         #
632         list=
633         set -- $choices
634         firstchoice=$2
635         while [ -n "$2" ]
636         do
637                 case "$1" in
638                 "$current"*)    if [ -z "$chosen" ]; then
639                                         list="$list $2 $1 ON "
640                                         chosen=1
641                                 else
642                                         list="$list $2 $1 OFF "
643                                 fi  ;;
644                 *)              list="$list $2 $1 OFF " ;;
645                 esac
646                         
647                 shift ; shift
648         done
649
650         while true
651         do
652                 if $DIALOG --title "$title" \
653                         --backtitle "$backtitle" \
654                         --radiolist "$radiolist_instructions" \
655                         15 70 6 $list 2>MCdialog.out
656                 then
657                         choice=`cat MCdialog.out`
658                         break
659                 fi
660
661                 help "$firstchoice" "$title"
662         done
663
664         #
665         # Now set the boolean value of each option based on
666         # the selection made from the radiolist.
667         #
668         set -- $choices
669         while [ -n "$2" ]
670         do
671                 if [ "$2" = "$choice" ]
672                 then
673                         eval $2=\"y\"
674                 else
675                         eval $2=\"n\"
676                 fi
677                 
678                 shift ; shift
679         done
680 }
681
682 #
683 # Call awk, and watch for error codes, etc.
684 #
685 function callawk () {
686 awk "$1" || { echo "Awk died with error code $?. Giving up."; exit 1; }
687 }
688
689 #
690 # A faster awk based recursive parser. (I hope)
691 #
692 function parser1 () {
693 callawk '
694 BEGIN {
695         menu_no = 0
696         comment_is_option = 0
697         parser("'$CONFIG_IN'","MCmenu0")
698 }
699
700 function parser(ifile,menu) {
701
702         while (getline <ifile) {
703                 if ($1 == "mainmenu_option") {
704                         comment_is_option = "1"
705                 }
706                 else if ($1 == "comment" && comment_is_option == "1") {
707                         comment_is_option= "0"
708                         sub($1,"",$0)
709                         ++menu_no
710
711                         printf("submenu %s MCmenu%s\n", $0, menu_no) >>menu
712
713                         newmenu = sprintf("MCmenu%d", menu_no);
714                         printf( "function MCmenu%s () {\n"\
715                                 "default=$1\n"\
716                                 "menu_name %s\n",\
717                                  menu_no, $0) >newmenu
718
719                         parser(ifile, newmenu)
720                 }
721                 else if ($0 ~ /^#|\$MAKE|mainmenu_name/) {
722                         printf("") >>menu
723                 }
724                 else if ($1 ~ "endmenu") {
725                         printf("}\n") >>menu
726                         return
727                 } 
728                 else if ($1 == "source") {
729                         parser($2,menu)
730                 }
731                 else {
732                         print >>menu
733                 }
734         }
735 }'
736 }
737
738 #
739 # Secondary parser for single menu mode.
740 #
741 function parser2 () {
742 callawk '
743 BEGIN {
744         parser("'$CONFIG_IN'","MCmenu0")
745 }
746
747 function parser(ifile,menu) {
748
749         while (getline <ifile) {
750                 if ($0 ~ /^#|$MAKE|mainmenu_name/) {
751                         printf("") >>menu
752                 }
753                 else if ($1 ~ /mainmenu_option|endmenu/) {
754                         printf("") >>menu
755                 } 
756                 else if ($1 == "source") {
757                         parser($2,menu)
758                 }
759                 else {
760                         print >>menu
761                 }
762         }
763 }'
764 }
765
766 #
767 # Parse all the config.in files into mini scripts.
768 #
769 function parse_config_files () {
770         rm -f MCmenu*
771
772         echo "function MCmenu0 () {" >MCmenu0
773         echo 'default=$1' >>MCmenu0
774         echo "menu_name 'Main Menu'" >>MCmenu0
775
776         if [ "_$single_menu_mode" = "_TRUE" ]
777         then
778                 parser2
779         else
780                 parser1
781         fi
782
783         echo "comment ''"       >>MCmenu0
784         echo "g_alt_config"     >>MCmenu0
785         echo "s_alt_config"     >>MCmenu0
786
787         echo "}" >>MCmenu0
788
789         #
790         # These mini scripts must be sourced into the current
791         # environment in order for all of this to work.  Leaving
792         # them on the disk as executables screws up the recursion
793         # in activate_menu(), among other things.  Once they are
794         # sourced we can discard them.
795         #
796         for i in MCmenu*
797         do
798                 echo -n "."
799                 source ./$i
800         done
801         rm -f MCmenu*
802 }
803
804 #
805 # This is the menu tree's bootstrap.
806 #
807 # Executes the parsed menus on demand and creates a set of functions,
808 # one per configuration option.  These functions will in turn execute
809 # dialog commands or recursively call other menus.
810 #
811 function activate_menu () {
812         rm -f lxdialog.scrltmp
813         while true
814         do
815                 comment_ctr=0           #So comment lines get unique tags
816
817                 $1 "$default" 2> MCerror #Create the lxdialog menu & functions
818
819                 if [ "$?" != "0" ]
820                 then
821                         clear
822                         cat <<EOM
823
824 Menuconfig has encountered a possible error in one of the kernel's
825 configuration files and is unable to continue.  Here is the error
826 report:
827
828 EOM
829                         sed 's/^/ Q> /' MCerror
830                         cat <<EOM
831
832 Please report this to the maintainer <mec@shout.net>.  You may also
833 send a problem report to <linux-kernel@vger.kernel.org>.
834
835 Please indicate the kernel version you are trying to configure and
836 which menu you were trying to enter when this error occurred.
837
838 EOM
839                         cleanup
840                         exit 1
841                 fi
842                 rm -f MCerror
843
844                 . ./MCradiolists                #Source the menu's functions
845
846                 . ./MCmenu 2>MCdialog.out       #Activate the lxdialog menu
847                 ret=$?
848
849                 read selection <MCdialog.out
850
851                 case "$ret" in
852                 0|3|4|5|6)
853                         defaults="$selection\12$defaults"  #pseudo stack
854                         case "$ret" in
855                         0) eval $selection   ;;
856                         3) eval $selection y ;;
857                         4) eval $selection n ;;
858                         5) eval $selection m ;;
859                         6) eval $selection c ;;
860                         esac
861                         default="${defaults%%\12*}" defaults="${defaults#*\12}"
862                         ;;
863                 2)      
864                         default="${selection%%\ *}"
865
866                         case "$selection" in
867                         *"-->"*|*"alt_config"*)
868                                 show_readme ;;
869                         *)
870                                 eval help $selection ;;
871                         esac
872                         ;;
873                 255|1)
874                         break
875                         ;;
876                 139)
877                         stty sane
878                         clear
879                         cat <<EOM
880
881 There seems to be a problem with the lxdialog companion utility which is
882 built prior to running Menuconfig.  Usually this is an indicator that you
883 have upgraded/downgraded your ncurses libraries and did not remove the 
884 old ncurses header file(s) in /usr/include or /usr/include/ncurses.
885
886 It is VERY important that you have only one set of ncurses header files
887 and that those files are properly version matched to the ncurses libraries 
888 installed on your machine.
889
890 You may also need to rebuild lxdialog.  This can be done by moving to
891 the /usr/src/linux/scripts/lxdialog directory and issuing the 
892 "make clean all" command.
893
894 If you have verified that your ncurses install is correct, you may email
895 the maintainer <mec@shout.net> or post a message to
896 <linux-kernel@vger.kernel.org> for additional assistance. 
897
898 EOM
899                         cleanup
900                         exit 139
901                         ;;
902                 esac
903         done
904 }
905
906 #
907 # Create a menu item to load an alternate configuration file.
908 #
909 g_alt_config () {
910         echo -n "get_alt_config 'Load an Alternate Configuration File' "\
911                 >>MCmenu
912 }
913
914 #
915 # Get alternate config file name and load the 
916 # configuration from it.
917 #
918 get_alt_config () {
919         set -f ## Switch file expansion OFF
920
921         while true
922         do
923                 ALT_CONFIG="${ALT_CONFIG:-$DEFAULTS}"
924
925                 $DIALOG --backtitle "$backtitle" \
926                         --inputbox "\
927 Enter the name of the configuration file you wish to load.  \
928 Accept the name shown to restore the configuration you \
929 last retrieved.  Leave blank to abort."\
930                         11 55 "$ALT_CONFIG" 2>MCdialog.out
931
932                 if [ "$?" = "0" ]
933                 then
934                         ALT_CONFIG=`cat MCdialog.out`
935
936                         [ "_" = "_$ALT_CONFIG" ] && break
937
938                         if eval [ -r \"$ALT_CONFIG\" ]
939                         then
940                                 eval load_config_file \"$ALT_CONFIG\"
941                                 break
942                         else
943                                 echo -ne "\007"
944                                 $DIALOG --backtitle "$backtitle" \
945                                         --infobox "File does not exist!"  3 38
946                                 sleep 2
947                         fi
948                 else
949                         cat <<EOM >help.out
950
951 For various reasons, one may wish to keep several different kernel
952 configurations available on a single machine.  
953
954 If you have saved a previous configuration in a file other than the
955 kernel's default, entering the name of the file here will allow you
956 to modify that configuration.
957
958 If you are uncertain, then you have probably never used alternate 
959 configuration files.  You should therefor leave this blank to abort.
960
961 EOM
962                         $DIALOG --backtitle "$backtitle"\
963                                 --title "Load Alternate Configuration"\
964                                 --textbox help.out $ROWS $COLS
965                 fi
966         done
967
968         set +f ## Switch file expansion ON
969         rm -f help.out MCdialog.out
970 }
971
972 #
973 # Create a menu item to store an alternate config file.
974 #
975 s_alt_config () {
976         echo -n "save_alt_config 'Save Configuration to an Alternate File' "\
977                  >>MCmenu
978 }
979
980 #
981 # Get an alternate config file name and save the current
982 # configuration to it.
983 #
984 save_alt_config () {
985         set -f  ## Switch file expansion OFF
986                         
987         while true
988         do
989                 $DIALOG --backtitle "$backtitle" \
990                         --inputbox "\
991 Enter a filename to which this configuration should be saved \
992 as an alternate.  Leave blank to abort."\
993                         10 55 "$ALT_CONFIG" 2>MCdialog.out
994
995                 if [ "$?" = "0" ]
996                 then
997                         ALT_CONFIG=`cat MCdialog.out`
998
999                         [ "_" = "_$ALT_CONFIG" ] && break
1000
1001                         if eval touch $ALT_CONFIG 2>/dev/null
1002                         then
1003                                 eval save_configuration $ALT_CONFIG
1004                                 load_functions  ## RELOAD
1005                                 break
1006                         else
1007                                 echo -ne "\007"
1008                                 $DIALOG --backtitle "$backtitle" \
1009                                         --infobox "Can't create file!  Probably a nonexistent directory." 3 60
1010                                 sleep 2
1011                         fi
1012                 else
1013                         cat <<EOM >help.out
1014
1015 For various reasons, one may wish to keep different kernel
1016 configurations available on a single machine.  
1017
1018 Entering a file name here will allow you to later retrieve, modify
1019 and use the current configuration as an alternate to whatever 
1020 configuration options you have selected at that time.
1021
1022 If you are uncertain what all this means then you should probably
1023 leave this blank.
1024 EOM
1025                         $DIALOG --backtitle "$backtitle"\
1026                                 --title "Save Alternate Configuration"\
1027                                 --textbox help.out $ROWS $COLS
1028                 fi
1029         done
1030
1031         set +f  ## Switch file expansion ON
1032         rm -f help.out MCdialog.out
1033 }
1034
1035 #
1036 # Load config options from a file.
1037 # Converts all "# OPTION is not set" lines to "OPTION=n" lines
1038 #
1039 function load_config_file () {
1040         awk '
1041           /# .* is not set.*/ { printf("%s=n\n", $2) }
1042         ! /# .* is not set.*/ { print }
1043         ' $1 >.tmpconfig
1044
1045         source ./.tmpconfig
1046         rm -f .tmpconfig
1047 }
1048
1049 #
1050 # Just what it says.
1051 #
1052 save_configuration () {
1053         echo
1054         echo -n "Saving your kernel configuration."
1055
1056         #
1057         # Now, let's redefine the configuration functions for final
1058         # output to the config files.
1059         #
1060         # Nested function definitions, YIPEE!
1061         #
1062         function bool () {
1063                 set_x_info "$2" "n"
1064                 eval define_bool \"$2\" \"$x\"
1065         }
1066
1067         function tristate () {
1068                 set_x_info "$2" "n"
1069                 eval define_tristate \"$2\" \"$x\"
1070         }
1071
1072         function dep_tristate () {
1073                 set_x_info "$2" "n"
1074                 var="$2"
1075                 shift 2
1076                 while [ $# -gt 0 ]; do
1077                         if   [ "$1" = y ]; then
1078                                 shift
1079                         elif [ "$1" = m -a "$x" != n ]; then
1080                                 x=m; shift
1081                         else 
1082                                 x=n; shift $#
1083                         fi
1084                 done
1085                 define_tristate "$var" "$x"
1086         }
1087
1088         function dep_bool () {
1089                 set_x_info "$2" "n"
1090                 var="$2"
1091                 shift 2
1092                 while [ $# -gt 0 ]; do
1093                         if   [ "$1" = y ]; then
1094                                 shift
1095                         else 
1096                                 x=n; shift $#
1097                         fi
1098                 done
1099                 define_bool "$var" "$x"
1100         }
1101
1102         function dep_mbool () {
1103                 set_x_info "$2" "n"
1104                 var="$2"
1105                 shift 2
1106                 while [ $# -gt 0 ]; do
1107                         if   [ "$1" = y -o "$1" = m ]; then
1108                                 shift
1109                         else 
1110                                 x=n; shift $#
1111                         fi
1112                 done
1113                 define_bool "$var" "$x"
1114         }
1115
1116         function int () {
1117                 set_x_info "$2" "$3"
1118                 echo "$2=$x"            >>$CONFIG
1119         }
1120
1121         function hex () {
1122                 set_x_info "$2" "$3"
1123                 echo "$2=$x"                     >>$CONFIG
1124         }
1125
1126         function string () {
1127                 set_x_info "$2" "$3"
1128                 echo "$2=\"$x\""                         >>$CONFIG
1129         }
1130
1131         function define_hex () {
1132                 eval $1=\"$2\"
1133                 echo "$1=$2"                    >>$CONFIG
1134         }
1135
1136         function define_int () {
1137                 eval $1=\"$2\"
1138                 echo "$1=$2"                    >>$CONFIG
1139         }
1140
1141         function define_string () {
1142                 eval $1=\"$2\"
1143                 echo "$1=\"$2\""                >>$CONFIG
1144         }
1145
1146         function define_bool () {
1147                 define_tristate "$1" "$2"
1148         }
1149
1150         function define_tristate () {
1151                 eval $1=\"$2\"
1152
1153                 case "$2" in
1154                 y)
1155                         echo "$1=y"             >>$CONFIG
1156                         ;;
1157
1158                 m)
1159                         if [ "$CONFIG_MODULES" = "y" ]
1160                         then
1161                                 echo "$1=m"                >>$CONFIG
1162                         else
1163                                 echo "$1=y"             >>$CONFIG
1164                         fi
1165                         ;;
1166
1167                 n)
1168                         echo "# $1 is not set"  >>$CONFIG
1169                         ;;
1170                 esac
1171         }
1172
1173         function choice () {
1174                 #
1175                 # Find the first choice that's already set to 'y'
1176                 #
1177                 choices="$2"
1178                 default="$3"
1179                 current=
1180                 chosen=
1181
1182                 set -- $choices
1183                 while [ -n "$2" ]
1184                 do
1185                         if eval [ \"_\$$2\" = \"_y\" ]
1186                         then
1187                                 current=$1
1188                                 break
1189                         fi
1190                         shift ; shift
1191                 done
1192
1193                 #
1194                 # Use the default if none were set.  
1195                 #
1196                 : ${current:=$default}
1197
1198                 #
1199                 # Output all choices (to be compatible with other configs).
1200                 #
1201                 set -- $choices
1202                 while [ -n "$2" ]
1203                 do
1204                         case "$1" in
1205                         "$current"*)    if [ -z "$chosen" ]; then
1206                                                 define_bool "$2" "y"
1207                                                 chosen=1
1208                                         else
1209                                                 define_bool "$2" "n"
1210                                         fi ;;
1211                         *)              define_bool "$2" "n" ;;
1212                         esac
1213                         shift ; shift
1214                 done
1215         }
1216
1217         function mainmenu_name () {
1218                 :
1219         }
1220
1221         function mainmenu_option () {
1222                 comment_is_option=TRUE
1223         }
1224
1225         function endmenu () {
1226                 :
1227         }
1228
1229         function comment () {
1230                 if [ "$comment_is_option" ]
1231                 then
1232                         comment_is_option=
1233                         echo        >>$CONFIG
1234                         echo "#"    >>$CONFIG
1235                         echo "# $1" >>$CONFIG
1236                         echo "#"    >>$CONFIG
1237                 fi
1238         }
1239
1240         echo -n "."
1241
1242         DEF_CONFIG="${1:-.config}"
1243
1244         CONFIG=.tmpconfig
1245
1246         echo "#" >$CONFIG
1247         echo "# Automatically generated by make menuconfig: don't edit" >>$CONFIG
1248         echo "#" >>$CONFIG
1249
1250         echo -n "."
1251         if . $CONFIG_IN >>.menuconfig.log 2>&1
1252         then
1253                 if [ -f "$DEF_CONFIG" ]
1254                 then
1255                         rm -f ${DEF_CONFIG}.old
1256                         mv $DEF_CONFIG ${DEF_CONFIG}.old
1257                 fi
1258
1259                 mv $CONFIG $DEF_CONFIG
1260                         
1261                 return 0
1262         else
1263                 return 1
1264         fi
1265 }
1266
1267 #
1268 # Remove temporary files
1269 #
1270 cleanup () {
1271         cleanup1
1272         cleanup2
1273 }
1274
1275 cleanup1 () {
1276         rm -f MCmenu* MCradiolists MCdialog.out help.out
1277 }
1278
1279 cleanup2 () {
1280         rm -f .tmpconfig
1281 }
1282
1283 set_geometry () {
1284         # Some distributions export these with incorrect values
1285         # which can really screw up some ncurses programs.
1286         LINES=  COLUMNS=
1287
1288         ROWS=${1:-24}  COLS=${2:-80} 
1289
1290         # Just in case the nasty rlogin bug returns.
1291         #
1292         [ $ROWS = 0 ] && ROWS=24
1293         [ $COLS = 0 ] && COLS=80
1294
1295         if [ $ROWS -lt 19 -o $COLS -lt 80 ]
1296         then
1297                 echo -e "\n\007Your display is too small to run Menuconfig!"
1298                 echo "It must be at least 19 lines by 80 columns."
1299                 exit 1
1300         fi 
1301
1302         ROWS=$((ROWS-4))  COLS=$((COLS-5))
1303 }
1304
1305
1306 set_geometry `stty size 2>/dev/null`
1307
1308 menu_instructions="\
1309 Arrow keys navigate the menu.  \
1310 <Enter> selects submenus --->.  \
1311 Highlighted letters are hotkeys.  \
1312 Pressing <Y> includes, <N> excludes, <M> modularizes features.  \
1313 Press <Esc><Esc> to exit, <?> for Help.  \
1314 Legend: [*] built-in  [ ] excluded  <M> module  < > module capable"
1315
1316 radiolist_instructions="\
1317 Use the arrow keys to navigate this window or \
1318 press the hotkey of the item you wish to select \
1319 followed by the <SPACE BAR>.
1320 Press <?> for additional information about this option."
1321
1322 inputbox_instructions_int="\
1323 Please enter a decimal value. \
1324 Fractions will not be accepted.  \
1325 Use the <TAB> key to move from the input field to the buttons below it."
1326
1327 inputbox_instructions_hex="\
1328 Please enter a hexadecimal value. \
1329 Use the <TAB> key to move from the input field to the buttons below it."
1330
1331 inputbox_instructions_string="\
1332 Please enter a string value. \
1333 Use the <TAB> key to move from the input field to the buttons below it."
1334
1335 DIALOG="./lxdialog/lxdialog"
1336
1337 backtitle="VideoLAN Client Configuration"
1338
1339 trap "cleanup ; exit 1" 1 2 15
1340
1341
1342 #
1343 # Locate default files.
1344 #
1345 CONFIG_IN=./config.in
1346 if [ "$1" != "" ] ; then
1347         CONFIG_IN=$1
1348 fi
1349
1350 DEFAULTS=defconfig
1351 if [ -f .config ]; then
1352   DEFAULTS=.config
1353 fi
1354
1355 if [ -f $DEFAULTS ]
1356 then
1357   echo "Using defaults found in" $DEFAULTS
1358   load_config_file $DEFAULTS
1359 else
1360   echo "No defaults found"
1361 fi
1362
1363
1364 # Fresh new log.
1365 >.menuconfig.log
1366
1367 # Load the functions used by the config.in files.
1368 echo -n "Preparing scripts: functions" 
1369 load_functions
1370
1371 if [ ! -e $CONFIG_IN ]
1372 then
1373         echo "Your main config.in file ($CONFIG_IN) does not exist"
1374         exit 1
1375 fi
1376
1377 if [ ! -x $DIALOG ]
1378 then
1379         echo "Building lxdialog"
1380         cd lxdialog
1381         make
1382         cd ..
1383 fi
1384 if [ ! -x $DIALOG ]
1385 then
1386         echo "Your lxdialog utility does not exist"
1387         exit 1
1388 fi
1389
1390
1391 #
1392 # Read config.in files and parse them into one shell function per menu.
1393 #
1394 echo -n ", parsing"
1395 parse_config_files $CONFIG_IN
1396
1397 echo "done."
1398 #
1399 # Start the ball rolling from the top.
1400 #
1401 activate_menu MCmenu0
1402
1403 #
1404 # All done!
1405 #
1406 cleanup1
1407
1408 #
1409 # Confirm and Save
1410 #
1411 if $DIALOG --backtitle "$backtitle" \
1412            --yesno "Do you wish to save your new kernel configuration?" 5 60
1413 then
1414         save_configuration
1415         echo
1416         echo "*** End of VideoLAN client configuration. ***"
1417         echo "Run ./build-vlc to launch the build process"
1418         echo
1419 else
1420         echo
1421         echo 
1422         echo Your kernel configuration changes were NOT saved.
1423         echo
1424 fi
1425
1426 # Remove log if empty.
1427 if [ ! -s .menuconfig.log ] ; then
1428         rm -f .menuconfig.log
1429 fi
1430
1431 exit 0