X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=scripts%2Fmulticonfig.sh;h=70f3a5df6f711081d9808cb67bd807a843164df9;hb=8e04d4c537eca06112fc8508689eb6c75d1f518e;hp=56cf0c2a5d56a19821f7a80038b3d03f0c27efcf;hpb=3e1b36bd584228b0a8070c8b63351aefda652523;p=u-boot diff --git a/scripts/multiconfig.sh b/scripts/multiconfig.sh old mode 100644 new mode 100755 index 56cf0c2a5d..70f3a5df6f --- a/scripts/multiconfig.sh +++ b/scripts/multiconfig.sh @@ -69,8 +69,8 @@ get_enabled_subimages() { # CONFIG_SPL=y -> spl # CONFIG_TPL=y -> tpl - sed -n -e 's/^CONFIG_\(SPL\|TPL\)=y$/\1/p' $KCONFIG_CONFIG | \ - tr '[A-Z]' '[a-z]' + sed -n -e 's/^CONFIG_SPL=y$/spl/p' -e 's/^CONFIG_TPL=y$/tpl/p' \ + $KCONFIG_CONFIG } do_silentoldconfig () { @@ -118,6 +118,13 @@ do_board_defconfig () { defconfig_path=$srctree/configs/$1 tmp_defconfig_path=configs/.tmp_defconfig + if [ ! -r $defconfig_path ]; then + echo >&2 "***" + echo >&2 "*** Can't find default configuration \"configs/$1\"!" + echo >&2 "***" + exit 1 + fi + mkdir -p arch configs # defconfig for Normal: # pick lines without prefixes and lines starting '+' prefix @@ -155,6 +162,16 @@ do_defconfig () { fi } +do_board_felconfig () { + do_board_defconfig ${1%%_felconfig}_defconfig + if ! grep -q CONFIG_ARCH_SUNXI=y .config || ! grep -q CONFIG_SPL=y .config ; then + echo "$progname: Cannot felconfig a non-sunxi or non-SPL platform" >&2 + exit 1 + fi + sed -i -e 's/\# CONFIG_SPL_FEL is not set/CONFIG_SPL_FEL=y/g' \ + .config spl/.config +} + do_savedefconfig () { if [ -r "$KCONFIG_CONFIG" ]; then subimages=$(get_enabled_subimages) @@ -170,7 +187,7 @@ do_savedefconfig () { # backslashes as an escape character while read -r line do - output_lines="$output_lines $line" + output_lines="$output_lines%$line" done < defconfig for img in $subimages @@ -185,42 +202,95 @@ do_savedefconfig () { tmp= match= + # "# CONFIG_FOO is not set" should not be divided. + # Use "%" as a separator, instead of a whitespace. + # "%" is unlikely to appear in defconfig context. + save_IFS=$IFS + IFS=% # coalesce common lines together for i in $output_lines do case "$i" in - "[+A-Z]*:$line") - tmp="$tmp $unmatched" + [+A-Z]*:$line) + tmp="$tmp%$unmatched" i=$(echo "$i" | \ - sed -e "s/^\([^:]\)*/\1$symbol/") - tmp="$tmp $i" + sed -e "s/^\([^:]*\)/\1$symbol/") + tmp="$tmp%$i" match=1 ;; - "$line") - tmp="$tmp $unmatched" - tmp="$tmp +$symbol:$i" + $line) + tmp="$tmp%$unmatched" + tmp="$tmp%+$symbol:$i" match=1 ;; *) - tmp="$tmp $i" + tmp="$tmp%$i" ;; esac done + # Restore the default separator for the outer for loop. + IFS=$save_IFS + if [ "$match" ]; then output_lines="$tmp" unmatched= else - unmatched="$unmatched $symbol:$line" + unmatched="$unmatched%$symbol:$line" fi done < defconfig + + output_lines="$output_lines%$unmatched" done rm -f defconfig + touch defconfig + + save_IFS=$IFS + IFS=% + for line in $output_lines do - echo $line >> defconfig + case "$line" in + "") + # do not output blank lines + ;; + *) + echo $line >> defconfig + ;; + esac done + + IFS=$save_IFS +} + +# Some sanity checks before running "make /", +# where should be either "spl" or "tpl". +# Doing "make spl/menuconfig" etc. on a non-SPL board makes no sense. +# It should be allowed only when ".config" exists and "CONFIG_SPL" is enabled. +# +# Usage: +# check_enabled_sumbimage / +check_enabled_subimage () { + + case $2 in + spl|tpl) ;; + *) + echo >&2 "***" + echo >&2 "*** \"make $1\" is not supported." + echo >&2 "***" + exit 1 + ;; + esac + test -r "$KCONFIG_CONFIG" && get_enabled_subimages | grep -q $2 || { + config=CONFIG_$(echo $2 | tr '[a-z]' '[A-Z]') + + echo >&2 "***" + echo >&2 "*** Create \"$KCONFIG_CONFIG\" with \"$config\" enabled" + echo >&2 "*** before \"make $1\"." + echo >&2 "***" + exit 1 + } } # Usage: @@ -236,9 +306,25 @@ do_others () { objdir= else objdir=${1%/*} + check_enabled_subimage $1 $objdir + + if [ -f "$objdir/$KCONFIG_CONFIG" ]; then + timestamp_before=$(stat --printf="%Y" \ + $objdir/$KCONFIG_CONFIG) + fi fi run_make_config $target $objdir + + if [ "$timestamp_before" -a -f "$objdir/$KCONFIG_CONFIG" ]; then + timestamp_after=$(stat --printf="%Y" $objdir/$KCONFIG_CONFIG) + + if [ "$timestamp_after" -gt "$timestamp_before" ]; then + # $objdir/.config has been updated. + # touch .config to invoke "make silentoldconfig" + touch $KCONFIG_CONFIG + fi + fi } progname=$(basename $0) @@ -247,7 +333,10 @@ target=$1 case $target in *_defconfig) do_board_defconfig $target;; +*_felconfig) + do_board_felconfig $target;; *_config) + # backward compatibility do_board_defconfig ${target%_config}_defconfig;; silentoldconfig) do_silentoldconfig;;