make menuconfig, patch-0.3

Bernhard Kaindl (bkaindl@ping.at)
Tue, 19 Sep 1995 11:46:33 +0200 (MET DST)


Hi!

When applied my last patch to 1.3.27 for a kernel config menu, you can
upgrade to 1.3.28 with only one failed hunk which is my fault since I
did a change in my last patch which was in pre-patch-1.3.28. Then, this hunk
was already applied, and you can ignore the reject.

I've included is a patch for a linux-1.3.28 with has the last 'make
menuconfing'-patch already applied.

With linux-1.3.28, Linus added the new dep_tristate function to the
kernel configuration, which I implemented in this patch to be useable
with version 1.3.28 and above.

This new function is used along with the new ability to load the entrie
SCSI subsystem as a module. When the subsystem is a module, it's cleary
not possible to link the SCSI-drivers into the kernel. Showing this is
the aim of the function.

It was real fun for me to implement it, and now it's ready with a nice
whistle:
For example, if you change SCSI to a module, it presents you with the
settings which depend on SCSI and offers you to load it as a module or
even not use it.

Here is an example of this:

[p1]08:18:15/usr/src/linux# make menuconfig
rm -f include/asm
( cd include ; ln -sf asm-i386 asm)
/bin/sh scripts/Configure.menu arch/i386/config.in
Loading .config
Please wait, building menus............

Linux Kernel Configuration

1: General setup
2: Loadable module support
3: Networking options
4: SCSI support
5: SCSI low-level drivers
6: Network device support
7: CD-ROM drivers (not for SCSI or IDE/ATAPI drives)
8: Filesystems
9: character devices
10: Sound
11: Kernel hacking
12: Configure sound driver

w: write kernel setup to disk and exit
l: load setup from a file saved by `s'
s: save setup to a file for later use
q: quit without saving changes

Enter a option, [wlsq] or `r' to redisplay the menu.
option: 4

Menu: SCSI support

1: [Y] SCSI support
SCSI support type (disk, tape, CDrom)
2: [Y] SCSI disk support
3: [M] SCSI tape support
4: [Y] SCSI CDROM support
5: [ ] SCSI generic support
Some SCSI devices (e.g. CD jukebox) support multiple LUNs
6: [ ] Probe all LUNs on each SCSI device

b: back to the main menu

Enter a option, [wlsq] or `r' to redisplay the menu.
option: 1
SCSI support (CONFIG_SCSI) [Y/m/n] m
Hmm, choose a new setting...
SCSI disk support (CONFIG_BLK_DEV_SD) [M/n] m
Hmm, choose a new setting...
SCSI CDROM support (CONFIG_BLK_DEV_SR) [M/n]
Hmm, choose a new setting...
Adaptec AHA1542 support (CONFIG_SCSI_AHA1542) [M/n] n

Menu: SCSI support

1: [M] SCSI support
SCSI support type (disk, tape, CDrom)
2: [M] SCSI disk support
3: [ ] SCSI tape support
4: [M] SCSI CDROM support
5: [ ] SCSI generic support
Some SCSI devices (e.g. CD jukebox) support multiple LUNs
6: [ ] Probe all LUNs on each SCSI device

b: back to the main menu

Enter a option, [wlsq] or `r' to redisplay the menu.
option: w
write new setup and quit ? [n] y

The linux kernel is now hopefully configured for your setup.
Check the top-level Makefile for additional configuration,
and do a 'make dep ; make clean' if you want to be sure all
the files are correctly re-made
------------------------------------------

This does things I have newer thought of, and it's a nice hack too. :-)

Here is the patch mentioned above, any comments are welcome.

It's a crazy script, but it work's like a charm.

- Bernhard

diff -ur linux-1.3.28-menu/scripts/Configure.menu linux/scripts/Configure.menu
--- linux-1.3.28-menu/scripts/Configure.menu Tue Sep 19 06:06:38 1995
+++ linux/scripts/Configure.menu Tue Sep 19 08:40:02 1995
@@ -124,6 +124,13 @@
echo setting $mmo_num $mmo_setting_num tristate "'$1'" $2 $def
eval "$2=$def"
}
+function dep_tristate () {
+ eval def=\$\{$2:-$3}
+ eval dep=\$$4
+ mmo_setting_num=$[ $mmo_setting_num + 1 ]
+ echo setting $mmo_num $mmo_setting_num dep_tristate "'$1'" $2 $def $4 $dep
+ eval "$2=$def"
+}
function choice () {
eval def=\$\{$2:-$3}
mmo_setting_num=$[ $mmo_setting_num + 1 ]
@@ -160,6 +167,7 @@
s/\][ ]*;[ ]*then[ ]*$/'/
s/^[ ]*else[ ]*$/menu_else/
s/^[ ]*fi[ ]*$/menu_fi/
+ s/\$\([a-zA-Z_][a-zA-Z_0-9]*\)[ ]*$/\1/
" $CONFIG_IN >> kmenu-config.in.tmp
echo "\
menu_if '\"\$CONFIG_SOUND\" -a \"\$CONFIG_SOUND\" != \"n\"'
@@ -204,11 +212,27 @@
n) defprompt=N/y/m ;;
esac
ans=
- while [ "$ans" != "y" -a "$ans" != "n" -a "$ans" != "m" ]; do
+ while [ "$ans" != y -a "$ans" != n -a "$ans" != m ]; do
readln "$1 ($2) [$defprompt] " $3
done
eval $2=$ans
}
+function dep_tristate () {
+ eval dep=\$$4
+ if [ $dep != m ]; then
+ tristate "$1" "$2" "$3"
+ else
+ case $3 in
+ y|m) defprompt=M/n ;def=m ;;
+ n) defprompt=N/m ;def=n ;;
+ esac
+ ans=
+ while [ "$ans" != n -a "$ans" != m ]; do
+ readln "$1 ($2) [$defprompt] " $def
+ done
+ eval $2=$ans
+ fi
+}
function int () {
ans=x
while [ $[$ans+0] != "$ans" ]; do
@@ -249,14 +273,25 @@
#
# Self-modifying part:
#
- eval $3 "'$4'" $5 $6
- sed '/^setting '$1' '$2' /s/'$6'$/'"$ans"'/' \
+ eval $3 "'$4'" $5 $6 $7
+ sed "/^setting .* $5 /s/$5 $6/$5 $ans/" \
kmenu-config.dat > kmenu-config.dat.tmp
mv kmenu-config.dat.tmp kmenu-config.dat
action=changed
fi
;;
- showmain|changed)
+ changed)
+ if test $3 = dep_tristate; then
+ eval dep=\$$7
+ if test $dep = m -a $6 = y; then
+ echo "This option can no longer be [Y]:"
+ action=change
+ shift 2
+ setting $option_num $setting_num "$@"
+ fi
+ fi
+ ;;
+ showmain)
:
;;
*)
@@ -503,6 +538,13 @@
function tristate () {
bool $*
}
+function dep_tristate () {
+ if [ $3 = m -a $2 = y ]; then
+ bool $1 m
+ else
+ bool $1 $2
+ fi
+}
function int () {
echo >&4 "#define $1 ($2)"
echo >&3 $1=$2
@@ -535,7 +577,7 @@
:
}
function setting () {
- eval $3 $5 $6
+ eval $3 $5 $6 $8
}

#