Skip to contentSkip to conversation

New make config options

DISCUSSION Eric 4 participants 6 messages May 26, 2003

lore
Share & tools
lore

Eric

author
#0 lore raw

#DEFINE RANT 1

Ok, I may not know what I'm talking about, or it may not actually be a good idea, but I had an ipifany about the configure scripts.

I spend most of my time in the configure script turning everything into a
module. (I play alot, and I like to have modules available to explore). There should a button or something where it will turn everything that CAN be compiled as a module, into kernel modules. Then you can de-select a few things and compile the other few options that you need directly into the kernel.

#IFDEF RANT
It would save me alot of time knowing that all those stupid NIC cards are being compiled as modules when i'm not sure which one I have. I would rather have all the modules available in case NIC breaks anyways. I change NICS and i'm never sure what kind it is until it doesn't work and I need to compile ANOTHER module. I know some of them are obscure cards, but with all the options I can't really be sure if it's a card I might come across or not. I'd rather be safe and have a meg or two of NIC modules around then have to rebuild or compile a new modules when I find an exotic card. #ENDIF

Modules aren't used used until they're needed anyways so It wouldn't cause
conflicts or a big size differnece in the kernel (in my understanding). For us with fast machines(AMD XP1800+) it would just be an extra 5-7 minutes for the other modules to compile.

Would anyone else be interested in this?
----------------------
Eric Bambach
[email protected]
----------------------

#1 lore raw
Quoted 25 lines

#DEFINE RANT 1

Ok, I may not know what I'm talking about, or it may not actually be a good idea, but I had an ipifany about the configure scripts.

I spend most of my time in the configure script turning
everything into a
module. (I play alot, and I like to have modules available to explore). There should a button or something where it will turn everything that CAN be compiled as a module, into kernel modules. Then you can de-select a few things and compile the other few options that you need directly into the kernel.

#IFDEF RANT
It would save me alot of time knowing that all those stupid NIC cards are being compiled as modules when i'm not sure which one I have. I would rather have all the modules available in case NIC breaks anyways. I change NICS and i'm never sure what kind it is until it doesn't work and I need to compile ANOTHER module. I know some of them are obscure cards, but with all the options I can't really be sure if it's a card I might come across or not. I'd rather be safe and have a meg or two of NIC modules around then have to rebuild or compile a new modules when I find an exotic card. #ENDIF

Quoted 7 lines

Modules aren't used used until they're needed anyways so It
wouldn't cause
conflicts or a big size differnece in the kernel (in my understanding). For us with fast machines(AMD XP1800+) it would just be an extra 5-7 minutes for the other modules to compile.

Would anyone else be interested in this?

I would be heavily interested in this. Right now I have a hacked-together Debian box running my server and servers for others, and I'm trying to do a full system reconstruction on the side to swap out once (and hopefully only once). One key to this is to make an absolute minimal kernel and to have everything as modules, because even if I don't have the module I need, I can compile it and use it without having to restart the machine. Being able to have an automatic option which lets me 1) specify minimal options and have everything else as "no", then 2) takes every "no" which can be a module, and turns it to module, and 3) lets me go back in and turn off any particular modules I definately don't want, would be *marvelous*.

#2 lore raw
In reply to Eric

what about make allmodconfig ??

then you have a .config with most things as module and you can always use make menuconfig to adjust it.

BTW try a make help to see all other make options.

Rudmer

author
#3 lore raw
Quoted 2 lines · Rudmer van Dijk

what about make allmodconfig ??

Now if we can convince someone to code it :(
I wish I could throw something together myself but I can only suggest the ideas. Hopefully someone with the time/skills/interest can put something together to do this. I would have no problems testing the feature if someone else who could write it needs some help testing.

Quoted 2 lines

then you have a .config with most things as module and you can always use make menuconfig to adjust it.

Great idea. Not really a button in make menuconfig, but a make allmodconfig and it resets everythign to modules. Then you could use the regualr make config facility to tune it. There would be no need to hack up make menuconfig.

Quoted 1 line

BTW try a make help to see all other make options.

Are you suggesting this as a feature? Lol, i tried make help and it there was no rule for it. 2.4.20 kernel.

----------------------
Eric Bambach
[email protected]
----------------------

author
#4 lore raw
Quoted 4 lines · Eric
Quoted 1 line · Rudmer van Dijk

what about make allmodconfig ??

Now if we can convince someone to code it :(

I've just been informed that this is part of the 2.5 kernel... silly me...

----------------------
Eric Bambach
[email protected]
----------------------

#5 lore raw
In reply to Eric
Quoted 8 lines · Eric
Quoted 2 lines · Rudmer van Dijk

what about make allmodconfig ??

Now if we can convince someone to code it :(
I wish I could throw something together myself but I can only suggest the ideas. Hopefully someone with the time/skills/interest can put something together to do this. I would have no problems testing the feature if someone else who could write it needs some help testing.

IIRC you can dig out allmodconfig + allnoconfig from Keith Owens kbuild-2.5 patch sets. See kbuild on sourceforge.

He made a version compatible with the 2.4 kernel, and what you need is the changes to the scripts/configure script.
If you do not find a 2.4 version, you can take that diff from the 2.5 kernel. [Browsing a bit - got it]
It was Ghozlane Toumi who actually coded this.

Here is the patch (for an older 2.5 kernel).
You may have to apply it by hand.
Then you just have to add a few targets in the main Makefile.

Sam

===== Configure 1.5 vs 1.6 =====

scripts/Configure +136 -22
@@ -48,6 +48,10 @@
 #
 # 24 January 1999, Michael Elizabeth Chastain, <[email protected]>
 # - Improve the exit message (Jeff Ronne).
+#
+# 7 October 2000, Ghozlane Toumi, <[email protected]>
+# added switches for "random" , "all yes" and "all modules"
+#
 
 #
 # Make sure we're really running bash.
@@ -76,6 +80,43 @@
 }
 
 #
+# returns a random number between 1 and $1
+#
+function rnd () {
+	rnd=$[ $RANDOM  %  $1 + 1 ]
+}
+
+#
+# randomly chose a number in a config list (LIST_CONFIG_NAME)
+# or in a range ( MIN_CONFIG_NAME MAX_CONFIG_NAME )
+# ONLY if there is no forced default (and we are in an "auto" mode)
+# we are limited by the range of values taken by  "$RANDOM"
+#
+#       rndval CONFIG_NAME
+#
+
+function rndval () {
+	[ "$AUTO" != "yes" -o -n "$old" ] && return
+	def_list=$(eval echo "\${LIST_$1}")
+	def_min=$(eval echo "\${MIN_$1}")
+	def_max=$(eval echo "\${MAX_$1}")
+
+	if [ -n "$def_list" ]; then
+	  set -- $(echo $def_list | sed 's/,/ /g')
+	  rnd $#
+	  while [ $rnd -le $# ] ; do
+	    def=$1
+	    shift
+	  done
+	  return
+	fi
+	if [ -n "$def_min" -a -n "$def_max" ]; then
+	  rnd $[ $def_max - $def_min ]
+	  def=$[ $def_min + $rnd ]
+	fi
+}
+
+#
 # help prints the corresponding help text from Configure.help to stdout
 #
 #       help variable
@@ -109,7 +150,11 @@
 #	readln prompt default oldval
 #
 function readln () {
-	if [ "$DEFAULT" = "-d" -a -n "$3" ]; then
+	if [ "$AUTO" = "yes" ]; then 
+		echo -n "$1"
+		ans=$2
+		echo $ans
+	elif [ "$DEFAULT" = "-d" -a -n "$3" ]; then
 		echo "$1"
 		ans=$2
 	else
@@ -169,6 +214,17 @@
 function bool () {
 	old=$(eval echo "\${$2}")
 	def=${old:-'n'}
+	if [ "$AUTO" = "yes" -a -z "$old" ]; then
+	  if [ "$RND" = "-r" ]; then
+	    rnd 2
+	    case $rnd in
+	      "1") def="y" ;;
+	      "2") def="n" ;;
+	    esac
+	  else
+	    def=$DEF_ANS;
+	  fi
+	fi
 	case "$def" in
 	 "y" | "m") defprompt="Y/n/?"
 	      def="y"
@@ -200,6 +256,18 @@
 	else 
 	  old=$(eval echo "\${$2}")
 	  def=${old:-'n'}
+	  if [ "$AUTO" = "yes" -a -z "$old" ]; then
+	     if [ "$RND" = "-r" ]; then 
+	      rnd 3
+	      case $rnd in
+	        "1") def="y" ;;
+	        "2") def="n" ;;
+	        "3") def="m" ;;
+	      esac
+	    else
+	      def=$DEF_ANS
+	    fi
+	  fi
 	  case "$def" in
 	   "y") defprompt="Y/m/n/?"
 		;;
@@ -256,6 +324,17 @@
 
 	if [ $need_module = 1 ]; then
 	   if [ "$CONFIG_MODULES" = "y" ]; then
+		if [ "$AUTO" = "yes" -a -z "$old" ]; then
+		   if [ "$RND" = "-r" ]; then
+		      rnd 2
+		      case $rnd in
+			"1") def="m" ;;
+			"2") def="n" ;;
+		      esac
+		   else
+		      def=$DEF_ANS
+		   fi
+		fi
 		case "$def" in
 		 "y" | "m") defprompt="M/n/?"
 		      def="m"
@@ -351,6 +430,7 @@
 	else
 	  max=10000000     # !!
 	fi
+	rndval $2
 	while :; do
 	  readln "$1 ($2) [$def] " "$def" "$old"
 	  if expr \( \( $ans + 0 \) \>= $min \) \& \( $ans \<= $max \) >/dev/null 2>&1 ; then
@@ -382,6 +462,7 @@
 	old=$(eval echo "\${$2}")
 	def=${old:-$3}
 	def=${def#*[x,X]}
+	rndval $2
 	while :; do
 	  readln "$1 ($2) [$def] " "$def" "$old"
 	  ans=${ans#*[x,X]}
@@ -464,6 +545,15 @@
 		shift; shift
 	done
 
+	if [ "$RND" = "-r" -a -z "$old" ] ; then 
+	  set -- $choices
+	  rnd $#
+	  while [ $rnd -le $# ] ; do 
+	    def=$1
+	    shift ; shift
+	  done
+	fi
+
 	val=""
 	while [ -z "$val" ]; do
 		ambg=n
@@ -512,6 +602,7 @@
 
 CONFIG=.tmpconfig
 CONFIG_H=.tmpconfig.h
+FORCE_DEFAULT=.force_default
 trap "rm -f $CONFIG $CONFIG_H ; exit 1" 1 2
 
 #
@@ -532,34 +623,57 @@
 	shift
 fi
 
+RND=""
+DEF_ANS=""
+AUTO=""
+case "$1" in 
+	-r) RND="-r" ; AUTO="yes" ; shift ;;
+	-y) DEF_ANS="y" ; AUTO="yes" ; shift ;;
+	-m) DEF_ANS="m" ; AUTO="yes" ; shift ;;
+	-n) DEF_ANS="n" ; AUTO="yes" ; shift ;;
+esac
+
 CONFIG_IN=./config.in
 if [ "$1" != "" ] ; then
 	CONFIG_IN=$1
 fi
 
-DEFAULTS=.config
-if [ ! -f .config ]; then
-  DEFAULTS=/etc/kernel-config
-  if [ ! -f $DEFAULTS ]; then
-    DEFAULTS=/boot/config-`uname -r`
-    if [ ! -f $DEFAULTS ]; then
-      DEFAULTS=arch/$ARCH/defconfig
-    fi
+for DEFAULTS in .config /lib/modules/`uname -r`/.config /etc/kernel-config /boot/config-`uname -r` arch/$ARCH/defconfig
+do
+  [ -r $DEFAULTS ] && break
+done
+
+if [ "$AUTO" != "yes" ]; then
+  if [ -f $DEFAULTS ]; then
+    echo "#"
+    echo "# Using defaults found in" $DEFAULTS
+    echo "#"
+    . $DEFAULTS
+    sed -e 's/# \(CONFIG_[^ ]*\) is not.*/\1=n/' <$DEFAULTS >.config-is-not.$$
+    . .config-is-not.$$
+    rm .config-is-not.$$
+  else
+    echo "#"
+    echo "# No defaults found"
+    echo "#"
   fi
-fi
-
-if [ -f $DEFAULTS ]; then
-  echo "#"
-  echo "# Using defaults found in" $DEFAULTS
-  echo "#"
-  . $DEFAULTS
-  sed -e 's/# \(CONFIG_[^ ]*\) is not.*/\1=n/' <$DEFAULTS >.config-is-not.$$
-  . .config-is-not.$$
-  rm .config-is-not.$$
 else
-  echo "#"
-  echo "# No defaults found"
-  echo "#"
+  if [ -f $FORCE_DEFAULT ]; then
+    echo "#"
+    echo "# Forcing defaults found in $FORCE_DEFAULT"
+    echo "#"
+    sed -e '
+s/# \(CONFIG_[^ ]*\) is not.*/\1=n/;
+s/# range \(CONFIG_[^ ]*\) \([^ ][^ ]*\) \([^ ][^ ]*\)/MIN_\1=\2; MAX_\1=\3/;
+s/# list \(CONFIG_[^ ]*\) \([^ ][^ ]*\)/LIST_\1=\2/
+' <$FORCE_DEFAULT >.default_val.$$
+    . .default_val.$$
+    rm .default_val.$$
+  else
+    echo "#"
+    echo "# No defaults found"
+    echo "#"
+  fi 
 fi
 
 . $CONFIG_IN