Commit 04fdcac1 authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Additional config targets for testing

This patch adds the following targets, which generate some configs
useful for testing - which kind should be clear from the names:

o allyesconfig
o allmodconfig
o allnoconfig
o randconfig

It also adds

o defconfig

which does the same as make oldconfig but uses the defaults for all
new options without asking.

The actual patch was done by Ghozlane Toumi, maintained in kbuild-2.5
by Keith Owens, and extracted by Sam Ravnborg and patch@luckynet.dynu.com.
parent 660ada4f
...@@ -119,8 +119,9 @@ export CPPFLAGS EXPORT_FLAGS ...@@ -119,8 +119,9 @@ export CPPFLAGS EXPORT_FLAGS
export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
noconfig_targets := oldconfig xconfig menuconfig config clean mrproper \ noconfig_targets := xconfig menuconfig config oldconfig randconfig \
distclean defconfig allyesconfig allnoconfig allmodconfig \
clean mrproper distclean
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
...@@ -518,9 +519,6 @@ else # ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) ...@@ -518,9 +519,6 @@ else # ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
.PHONY: oldconfig xconfig menuconfig config \ .PHONY: oldconfig xconfig menuconfig config \
make_with_config make_with_config
oldconfig:
$(CONFIG_SHELL) scripts/Configure -d arch/$(ARCH)/config.in
xconfig: xconfig:
@$(MAKE) -C scripts kconfig.tk @$(MAKE) -C scripts kconfig.tk
wish -f scripts/kconfig.tk wish -f scripts/kconfig.tk
...@@ -532,6 +530,24 @@ menuconfig: ...@@ -532,6 +530,24 @@ menuconfig:
config: config:
$(CONFIG_SHELL) scripts/Configure arch/$(ARCH)/config.in $(CONFIG_SHELL) scripts/Configure arch/$(ARCH)/config.in
oldconfig:
$(CONFIG_SHELL) scripts/Configure -d arch/$(ARCH)/config.in
randconfig:
$(CONFIG_SHELL) scripts/Configure -r arch/$(ARCH)/config.in
allyesconfig:
$(CONFIG_SHELL) scripts/Configure -y arch/$(ARCH)/config.in
allnoconfig:
$(CONFIG_SHELL) scripts/Configure -n arch/$(ARCH)/config.in
allmodconfig:
$(CONFIG_SHELL) scripts/Configure -m arch/$(ARCH)/config.in
defconfig:
yes '' | $(CONFIG_SHELL) scripts/Configure -d arch/$(ARCH)/config.in
# How we generate .config depends on which *config the # How we generate .config depends on which *config the
# user chose when calling make # user chose when calling make
......
...@@ -48,6 +48,10 @@ ...@@ -48,6 +48,10 @@
# #
# 24 January 1999, Michael Elizabeth Chastain, <mec@shout.net> # 24 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
# - Improve the exit message (Jeff Ronne). # - Improve the exit message (Jeff Ronne).
#
# 7 October 2000, Ghozlane Toumi, <gtoumi@messel.emse.fr>
# added switches for "random" , "all yes" and "all modules"
#
# #
# Make sure we're really running bash. # Make sure we're really running bash.
...@@ -75,6 +79,43 @@ function endmenu () { ...@@ -75,6 +79,43 @@ function endmenu () {
: :
} }
#
# 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 prints the corresponding help text from Configure.help to stdout
# #
...@@ -109,7 +150,11 @@ ${var}:\\ ...@@ -109,7 +150,11 @@ ${var}:\\
# readln prompt default oldval # readln prompt default oldval
# #
function readln () { 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" echo "$1"
ans=$2 ans=$2
else else
...@@ -169,6 +214,17 @@ function define_tristate () { ...@@ -169,6 +214,17 @@ function define_tristate () {
function bool () { function bool () {
old=$(eval echo "\${$2}") old=$(eval echo "\${$2}")
def=${old:-'n'} 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 case "$def" in
"y" | "m") defprompt="Y/n/?" "y" | "m") defprompt="Y/n/?"
def="y" def="y"
...@@ -200,6 +256,18 @@ function tristate () { ...@@ -200,6 +256,18 @@ function tristate () {
else else
old=$(eval echo "\${$2}") old=$(eval echo "\${$2}")
def=${old:-'n'} 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 case "$def" in
"y") defprompt="Y/m/n/?" "y") defprompt="Y/m/n/?"
;; ;;
...@@ -256,6 +324,17 @@ function dep_tristate () { ...@@ -256,6 +324,17 @@ function dep_tristate () {
if [ $need_module = 1 ]; then if [ $need_module = 1 ]; then
if [ "$CONFIG_MODULES" = "y" ]; 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 case "$def" in
"y" | "m") defprompt="M/n/?" "y" | "m") defprompt="M/n/?"
def="m" def="m"
...@@ -351,6 +430,7 @@ function int () { ...@@ -351,6 +430,7 @@ function int () {
else else
max=10000000 # !! max=10000000 # !!
fi fi
rndval $2
while :; do while :; do
readln "$1 ($2) [$def] " "$def" "$old" readln "$1 ($2) [$def] " "$def" "$old"
if expr \( \( $ans + 0 \) \>= $min \) \& \( $ans \<= $max \) >/dev/null 2>&1 ; then if expr \( \( $ans + 0 \) \>= $min \) \& \( $ans \<= $max \) >/dev/null 2>&1 ; then
...@@ -382,6 +462,7 @@ function hex () { ...@@ -382,6 +462,7 @@ function hex () {
old=$(eval echo "\${$2}") old=$(eval echo "\${$2}")
def=${old:-$3} def=${old:-$3}
def=${def#*[x,X]} def=${def#*[x,X]}
rndval $2
while :; do while :; do
readln "$1 ($2) [$def] " "$def" "$old" readln "$1 ($2) [$def] " "$def" "$old"
ans=${ans#*[x,X]} ans=${ans#*[x,X]}
...@@ -464,6 +545,15 @@ function choice () { ...@@ -464,6 +545,15 @@ function choice () {
shift; shift shift; shift
done done
if [ "$RND" = "-r" -a -z "$old" ] ; then
set -- $choices
rnd $#
while [ $rnd -le $# ] ; do
def=$1
shift ; shift
done
fi
val="" val=""
while [ -z "$val" ]; do while [ -z "$val" ]; do
ambg=n ambg=n
...@@ -512,6 +602,7 @@ function choice () { ...@@ -512,6 +602,7 @@ function choice () {
CONFIG=.tmpconfig CONFIG=.tmpconfig
CONFIG_H=.tmpconfig.h CONFIG_H=.tmpconfig.h
FORCE_DEFAULT=.force_default
trap "rm -f $CONFIG $CONFIG_H ; exit 1" 1 2 trap "rm -f $CONFIG $CONFIG_H ; exit 1" 1 2
# #
...@@ -532,34 +623,57 @@ if [ "$1" = "-d" ] ; then ...@@ -532,34 +623,57 @@ if [ "$1" = "-d" ] ; then
shift shift
fi 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 CONFIG_IN=./config.in
if [ "$1" != "" ] ; then if [ "$1" != "" ] ; then
CONFIG_IN=$1 CONFIG_IN=$1
fi fi
DEFAULTS=.config for DEFAULTS in .config /lib/modules/`uname -r`/.config /etc/kernel-config /boot/config-`uname -r` arch/$ARCH/defconfig
if [ ! -f .config ]; then do
DEFAULTS=/etc/kernel-config [ -r $DEFAULTS ] && break
if [ ! -f $DEFAULTS ]; then done
DEFAULTS=/boot/config-`uname -r`
if [ ! -f $DEFAULTS ]; then if [ "$AUTO" != "yes" ]; then
DEFAULTS=arch/$ARCH/defconfig if [ -f $DEFAULTS ]; then
fi 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
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 else
echo "#" if [ -f $FORCE_DEFAULT ]; then
echo "# No defaults found" echo "#"
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 fi
. $CONFIG_IN . $CONFIG_IN
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment