* modules/mux/mp4.c: added a 3gp mode which writes a 3gp ftyp header.
[vlc.git] / menuconfig
blobf27bb95af54901ee84b1c34a8de649433d620222
1 #! /bin/sh
3 # VLC media player configuration script, borrowed from linux menuconfig
4 # Cyril Deguet <asmax@videolan.org>
6 #-----------------------------------------------------------------
7 # William Roadcap was the original author of Menuconfig.
8 # Michael Elizabeth Chastain (mec@shout.net) is the current maintainer.
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.
14 # 180697 Bernhard Kaindl (bkaindl@netway.at) - added the needed support
15 # for string options. They are handled like the int and hex options.
17 # 081297 Pavel Machek (pavel@atrey.karlin.mff.cuni.cz) - better error
18 # handling
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.
25 # 101297 Michael Chastain (mec@shout.net) - remove sound driver cruft.
27 # 221297 Michael Chastain (mec@shout.net) - make define_bool actually
28 # define its arguments so that later tests on them work right.
30 # 160198 Michael Chastain (mec@shout.net) - fix bug with 'c' command
31 # (complement existing value) when used on virgin uninitialized variables.
33 # 090398 Axel Boldt (boldt@math.ucsb.edu) - allow for empty lines in help
34 # texts.
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).
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.
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".
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.
54 # 24 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
55 # - Improve the exit message (Jeff Ronne).
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().
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.
69 # Change this to TRUE if you prefer all kernel options listed
70 # in a single menu rather than the standard menu hierarchy.
72 single_menu_mode=
75 # Make sure we're really running bash.
77 [ -z "$BASH" ] && { echo "Menuconfig requires bash" 1>&2; exit 1; }
80 # Cache function definitions, turn off posix compliance
82 set -h +o posix
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.
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.
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)'"
101 eval info=\"\$INFO_$1\"
105 # Load the functions used by the config.in files.
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.
111 # Thank the heavens bash supports nesting function definitions.
113 load_functions () {
116 # Additional comments
118 function comment () {
119 comment_ctr=$[ comment_ctr + 1 ]
120 echo -ne "': $comment_ctr' '--- $1' " >>MCmenu
124 # Define a boolean to a specific value.
126 function define_bool () {
127 eval $1=$2
130 function define_tristate () {
131 eval $1=$2
134 function define_hex () {
135 eval $1=$2
138 function define_int () {
139 eval $1=$2
142 function define_string () {
143 eval $1=\"$2\"
147 # Create a boolean (Yes/No) function for our current menu
148 # which calls our local bool function.
150 function bool () {
151 set_x_info "$2" "n"
153 case $x in
154 y|m) flag="*" ;;
155 n) flag=" " ;;
156 esac
158 echo -ne "'$2' '[$flag] $1$info' " >>MCmenu
160 echo -e "function $2 () { l_bool '$2' \"\$1\" ;}\n" >>MCradiolists
164 # Create a tristate (Yes/No/Module) radiolist function
165 # which calls our local tristate function.
167 # Collapses to a boolean (Yes/No) if module support is disabled.
169 function tristate () {
170 if [ "$CONFIG_MODULES" != "y" ]
171 then
172 bool "$1" "$2"
173 else
174 set_x_info "$2" "n"
176 case $x in
177 y) flag="*" ;;
178 m) flag="M" ;;
179 *) flag=" " ;;
180 esac
182 echo -ne "'$2' '<$flag> $1$info' " >>MCmenu
184 echo -e "
185 function $2 () { l_tristate '$2' \"\$1\" ;}" >>MCradiolists
190 # Create a tristate radiolist function which is dependent on
191 # another vlc configuration option.
193 # Quote from the original configure script:
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.
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 $#
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
227 # Same as above, but now only Y and N are allowed as dependency
228 # (i.e. third and next arguments).
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 $#
242 done
243 if [ "$dep" = y ]; then
244 bool "$ques" "$var"
245 else
246 define_bool "$var" n
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 $#
262 done
263 if [ "$dep" = y ]; then
264 bool "$ques" "$var"
265 else
266 define_bool "$var" n
271 # Add a menu item which will call our local int function.
273 function int () {
274 set_x_info "$2" "$3"
276 echo -ne "'$2' '($x) $1$info' " >>MCmenu
278 echo -e "function $2 () { l_int '$1' '$2' '$3' '$x' ;}" >>MCradiolists
282 # Add a menu item which will call our local hex function.
284 function hex () {
285 set_x_info "$2" "$3"
286 x=${x##*[x,X]}
288 echo -ne "'$2' '($x) $1$info' " >>MCmenu
290 echo -e "function $2 () { l_hex '$1' '$2' '$3' '$x' ;}" >>MCradiolists
294 # Add a menu item which will call our local string function.
296 function string () {
297 set_x_info "$2" "$3"
299 echo -ne "'$2' ' $1: \"$x\"$info' " >>MCmenu
301 echo -e "function $2 () { l_string '$1' '$2' '$3' '$x' ;}" >>MCradiolists
305 # Add a menu item which will call our local One-of-Many choice list.
307 function choice () {
309 # Need to remember params cause they're gonna get reset.
311 title=$1
312 choices=$2
313 default=$3
314 current=
317 # Find out if one of the choices is already set.
318 # If it's not then make it the default.
320 set -- $choices
321 firstchoice=$2
323 while [ -n "$2" ]
325 if eval [ \"_\$$2\" = \"_y\" ]
326 then
327 current=$1
328 break
330 shift ; shift
331 done
333 : ${current:=$default}
335 echo -ne "'$firstchoice' '($current) $title' " >>MCmenu
337 echo -e "
338 function $firstchoice () \
339 { l_choice '$title' \"$choices\" \"$current\" ;}" >>MCradiolists
342 } # END load_functions()
349 # Extract available help for an option from Configure.help
350 # and send it to standard output.
352 # Most of this function was borrowed from the original kernel
353 # Configure script.
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}:\\
365 /^#/b
366 /^[^ ]/q
367 s/^ //
368 /<file:\\([^>]*\\)>/s//\\1/g
370 }" doc/Configure.help)
372 if [ -z "$text" ]
373 then
374 echo "There is no help available for this option."
375 return 1
376 else
377 echo "$text"
379 else
380 echo "There is no help available for this option."
381 return 1
386 # Activate a help dialog.
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
397 rm -f help.out
401 # Show the README file.
403 function show_readme () {
404 $DIALOG --backtitle "$backtitle" \
405 --textbox scripts/README.Menuconfig $ROWS $COLS
409 # Begin building the dialog menu command and Initialize the
410 # Radiolist function file.
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
422 # Add a submenu option to the menu currently under construction.
424 function submenu () {
425 echo -ne "'activate_menu $2' '$1 --->' " >>MCmenu
429 # Handle a boolean (Yes/No) option.
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"
450 # Same as bool() except options are (Module/No)
452 function mod_bool () {
453 if [ "$CONFIG_MODULES" != "y" ]; then
454 define_bool "$2" "n"
455 else
456 set_x_info "$2" "n"
458 case $x in
459 y|m) flag='M' ;;
460 *) flag=' ' ;;
461 esac
463 echo -ne "'$2' '<$flag> $1$info' " >>MCmenu
465 echo -e "function $2 () { l_mod_bool '$2' \"\$1\" ;}" >>MCradiolists
470 # Same as l_bool() except options are (Module/No)
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"
498 # Handle a tristate (Yes/No/Module) option.
500 function l_tristate () {
501 if [ -n "$2" ]
502 then
503 eval x=\$$1
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"
523 # Create a dialog for entering an integer into a kernel option.
525 function l_int () {
526 while true
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}"
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
549 break
552 help "$2" "$1"
553 done
557 # Create a dialog for entering a hexadecimal into a kernel option.
559 function l_hex () {
560 while true
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]}"
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
582 break
585 help "$2" "$1"
586 done
590 # Create a dialog for entering a string into a kernel option.
592 function l_string () {
593 while true
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}"
604 # Someone may add a nice check for the entered
605 # string here...
607 eval $2=\"$answer\"
609 break
612 help "$2" "$1"
613 done
618 # Handle a one-of-many choice list.
620 function l_choice () {
622 # Need to remember params cause they're gonna get reset.
624 title="$1"
625 choices="$2"
626 current="$3"
627 chosen=
630 # Scan current value of choices and set radiolist switches.
632 list=
633 set -- $choices
634 firstchoice=$2
635 while [ -n "$2" ]
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
647 shift ; shift
648 done
650 while true
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
661 help "$firstchoice" "$title"
662 done
665 # Now set the boolean value of each option based on
666 # the selection made from the radiolist.
668 set -- $choices
669 while [ -n "$2" ]
671 if [ "$2" = "$choice" ]
672 then
673 eval $2=\"y\"
674 else
675 eval $2=\"n\"
678 shift ; shift
679 done
683 # Call awk, and watch for error codes, etc.
685 function callawk () {
686 awk "$1" || { echo "Awk died with error code $?. Giving up."; exit 1; }
690 # A faster awk based recursive parser. (I hope)
692 function parser1 () {
693 callawk '
694 BEGIN {
695 menu_no = 0
696 comment_is_option = 0
697 parser("'$CONFIG_IN'","MCmenu0")
700 function parser(ifile,menu) {
702 while (getline <ifile) {
703 if ($1 == "mainmenu_option") {
704 comment_is_option = "1"
706 else if ($1 == "comment" && comment_is_option == "1") {
707 comment_is_option= "0"
708 sub($1,"",$0)
709 ++menu_no
711 printf("submenu %s MCmenu%s\n", $0, menu_no) >>menu
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
719 parser(ifile, newmenu)
721 else if ($0 ~ /^#|\$MAKE|mainmenu_name/) {
722 printf("") >>menu
724 else if ($1 ~ "endmenu") {
725 printf("}\n") >>menu
726 return
728 else if ($1 == "source") {
729 parser($2,menu)
731 else {
732 print >>menu
739 # Secondary parser for single menu mode.
741 function parser2 () {
742 callawk '
743 BEGIN {
744 parser("'$CONFIG_IN'","MCmenu0")
747 function parser(ifile,menu) {
749 while (getline <ifile) {
750 if ($0 ~ /^#|$MAKE|mainmenu_name/) {
751 printf("") >>menu
753 else if ($1 ~ /mainmenu_option|endmenu/) {
754 printf("") >>menu
756 else if ($1 == "source") {
757 parser($2,menu)
759 else {
760 print >>menu
767 # Parse all the config.in files into mini scripts.
769 function parse_config_files () {
770 rm -f MCmenu*
772 echo "function MCmenu0 () {" >MCmenu0
773 echo 'default=$1' >>MCmenu0
774 echo "menu_name 'Main Menu'" >>MCmenu0
776 if [ "_$single_menu_mode" = "_TRUE" ]
777 then
778 parser2
779 else
780 parser1
783 echo "comment ''" >>MCmenu0
784 echo "g_alt_config" >>MCmenu0
785 echo "s_alt_config" >>MCmenu0
787 echo "}" >>MCmenu0
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.
796 for i in MCmenu*
798 echo -n "."
799 source ./$i
800 done
801 rm -f MCmenu*
805 # This is the menu tree's bootstrap.
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.
811 function activate_menu () {
812 rm -f lxdialog.scrltmp
813 while true
815 comment_ctr=0 #So comment lines get unique tags
817 $1 "$default" 2> MCerror #Create the lxdialog menu & functions
819 if [ "$?" != "0" ]
820 then
821 clear
822 cat <<EOM
824 Menuconfig has encountered a possible error in one of the vlc's
825 configuration files and is unable to continue. Here is the error
826 report:
829 sed 's/^/ Q> /' MCerror
830 cat <<EOM
832 Please report this to the maintainer <asmax@videolan.org>.
834 Please indicate the vlc version you are trying to configure and
835 which menu you were trying to enter when this error occurred.
838 cleanup
839 exit 1
841 rm -f MCerror
843 . ./MCradiolists #Source the menu's functions
845 . ./MCmenu 2>MCdialog.out #Activate the lxdialog menu
846 ret=$?
848 read selection <MCdialog.out
850 case "$ret" in
851 0|3|4|5|6)
852 defaults="$selection\x12$defaults" #pseudo stack
853 case "$ret" in
854 0) eval $selection ;;
855 3) eval $selection y ;;
856 4) eval $selection n ;;
857 5) eval $selection m ;;
858 6) eval $selection c ;;
859 esac
860 default="${defaults%%\x12*}" defaults="${defaults#*\x12}"
863 default="${selection%%\ *}"
865 case "$selection" in
866 *"-->"*|*"alt_config"*)
867 show_readme ;;
869 eval help $selection ;;
870 esac
872 255|1)
873 break
875 139)
876 stty sane
877 clear
878 cat <<EOM
880 There seems to be a problem with the lxdialog companion utility which is
881 built prior to running Menuconfig. Usually this is an indicator that you
882 have upgraded/downgraded your ncurses libraries and did not remove the
883 old ncurses header file(s) in /usr/include or /usr/include/ncurses.
885 It is VERY important that you have only one set of ncurses header files
886 and that those files are properly version matched to the ncurses libraries
887 installed on your machine.
889 You may also need to rebuild lxdialog. This can be done by moving to
890 the /usr/src/linux/scripts/lxdialog directory and issuing the
891 "make clean all" command.
893 If you have verified that your ncurses install is correct, you may email
894 the maintainer <asmax@videolan.org>.
897 cleanup
898 exit 139
900 esac
901 done
905 # Create a menu item to load an alternate configuration file.
907 g_alt_config () {
908 echo -n "get_alt_config 'Load an Alternate Configuration File' "\
909 >>MCmenu
913 # Get alternate config file name and load the
914 # configuration from it.
916 get_alt_config () {
917 set -f ## Switch file expansion OFF
919 while true
921 ALT_CONFIG="${ALT_CONFIG:-$DEFAULTS}"
923 $DIALOG --backtitle "$backtitle" \
924 --inputbox "\
925 Enter the name of the configuration file you wish to load. \
926 Accept the name shown to restore the configuration you \
927 last retrieved. Leave blank to abort."\
928 11 55 "$ALT_CONFIG" 2>MCdialog.out
930 if [ "$?" = "0" ]
931 then
932 ALT_CONFIG=`cat MCdialog.out`
934 [ "_" = "_$ALT_CONFIG" ] && break
936 if eval [ -r \"$ALT_CONFIG\" ]
937 then
938 eval load_config_file \"$ALT_CONFIG\"
939 break
940 else
941 echo -ne "\007"
942 $DIALOG --backtitle "$backtitle" \
943 --infobox "File does not exist!" 3 38
944 sleep 2
946 else
947 cat <<EOM >help.out
949 For various reasons, one may wish to keep several different vlc
950 configurations available on a single machine.
952 If you have saved a previous configuration in a file other than the
953 vlc's default, entering the name of the file here will allow you
954 to modify that configuration.
956 If you are uncertain, then you have probably never used alternate
957 configuration files. You should therefor leave this blank to abort.
960 $DIALOG --backtitle "$backtitle"\
961 --title "Load Alternate Configuration"\
962 --textbox help.out $ROWS $COLS
964 done
966 set +f ## Switch file expansion ON
967 rm -f help.out MCdialog.out
971 # Create a menu item to store an alternate config file.
973 s_alt_config () {
974 echo -n "save_alt_config 'Save Configuration to an Alternate File' "\
975 >>MCmenu
979 # Get an alternate config file name and save the current
980 # configuration to it.
982 save_alt_config () {
983 set -f ## Switch file expansion OFF
985 while true
987 $DIALOG --backtitle "$backtitle" \
988 --inputbox "\
989 Enter a filename to which this configuration should be saved \
990 as an alternate. Leave blank to abort."\
991 10 55 "$ALT_CONFIG" 2>MCdialog.out
993 if [ "$?" = "0" ]
994 then
995 ALT_CONFIG=`cat MCdialog.out`
997 [ "_" = "_$ALT_CONFIG" ] && break
999 if eval touch $ALT_CONFIG 2>/dev/null
1000 then
1001 eval save_configuration $ALT_CONFIG
1002 load_functions ## RELOAD
1003 break
1004 else
1005 echo -ne "\007"
1006 $DIALOG --backtitle "$backtitle" \
1007 --infobox "Can't create file! Probably a nonexistent directory." 3 60
1008 sleep 2
1010 else
1011 cat <<EOM >help.out
1013 For various reasons, one may wish to keep different vlc
1014 configurations available on a single machine.
1016 Entering a file name here will allow you to later retrieve, modify
1017 and use the current configuration as an alternate to whatever
1018 configuration options you have selected at that time.
1020 If you are uncertain what all this means then you should probably
1021 leave this blank.
1023 $DIALOG --backtitle "$backtitle"\
1024 --title "Save Alternate Configuration"\
1025 --textbox help.out $ROWS $COLS
1027 done
1029 set +f ## Switch file expansion ON
1030 rm -f help.out MCdialog.out
1034 # Load config options from a file.
1035 # Converts all "# OPTION is not set" lines to "OPTION=n" lines
1037 function load_config_file () {
1038 awk '
1039 /# .* is not set.*/ { printf("%s=n\n", $2) }
1040 ! /# .* is not set.*/ { print }
1041 ' $1 >.tmpconfig
1043 source ./.tmpconfig
1044 rm -f .tmpconfig
1048 # Just what it says.
1050 save_configuration () {
1051 echo
1052 echo -n "Saving your vlc configuration."
1055 # Now, let's redefine the configuration functions for final
1056 # output to the config files.
1058 # Nested function definitions, YIPEE!
1060 function bool () {
1061 set_x_info "$2" "n"
1062 eval define_bool \"$2\" \"$x\"
1065 function tristate () {
1066 set_x_info "$2" "n"
1067 eval define_tristate \"$2\" \"$x\"
1070 function dep_tristate () {
1071 set_x_info "$2" "n"
1072 var="$2"
1073 shift 2
1074 while [ $# -gt 0 ]; do
1075 if [ "$1" = y ]; then
1076 shift
1077 elif [ "$1" = m -a "$x" != n ]; then
1078 x=m; shift
1079 else
1080 x=n; shift $#
1082 done
1083 define_tristate "$var" "$x"
1086 function dep_bool () {
1087 set_x_info "$2" "n"
1088 var="$2"
1089 shift 2
1090 while [ $# -gt 0 ]; do
1091 if [ "$1" = y ]; then
1092 shift
1093 else
1094 x=n; shift $#
1096 done
1097 define_bool "$var" "$x"
1100 function dep_mbool () {
1101 set_x_info "$2" "n"
1102 var="$2"
1103 shift 2
1104 while [ $# -gt 0 ]; do
1105 if [ "$1" = y -o "$1" = m ]; then
1106 shift
1107 else
1108 x=n; shift $#
1110 done
1111 define_bool "$var" "$x"
1114 function int () {
1115 set_x_info "$2" "$3"
1116 echo "$2=$x" >>$CONFIG
1119 function hex () {
1120 set_x_info "$2" "$3"
1121 echo "$2=$x" >>$CONFIG
1124 function string () {
1125 set_x_info "$2" "$3"
1126 echo "$2=\"$x\"" >>$CONFIG
1129 function define_hex () {
1130 eval $1=\"$2\"
1131 echo "$1=$2" >>$CONFIG
1134 function define_int () {
1135 eval $1=\"$2\"
1136 echo "$1=$2" >>$CONFIG
1139 function define_string () {
1140 eval $1=\"$2\"
1141 echo "$1=\"$2\"" >>$CONFIG
1144 function define_bool () {
1145 define_tristate "$1" "$2"
1148 function define_tristate () {
1149 eval $1=\"$2\"
1151 case "$2" in
1153 echo "$1=y" >>$CONFIG
1157 if [ "$CONFIG_MODULES" = "y" ]
1158 then
1159 echo "$1=m" >>$CONFIG
1160 else
1161 echo "$1=y" >>$CONFIG
1166 echo "# $1 is not set" >>$CONFIG
1168 esac
1171 function choice () {
1173 # Find the first choice that's already set to 'y'
1175 choices="$2"
1176 default="$3"
1177 current=
1178 chosen=
1180 set -- $choices
1181 while [ -n "$2" ]
1183 if eval [ \"_\$$2\" = \"_y\" ]
1184 then
1185 current=$1
1186 break
1188 shift ; shift
1189 done
1192 # Use the default if none were set.
1194 : ${current:=$default}
1197 # Output all choices (to be compatible with other configs).
1199 set -- $choices
1200 while [ -n "$2" ]
1202 case "$1" in
1203 "$current"*) if [ -z "$chosen" ]; then
1204 define_bool "$2" "y"
1205 chosen=1
1206 else
1207 define_bool "$2" "n"
1208 fi ;;
1209 *) define_bool "$2" "n" ;;
1210 esac
1211 shift ; shift
1212 done
1215 function mainmenu_name () {
1219 function mainmenu_option () {
1220 comment_is_option=TRUE
1223 function endmenu () {
1227 function comment () {
1228 if [ "$comment_is_option" ]
1229 then
1230 comment_is_option=
1231 echo >>$CONFIG
1232 echo "#" >>$CONFIG
1233 echo "# $1" >>$CONFIG
1234 echo "#" >>$CONFIG
1238 echo -n "."
1240 DEF_CONFIG="${1:-.config}"
1242 CONFIG=.tmpconfig
1244 echo "#" >$CONFIG
1245 echo "# Automatically generated by make menuconfig: don't edit" >>$CONFIG
1246 echo "#" >>$CONFIG
1248 echo -n "."
1249 if . $CONFIG_IN >>.menuconfig.log 2>&1
1250 then
1251 if [ -f "$DEF_CONFIG" ]
1252 then
1253 rm -f ${DEF_CONFIG}.old
1254 mv $DEF_CONFIG ${DEF_CONFIG}.old
1257 mv $CONFIG $DEF_CONFIG
1259 return 0
1260 else
1261 return 1
1266 # Remove temporary files
1268 cleanup () {
1269 cleanup1
1270 cleanup2
1273 cleanup1 () {
1274 rm -f MCmenu* MCradiolists MCdialog.out help.out
1277 cleanup2 () {
1278 rm -f .tmpconfig
1281 set_geometry () {
1282 # Some distributions export these with incorrect values
1283 # which can really screw up some ncurses programs.
1284 LINES= COLUMNS=
1286 ROWS=${1:-24} COLS=${2:-80}
1288 # Just in case the nasty rlogin bug returns.
1290 [ $ROWS = 0 ] && ROWS=24
1291 [ $COLS = 0 ] && COLS=80
1293 if [ $ROWS -lt 19 -o $COLS -lt 80 ]
1294 then
1295 echo -e "\n\007Your display is too small to run Menuconfig!"
1296 echo "It must be at least 19 lines by 80 columns."
1297 exit 1
1300 ROWS=$((ROWS-4)) COLS=$((COLS-5))
1304 set_geometry `stty size 2>/dev/null`
1306 menu_instructions="\
1307 Arrow keys navigate the menu. \
1308 <Enter> selects submenus --->. \
1309 Highlighted letters are hotkeys. \
1310 Pressing <Y> includes, <N> excludes, <M> modularizes features. \
1311 Press <Esc><Esc> to exit, <?> for Help. \
1312 Legend: [*] built-in [ ] excluded <M> module < > module capable"
1314 radiolist_instructions="\
1315 Use the arrow keys to navigate this window or \
1316 press the hotkey of the item you wish to select \
1317 followed by the <SPACE BAR>.
1318 Press <?> for additional information about this option."
1320 inputbox_instructions_int="\
1321 Please enter a decimal value. \
1322 Fractions will not be accepted. \
1323 Use the <TAB> key to move from the input field to the buttons below it."
1325 inputbox_instructions_hex="\
1326 Please enter a hexadecimal value. \
1327 Use the <TAB> key to move from the input field to the buttons below it."
1329 inputbox_instructions_string="\
1330 Please enter a string value. \
1331 Use the <TAB> key to move from the input field to the buttons below it."
1333 DIALOG="./lxdialog/lxdialog"
1335 backtitle="VLC media player configuration"
1337 trap "cleanup ; exit 1" 1 2 15
1341 # Locate default files.
1343 CONFIG_IN=./config.in
1344 if [ "$1" != "" ] ; then
1345 CONFIG_IN=$1
1348 DEFAULTS=defconfig
1349 if [ -f .config ]; then
1350 DEFAULTS=.config
1353 if [ -f $DEFAULTS ]
1354 then
1355 echo "Using defaults found in" $DEFAULTS
1356 load_config_file $DEFAULTS
1357 else
1358 echo "No defaults found"
1362 # Fresh new log.
1363 >.menuconfig.log
1365 # Load the functions used by the config.in files.
1366 echo -n "Preparing scripts: functions"
1367 load_functions
1369 if [ ! -e $CONFIG_IN ]
1370 then
1371 echo "Your main config.in file ($CONFIG_IN) does not exist"
1372 exit 1
1375 if [ ! -x $DIALOG ]
1376 then
1377 echo "Building lxdialog"
1378 cd lxdialog
1379 make
1380 cd ..
1382 if [ ! -x $DIALOG ]
1383 then
1384 echo "Your lxdialog utility does not exist"
1385 exit 1
1390 # Read config.in files and parse them into one shell function per menu.
1392 echo -n ", parsing"
1393 parse_config_files $CONFIG_IN
1395 echo "done."
1397 # Start the ball rolling from the top.
1399 activate_menu MCmenu0
1402 # All done!
1404 cleanup1
1407 # Confirm and Save
1409 if $DIALOG --backtitle "$backtitle" \
1410 --yesno "Do you wish to save your new vlc configuration?" 5 60
1411 then
1412 save_configuration
1413 echo
1414 echo "*** End of VideoLAN client configuration. ***"
1415 echo "Run ./build-vlc to launch the build process"
1416 echo
1417 else
1418 echo
1419 echo
1420 echo Your vlc configuration changes were NOT saved.
1421 echo
1424 # Remove log if empty.
1425 if [ ! -s .menuconfig.log ] ; then
1426 rm -f .menuconfig.log
1429 exit 0