summaryrefslogtreecommitdiff
path: root/scripts/config
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-06-14 14:12:18 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-14 14:12:18 -0700
commit45e3e1935e2857c54783291107d33323b3ef33c8 (patch)
tree26a6e3228b52d0f96f6e56e5879ca898fe909592 /scripts/config
parentcf5046323ea254be72535648a9d090b18b8510f3 (diff)
parent3f8d9ced7746f3f329ccca0bb3f3c7a2c15c47bb (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-next
* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-next: (53 commits) .gitignore: ignore *.lzma files kbuild: add generic --set-str option to scripts/config kbuild: simplify argument loop in scripts/config kbuild: handle non-existing options in scripts/config kallsyms: generalize text region handling kallsyms: support kernel symbols in Blackfin on-chip memory documentation: make version fix kbuild: fix a compile warning gitignore: Add GNU GLOBAL files to top .gitignore kbuild: fix delay in setlocalversion on readonly source README: fix misleading pointer to the defconf directory vmlinux.lds.h update kernel-doc: cleanup perl script Improve vmlinux.lds.h support for arch specific linker scripts kbuild: fix headers_exports with boolean expression kbuild/headers_check: refine extern check kbuild: fix "Argument list too long" error for "make headers_check", ignore *.patch files Remove bashisms from scripts menu: fix embedded menu presentation ...
Diffstat (limited to 'scripts/config')
-rwxr-xr-xscripts/config87
1 files changed, 41 insertions, 46 deletions
diff --git a/scripts/config b/scripts/config
index db6084b78a1..608d7fdb13e 100755
--- a/scripts/config
+++ b/scripts/config
@@ -9,8 +9,10 @@ config options command ...
commands:
--enable|-e option Enable option
--disable|-d option Disable option
- --module|-m option Turn option into a module
- --state|-s option Print state of option (n,y,m,undef)
+ --module|-m option Turn option into a module
+ --set-str option value
+ Set option to "value"
+ --state|-s option Print state of option (n,y,m,undef)
--enable-after|-E beforeopt option
Enable option directly after other option
@@ -26,8 +28,6 @@ options:
config doesn't check the validity of the .config file. This is done at next
make time.
-The options need to be already in the file before they can be changed,
-but sometimes you can cheat with the --*-after options.
EOL
exit 1
}
@@ -45,8 +45,18 @@ checkarg() {
ARG="`echo $ARG | tr a-z A-Z`"
}
-replace() {
- sed -i -e "$@" $FN
+set_var() {
+ local name=$1 new=$2 before=$3
+
+ name_re="^($name=|# $name is not set)"
+ before_re="^($before=|# $before is not set)"
+ if test -n "$before" && grep -Eq "$before_re" "$FN"; then
+ sed -ri "/$before_re/a $new" "$FN"
+ elif grep -Eq "$name_re" "$FN"; then
+ sed -ri "s:$name_re.*:$new:" "$FN"
+ else
+ echo "$new" >>"$FN"
+ fi
}
if [ "$1" = "--file" ]; then
@@ -54,8 +64,7 @@ if [ "$1" = "--file" ]; then
if [ "$FN" = "" ] ; then
usage
fi
- shift
- shift
+ shift 2
else
FN=.config
fi
@@ -68,27 +77,39 @@ while [ "$1" != "" ] ; do
CMD="$1"
shift
case "$CMD" in
- --enable|-e)
+ --refresh)
+ ;;
+ --*-after)
+ checkarg "$1"
+ A=$ARG
+ checkarg "$2"
+ B=$ARG
+ shift 2
+ ;;
+ --*)
checkarg "$1"
- replace "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/"
shift
;;
+ esac
+ case "$CMD" in
+ --enable|-e)
+ set_var "CONFIG_$ARG" "CONFIG_$ARG=y"
+ ;;
--disable|-d)
- checkarg "$1"
- replace "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/"
- shift
+ set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set"
;;
--module|-m)
- checkarg "$1"
- replace "s/CONFIG_$ARG=y/CONFIG_$ARG=m/" \
- -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=m/"
+ set_var "CONFIG_$ARG" "CONFIG_$ARG=m"
+ ;;
+
+ --set-str)
+ set_var "CONFIG_$ARG" "CONFIG_$ARG=\"$1\""
shift
;;
--state|-s)
- checkarg "$1"
if grep -q "# CONFIG_$ARG is not set" $FN ; then
echo n
else
@@ -101,44 +122,18 @@ while [ "$1" != "" ] ; do
echo "$V"
fi
fi
- shift
;;
--enable-after|-E)
- checkarg "$1"
- A=$ARG
- checkarg "$2"
- B=$ARG
- replace "/CONFIG_$A=[my]/aCONFIG_$B=y" \
- -e "/# CONFIG_$ARG is not set/a/CONFIG_$ARG=y" \
- -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/"
- shift
- shift
+ set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A"
;;
--disable-after|-D)
- checkarg "$1"
- A=$ARG
- checkarg "$2"
- B=$ARG
- replace "/CONFIG_$A=[my]/a# CONFIG_$B is not set" \
- -e "/# CONFIG_$ARG is not set/a/# CONFIG_$ARG is not set" \
- -e "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/"
- shift
- shift
+ set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A"
;;
--module-after|-M)
- checkarg "$1"
- A=$ARG
- checkarg "$2"
- B=$ARG
- replace "/CONFIG_$A=[my]/aCONFIG_$B=m" \
- -e "/# CONFIG_$ARG is not set/a/CONFIG_$ARG=m" \
- -e "s/CONFIG_$ARG=y/CONFIG_$ARG=m/" \
- -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=m/"
- shift
- shift
+ set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A"
;;
# undocumented because it ignores --file (fixme)