# 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 () {
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
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)
# 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
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 <objdir>/<target>",
+# where <objdir> 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 <objdir>/<target> <objdir>
+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:
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)
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;;