Configure & Makefile patch for batch config

Karl O. Pinc (kop@meme.com)
Wed, 15 Oct 1997 19:41:42 -0500 (CDT)


Hi,

If this is not going to the right place, please let me know. If it
is, I'd like to know that too. Thanks.

The addresses I have are:
raymondc@microsoft.com for linux/scripts/Configure
?? for linux/Makefile
?? for linux/README
linux-kernel@vger.rutgers.edu for linux kernel stuff. (To which I'm
not subscribed.)

This patch is to support "batch", i.e. non-interactive, kernel
configuration. That is, you can use a .config file you've saved
somewhere and use it to re-configure a new kernel without having to
hold down the \n key in "make config". If there's a new kernel
configuration parameter, the script has to stop and ask you about it.
I've forgotten details about "make config" and had hassles too many
times, so I wrote this.

The patch contains tabs and so likely will mess up your Makefile if
you cut and paste it from this message. Best to get it from

ftp://ftp.meme.com/pub/software/patches/batchconfig.patch.gz.

The patch should be applied by:

cd /usr/src/linux
patch -p1 < batchconfig.patch

Notes:

I'm working off a 2.0.30 kernel. I've no idea what's going on in the
latest releases. Hopefully not too much new config stuff and this
patch will apply. (I don't really want to spend the time it takes to
download the latest kernel, sorry.)

I dunno who maintains the Makefile or the README.

I dunno the convention regarding introduction of variables into the
Makefile. In particular, the kernel configuration symbols all seem to
start with "CONFIG_" and so I deliberately avoided starting the two
variables I added with this string. I did check to see that the
strings didn't show up anywhere else in the kernel.

Likewise, I introduced one of those weirdo internal targets
"_batchconfig" into the makefile. I'm not a makefile wiz and don't
know whether this is good style or what.

I used some tabs for formatting in scripts/Configure. Dunno if this
is kosher.

The patch works for me, but nobody else has tested it.

The regular copyright used in the linux kernel is the copyright used
for this patch. (So that it can drop right into the distribution
stream.)

I'd appreciate a note from the maintainers so I know if this gets
used. Thanks.

Karl <kop@meme.com>

I include the text of the patch for review here:

diff -rcN linux-2.0.30-origConfig/Makefile linux-2.0.30-newConfig/Makefile
*** linux-2.0.30-origConfig/Makefile Tue Oct 14 23:45:46 1997
--- linux-2.0.30-newConfig/Makefile Wed Oct 15 05:18:35 1997
***************
*** 21,26 ****
--- 21,27 ----
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi)
+ STD_CONFIG = arch/$(ARCH)/config.in
TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)

HPATH = $(TOPDIR)/include
***************
*** 183,189 ****
( cd include ; ln -sf asm-$(ARCH) asm)

oldconfig: symlinks
! $(CONFIG_SHELL) scripts/Configure -d arch/$(ARCH)/config.in

xconfig: symlinks
$(MAKE) -C scripts kconfig.tk
--- 184,190 ----
( cd include ; ln -sf asm-$(ARCH) asm)

oldconfig: symlinks
! $(CONFIG_SHELL) scripts/Configure -d $(STD_CONFIG)

xconfig: symlinks
$(MAKE) -C scripts kconfig.tk
***************
*** 191,200 ****

menuconfig: include/linux/version.h symlinks
$(MAKE) -C scripts/lxdialog all
! $(CONFIG_SHELL) scripts/Menuconfig arch/$(ARCH)/config.in

config: symlinks
! $(CONFIG_SHELL) scripts/Configure arch/$(ARCH)/config.in

linuxsubdirs: dummy
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done
--- 192,209 ----

menuconfig: include/linux/version.h symlinks
$(MAKE) -C scripts/lxdialog all
! $(CONFIG_SHELL) scripts/Menuconfig $(STD_CONFIG)

config: symlinks
! $(CONFIG_SHELL) scripts/Configure $(STD_CONFIG)
!
! batchconfig: symlinks _batchconfig
! ifeq ($(strip $(USE_CONFIG)),)
! # Prevent Configure -f from using standard config as default.
! USE_CONFIG=.config
! endif
! _batchconfig:
! $(CONFIG_SHELL) scripts/Configure -d -f $(USE_CONFIG) $(STD_CONFIG)

linuxsubdirs: dummy
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done
diff -rcN linux-2.0.30-origConfig/README linux-2.0.30-newConfig/README
*** linux-2.0.30-origConfig/README Wed Oct 15 03:40:31 1997
--- linux-2.0.30-newConfig/README Wed Oct 15 04:00:50 1997
***************
*** 101,106 ****
--- 101,109 ----
- Alternate configuration commands are:
"make menuconfig" Text based color menus, radiolists & dialogs.
"make xconfig" X windows based configuration tool.
+ "make batchconf" Attempt batch configuration from .config.
+ "make batchconf USE_CONFIG=<file>"
+ Like batchconf but specify a config file.

NOTES on "make config":
- having unnecessary drivers will make the kernel bigger, and can
diff -rcN linux-2.0.30-origConfig/scripts/Configure
linux-2.0.30-newConfig/scripts/Configure
*** linux-2.0.30-origConfig/scripts/Configure Tue Oct 14 23:46:07 1997
--- linux-2.0.30-newConfig/scripts/Configure Wed Oct 15 04:28:43 1997
***************
*** 45,50 ****
--- 45,53 ----
#
# 090397 Axel Boldt (boldt@math.ucsb.edu) - avoid ? and + in regular
# expressions for GNU expr since version 1.15 and up use \? and \+.
+ #
+ # 151097 Karl O. Pinc (kop@meme.com) - -f option, alternate default
+ # config file. Command line parsing.

#
# Make sure we're really running bash.
***************
*** 411,416 ****
--- 414,453 ----
done
}

+ #
+ # Parse command line.
+ # (Don't use getops so we can have long option names.)
+ #
+ DEFAULT=""
+ CONFIG_IN=./config.in
+ DEFAULTS=arch/$ARCH/defconfig
+ if [ -f .config ]; then
+ DEFAULTS=.config
+ fi
+
+ while [ -n "$1" ] ; do
+ case "$1" in
+ -d )
+ DEFAULT="-d"
+ ;;
+ -f )
+ shift
+ if [ ! -f "$1" ] ; then
+ echo "$0: $1:No such file" 1>&2
+ exit 1
+ fi
+ DEFAULTS="$1"
+ ;;
+ * )
+ CONFIG_IN=$1
+ ;;
+ esac
+ shift
+ done
+
+ #
+ # Start generating the config.
+ #
CONFIG=.tmpconfig
CONFIG_H=.tmpconfig.h
trap "rm -f $CONFIG $CONFIG_H ; exit 1" 1 2
***************
*** 426,447 ****
echo " * Automatically generated C config: don't edit" >> $CONFIG_H
echo " */" >> $CONFIG_H
echo "#define AUTOCONF_INCLUDED" >> $CONFIG_H
-
- DEFAULT=""
- if [ "$1" = "-d" ] ; then
- DEFAULT="-d"
- shift
- fi
-
- CONFIG_IN=./config.in
- if [ "$1" != "" ] ; then
- CONFIG_IN=$1
- fi
-
- DEFAULTS=arch/$ARCH/defconfig
- if [ -f .config ]; then
- DEFAULTS=.config
- fi

if [ -f $DEFAULTS ]; then
echo "#"
--- 463,468 ----